public static boolean onMenuItemClicked(Context context, int menuItemId, FeedItem selectedItem)
      throws DownloadRequestException {
    DownloadRequester requester = DownloadRequester.getInstance();
    switch (menuItemId) {
      case R.id.skip_episode_item:
        context.sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
        break;
      case R.id.download_item:
        DBTasks.downloadFeedItems(context, selectedItem);
        break;
      case R.id.play_item:
        DBTasks.playMedia(context, selectedItem.getMedia(), true, true, false);
        break;
      case R.id.remove_item:
        DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
        break;
      case R.id.cancel_download_item:
        requester.cancelDownload(context, selectedItem.getMedia());
        break;
      case R.id.mark_read_item:
        DBWriter.markItemRead(context, selectedItem, true, true);
        break;
      case R.id.mark_unread_item:
        DBWriter.markItemRead(context, selectedItem, false, true);
        break;
      case R.id.add_to_queue_item:
        DBWriter.addQueueItem(context, selectedItem.getId());
        break;
      case R.id.remove_from_queue_item:
        DBWriter.removeQueueItem(context, selectedItem.getId(), true);
        break;
      case R.id.stream_item:
        DBTasks.playMedia(context, selectedItem.getMedia(), true, true, true);
        break;
      case R.id.visit_website_item:
        Uri uri = Uri.parse(selectedItem.getLink());
        context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
        break;
      case R.id.support_item:
        DBTasks.flattrItemIfLoggedIn(context, selectedItem);
        break;
      case R.id.share_link_item:
        ShareUtils.shareFeedItemLink(context, selectedItem);
        break;
      default:
        return false;
    }
    // Refresh menu state

    return true;
  }
Пример #2
0
  public static boolean onMenuItemClicked(Context context, MenuItem item, FeedItem selectedItem)
      throws DownloadRequestException {
    DownloadRequester requester = DownloadRequester.getInstance();
    FeedManager manager = FeedManager.getInstance();
    switch (item.getItemId()) {
      case R.id.download_item:
        manager.downloadFeedItem(context, selectedItem);
        break;
      case R.id.play_item:
        manager.playMedia(context, selectedItem.getMedia(), true, true, false);
        break;
      case R.id.remove_item:
        manager.deleteFeedMedia(context, selectedItem.getMedia());
        break;
      case R.id.cancel_download_item:
        requester.cancelDownload(context, selectedItem.getMedia());
        break;
      case R.id.mark_read_item:
        manager.markItemRead(context, selectedItem, true, true);
        break;
      case R.id.mark_unread_item:
        manager.markItemRead(context, selectedItem, false, true);
        break;
      case R.id.add_to_queue_item:
        manager.addQueueItem(context, selectedItem);
        break;
      case R.id.remove_from_queue_item:
        manager.removeQueueItem(context, selectedItem);
        break;
      case R.id.stream_item:
        manager.playMedia(context, selectedItem.getMedia(), true, true, true);
        break;
      case R.id.visit_website_item:
        Uri uri = Uri.parse(selectedItem.getLink());
        context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
        break;
      case R.id.support_item:
        new FlattrClickWorker(context, selectedItem.getPaymentLink()).executeAsync();
        break;
      case R.id.share_link_item:
        ShareUtils.shareFeedItemLink(context, selectedItem);
        break;
      default:
        return false;
    }
    // Refresh menu state

    return true;
  }