diff options
author | Winson Chung <winsonc@google.com> | 2012-01-10 16:20:33 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2012-01-10 16:21:56 -0800 |
commit | e428e292c27e650ab4de76b78728ba55019cd282 (patch) | |
tree | 80c1e3a91d4023de9d2e384d170f03411bf4551d /src/com/android/launcher2/InstallShortcutReceiver.java | |
parent | 25595a611aa3ced225cc2f3ad9cc3c0ef9241912 (diff) | |
download | packages_apps_trebuchet-e428e292c27e650ab4de76b78728ba55019cd282.zip packages_apps_trebuchet-e428e292c27e650ab4de76b78728ba55019cd282.tar.gz packages_apps_trebuchet-e428e292c27e650ab4de76b78728ba55019cd282.tar.bz2 |
Fixing issue where multiple toasts were showing when installing a new app from Market (Bug 5785281)
Change-Id: Iba395354374ab721f05e03dd449e4ed9205508e5
Diffstat (limited to 'src/com/android/launcher2/InstallShortcutReceiver.java')
-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 ed8f299..3cb37a7 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; |