Browse Source

Don't instantiate intent each time in the for loop

https://github.com/stefan-niedermann/nextcloud-deck/issues/208
Stefan Niedermann 5 years ago
parent
commit
820f6745e1

+ 2 - 1
src/main/java/com/nextcloud/client/integration/deck/DeckNotificationHandler.java

@@ -54,8 +54,9 @@ public class DeckNotificationHandler implements NotificationHandler {
         if (!APP_NAME.equalsIgnoreCase(notification.app)) {
         if (!APP_NAME.equalsIgnoreCase(notification.app)) {
             throw new AppCannotHandleNotificationException();
             throw new AppCannotHandleNotificationException();
         }
         }
+        final Intent intent = new Intent();
         for (String flavor : DECK_APP_ID_FLAVOR_SUFFIXES) {
         for (String flavor : DECK_APP_ID_FLAVOR_SUFFIXES) {
-            final Intent intent = new Intent().setClassName(DECK_APP_ID_BASE + flavor, DECK_ACTIVITY_TO_START);
+            intent.setClassName(DECK_APP_ID_BASE + flavor, DECK_ACTIVITY_TO_START);
             if (packageManager.resolveActivity(intent, 0) != null) {
             if (packageManager.resolveActivity(intent, 0) != null) {
                 Log.i(TAG, "Found deck app flavor \"" + flavor + "\"");
                 Log.i(TAG, "Found deck app flavor \"" + flavor + "\"");
                 return intent
                 return intent