本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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);
}
示例11: setBadge
import me.leolin.shortcutbadger.ShortcutBadger; //导入方法依赖的package包/类
@ReactMethod
public void setBadge(int number) {
ShortcutBadger.applyCount(getReactApplicationContext(), number);
}
示例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);
}