That fuck shit the fascists are using
at master 39 lines 1.2 kB view raw
1package org.tm.archive.blurhash; 2 3import android.graphics.Bitmap; 4 5import androidx.annotation.NonNull; 6import androidx.annotation.Nullable; 7 8import com.bumptech.glide.load.Options; 9import com.bumptech.glide.load.ResourceDecoder; 10import com.bumptech.glide.load.engine.Resource; 11import com.bumptech.glide.load.resource.SimpleResource; 12 13import java.io.IOException; 14 15public class BlurHashResourceDecoder implements ResourceDecoder<BlurHash, Bitmap> { 16 17 private static final int MAX_DIMEN = 20; 18 19 @Override 20 public boolean handles(@NonNull BlurHash source, @NonNull Options options) throws IOException { 21 return true; 22 } 23 24 @Override 25 public @Nullable Resource<Bitmap> decode(@NonNull BlurHash source, int width, int height, @NonNull Options options) throws IOException { 26 final int finalWidth; 27 final int finalHeight; 28 29 if (width > height) { 30 finalWidth = Math.min(width, MAX_DIMEN); 31 finalHeight = (int) (finalWidth * height / (float) width); 32 } else { 33 finalHeight = Math.min(height, MAX_DIMEN); 34 finalWidth = (int) (finalHeight * width / (float) height); 35 } 36 37 return new SimpleResource<>(BlurHashDecoder.decode(source.getHash(), finalWidth, finalHeight)); 38 } 39}