|
1 | 1 | package org.schabi.newpipe; |
2 | 2 |
|
| 3 | +import static org.schabi.newpipe.util.SparseItemUtil.fetchStreamInfoAndSaveToDatabase; |
3 | 4 | import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText; |
4 | 5 |
|
5 | 6 | import android.content.Context; |
6 | 7 | import android.view.ContextThemeWrapper; |
7 | 8 | import android.view.View; |
8 | 9 | import android.widget.PopupMenu; |
9 | 10 |
|
| 11 | +import androidx.appcompat.app.AppCompatActivity; |
10 | 12 | import androidx.fragment.app.FragmentManager; |
11 | 13 |
|
12 | 14 | import org.schabi.newpipe.database.stream.model.StreamEntity; |
| 15 | +import org.schabi.newpipe.download.DownloadDialog; |
13 | 16 | import org.schabi.newpipe.local.dialog.PlaylistDialog; |
14 | 17 | import org.schabi.newpipe.player.playqueue.PlayQueue; |
15 | 18 | import org.schabi.newpipe.player.playqueue.PlayQueueItem; |
@@ -75,6 +78,15 @@ public static void openPopupMenu(final PlayQueue playQueue, |
75 | 78 | shareText(context, item.getTitle(), item.getUrl(), |
76 | 79 | item.getThumbnailUrl()); |
77 | 80 | return true; |
| 81 | + case R.id.menu_item_download: |
| 82 | + fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), |
| 83 | + item.getUrl(), info -> { |
| 84 | + final DownloadDialog downloadDialog = new DownloadDialog(context, |
| 85 | + info); |
| 86 | + downloadDialog.show(((AppCompatActivity) context) |
| 87 | + .getSupportFragmentManager(), "downloadDialog"); |
| 88 | + }); |
| 89 | + return true; |
78 | 90 | } |
79 | 91 | return false; |
80 | 92 | }); |
|
0 commit comments