当前位置: 首页>>代码示例>>Java>>正文


Java ShortcutBadger.applyCount方法代码示例

本文整理汇总了Java中me.leolin.shortcutbadger.ShortcutBadger.applyCount方法的典型用法代码示例。如果您正苦于以下问题:Java ShortcutBadger.applyCount方法的具体用法?Java ShortcutBadger.applyCount怎么用?Java ShortcutBadger.applyCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在me.leolin.shortcutbadger.ShortcutBadger的用法示例。


在下文中一共展示了ShortcutBadger.applyCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markAndroidNotificationBundledDetailRead

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
/**
 * Call this when you want to mark android notification issued by this app as read - remove it
 */
public void markAndroidNotificationBundledDetailRead(int androidNotificationIdToCancel) {
  Utils.getNotificationManager(context).cancel(androidNotificationIdToCancel);
  long c = PreferencesUtils.getLong(context, NUM_OF_BUNDLED_ANDROID_NOTIFICATIONS,0);
  if(c>1){
    PreferencesUtils.storeLong(context, NUM_OF_BUNDLED_ANDROID_NOTIFICATIONS, --c);
  } else {
    markAndroidNotificationsRead();
  }

  int bc = PreferencesUtils.getInt(context, NUM_OF_BADGED_ANDROID_NOTIFICATIONS,0);
  if(bc>1){
    PreferencesUtils.storeInt(context, NUM_OF_BADGED_ANDROID_NOTIFICATIONS, --bc);
    ShortcutBadger.applyCount(context, bc);
  } else {
    ShortcutBadger.removeCount(context);
  }

}
 
开发者ID:Daskiworks,项目名称:ghwatch,代码行数:22,代码来源:UnreadNotificationsService.java

示例2: onResume

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    /** Register for broadcast action if you need to be notified when Countly message received */
    messageReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Message message = intent.getParcelableExtra(CountlyMessaging.BROADCAST_RECEIVER_ACTION_MESSAGE);
            Log.i("CountlyActivity", "Got a message with data: " + message.getData());

            //Badge related things
            Bundle data = message.getData();
            String badgeString = data.getString("badge");
            try {
                if(badgeString != null) {
                    int badgeCount = Integer.parseInt(badgeString);

                    boolean succeded = ShortcutBadger.applyCount(getApplicationContext(), badgeCount);
                    if (!succeded) {
                        Toast.makeText(getApplicationContext(), "Unable to put badge", Toast.LENGTH_SHORT).show();
                    }
                }
            } catch (NumberFormatException exception) {
                Toast.makeText(getApplicationContext(), "Unable to parse given badge number", Toast.LENGTH_SHORT).show();
            }
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(CountlyMessaging.getBroadcastAction(getApplicationContext()));
    registerReceiver(messageReceiver, filter);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:MainActivity.java

示例3: updateBadge

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
private static void updateBadge(Context context, int count) {
  try {
    if (count == 0) ShortcutBadger.removeCount(context);
    else            ShortcutBadger.applyCount(context, count);
  } catch (Throwable t) {
    // NOTE :: I don't totally trust this thing, so I'm catching
    // everything.
    Log.w("MessageNotifier", t);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:MessageNotifier.java

示例4: tryAutomaticBadge

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
private void tryAutomaticBadge(Context context, int number) {
    if (null == applyAutomaticBadger) {
        applyAutomaticBadger = ShortcutBadger.applyCount(context, number);
        if (applyAutomaticBadger) {
            FLog.i(LOG_TAG, "First attempt to use automatic badger succeeded; permanently enabling method.");
        } else {
            FLog.i(LOG_TAG, "First attempt to use automatic badger failed; permanently disabling method.");
        }
        return;
    } else if (!applyAutomaticBadger) {
        return;
    }
    ShortcutBadger.applyCount(context, number);
}
 
开发者ID:zzzkk2009,项目名称:react-native-leancloud-sdk,代码行数:15,代码来源:ApplicationBadgeHelper.java

示例5: updateUnreadCountBadge

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
public synchronized void updateUnreadCountBadge() {
	int count = unreadCount();
	if (unreadCount != count) {
		Log.d(Config.LOGTAG, "update unread count to " + count);
		if (count > 0) {
			ShortcutBadger.applyCount(getApplicationContext(), count);
		} else {
			ShortcutBadger.removeCount(getApplicationContext());
		}
		unreadCount = count;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:13,代码来源:XmppConnectionService.java

示例6: setBadgeCount

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
public void setBadgeCount(int badgeCount) {
    storeBadgeCount(badgeCount);
    if (badgeCount == 0) {
        ShortcutBadger.removeCount(mContext);
        Log.d(TAG, "Remove count");
    } else {
        ShortcutBadger.applyCount(mContext, badgeCount);
        Log.d(TAG, "Apply count: " + badgeCount);
    }
}
 
开发者ID:evollu,项目名称:react-native-fcm,代码行数:11,代码来源:BadgeHelper.java

示例7: Click

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
@OnClick({R.id.set_badge_num, R.id.get, R.id.format, R.id.getMac1, R.id.getMac2, R.id.link})
public void Click(View view) {
    switch (view.getId()) {
        case R.id.set_badge_num:
            int count = 0;
            if (!TextUtils.isEmpty(mInput.getText().toString())) {
                count = Integer.parseInt(mInput.getText().toString());
            }

            if (ShortcutBadger.applyCount(this, count)) {
                T.showSToast(this, "success");
            } else {
                T.showSToast(this, "fail");
            }


            break;
        case R.id.get:
            mResult.setText(mInput.getText().toString());
            break;
        case R.id.format:
            String temp = mResult.getText().toString();

            temp = temp.replace("\n", "");

            mResult.setText(temp);
            break;
        case R.id.getMac1:
            getMacAddress1();
            break;
        case R.id.getMac2:
            getMacAddress2();
            break;
        case R.id.link:
            Toast.makeText(this, "link !", Toast.LENGTH_SHORT).show();
            break;
        default:
            break;
    }
}
 
开发者ID:REBOOTERS,项目名称:AndroidAnimationExercise,代码行数:41,代码来源:InputActivity.java

示例8: setApplicationIconBadgeNumber

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
public static void setApplicationIconBadgeNumber(Context context, int badgeCount) {
  if (badgeCount > 0) {
    ShortcutBadger.applyCount(context, badgeCount);
  } else {
    ShortcutBadger.removeCount(context);
  }

  SharedPreferences.Editor editor = context.getSharedPreferences(BADGE, Context.MODE_PRIVATE).edit();
  editor.putInt(BADGE, Math.max(badgeCount, 0));
  editor.apply();
}
 
开发者ID:phonegap,项目名称:phonegap-plugin-push,代码行数:12,代码来源:PushPlugin.java

示例9: fireAndroidNotification

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
protected void fireAndroidNotification(NotificationStream newStream, NotificationStream oldStream) {
  if (newStream == null || !PreferencesUtils.getBoolean(context, PreferencesUtils.PREF_NOTIFY, true))
    return;

  Log.d(TAG, "fireAndroidNotification count before filter " + newStream.size());
  newStream = filterForAndroidNotification(newStream);
  Log.d(TAG, "fireAndroidNotification count after filter " + newStream.size());
  if (newStream.isNewNotification(oldStream)) {
    ShortcutBadger.applyCount(context, newStream.size());
    PreferencesUtils.storeInt(context, NUM_OF_BADGED_ANDROID_NOTIFICATIONS, newStream.size());

    //TEST with only one notification
    if(false) {
      Notification on = newStream.get(0);
      Notification on2 = newStream.get(1);
      newStream = new NotificationStream();
      newStream.addNotification(on);
      newStream.addNotification(on2);
    }

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.N) {
      fireAndroidNotificationInboxStyle(newStream);
    } else {
      fireAndroidNotificationBundledStyle(newStream);
    }
    ActivityTracker.sendEvent(context, ActivityTracker.CAT_NOTIF, "new_notif", "notif count: " + newStream.size(), Long.valueOf(newStream.size()));
  } else if (newStream.isEmpty()) {
    // #54 dismiss previous android notification if no any Github notification is available (as it was read on another device)
    Utils.getNotificationManager(context).cancel(ANDROID_NOTIFICATION_MAIN_ID);
    ShortcutBadger.removeCount(context);
  }
}
 
开发者ID:Daskiworks,项目名称:ghwatch,代码行数:33,代码来源:UnreadNotificationsService.java

示例10: updateBadgeCount

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
public void updateBadgeCount(int badgeCount) {
    Log.d(TAG, "updateBadgeCount: " + badgeCount);

 Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
    ShortcutBadger.applyCount(currentActivity, badgeCount);
}
 
开发者ID:a-voityuk,项目名称:CTTimekoGCM,代码行数:7,代码来源:CttimekogcmModule.java

示例11: setBadge

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
@ReactMethod
public void setBadge(int number) {
  ShortcutBadger.applyCount(getReactApplicationContext(), number);
}
 
开发者ID:jhen0409,项目名称:react-native-android-badge,代码行数:5,代码来源:BadgeModule.java

示例12: setBadge

import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
/**
 * Set the badge number.
 *
 * @param badge The number to set as the badge number.
 */
public void setBadge(int badge) {
    saveBadge(badge);
    ShortcutBadger.applyCount(ctx, badge);
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:10,代码来源:BadgeImpl.java


注:本文中的me.leolin.shortcutbadger.ShortcutBadger.applyCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。