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;
}
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();
}
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);
}
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));
}
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));
}
Aggregations