Search in sources :

Example 11 with DBQuery

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

the class URLHelper method createDBQueryFromIntentExtras.

public static DBQuery createDBQueryFromIntentExtras(EntryManager entryManager, Intent intent) {
    String filterLabel = null;
    Long filterFeedId = null;
    long startDate = 0;
    Bundle extras = intent.getExtras();
    boolean sortOrderAscending = !entryManager.shouldShowNewestArticlesFirst();
    if (extras != null) {
        filterLabel = extras.getString(UIHelper.EXTRA_KEY_FILTER_LABEL);
        filterFeedId = extras.getLong(UIHelper.EXTRA_KEY_FILTER_FEED, -1l);
        if (filterFeedId == -1l)
            // NOPMD by mkamp on 1/18/10 12:36 PM
            filterFeedId = null;
        startDate = extras.getLong(UIHelper.EXTRA_KEY_START_DATE, 0);
        if (extras.containsKey(UIHelper.EXTRA_KEY_SORT_ORDER_ASCENDING))
            sortOrderAscending = extras.getBoolean(UIHelper.EXTRA_KEY_SORT_ORDER_ASCENDING, sortOrderAscending);
    }
    DBQuery dbq = new DBQuery(entryManager, filterLabel, filterFeedId);
    dbq.setStartDate(startDate);
    dbq.setSortOrderAscending(sortOrderAscending);
    // REMOVE TODO
    PL.log("dbq=" + dbq, entryManager.getContext());
    return dbq;
}
Also used : Bundle(android.os.Bundle) DBQuery(com.newsrob.DBQuery)

Example 12 with DBQuery

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

the class FeedListActivity method getDefaultStatusBarTitle.

@Override
public String getDefaultStatusBarTitle() {
    StringBuilder sb = new StringBuilder();
    DBQuery dbq = getDbQuery();
    if (dbq.getFilterLabel() != null && !"all articles".equals(dbq.getFilterLabel()))
        sb.append("- " + dbq.getFilterLabel());
    if (sb.length() == 0)
        sb.append("- Feeds");
    return getResources().getString(R.string.app_name) + " " + sb.toString();
}
Also used : DBQuery(com.newsrob.DBQuery)

Example 13 with DBQuery

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

the class FeedListActivity method onCreateContextMenu.

@Override
protected void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo, int selectedPosition) {
    String title = getSelectedTitle(selectedPosition);
    if (title == null)
        return;
    long feedId = getSelectedFeedId(selectedPosition);
    menu.setHeaderTitle(title);
    menu.add(0, MENU_ITEM_MANAGE_FEED_ID, 0, R.string.menu_item_manage_feed);
    menu.add(0, MENU_ITEM_MARK_ALL_READ_ID, 0, R.string.menu_item_mark_all_read);
    DBQuery dbq = new DBQuery(getDbQuery());
    dbq.setFilterFeedId(feedId);
    if (!getEntryManager().isMarkAllReadPossible(dbq))
        menu.getItem(1).setEnabled(false);
    boolean feedCanBeUnsubscribed = false;
    Feed f = getEntryManager().findFeedById(feedId);
    if (f != null)
        feedCanBeUnsubscribed = !getEntryManager().isModelCurrentlyUpdated() && getEntryManager().canFeedBeUnsubscribed(f.getAtomId());
    menu.add(0, MENU_ITEM_UNSUBSCRIBE_FEED_ID, 10, "Unsubscribe Feed").setEnabled(feedCanBeUnsubscribed);
}
Also used : DBQuery(com.newsrob.DBQuery) Feed(com.newsrob.Feed)

Example 14 with DBQuery

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

the class MarkAllReadDbQueryTests method testDateLimitSortAscendingDescending.

public void testDateLimitSortAscendingDescending() {
    DBQuery dbq = new DBQuery(entryManager, null, null);
    dbq.setSortOrderAscending(true);
    dbq.setDateLimit(new Date(2010, 10, 16).getTime() * 1000);
    assertEquals(2, entryManager.getMarkAllReadCount(dbq));
    dbq.setSortOrderAscending(false);
    assertEquals(3, entryManager.getMarkAllReadCount(dbq));
}
Also used : DBQuery(com.newsrob.DBQuery) Date(java.util.Date)

Example 15 with DBQuery

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

the class MarkAllReadDbQueryTests method testMarkAllReadWithLabel.

public void testMarkAllReadWithLabel() {
    DBQuery dbq = new DBQuery(entryManager, null, null);
    dbq.setFilterLabel("l1");
    assertEquals(1, entryManager.getMarkAllReadCount(dbq));
    dbq.setFilterLabel("l2");
    assertEquals(3, entryManager.getMarkAllReadCount(dbq));
    // non-existing
    dbq.setFilterLabel("l3");
    assertEquals(0, entryManager.getMarkAllReadCount(dbq));
}
Also used : DBQuery(com.newsrob.DBQuery)

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