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;
}
}
Aggregations