Exemplo n.º 1
0
  public static void cancel(Context context, String accountKey, String type) {
    NotificationManager notificationManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel((accountKey + type).hashCode());

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor edit = preferences.edit();
    edit.putInt(SharedPreferencesConstants.NOTIFICATION_COUNT + accountKey + type, 0);
    edit.putString(SharedPreferencesConstants.NOTIFICATION_SUMMARY + accountKey + type, "");
    edit.commit();

    Notifier.setDashclockValues(context, accountKey, type, 0, "");
  }
Exemplo n.º 2
0
  public static void saveLastNotificationActioned(
      Context context, String accountKey, String type, long postId) {

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String pref =
        type.equals(SharedPreferencesConstants.NOTIFICATION_TYPE_MENTION)
            ? SharedPreferencesConstants.NOTIFICATION_LAST_ACTIONED_MENTION_ID
            : SharedPreferencesConstants.NOTIFICATION_LAST_ACTIONED_DIRECT_MESSAGE_ID;
    long lastDisplayedMentionId = preferences.getLong(pref + accountKey, 0);

    if (postId > lastDisplayedMentionId) {
      SharedPreferences.Editor edit = preferences.edit();
      edit.putLong(pref + accountKey, postId);
      edit.commit();

      saveLastNotificationDisplayed(context, accountKey, type, postId);
      Notifier.setDashclockValues(context, accountKey, type, 0, "");
    }
  }