use of com.newsrob.EntryManager in project newsrob by marianokamp.
the class SettingsActivity method onResume.
@Override
protected void onResume() {
super.onResume();
EntryManager em = EntryManager.getInstance(this);
manageModelRelatedSettingsState(em.isModelCurrentlyUpdated());
em.addListener(this);
}
use of com.newsrob.EntryManager in project newsrob by marianokamp.
the class UnreadWidgetPrefActivity method createWidget.
private void createWidget() {
WidgetPreferences widgetPrefs = new WidgetPreferences();
widgetPrefs.setLabel(wizard.getWidgetLabel());
EntryManager entryManager = EntryManager.getInstance(this);
String filterLabel = null;
if (wizard.getScope() == Scope.LABEL && wizard.getSelectedLabelName().length() > 0) {
filterLabel = wizard.getSelectedLabelName();
if (filterLabel.length() == 0)
filterLabel = null;
}
Long filterFeedId = null;
if (wizard.getScope() == Scope.FEED && wizard.getSelectedFeedName().length() > 0)
filterFeedId = wizard.getSelectedFeedId();
if (wizard.getScope() == Scope.READING_LIST) {
Class<? extends AbstractNewsRobListActivity> startingActivity = ArticleListActivity.class;
if (wizard.getStartingActivity() == StartingActivity.DASHBOARD)
startingActivity = DashboardListActivity.class;
else if (wizard.getStartingActivity() == StartingActivity.FEEDS)
startingActivity = FeedListActivity.class;
widgetPrefs.setStartingActivityName(startingActivity.getName());
}
doCreateWidget(widgetPrefs, entryManager, filterLabel, filterFeedId);
}
use of com.newsrob.EntryManager in project newsrob by marianokamp.
the class UnreadWidgetProvider method onDeleted.
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
super.onDeleted(context, appWidgetIds);
EntryManager entryManager = EntryManager.getInstance(context);
for (int appWidgetId : appWidgetIds) entryManager.clearWidgetPreferences(appWidgetId);
}
use of com.newsrob.EntryManager in project newsrob by marianokamp.
the class UnreadWidgetProvider method buildUpdate.
public static RemoteViews buildUpdate(Context context, int appWidgetId) {
RemoteViews updateViews = null;
Timing t = new Timing("buildUpdate for widget " + appWidgetId, context);
try {
EntryManager entryManager = EntryManager.getInstance(context);
WidgetPreferences wp = entryManager.getWidgetPreferences(appWidgetId);
updateViews = new RemoteViews(context.getPackageName(), R.layout.unread_widget);
if (wp == null) {
PL.log(TAG + "Nothing stored for appWidgetId=" + appWidgetId, context);
updateViews.setTextViewText(R.id.unread_count, "oops!");
updateViews.setViewVisibility(R.id.unread_count, View.VISIBLE);
return updateViews;
}
int count = getCount(entryManager, wp.getDBQuery());
updateViews.setViewVisibility(R.id.unread_count, count > 0 ? View.VISIBLE : View.INVISIBLE);
updateViews.setTextViewText(R.id.unread_count, String.valueOf(count));
updateViews.setViewVisibility(R.id.label, wp.getLabel() != null && wp.getLabel().trim().length() > 0 ? View.VISIBLE : View.INVISIBLE);
updateViews.setTextViewText(R.id.label, wp.getLabel() == null ? "" : wp.getLabel());
Class startingActivityClass = ArticleListActivity.class;
if (wp.getStartingActivityName() != null) {
try {
startingActivityClass = Class.forName(wp.getStartingActivityName());
} catch (ClassNotFoundException e) {
throw e;
}
}
Intent intent = new Intent(context, startingActivityClass);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// intent.addCategory(Intent.CATEGORY_LAUNCHER);
// intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
// Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
// | Intent.FLAG_ACTIVITY_CLEAR_TOP);
UIHelper.addExtrasFromDBQuery(intent, wp.getDBQuery());
//
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// | Intent.FLAG_DEBUG_LOG_RESOLUTION
updateViews.setOnClickPendingIntent(R.id.container, pendingIntent);
} catch (Throwable throwable) {
PL.log("Exception during buildUpdate()", throwable, context);
} finally {
t.stop();
return updateViews;
}
}
use of com.newsrob.EntryManager in project newsrob by marianokamp.
the class FireReceiver method onReceive.
@Override
public void onReceive(final Context context, final Intent intent) {
EntryManager entryManager = EntryManager.getInstance(context);
PL.log("FireReceiver with intent action: " + intent.getAction(), context);
if ("com.newsrob.CANCEL_SYNC".equals(intent.getAction())) {
entryManager.cancel();
PL.log("Externally triggered cancel.", context);
} else if ("com.newsrob.UP_SYNC".equals(intent.getAction())) {
entryManager.requestSynchronization(true);
PL.log("Externally triggered refresh (up sync only).", context);
} else {
entryManager.requestSynchronization(false);
PL.log("Externally triggered refresh (full).", context);
}
}
Aggregations