OSDN Git Service

Moving icon generation out of ShortcutInfo constructor so that it
[android-x86/packages-apps-Launcher3.git] / src / com / android / launcher3 / shortcuts / DeepShortcutView.java
index e7fc415..6e98100 100644 (file)
@@ -26,14 +26,11 @@ import android.util.AttributeSet;
 import android.view.View;
 import android.widget.FrameLayout;
 
-import com.android.launcher3.IconCache;
 import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.LogAccelerateInterpolator;
 import com.android.launcher3.R;
 import com.android.launcher3.ShortcutInfo;
 import com.android.launcher3.Utilities;
-import com.android.launcher3.shortcuts.DeepShortcutsContainer.UnbadgedShortcutInfo;
 import com.android.launcher3.util.PillRevealOutlineProvider;
 import com.android.launcher3.util.PillWidthRevealOutlineProvider;
 
@@ -51,7 +48,8 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima
     private View mIconView;
     private float mOpenAnimationProgress;
 
-    private UnbadgedShortcutInfo mInfo;
+    private ShortcutInfo mInfo;
+    private ShortcutInfoCompat mDetail;
 
     public DeepShortcutView(Context context) {
         this(context, null, 0);
@@ -93,19 +91,20 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima
     }
 
     /** package private **/
-    void applyShortcutInfo(UnbadgedShortcutInfo info, DeepShortcutsContainer container) {
+    void applyShortcutInfo(ShortcutInfo info, ShortcutInfoCompat detail,
+            DeepShortcutsContainer container) {
         mInfo = info;
-        IconCache cache = LauncherAppState.getInstance().getIconCache();
-        mBubbleText.applyFromShortcutInfo(info, cache);
+        mDetail = detail;
+        mBubbleText.applyFromShortcutInfo(info);
         mIconView.setBackground(mBubbleText.getIcon());
 
         // Use the long label as long as it exists and fits.
-        CharSequence longLabel = info.mDetail.getLongLabel();
+        CharSequence longLabel = mDetail.getLongLabel();
         int availableWidth = mBubbleText.getWidth() - mBubbleText.getTotalPaddingLeft()
                 - mBubbleText.getTotalPaddingRight();
         boolean usingLongLabel = !TextUtils.isEmpty(longLabel)
                 && mBubbleText.getPaint().measureText(longLabel.toString()) <= availableWidth;
-        mBubbleText.setText(usingLongLabel ? longLabel : info.mDetail.getShortLabel());
+        mBubbleText.setText(usingLongLabel ? longLabel : mDetail.getShortLabel());
 
         // TODO: Add the click handler to this view directly and not the child view.
         mBubbleText.setOnClickListener(Launcher.getLauncher(getContext()));
@@ -117,10 +116,11 @@ public class DeepShortcutView extends FrameLayout implements ValueAnimator.Anima
      * Returns the shortcut info that is suitable to be added on the homescreen
      */
     public ShortcutInfo getFinalInfo() {
-        ShortcutInfo badged = new ShortcutInfo(mInfo);
+        final ShortcutInfo badged = new ShortcutInfo(mInfo);
         // Queue an update task on the worker thread. This ensures that the badged
         // shortcut eventually gets its icon updated.
-        Launcher.getLauncher(getContext()).getModel().updateShortcutInfo(mInfo.mDetail, badged);
+        Launcher.getLauncher(getContext()).getModel()
+                .updateAndBindShortcutInfo(badged, mDetail);
         return badged;
     }