Merge "Moving some common functionality to IconLoaderLib" into sc-dev
This commit is contained in:
@@ -68,6 +68,7 @@ import androidx.annotation.Nullable;
|
||||
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutView;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.FastBitmapDrawable.newIcon;
|
||||
import static com.android.launcher3.uioverrides.QuickstepLauncher.GO_LOW_RAM_RECENTS_ENABLED;
|
||||
|
||||
import android.app.ActivityManager.TaskDescription;
|
||||
@@ -34,7 +33,6 @@ import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.FastBitmapDrawable;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
@@ -137,11 +135,12 @@ public class TaskIconCache {
|
||||
// TODO: Load icon resource (b/143363444)
|
||||
Bitmap icon = TaskDescriptionCompat.getIcon(desc, key.userId);
|
||||
if (icon != null) {
|
||||
entry.icon = new FastBitmapDrawable(getBitmapInfo(
|
||||
/* isInstantApp */
|
||||
entry.icon = getBitmapInfo(
|
||||
new BitmapDrawable(mContext.getResources(), icon),
|
||||
key.userId,
|
||||
desc.getPrimaryColor(),
|
||||
false /* isInstantApp */));
|
||||
false /* isInstantApp */).newIcon(mContext);
|
||||
} else {
|
||||
activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(
|
||||
key.getComponent(), key.userId);
|
||||
@@ -151,7 +150,7 @@ public class TaskIconCache {
|
||||
key.userId,
|
||||
desc.getPrimaryColor(),
|
||||
activityInfo.applicationInfo.isInstantApp());
|
||||
entry.icon = newIcon(mContext, bitmapInfo);
|
||||
entry.icon = bitmapInfo.newIcon(mContext);
|
||||
} else {
|
||||
entry.icon = getDefaultIcon(key.userId);
|
||||
}
|
||||
@@ -199,7 +198,7 @@ public class TaskIconCache {
|
||||
}
|
||||
mDefaultIcons.put(userId, info);
|
||||
}
|
||||
return new FastBitmapDrawable(info);
|
||||
return info.newIcon(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,26 +21,14 @@ import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.FastBitmapDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A view which draws a drawable stretched to fit its size. Unlike ImageView, it avoids relayout
|
||||
* when the drawable changes.
|
||||
*/
|
||||
public class IconView extends View {
|
||||
|
||||
public interface OnScaleUpdateListener {
|
||||
public void onScaleUpdate(float scale);
|
||||
}
|
||||
|
||||
private Drawable mDrawable;
|
||||
|
||||
private ArrayList<OnScaleUpdateListener> mScaleListeners;
|
||||
|
||||
public IconView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -93,16 +81,6 @@ public class IconView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateDrawable(@NonNull Drawable drawable) {
|
||||
super.invalidateDrawable(drawable);
|
||||
if (drawable instanceof FastBitmapDrawable && mScaleListeners != null) {
|
||||
for (OnScaleUpdateListener listener : mScaleListeners) {
|
||||
listener.onScaleUpdate(((FastBitmapDrawable) drawable).getScale());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mDrawable != null) {
|
||||
@@ -115,22 +93,6 @@ public class IconView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addUpdateScaleListener(OnScaleUpdateListener listener) {
|
||||
if (mScaleListeners == null) {
|
||||
mScaleListeners = new ArrayList<>();
|
||||
}
|
||||
mScaleListeners.add(listener);
|
||||
if (mDrawable instanceof FastBitmapDrawable) {
|
||||
listener.onScaleUpdate(((FastBitmapDrawable) mDrawable).getScale());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUpdateScaleListener(OnScaleUpdateListener listener) {
|
||||
if (mScaleListeners != null) {
|
||||
mScaleListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(float alpha) {
|
||||
super.setAlpha(alpha);
|
||||
|
||||
Reference in New Issue
Block a user