Load clipboard image thumbnail in background
Also fixes a bug where copying several things in quick succession could cause the UI to appear to freeze (due to starting and cancelling an exit animation, but not redoing the enter animation). Bug: 267161222 Fix: 267161222 Test: manual, atest ClipboardOverlayControllerTest Change-Id: I59de7152cd0655417ee78ee787edb54d30e0e39c
This commit is contained in:
@@ -263,10 +263,11 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv
|
||||
@Override // ClipboardListener.ClipboardOverlay
|
||||
public void setClipData(ClipData data, String source) {
|
||||
ClipboardModel model = ClipboardModel.fromClipData(mContext, mClipboardUtils, data, source);
|
||||
if (mExitAnimator != null && mExitAnimator.isRunning()) {
|
||||
boolean wasExiting = (mExitAnimator != null && mExitAnimator.isRunning());
|
||||
if (wasExiting) {
|
||||
mExitAnimator.cancel();
|
||||
}
|
||||
boolean shouldAnimate = !model.dataMatches(mClipboardModel);
|
||||
boolean shouldAnimate = !model.dataMatches(mClipboardModel) || wasExiting;
|
||||
mClipboardModel = model;
|
||||
mClipboardLogger.setClipSource(mClipboardModel.getSource());
|
||||
if (shouldAnimate) {
|
||||
@@ -313,15 +314,19 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv
|
||||
mOnPreviewTapped = this::editText;
|
||||
break;
|
||||
case IMAGE:
|
||||
if (model.isSensitive() || model.loadThumbnail(mContext) != null) {
|
||||
mView.showImagePreview(
|
||||
model.isSensitive() ? null : model.loadThumbnail(mContext));
|
||||
mView.setEditAccessibilityAction(true);
|
||||
mOnPreviewTapped = () -> editImage(model.getUri());
|
||||
} else {
|
||||
// image loading failed
|
||||
mView.showDefaultTextPreview();
|
||||
}
|
||||
mBgExecutor.execute(() -> {
|
||||
if (model.isSensitive() || model.loadThumbnail(mContext) != null) {
|
||||
mView.post(() -> {
|
||||
mView.showImagePreview(
|
||||
model.isSensitive() ? null : model.loadThumbnail(mContext));
|
||||
mView.setEditAccessibilityAction(true);
|
||||
});
|
||||
mOnPreviewTapped = () -> editImage(model.getUri());
|
||||
} else {
|
||||
// image loading failed
|
||||
mView.post(mView::showDefaultTextPreview);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case URI:
|
||||
case OTHER:
|
||||
|
||||
Reference in New Issue
Block a user