Search in sources :

Example 31 with FastBitmapDrawable

use of com.android.launcher3.FastBitmapDrawable in project android_packages_apps_Launcher3 by ProtonAOSP.

the class DragPreviewProvider method createDrawable.

/**
 * Returns a new drawable to show when the {@link #mView} is being dragged around.
 * Responsibility for the drawable is transferred to the caller.
 */
public Drawable createDrawable() {
    if (mView instanceof LauncherAppWidgetHostView) {
        return null;
    }
    int width = 0;
    int height = 0;
    // Assume scaleX == scaleY, which is always the case for workspace items.
    float scale = mView.getScaleX();
    if (mView instanceof DraggableView) {
        ((DraggableView) mView).getSourceVisualDragBounds(mTempRect);
        width = mTempRect.width();
        height = mTempRect.height();
    } else {
        width = mView.getWidth();
        height = mView.getHeight();
    }
    return new FastBitmapDrawable(BitmapRenderer.createHardwareBitmap(width + blurSizeOutline, height + blurSizeOutline, (c) -> drawDragView(c, scale)));
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Context(android.content.Context) Rect(android.graphics.Rect) BitmapRenderer(com.android.launcher3.icons.BitmapRenderer) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) ActivityContext(com.android.launcher3.views.ActivityContext) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) BlurMaskFilter(android.graphics.BlurMaskFilter) FeatureFlags(com.android.launcher3.config.FeatureFlags) PorterDuff(android.graphics.PorterDuff) SafeCloseable(com.android.launcher3.util.SafeCloseable) Drawable(android.graphics.drawable.Drawable) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) ByteBuffer(java.nio.ByteBuffer) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Nullable(androidx.annotation.Nullable) R(com.android.launcher3.R) Bitmap(android.graphics.Bitmap) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DraggableView(com.android.launcher3.dragndrop.DraggableView) Paint(android.graphics.Paint)

Example 32 with FastBitmapDrawable

use of com.android.launcher3.FastBitmapDrawable in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FloatingIconView method fetchIcon.

/**
 * Loads the icon drawable on a worker thread to reduce latency between swapping views.
 */
@UiThread
public static IconLoadResult fetchIcon(Launcher l, View v, ItemInfo info, boolean isOpening) {
    RectF position = new RectF();
    getLocationBoundsForView(l, v, isOpening, position);
    final FastBitmapDrawable btvIcon;
    if (v instanceof BubbleTextView) {
        BubbleTextView btv = (BubbleTextView) v;
        if (info instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) info).runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
            btvIcon = btv.makePreloadIcon();
        } else {
            btvIcon = btv.getIcon();
        }
    } else {
        btvIcon = null;
    }
    IconLoadResult result = new IconLoadResult(info, btvIcon == null ? false : btvIcon.isThemed());
    result.btvDrawable = btvIcon;
    final long fetchIconId = sFetchIconId++;
    MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
        if (fetchIconId < sRecycledFetchIconId) {
            return;
        }
        getIconResult(l, v, info, position, btvIcon, result);
    });
    sIconLoadResult = result;
    return result;
}
Also used : RectF(android.graphics.RectF) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) BubbleTextView(com.android.launcher3.BubbleTextView) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) UiThread(androidx.annotation.UiThread)

Example 33 with FastBitmapDrawable

use of com.android.launcher3.FastBitmapDrawable in project android_packages_apps_Launcher3 by ProtonAOSP.

the class BubbleTextView method applyIconAndLabel.

@UiThread
protected void applyIconAndLabel(ItemInfoWithIcon info) {
    boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER || mDisplay == DISPLAY_TASKBAR;
    FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme);
    mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f);
    setIcon(iconDrawable);
    applyLabel(info);
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) UiThread(androidx.annotation.UiThread)

Example 34 with FastBitmapDrawable

use of com.android.launcher3.FastBitmapDrawable in project Launcher3 by chislon.

the class AppsCustomizePagedView method onSyncWidgetPageItems.

private void onSyncWidgetPageItems(AsyncTaskPageData data) {
    if (mInTransition) {
        mDeferredSyncWidgetPageItems.add(data);
        return;
    }
    try {
        int page = data.page;
        PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(page);
        ArrayList<Object> items = data.items;
        int count = items.size();
        for (int i = 0; i < count; ++i) {
            PagedViewWidget widget = (PagedViewWidget) layout.getChildAt(i);
            if (widget != null) {
                Bitmap preview = data.generatedImages.get(i);
                widget.applyPreview(new FastBitmapDrawable(preview), i);
            }
        }
        enableHwLayersOnVisiblePages();
        // Update all thread priorities
        Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
        while (iter.hasNext()) {
            AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
            int pageIndex = task.page;
            task.setThreadPriority(getThreadPriorityForPage(pageIndex));
        }
    } finally {
        data.cleanup(false);
    }
}
Also used : Bitmap(android.graphics.Bitmap) DragObject(com.android.launcher3.DropTarget.DragObject) Point(android.graphics.Point)

Example 35 with FastBitmapDrawable

use of com.android.launcher3.FastBitmapDrawable in project android_packages_apps_404Launcher by P-404.

the class BubbleTextView method applyIconAndLabel.

@UiThread
protected void applyIconAndLabel(ItemInfoWithIcon info) {
    boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER || mDisplay == DISPLAY_TASKBAR;
    FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme);
    mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f);
    setIcon(iconDrawable);
    applyLabel(info);
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) UiThread(androidx.annotation.UiThread)

Aggregations

FastBitmapDrawable (com.android.launcher3.icons.FastBitmapDrawable)66 Drawable (android.graphics.drawable.Drawable)40 Point (android.graphics.Point)35 Bitmap (android.graphics.Bitmap)33 Rect (android.graphics.Rect)27 Paint (android.graphics.Paint)17 DraggableView (com.android.launcher3.dragndrop.DraggableView)16 TargetApi (android.annotation.TargetApi)14 FastBitmapDrawable (com.android.launcher3.FastBitmapDrawable)13 LauncherIcons (com.android.launcher3.icons.LauncherIcons)13 SuppressLint (android.annotation.SuppressLint)12 UiThread (androidx.annotation.UiThread)12 AdaptiveIconDrawable (android.graphics.drawable.AdaptiveIconDrawable)11 BubbleTextView (com.android.launcher3.BubbleTextView)11 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)11 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)11 View (android.view.View)10 RoundDrawableWrapper (com.android.launcher3.icons.RoundDrawableWrapper)10 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)10 ShortcutInfo (android.content.pm.ShortcutInfo)8