use of com.frostwire.android.gui.views.MenuBuilder in project frostwire by frostwire.
the class FileListAdapter method getGridItemView.
private View getGridItemView(final int position, View view) {
final FileDescriptorItem item = getItem(position);
Context ctx = getContext();
if (view == null && ctx != null) {
// every list view item is wrapped in a generic container which has a hidden checkbox on the left hand side.
view = View.inflate(ctx, R.layout.view_my_files_thumbnail_grid_item, null);
}
try {
initCheckableGridImageView((RelativeLayout) view, item);
// toggles checkbox mode.
initTouchFeedback(view, item, v -> {
// background image listener
if (selectAllMode) {
onItemClicked(v);
} else {
if (item.fd.fileType == Constants.FILE_TYPE_VIDEOS) {
LOG.info("getGridItemView() Background ImageView.onClick(), show the menu");
MenuAdapter menuAdapter = getMenuAdapter(v);
if (menuAdapter != null) {
new MenuBuilder(menuAdapter).show();
}
} else {
localPlay(item.fd, v, position);
}
}
}, this::onItemLongClicked, null);
initPlaybackStatusOverlayTouchFeedback(view, item);
} catch (Throwable e) {
LOG.error("Fatal error getting view: " + e.getMessage(), e);
}
return view;
}
use of com.frostwire.android.gui.views.MenuBuilder in project frostwire by frostwire.
the class FileListAdapter method localPlay.
private void localPlay(FileDescriptor fd, View view, int position) {
if (fd == null) {
return;
}
onLocalPlay();
Context ctx = getContext();
if (fd.mime != null && fd.mime.contains("audio")) {
if (fd.equals(Engine.instance().getMediaPlayer().getCurrentFD(getContext()))) {
Engine.instance().getMediaPlayer().stop();
} else {
try {
UIUtils.playEphemeralPlaylist(ctx, fd);
UXStats.instance().log(UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE);
} catch (RuntimeException re) {
re.printStackTrace();
UIUtils.showShortMessage(ctx, R.string.media_player_failed);
}
}
notifyDataSetChanged();
} else {
if (fd.filePath != null && fd.mime != null) {
// special treatment of ringtones
if (fd.fileType == Constants.FILE_TYPE_RINGTONES) {
playRingtone(fd);
} else if (fd.fileType == Constants.FILE_TYPE_PICTURES && ctx instanceof MainActivity) {
Intent intent = new Intent(ctx, ImageViewerActivity.class);
intent.putExtra(ImageViewerFragment.EXTRA_FILE_DESCRIPTOR_BUNDLE, fd.toBundle());
intent.putExtra(ImageViewerFragment.EXTRA_ADAPTER_FILE_OFFSET, position);
ctx.startActivity(intent);
} else if ("application/x-bittorrent".equals(fd.mime)) {
// torrents are often DOCUMENT typed
TransferManager.instance().downloadTorrent(UIUtils.getFileUri(ctx, fd.filePath, false).toString());
UIUtils.showTransfersOnDownloadStart(ctx);
} else {
UIUtils.openFile(ctx, fd.filePath, fd.mime, true);
}
} else {
// it will automatically remove the 'Open' entry.
MenuAdapter menuAdapter = getMenuAdapter(view);
if (menuAdapter != null) {
new MenuBuilder(menuAdapter).show();
UIUtils.showShortMessage(ctx, R.string.cant_open_file);
}
}
}
}
use of com.frostwire.android.gui.views.MenuBuilder in project frostwire by frostwire.
the class AddToPlaylistMenuAction method onClick.
@Override
public void onClick(Context context) {
MenuBuilder menuBuilder = new MenuBuilder(new MenuAdapter(getContext(), R.string.add_to_playlist, getMenuActions()));
menuBuilder.show();
}
Aggregations