Search in sources :

Example 6 with DBQuery

use of com.newsrob.DBQuery in project newsrob by marianokamp.

the class DBQueryContentCursorTests method testContentCursorCount.

public void testContentCursorCount() {
    DBQuery dbq = new DBQuery(entryManager, null, null);
    dbq.setSortOrderAscending(true);
    dbq.setShouldHideReadItemsWithoutUpdatingThePreference(false);
    assertEquals(5, entryManager.getContentCount(dbq));
}
Also used : DBQuery(com.newsrob.DBQuery)

Example 7 with DBQuery

use of com.newsrob.DBQuery in project newsrob by marianokamp.

the class DBQueryContentCursorTests method testContentCursorOrderAscendingWithLimit.

public void testContentCursorOrderAscendingWithLimit() {
    DBQuery dbq = new DBQuery(entryManager, null, null);
    dbq.setSortOrderAscending(true);
    dbq.setShouldHideReadItemsWithoutUpdatingThePreference(false);
    dbq.setLimit(3);
    List<String> expectedIds = atomIdsOrderedAscending;
    expectedIds = expectedIds.subList(0, 3);
    executeAndVerify(dbq, expectedIds);
}
Also used : DBQuery(com.newsrob.DBQuery)

Example 8 with DBQuery

use of com.newsrob.DBQuery in project newsrob by marianokamp.

the class UnsubscribeFeedTask method onContextItemSelected.

@Override
public boolean onContextItemSelected(final MenuItem item, final int position) {
    Entry entry = findEntryByPosition(position);
    if (entry == null)
        return false;
    if (position > -1 && item.getItemId() == MENU_ITEM_MARK_READ_UNTIL_HERE_ID) {
        DBQuery dbq = new DBQuery(getDbQuery());
        dbq.setDateLimit(entry.getUpdatedInHighResolution());
        instantiateMarkAllReadDialog(dbq);
        return true;
    }
    if (position > -1 && item.getItemId() == MENU_ITEM_UNSUBSCRIBE_FEED_ID) {
        Feed f = getEntryManager().findFeedById(entry.getFeedId());
        if (f == null)
            return true;
        final String feedAtomId = f.getAtomId();
        Runnable r = new Runnable() {

            @Override
            public void run() {
                new UnsubscribeFeedTask(getEntryManager()).execute(feedAtomId);
            }
        };
        showConfirmationDialog("Unsubscribe from \'" + f.getTitle() + "\' during the next sync and mark all remaining articles read?", r);
        return true;
    }
    if (ArticleViewHelper.articleActionSelected(this, item, getEntryManager(), entry))
        return true;
    return false;
}
Also used : Entry(com.newsrob.Entry) DBQuery(com.newsrob.DBQuery) Feed(com.newsrob.Feed)

Example 9 with DBQuery

use of com.newsrob.DBQuery in project newsrob by marianokamp.

the class AbstractNewsRobListActivity method updateButtons.

protected void updateButtons() {
    if (EntryManager.ACTION_BAR_GONE.equals(getEntryManager().getActionBarLocation())) {
        ProgressBar progressStatusBar = (ProgressBar) findViewById(R.id.progress_status_bar);
        progressStatusBar.setVisibility(entryManager.isModelCurrentlyUpdated() ? View.VISIBLE : View.INVISIBLE);
    }
    if (shouldActionBarBeHidden())
        return;
    if (refreshButton == null)
        setupButtons();
    if (refreshButton == null)
        return;
    View cancelButton = (View) findViewById(R.id.cancel_sync);
    if (cancelButton != null)
        cancelButton.setEnabled(entryManager.isModelCurrentlyUpdated() && !entryManager.isCancelRequested());
    refreshButton.setTag("Refresh");
    refreshButton.setImageResource(R.drawable.gen_toolbar_icon_sync);
    refreshButton.setEnabled(shouldRefreshButtonBeEnabled());
    refreshButton.setFocusable(refreshButton.isEnabled());
    DBQuery dbq = getDbQuery();
    boolean shouldHideReadItems = dbq.shouldHideReadItems();
    showHideButton.setImageResource(shouldHideReadItems ? R.drawable.gen_toolbar_icon_show : R.drawable.gen_toolbar_icon_hide);
    toggleOrderButton.setImageResource(getDbQuery().isSortOrderAscending() ? R.drawable.gen_toolbar_icon_sort_order_ascending : R.drawable.gen_toolbar_icon_sort_order_descending);
    markAllReadButton.setEnabled(shouldMarkAllReadButtonBeEnabled());
    markAllReadButton.setFocusable(markAllReadButton.isEnabled());
}
Also used : DBQuery(com.newsrob.DBQuery) ProgressBar(android.widget.ProgressBar) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Example 10 with DBQuery

use of com.newsrob.DBQuery in project newsrob by marianokamp.

the class ShowArticleActivity method initialize.

private void initialize(Intent i) {
    TypedValue tv = new TypedValue();
    getTheme().resolveAttribute(R.attr.webViewBackgroundColorLight, tv, true);
    backgroundColorLight = Color.parseColor(tv.coerceToString().toString());
    backgroundColorDark = Color.argb(255, 11, 11, 11);
    int position = i.getExtras().getInt(UIHelper.EXTRA_KEY_POSITION);
    if ("com.newsrob.VIEW".equals(i.getAction())) {
        contentCursor = getEntryManager().getArticleAsCursor(i.getDataString());
    } else if (Intent.ACTION_SEARCH.equals(i.getAction()) && i.hasExtra("atomId")) {
        contentCursor = getEntryManager().getArticleAsCursor(i.getExtras().getString("atomId"));
    } else {
        DBQuery dbQuery = UIHelper.createDBQueryFromIntentExtras(getEntryManager(), i);
        dbQuery.setLimit(getEntryManager().getMaxArticlesInArticleList());
        contentCursor = getEntryManager().getContentCursor(dbQuery);
    }
    startManagingCursor(contentCursor);
    if (!contentCursor.moveToPosition(position)) {
        PL.log("MoveToPosition failed. position=" + position, this);
        finish();
        return;
    }
    newPosition();
    getEntryManager().updateLastUsed();
    currentTheme = getEntryManager().getCurrentThemeResourceId();
}
Also used : DBQuery(com.newsrob.DBQuery) TypedValue(android.util.TypedValue)

Aggregations

DBQuery (com.newsrob.DBQuery)32 Feed (com.newsrob.Feed)7 Intent (android.content.Intent)3 Entry (com.newsrob.Entry)2 ArrayList (java.util.ArrayList)2 AppWidgetManager (android.appwidget.AppWidgetManager)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ProgressBar (android.widget.ProgressBar)1 RemoteViews (android.widget.RemoteViews)1 TextView (android.widget.TextView)1 Date (java.util.Date)1