use of de.danoeh.antennapod.core.dialog.ConfirmationDialog in project AntennaPod by AntennaPod.
the class FeedMenuHandler method onOptionsItemClicked.
/**
* NOTE: This method does not handle clicks on the 'remove feed' - item.
*
* @throws DownloadRequestException
*/
public static boolean onOptionsItemClicked(final Context context, final MenuItem item, final Feed selectedFeed) throws DownloadRequestException {
switch(item.getItemId()) {
case R.id.refresh_item:
DBTasks.forceRefreshFeed(context, selectedFeed);
break;
case R.id.refresh_complete_item:
DBTasks.forceRefreshCompleteFeed(context, selectedFeed);
break;
case R.id.filter_items:
showFilterDialog(context, selectedFeed);
break;
case R.id.mark_all_read_item:
ConfirmationDialog conDialog = new ConfirmationDialog(context, R.string.mark_all_read_label, R.string.mark_all_read_feed_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.markFeedRead(selectedFeed.getId());
}
};
conDialog.createNewDialog().show();
break;
case R.id.visit_website_item:
Uri uri = Uri.parse(selectedFeed.getLink());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (IntentUtils.isCallable(context, intent)) {
context.startActivity(intent);
} else {
Toast.makeText(context, context.getString(R.string.download_error_malformed_url), Toast.LENGTH_SHORT).show();
}
break;
case R.id.support_item:
DBTasks.flattrFeedIfLoggedIn(context, selectedFeed);
break;
case R.id.share_link_item:
ShareUtils.shareFeedlink(context, selectedFeed);
break;
case R.id.share_download_url_item:
ShareUtils.shareFeedDownloadLink(context, selectedFeed);
break;
default:
return false;
}
return true;
}
use of de.danoeh.antennapod.core.dialog.ConfirmationDialog in project AntennaPod by AntennaPod.
the class SubscriptionFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final int position = mPosition;
// reset
mPosition = -1;
if (position < 0) {
return false;
}
Object selectedObject = subscriptionAdapter.getItem(position);
if (selectedObject.equals(SubscriptionsAdapter.ADD_ITEM_OBJ)) {
// this is the add object, do nothing
return false;
}
Feed feed = (Feed) selectedObject;
switch(item.getItemId()) {
case R.id.mark_all_seen_item:
Observable.fromCallable(() -> DBWriter.markFeedSeen(feed.getId())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> loadSubscriptions(), error -> Log.e(TAG, Log.getStackTraceString(error)));
return true;
case R.id.mark_all_read_item:
Observable.fromCallable(() -> DBWriter.markFeedRead(feed.getId())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> loadSubscriptions(), error -> Log.e(TAG, Log.getStackTraceString(error)));
return true;
case R.id.rename_item:
new RenameFeedDialog(getActivity(), feed).show();
return true;
case R.id.remove_item:
final FeedRemover remover = new FeedRemover(getContext(), feed) {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
loadSubscriptions();
}
};
ConfirmationDialog conDialog = new ConfirmationDialog(getContext(), R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
long mediaId = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
if (mediaId > 0 && FeedItemUtil.indexOfItemWithMediaId(feed.getItems(), mediaId) >= 0) {
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
remover.skipOnCompletion = true;
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
if (playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
getActivity().sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
}
}
remover.executeAsync();
}
};
conDialog.createNewDialog().show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of de.danoeh.antennapod.core.dialog.ConfirmationDialog in project AntennaPod by AntennaPod.
the class MediaplayerInfoActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final int position = mPosition;
// reset
mPosition = -1;
if (position < 0) {
return false;
}
Feed feed = navDrawerData.feeds.get(position - navAdapter.getSubscriptionOffset());
switch(item.getItemId()) {
case R.id.mark_all_seen_item:
DBWriter.markFeedSeen(feed.getId());
return true;
case R.id.mark_all_read_item:
DBWriter.markFeedRead(feed.getId());
return true;
case R.id.rename_item:
new RenameFeedDialog(this, feed).show();
return true;
case R.id.remove_item:
final FeedRemover remover = new FeedRemover(this, feed) {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
};
ConfirmationDialog conDialog = new ConfirmationDialog(this, R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
if (controller != null) {
Playable playable = controller.getMedia();
if (playable != null && playable instanceof FeedMedia) {
FeedMedia media = (FeedMedia) playable;
if (media.getItem().getFeed().getId() == feed.getId()) {
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
remover.skipOnCompletion = true;
if (controller.getStatus() == PlayerStatus.PLAYING) {
sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
}
}
}
}
remover.executeAsync();
}
};
conDialog.createNewDialog().show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of de.danoeh.antennapod.core.dialog.ConfirmationDialog in project AntennaPod by AntennaPod.
the class MainActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
final int position = mPosition;
// reset
mPosition = -1;
if (position < 0) {
return false;
}
Feed feed = navDrawerData.feeds.get(position - navAdapter.getSubscriptionOffset());
switch(item.getItemId()) {
case R.id.mark_all_seen_item:
DBWriter.markFeedSeen(feed.getId());
return true;
case R.id.mark_all_read_item:
DBWriter.markFeedRead(feed.getId());
return true;
case R.id.rename_item:
new RenameFeedDialog(this, feed).show();
return true;
case R.id.remove_item:
final FeedRemover remover = new FeedRemover(this, feed) {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (getSelectedNavListIndex() == position) {
loadFragment(EpisodesFragment.TAG, null);
}
}
};
ConfirmationDialog conDialog = new ConfirmationDialog(this, R.string.remove_feed_label, R.string.feed_delete_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
long mediaId = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
if (mediaId > 0 && FeedItemUtil.indexOfItemWithMediaId(feed.getItems(), mediaId) >= 0) {
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
remover.skipOnCompletion = true;
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
if (playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
}
}
remover.executeAsync();
}
};
conDialog.createNewDialog().show();
return true;
default:
return super.onContextItemSelected(item);
}
}
use of de.danoeh.antennapod.core.dialog.ConfirmationDialog in project AntennaPod by AntennaPod.
the class QueueFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (!super.onOptionsItemSelected(item)) {
switch(item.getItemId()) {
case R.id.queue_lock:
boolean newLockState = !UserPreferences.isQueueLocked();
UserPreferences.setQueueLocked(newLockState);
getActivity().supportInvalidateOptionsMenu();
recyclerAdapter.setLocked(newLockState);
if (newLockState) {
Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_locked, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(getActivity().findViewById(R.id.content), R.string.queue_unlocked, Snackbar.LENGTH_SHORT).show();
}
return true;
case R.id.refresh_item:
List<Feed> feeds = ((MainActivity) getActivity()).getFeeds();
if (feeds != null) {
DBTasks.refreshAllFeeds(getActivity(), feeds);
}
return true;
case R.id.clear_queue:
// make sure the user really wants to clear the queue
ConfirmationDialog conDialog = new ConfirmationDialog(getActivity(), R.string.clear_queue_label, R.string.clear_queue_confirmation_msg) {
@Override
public void onConfirmButtonPressed(DialogInterface dialog) {
dialog.dismiss();
DBWriter.clearQueue();
}
};
conDialog.createNewDialog().show();
return true;
case R.id.queue_sort_episode_title_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_ASC, true);
return true;
case R.id.queue_sort_episode_title_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.EPISODE_TITLE_DESC, true);
return true;
case R.id.queue_sort_date_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_ASC, true);
return true;
case R.id.queue_sort_date_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DATE_DESC, true);
return true;
case R.id.queue_sort_duration_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_ASC, true);
return true;
case R.id.queue_sort_duration_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.DURATION_DESC, true);
return true;
case R.id.queue_sort_feed_title_asc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_ASC, true);
return true;
case R.id.queue_sort_feed_title_desc:
QueueSorter.sort(getActivity(), QueueSorter.Rule.FEED_TITLE_DESC, true);
return true;
default:
return false;
}
} else {
return true;
}
}
Aggregations