@TargetApi(25)
public static void updateShortcuts(Activity parentActivity, ShortcutManager shortcutManager, int sizeOfForumFavArray) {
ArrayList<ShortcutInfo> listOfShortcuts = new ArrayList<>();
int sizeOfShortcutArray = (sizeOfForumFavArray > 4 ? 4 : sizeOfForumFavArray);
for (int i = 0; i < sizeOfShortcutArray; ++i) {
String currentShortcutLink = PrefsManager.getStringWithSufix(PrefsManager.StringPref.Names.FORUM_FAV_LINK, String.valueOf(i));
String currentShortcutName = PrefsManager.getStringWithSufix(PrefsManager.StringPref.Names.FORUM_FAV_NAME, String.valueOf(i));
ShortcutInfo newShortcut = new ShortcutInfo.Builder(parentActivity, String.valueOf(i) + "_" + currentShortcutLink)
.setShortLabel(currentShortcutName)
.setLongLabel(currentShortcutName)
.setIcon(Icon.createWithResource(parentActivity, R.mipmap.ic_shortcut_forum))
.setIntent(new Intent(MainActivity.ACTION_OPEN_LINK, Uri.parse(currentShortcutLink))).build();
listOfShortcuts.add(newShortcut);
}
try {
shortcutManager.setDynamicShortcuts(listOfShortcuts);
} catch (Exception e) {
/* À ce qu'il parait ça peut crash "when the user is locked", je sais pas ce que ça
* veut dire donc dans le doute je mets ça là. */
}
}
Utils.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:RespawnIRC-Android
作者:
评论列表
文章目录