Search in sources :

Example 1 with EntryManager

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);
}
Also used : EntryManager(com.newsrob.EntryManager)

Example 2 with EntryManager

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);
}
Also used : ArticleListActivity(com.newsrob.activities.ArticleListActivity) DashboardListActivity(com.newsrob.DashboardListActivity) EntryManager(com.newsrob.EntryManager)

Example 3 with EntryManager

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);
}
Also used : EntryManager(com.newsrob.EntryManager)

Example 4 with EntryManager

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;
    }
}
Also used : ArticleListActivity(com.newsrob.activities.ArticleListActivity) RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Timing(com.newsrob.util.Timing) PendingIntent(android.app.PendingIntent) EntryManager(com.newsrob.EntryManager)

Example 5 with EntryManager

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);
    }
}
Also used : EntryManager(com.newsrob.EntryManager)

Aggregations

EntryManager (com.newsrob.EntryManager)9 Intent (android.content.Intent)3 DashboardListActivity (com.newsrob.DashboardListActivity)2 ArticleListActivity (com.newsrob.activities.ArticleListActivity)2 Dialog (android.app.Dialog)1 PendingIntent (android.app.PendingIntent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 ContextMenu (android.view.ContextMenu)1 BadTokenException (android.view.WindowManager.BadTokenException)1 RemoteViews (android.widget.RemoteViews)1 IAuthenticationCallback (com.newsrob.auth.IAuthenticationCallback)1 ListPreference (com.newsrob.preference.ListPreference)1 Timing (com.newsrob.util.Timing)1 IOException (java.io.IOException)1