Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Check api level before clearing shortcut items #37

Merged
merged 1 commit into from
May 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,17 @@ public void setShortcutItems(ReadableArray items) {
.build());
}

getReactApplicationContext().getSystemService(ShortcutManager.class)
.setDynamicShortcuts(shortcuts);
getShortcutManager().setDynamicShortcuts(shortcuts);
}

@ReactMethod
@TargetApi(25)
public void clearShortcutItems() {
getReactApplicationContext().getSystemService(ShortcutManager.class)
.removeAllDynamicShortcuts();
if (!isShortcutSupported()) {
return;
}

getShortcutManager().removeAllDynamicShortcuts();
mShortcutItems = null;
}

Expand All @@ -134,6 +136,11 @@ private boolean isShortcutSupported() {
return Build.VERSION.SDK_INT >= 25;
}

@TargetApi(25)
private ShortcutManager getShortcutManager() {
return getReactApplicationContext().getSystemService(ShortcutManager.class);
}

private void sendJSEvent(Intent intent) {
if (!ACTION_SHORTCUT.equals(intent.getAction()) || !isShortcutSupported()) {
return;
Expand Down