Пример #1
0
 @Override
 public void onReceive(Context context, Intent intent) {
   if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
     // postpone notification service launch a minute,
     // we don't want to slow down booting
     Timber.d("Postponing notifications service launch");
     Utils.runNotificationServiceDelayed(context);
   } else {
     // run the notification service right away
     Timber.d("Run notifications service right away");
     Utils.runNotificationService(context);
   }
 }
Пример #2
0
  private void onFavoriteShow(String showId, boolean isFavorite) {
    ContentValues values = new ContentValues();
    values.put(Shows.FAVORITE, isFavorite);
    getActivity().getContentResolver().update(Shows.buildShowUri(showId), values, null, null);

    Utils.runNotificationService(getActivity());

    Toast.makeText(
            getActivity(),
            getString(isFavorite ? R.string.favorited : R.string.unfavorited),
            Toast.LENGTH_SHORT)
        .show();

    fireTrackerEventContext(isFavorite ? "Favorite show" : "Unfavorite show");
  }
  @Override
  public void onCreate() {
    super.onCreate();

    // set provider authority
    CONTENT_AUTHORITY = getPackageName() + ".provider";

    // initialize settings on first run
    PreferenceManager.setDefaultValues(this, R.xml.settings_basic, false);
    PreferenceManager.setDefaultValues(this, R.xml.settings_advanced, false);

    // ensure the notifications service is started (we also restart it on
    // boot)
    Utils.runNotificationService(this);

    // load the current theme into a global variable
    final String theme =
        PreferenceManager.getDefaultSharedPreferences(this)
            .getString(SeriesGuidePreferences.KEY_THEME, "0");
    Utils.updateTheme(theme);

    // set a context for Google Analytics
    EasyTracker.getInstance().setContext(getApplicationContext());
  }