private void hideBookmarks() { shortcuts.removeAllDynamicShortcuts(); }
@RequiresApi(25) private static void setShortcuts(@NonNull Context context) { ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class); if (createShortcuts == null) { shortcutManager.removeAllDynamicShortcuts(); } else { //noinspection TryWithIdenticalCatches try { final Object returnValue = createShortcuts.invoke(generated, context); @SuppressWarnings("unchecked") List<List<ShortcutInfo>> shortcuts = (List<List<ShortcutInfo>>) returnValue; List<ShortcutInfo> enabledShortcuts = shortcuts.get(0); List<String> disabledShortcutsIds = new ArrayList<>(); for (final ShortcutInfo shortcutInfo : shortcuts.get(1)) { disabledShortcutsIds.add(shortcutInfo.getId()); } shortcutManager.disableShortcuts(disabledShortcutsIds); shortcutManager.setDynamicShortcuts(enabledShortcuts); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } shortcutsSet = true; }
@Test public void testRemoveAllDynamicShortcuts() throws Exception { shortcutManager.addDynamicShortcuts( ImmutableList.of(createShortcut("id1"), createShortcut("id2"))); assertThat(shortcutManager.getDynamicShortcuts()).hasSize(2); shortcutManager.removeAllDynamicShortcuts(); assertThat(shortcutManager.getDynamicShortcuts()).isEmpty(); }
shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < 4; i++) { NavigationFragment fragment = findNavigationFragmentByClass(queue.poll());
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); int newWallId = ShortcutsUtils.getNextRailNumber(shortcutManager); ShortcutInfo ballShortcut = ShortcutsUtils.createTrainShortcut(this); ShortcutInfo wallShortcut = ShortcutsUtils.createRailShortcut(this, newWallId); shortcutManager.setDynamicShortcuts(Arrays.asList(ballShortcut, wallShortcut)); setContentView(R.layout.activity_main); rootView = findViewById(R.id.activity_main_root); viewPager = (ViewPager) findViewById(R.id.activity_main_view_pager); pagerAdapter = new TutorialViewPagerAdapter(getFragmentManager()); viewPager.setAdapter(pagerAdapter); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finishActivity(); } }); }