Exemple #1
0
 private void flushStoriesMarkedRead() {
   synchronized (this.storiesToMarkAsRead) {
     if (this.storiesToMarkAsRead.size() > 0) {
       FeedUtils.markStoriesAsRead(this.storiesToMarkAsRead, this);
       this.storiesToMarkAsRead.clear();
     }
   }
 }
Exemple #2
0
  @Override
  protected void onResume() {
    super.onResume();

    NBSyncService.clearPendingStoryRequest();
    NBSyncService.flushRecounts();
    NBSyncService.setActivationMode(NBSyncService.ActivationMode.ALL);
    FeedUtils.activateAllStories();
    FeedUtils.clearReadingSession();

    updateStatusIndicators();
    triggerSync();

    if (PrefsUtils.isLightThemeSelected(this) != isLightTheme) {
      UIUtils.restartActivity(this);
    }
  }
 @Override
 protected void triggerRefresh(int page) {
   FeedUtils.updateFeeds(
       this,
       this,
       feedIds,
       page,
       PrefsUtils.getStoryOrderForFolder(this, folderName),
       PrefsUtils.getReadFilterForFolder(this, folderName));
 }
Exemple #4
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int currentItem = pager.getCurrentItem();
    Story story = readingAdapter.getStory(currentItem);
    UserDetails user = PrefsUtils.getUserDetails(this);

    if (item.getItemId() == android.R.id.home) {
      finish();
      return true;
    } else if (item.getItemId() == R.id.menu_reading_original) {
      if (story != null) {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(story.permalink));
        startActivity(i);
      }
      return true;
    } else if (item.getItemId() == R.id.menu_reading_sharenewsblur) {
      if (story != null) {
        ReadingItemFragment currentFragment =
            (ReadingItemFragment) readingAdapter.instantiateItem(pager, currentItem);
        DialogFragment newFragment =
            ShareDialogFragment.newInstance(
                currentFragment, story, currentFragment.previouslySavedShareText);
        newFragment.show(getSupportFragmentManager(), "dialog");
      }
      return true;
    } else if (item.getItemId() == R.id.menu_shared) {
      Intent intent = new Intent(android.content.Intent.ACTION_SEND);
      intent.setType("text/plain");
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Intent.EXTRA_SUBJECT, story.title);
      final String shareString = getResources().getString(R.string.share);
      intent.putExtra(
          Intent.EXTRA_TEXT,
          String.format(shareString, new Object[] {story.title, story.permalink}));
      startActivity(Intent.createChooser(intent, "Share using"));
      return true;
    } else if (item.getItemId() == R.id.menu_textsize) {
      float currentValue =
          getSharedPreferences(PrefConstants.PREFERENCES, 0)
              .getFloat(PrefConstants.PREFERENCE_TEXT_SIZE, 0.5f);
      TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(currentValue);
      textSize.show(getSupportFragmentManager(), TEXT_SIZE);
      return true;
    } else if (item.getItemId() == R.id.menu_reading_save) {
      FeedUtils.saveStory(story, Reading.this, apiManager);
      return true;
    } else if (item.getItemId() == R.id.menu_reading_markunread) {
      this.markStoryUnread(story);
      return true;
    } else {
      return super.onOptionsItemSelected(item);
    }
  }
 @Override
 protected int getUnreadCount() {
   Cursor folderCursor =
       contentResolver.query(
           FeedProvider.FOLDERS_URI.buildUpon().appendPath(folderName).build(),
           null,
           null,
           new String[] {DatabaseConstants.getFolderSelectionFromState(currentState)},
           null);
   int c = FeedUtils.getCursorUnreadCount(folderCursor, currentState);
   folderCursor.close();
   return c;
 }
Exemple #6
0
  private void markStoryUnread(Story story) {

    // first, ensure the story isn't queued up to be marked as read
    this.storiesToMarkAsRead.remove(story);

    // next, call the API to un-mark it as read, just in case we missed the batch
    // operation, or it was read long before now.
    FeedUtils.markStoryUnread(story, Reading.this, this.apiManager);

    this.unreadCount++;
    this.storiesAlreadySeen.remove(story);

    this.enableOverlays();
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo menuInfo =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int truePosition = menuInfo.position - 1;
    Story story = adapter.getStory(truePosition);
    Activity activity = getActivity();

    switch (item.getItemId()) {
      case R.id.menu_mark_story_as_read:
        FeedUtils.markStoryAsRead(story, activity);
        return true;

      case R.id.menu_mark_story_as_unread:
        FeedUtils.markStoryUnread(story, activity);
        return true;

      case R.id.menu_mark_older_stories_as_read:
        FeedUtils.markFeedsRead(getFeedSet(), story.timestamp, null, activity);
        return true;

      case R.id.menu_mark_newer_stories_as_read:
        FeedUtils.markFeedsRead(getFeedSet(), null, story.timestamp, activity);
        return true;

      case R.id.menu_send_story:
        FeedUtils.sendStory(story, activity);
        return true;

      case R.id.menu_save_story:
        FeedUtils.setStorySaved(story, true, activity);
        return true;

      case R.id.menu_unsave_story:
        FeedUtils.setStorySaved(story, false, activity);

        return true;

      default:
        return super.onContextItemSelected(item);
    }
  }