diff options
author | Winson Chung <winsonc@google.com> | 2012-01-11 12:04:37 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-01-11 12:04:37 -0800 |
commit | 21d9b58734a26a02b85c232477bd21bf13332694 (patch) | |
tree | be5356c6d27add2c5538302e40c91a83896623f5 /src/com/android/launcher2 | |
parent | 7407d2a16ed6cf22494122cf683bf13de6fa3695 (diff) | |
parent | e428e292c27e650ab4de76b78728ba55019cd282 (diff) | |
download | android_packages_apps_Trebuchet-21d9b58734a26a02b85c232477bd21bf13332694.tar.gz android_packages_apps_Trebuchet-21d9b58734a26a02b85c232477bd21bf13332694.tar.bz2 android_packages_apps_Trebuchet-21d9b58734a26a02b85c232477bd21bf13332694.zip |
Merge "Fixing issue where multiple toasts were showing when installing a new app from Market (Bug 5785281)"
Diffstat (limited to 'src/com/android/launcher2')
-rw-r--r-- | src/com/android/launcher2/InstallShortcutReceiver.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java index ed8f29942..3cb37a724 100644 --- a/src/com/android/launcher2/InstallShortcutReceiver.java +++ b/src/com/android/launcher2/InstallShortcutReceiver.java @@ -16,8 +16,6 @@ package com.android.launcher2; -import java.util.ArrayList; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -25,6 +23,8 @@ import android.widget.Toast; import com.android.launcher.R; +import java.util.ArrayList; + public class InstallShortcutReceiver extends BroadcastReceiver { public static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; @@ -41,16 +41,21 @@ public class InstallShortcutReceiver extends BroadcastReceiver { } int screen = Launcher.getScreen(); - - if (!installShortcut(context, data, screen)) { + String[] errorMsgs = {""}; + if (!installShortcut(context, data, screen, errorMsgs)) { // The target screen is full, let's try the other screens for (int i = 0; i < Launcher.SCREEN_COUNT; i++) { - if (i != screen && installShortcut(context, data, i)) break; + if (i != screen && installShortcut(context, data, i, errorMsgs)) break; } } + + if (!errorMsgs[0].isEmpty()) { + Toast.makeText(context, errorMsgs[0], + Toast.LENGTH_SHORT).show(); + } } - private boolean installShortcut(Context context, Intent data, int screen) { + private boolean installShortcut(Context context, Intent data, int screen, String[] errorMsgs) { String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (findEmptyCell(context, mCoordinates, screen)) { @@ -69,21 +74,18 @@ public class InstallShortcutReceiver extends BroadcastReceiver { LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0], mCoordinates[1], true); if (info != null) { - Toast.makeText(context, context.getString(R.string.shortcut_installed, name), - Toast.LENGTH_SHORT).show(); + errorMsgs[0] = context.getString(R.string.shortcut_installed, name); } else { return false; } } else { - Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name), - Toast.LENGTH_SHORT).show(); + errorMsgs[0] = context.getString(R.string.shortcut_duplicate, name); } return true; } } else { - Toast.makeText(context, context.getString(R.string.out_of_space), - Toast.LENGTH_SHORT).show(); + errorMsgs[0] = context.getString(R.string.out_of_space); } return false; |