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);
}
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()));
}
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;
}
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;
}
Aggregations