use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by signalapp.
the class ScribbleView method getRenderedImage.
@SuppressLint("StaticFieldLeak")
@NonNull
public ListenableFuture<Bitmap> getRenderedImage(@NonNull GlideRequests glideRequests) {
final SettableFuture<Bitmap> future = new SettableFuture<>();
final Context context = getContext();
final boolean isLowMemory = Util.isLowMemory(context);
if (imageUri == null) {
future.set(null);
return future;
}
new AsyncTask<Void, Void, Bitmap>() {
@Override
@Nullable
protected Bitmap doInBackground(Void... params) {
try {
int width = Target.SIZE_ORIGINAL;
int height = Target.SIZE_ORIGINAL;
if (isLowMemory) {
width = 768;
height = 768;
}
return glideRequests.asBitmap().load(new DecryptableUri(imageUri)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(width, height).get();
} catch (InterruptedException | ExecutionException e) {
Log.w(TAG, e);
return null;
}
}
@Override
protected void onPostExecute(@Nullable Bitmap bitmap) {
if (bitmap == null) {
future.set(null);
return;
}
Canvas canvas = new Canvas(bitmap);
motionView.render(canvas);
canvasView.render(canvas);
future.set(bitmap);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return future;
}
use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.
the class ThumbnailView method buildThumbnailGlideRequest.
private GlideRequest buildThumbnailGlideRequest(@NonNull GlideRequests glideRequests, @NonNull Slide slide) {
GlideRequest request = applySizing(glideRequests.load(new DecryptableUri(slide.getUri())).diskCacheStrategy(DiskCacheStrategy.RESOURCE).transition(withCrossFade()), fit);
boolean doNotShowMissingThumbnailImage = Build.VERSION.SDK_INT < 23;
if (slide.isInProgress() || doNotShowMissingThumbnailImage)
return request;
else
return request.apply(RequestOptions.errorOf(R.drawable.ic_missing_thumbnail_picture));
}
use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.
the class ThumbnailView method setImageResource.
public ListenableFuture<Boolean> setImageResource(@NonNull GlideRequests glideRequests, @NonNull Uri uri, int width, int height) {
SettableFuture<Boolean> future = new SettableFuture<>();
if (transferControls.isPresent())
getTransferControls().setVisibility(View.GONE);
GlideRequest request = glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).transition(withCrossFade());
if (width > 0 && height > 0) {
request = request.override(width, height);
}
if (radius > 0) {
request = request.transforms(new CenterCrop(), new RoundedCorners(radius));
} else {
request = request.transforms(new CenterCrop());
}
request.into(new GlideDrawableListeningTarget(image, future));
blurhash.setImageDrawable(null);
return future;
}
use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.
the class ZoomingImageView method setImageViewUri.
private void setImageViewUri(@NonNull GlideRequests glideRequests, @NonNull Uri uri) {
photoView.setVisibility(View.VISIBLE);
subsamplingImageView.setVisibility(View.GONE);
glideRequests.load(new DecryptableUri(uri)).diskCacheStrategy(DiskCacheStrategy.NONE).dontTransform().override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).into(photoView);
}
use of org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri in project Signal-Android by WhisperSystems.
the class CameraXFragment method presentRecentItemThumbnail.
private void presentRecentItemThumbnail(Optional<Media> media) {
if (media == null) {
return;
}
ImageView thumbnail = controlsContainer.findViewById(R.id.camera_gallery_button);
if (media.isPresent()) {
thumbnail.setVisibility(View.VISIBLE);
Glide.with(this).load(new DecryptableUri(media.get().getUri())).centerCrop().into(thumbnail);
} else {
thumbnail.setVisibility(View.GONE);
thumbnail.setImageResource(0);
}
}
Aggregations