Search in sources :

Example 1 with MenuAction

use of com.frostwire.android.gui.views.MenuAction in project frostwire by frostwire.

the class FileListAdapter method getMenuAdapter.

@Override
protected MenuAdapter getMenuAdapter(View view) {
    Context context = getContext();
    List<MenuAction> items = new ArrayList<>();
    // due to long click generic handle
    FileDescriptor fd = null;
    if (view.getTag() instanceof FileDescriptorItem) {
        FileDescriptorItem item = (FileDescriptorItem) view.getTag();
        fd = item.fd;
    } else if (view.getTag() instanceof FileDescriptor) {
        fd = (FileDescriptor) view.getTag();
    }
    if (checkIfNotExists(fd)) {
        notifyDataSetInvalidated();
        return null;
    }
    List<FileDescriptor> checked = convertItems(getChecked());
    boolean canOpenFile = fd.mime != null && (fd.mime.contains("audio") || fd.mime.contains("bittorrent") || fd.filePath != null);
    int numChecked = checked.size();
    boolean showSingleOptions = showSingleOptions(checked, fd);
    if (showSingleOptions) {
        if (!AndroidPlatform.saf(new File(fd.filePath)) && fd.fileType != Constants.FILE_TYPE_RINGTONES) {
            items.add(new SeedAction(context, fd));
        }
        if (canOpenFile) {
            items.add(new OpenMenuAction(context, fd, getViewPosition(view)));
        }
        items.add(new FileInformationAction(context, fd));
        if ((fd.fileType == Constants.FILE_TYPE_AUDIO && numChecked <= 1) || fd.fileType == Constants.FILE_TYPE_RINGTONES) {
            items.add(new SetAsRingtoneMenuAction(context, fd));
        }
        if (fd.fileType == Constants.FILE_TYPE_PICTURES && numChecked <= 1) {
            items.add(new SetAsWallpaperMenuAction(context, fd));
        }
        if (fd.fileType != Constants.FILE_TYPE_APPLICATIONS && numChecked <= 1 && fd.fileType != Constants.FILE_TYPE_RINGTONES) {
            items.add(new RenameFileMenuAction(context, this, fd));
        }
        if (fd.mime != null && fd.mime.equals(Constants.MIME_TYPE_BITTORRENT) && numChecked <= 1) {
            items.add(new CopyMagnetMenuAction(context, R.drawable.contextmenu_icon_magnet, R.string.transfers_context_menu_copy_magnet, R.string.transfers_context_menu_copy_magnet_copied, fd.filePath));
            items.add(new CopyMagnetMenuAction(context, R.drawable.contextmenu_icon_copy, R.string.transfers_context_menu_copy_infohash, R.string.transfers_context_menu_copy_infohash_copied, fd.filePath, false));
        }
    }
    List<FileDescriptor> list = checked;
    if (list.size() == 0) {
        list = Collections.singletonList(fd);
    }
    if (fd.fileType == Constants.FILE_TYPE_AUDIO) {
        items.add(new AddToPlaylistMenuAction(context, list));
    }
    if (fd.fileType != Constants.FILE_TYPE_APPLICATIONS && fd.fileType != Constants.FILE_TYPE_RINGTONES) {
        items.add(new SendFileMenuAction(context, fd));
        items.add(new DeleteFileMenuAction(context, this, list));
    }
    return new MenuAdapter(context, fd.title, items);
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) MenuAdapter(com.frostwire.android.gui.views.MenuAdapter) FileDescriptorItem(com.frostwire.android.gui.adapters.menu.FileListAdapter.FileDescriptorItem) FileDescriptor(com.frostwire.android.core.FileDescriptor) MenuAction(com.frostwire.android.gui.views.MenuAction) File(java.io.File)

Example 2 with MenuAction

use of com.frostwire.android.gui.views.MenuAction in project frostwire by frostwire.

the class OnBittorrentConnectRunnable method run.

public void run() {
    Engine.instance().startServices();
    while (!Engine.instance().isStarted()) {
        SystemClock.sleep(1000);
    }
    if (!Ref.alive(menuActionRef)) {
        return;
    }
    final MenuAction menuAction = menuActionRef.get();
    final Looper mainLooper = menuAction.getContext().getMainLooper();
    Handler h = new Handler(mainLooper);
    h.post(() -> menuAction.onClick(menuAction.getContext()));
}
Also used : MenuAction(com.frostwire.android.gui.views.MenuAction) Looper(android.os.Looper) Handler(android.os.Handler)

Example 3 with MenuAction

use of com.frostwire.android.gui.views.MenuAction in project frostwire by frostwire.

the class TransferListAdapter method getMenuAdapter.

private MenuAdapter getMenuAdapter(View view) {
    Object tag = view.getTag();
    String title = "";
    List<MenuAction> items = new ArrayList<>();
    if (tag instanceof BittorrentDownload) {
        title = populateBittorrentDownloadMenuActions((BittorrentDownload) tag, items);
    } else if (tag instanceof Transfer) {
        title = populateCloudDownloadMenuActions(tag, items);
    }
    return items.size() > 0 ? new MenuAdapter(contextRef.get(), title, items) : null;
}
Also used : ResumeDownloadMenuAction(com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction) MenuAction(com.frostwire.android.gui.views.MenuAction) CopyToClipboardMenuAction(com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction) OpenMenuAction(com.frostwire.android.gui.adapters.menu.OpenMenuAction) CancelMenuAction(com.frostwire.android.gui.adapters.menu.CancelMenuAction) TransferDetailsMenuAction(com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction) PauseDownloadMenuAction(com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction) BittorrentDownload(com.frostwire.transfers.BittorrentDownload) UIBittorrentDownload(com.frostwire.android.gui.transfers.UIBittorrentDownload) ArrayList(java.util.ArrayList) Transfer(com.frostwire.transfers.Transfer) MenuAdapter(com.frostwire.android.gui.views.MenuAdapter)

Example 4 with MenuAction

use of com.frostwire.android.gui.views.MenuAction in project frostwire by frostwire.

the class AddToPlaylistMenuAction method getMenuActions.

private List<MenuAction> getMenuActions() {
    List<MenuAction> actions = new ArrayList<>();
    actions.add(new CreateNewPlaylistMenuAction(getContext(), fds));
    List<Playlist> playlists = MusicUtils.getPlaylists(getContext());
    for (int i = 0; i < playlists.size(); i++) {
        final Playlist playlist = playlists.get(i);
        actions.add(new AddToThisPlaylistMenuAction(getContext(), playlist.mPlaylistId, playlist.mPlaylistName, fds));
    }
    return actions;
}
Also used : MenuAction(com.frostwire.android.gui.views.MenuAction) Playlist(com.andrew.apollo.model.Playlist) ArrayList(java.util.ArrayList)

Aggregations

MenuAction (com.frostwire.android.gui.views.MenuAction)4 ArrayList (java.util.ArrayList)3 MenuAdapter (com.frostwire.android.gui.views.MenuAdapter)2 Context (android.content.Context)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Playlist (com.andrew.apollo.model.Playlist)1 FileDescriptor (com.frostwire.android.core.FileDescriptor)1 CancelMenuAction (com.frostwire.android.gui.adapters.menu.CancelMenuAction)1 CopyToClipboardMenuAction (com.frostwire.android.gui.adapters.menu.CopyToClipboardMenuAction)1 FileDescriptorItem (com.frostwire.android.gui.adapters.menu.FileListAdapter.FileDescriptorItem)1 OpenMenuAction (com.frostwire.android.gui.adapters.menu.OpenMenuAction)1 PauseDownloadMenuAction (com.frostwire.android.gui.adapters.menu.PauseDownloadMenuAction)1 ResumeDownloadMenuAction (com.frostwire.android.gui.adapters.menu.ResumeDownloadMenuAction)1 TransferDetailsMenuAction (com.frostwire.android.gui.adapters.menu.TransferDetailsMenuAction)1 UIBittorrentDownload (com.frostwire.android.gui.transfers.UIBittorrentDownload)1 BittorrentDownload (com.frostwire.transfers.BittorrentDownload)1 Transfer (com.frostwire.transfers.Transfer)1 File (java.io.File)1