Search in sources :

Example 86 with FastBitmapDrawable

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

the class WidgetCell method applyPreview.

private void applyPreview(Bitmap bitmap) {
    if (bitmap != null) {
        Drawable drawable = new RoundDrawableWrapper(new FastBitmapDrawable(bitmap), mEnforcedCornerRadius);
        // Scale down the preview size if it's wider than the cell.
        float scale = 1f;
        if (mTargetPreviewWidth > 0) {
            float maxWidth = mTargetPreviewWidth;
            float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale;
            scale = Math.min(maxWidth / previewWidth, 1);
        }
        setContainerSize(Math.round(drawable.getIntrinsicWidth() * scale * mPreviewContainerScale), Math.round(drawable.getIntrinsicHeight() * scale * mPreviewContainerScale));
        mWidgetImage.setDrawable(drawable);
        mWidgetImage.setVisibility(View.VISIBLE);
        if (mAppWidgetHostViewPreview != null) {
            removeView(mAppWidgetHostViewPreview);
            mAppWidgetHostViewPreview = null;
        }
    }
    if (mAnimatePreview) {
        mWidgetImageContainer.setAlpha(0f);
        ViewPropertyAnimator anim = mWidgetImageContainer.animate();
        anim.alpha(1.0f).setDuration(FADE_IN_DURATION_MS);
    } else {
        mWidgetImageContainer.setAlpha(1f);
    }
    if (mActiveRequest != null) {
        mActiveRequest.cancel();
        mActiveRequest = null;
    }
}
Also used : FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) Drawable(android.graphics.drawable.Drawable) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) RoundDrawableWrapper(com.android.launcher3.icons.RoundDrawableWrapper) ViewPropertyAnimator(android.view.ViewPropertyAnimator)

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