MD5 校验值:290b0e4cd89c7a20355df0a13ec24559
ImageKit.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.ideaflow.zmcy.image; import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; import android.view.View; import android.widget.ImageView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.palette.graphics.Palette; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions; import com.bumptech.glide.request.BaseRequestOptions; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; import com.google.common.net.HttpHeaders; import com.ideaflow.zmcy.R; import com.ideaflow.zmcy.tools.BlurTransformation; import com.ideaflow.zmcy.tools.palette.BitmapPalette; import com.ideaflow.zmcy.tools.palette.GlidePalette; import com.jstudio.jkit.LogKit; import com.jstudio.jkit.UIKit; import com.umeng.analytics.pro.f; import java.io.File; import kotlin.Metadata; import kotlin.Unit; import kotlin.enums.EnumEntries; import kotlin.enums.EnumEntriesKt; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.Intrinsics; import kotlin.text.StringsKt; @Metadata(d1 = {"\u0000p\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0007\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\bÆ\u0002\u0018\u00002\u00020\u0001:\u0001+B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0005\u001a\u00020\u00042\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0007\u001a\u00020\bJ \u0010\t\u001a\u00020\u00042\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\n\u001a\u00020\u000bJ\u000e\u0010\f\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u000fJ\u000e\u0010\f\u001a\u00020\r2\u0006\u0010\u0010\u001a\u00020\u0011J\u000e\u0010\f\u001a\u00020\r2\u0006\u0010\u0012\u001a\u00020\u0013J\u000e\u0010\f\u001a\u00020\r2\u0006\u0010\u0012\u001a\u00020\u0014J&\u0010\u0015\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0019\u001a\u0004\u0018\u00010\u001a2\b\b\u0002\u0010\u001b\u001a\u00020\u001cJ$\u0010\u0015\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u001d\u001a\u00020\u001e2\b\b\u0002\u0010\u001b\u001a\u00020\u001cJ0\u0010\u0015\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\b\b\u0002\u0010\u001f\u001a\u00020 J8\u0010!\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\"\u001a\u00020\b2\b\b\u0002\u0010\n\u001a\u00020\u000bJJ\u0010#\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\b\b\u0002\u0010\n\u001a\u00020\u000b2\u0016\b\u0002\u0010$\u001a\u0010\u0012\u0004\u0012\u00020&\u0012\u0004\u0012\u00020\u0016\u0018\u00010%H\u0007JF\u0010'\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\n\u001a\u00020\u000b2\u0016\b\u0002\u0010(\u001a\u0010\u0012\u0004\u0012\u00020 \u0012\u0004\u0012\u00020\u0016\u0018\u00010%J&\u0010)\u001a\u00020\u0016*\u00020\r2\u0006\u0010\u0017\u001a\u00020\u00182\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001cJ(\u0010*\u001a\u00020\u0016*\u00020\r2\b\u0010\u0006\u001a\u0004\u0018\u00010\u00042\b\b\u0002\u0010\u001b\u001a\u00020\u001c2\b\b\u0002\u0010\n\u001a\u00020\u000bR\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000¨\u0006,"}, d2 = {"Lcom/ideaflow/zmcy/image/ImageKit;", "", "()V", "DEFAULT_AVATAR", "", "getThumbUrl", "url", "size", "", "getThumbUrlBySide", "side", "Lcom/ideaflow/zmcy/image/ImageKit$ImageSide;", "with", "Lcom/bumptech/glide/RequestManager;", f.X, "Landroid/content/Context;", "view", "Landroid/view/View;", "fragment", "Landroidx/fragment/app/Fragment;", "Landroidx/fragment/app/FragmentActivity;", "loadAvatar", "", "imageView", "Landroid/widget/ImageView;", "uri", "Landroid/net/Uri;", "sizeDp", "", "file", "Ljava/io/File;", "showPlaceholder", "", "loadBlurImage", "radius", "loadCardImage", "usePalette", "Lkotlin/Function1;", "Landroidx/palette/graphics/Palette;", "loadLargeImage", "onFinished", "loadOriginal", "preload", "ImageSide", "1.1.73-20240523_yybRelease"}, k = 1, mv = {1, 9, 0}, xi = 48) public final class ImageKit { private static final String DEFAULT_AVATAR = "https://img.metatube.pro/banner/active/default-avatar.jpg"; public static final ImageKit INSTANCE = new ImageKit(); @Metadata(k = 3, mv = {1, 9, 0}, xi = 48) public class WhenMappings { public static final int[] $EnumSwitchMapping$0; static { int[] iArr = new int[ImageSide.values().length]; try { iArr[ImageSide.All.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { iArr[ImageSide.Width.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } $EnumSwitchMapping$0 = iArr; } } @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0005\b\u0086\u0081\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004j\u0002\b\u0005¨\u0006\u0006"}, d2 = {"Lcom/ideaflow/zmcy/image/ImageKit$ImageSide;", "", "(Ljava/lang/String;I)V", HttpHeaders.WIDTH, "Height", "All", "1.1.73-20240523_yybRelease"}, k = 1, mv = {1, 9, 0}, xi = 48) public static final class ImageSide extends Enum<ImageSide> { private static final EnumEntries $ENTRIES; private static final ImageSide[] $VALUES; public static final ImageSide Width = new ImageSide(HttpHeaders.WIDTH, 0); public static final ImageSide Height = new ImageSide("Height", 1); public static final ImageSide All = new ImageSide("All", 2); private static final ImageSide[] $values() { return new ImageSide[]{Width, Height, All}; } public static EnumEntries<ImageSide> getEntries() { return $ENTRIES; } public static ImageSide valueOf(String str) { return (ImageSide) Enum.valueOf(ImageSide.class, str); } public static ImageSide[] values() { return (ImageSide[]) $VALUES.clone(); } private ImageSide(String str, int i) { super(str, i); } static { ImageSide[] $values = $values(); $VALUES = $values; $ENTRIES = EnumEntriesKt.enumEntries($values); } } private ImageKit() { } public final RequestManager with(View view) { Intrinsics.checkNotNullParameter(view, "view"); RequestManager with = Glide.with(view); Intrinsics.checkNotNullExpressionValue(with, "with(...)"); return with; } public final RequestManager with(Context r2) { Intrinsics.checkNotNullParameter(r2, "context"); RequestManager with = Glide.with(r2); Intrinsics.checkNotNullExpressionValue(with, "with(...)"); return with; } public final RequestManager with(Fragment fragment) { Intrinsics.checkNotNullParameter(fragment, "fragment"); RequestManager with = Glide.with(fragment); Intrinsics.checkNotNullExpressionValue(with, "with(...)"); return with; } public final RequestManager with(FragmentActivity fragment) { Intrinsics.checkNotNullParameter(fragment, "fragment"); RequestManager with = Glide.with(fragment); Intrinsics.checkNotNullExpressionValue(with, "with(...)"); return with; } public final String getThumbUrl(String url, int size) { return getThumbUrlBySide(url, size, ImageSide.All); } public final String getThumbUrlBySide(String url, int size, ImageSide side) { Intrinsics.checkNotNullParameter(side, "side"); String str = url; if (str == null || str.length() == 0) { return ""; } if (!StringsKt.contains$default((CharSequence) str, (CharSequence) "metatube.pro", false, 2, (Object) null) && !StringsKt.contains$default((CharSequence) str, (CharSequence) "ideaflow.pro", false, 2, (Object) null)) { return url; } int i = WhenMappings.$EnumSwitchMapping$0[side.ordinal()]; if (i == 1) { return url + "?imageView2/3/w/" + size + "/h/" + size; } if (i == 2) { return url + "?imageView2/3/w/" + size; } return url + "?imageView2/3/h/" + size; } public static void loadAvatar$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, String str, float f, boolean z, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(30.0f); } imageKit.loadAvatar(requestManager, imageView, str, f, (i & 8) != 0 ? true : z); } public final void loadAvatar(RequestManager requestManager, ImageView imageView, String str, float f, boolean z) { String str2; Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); if (!z && ((str2 = str) == null || str2.length() == 0)) { imageView.setImageBitmap(null); return; } String thumbUrl = getThumbUrl(str, (int) f); if (thumbUrl.length() == 0) { requestManager.load(DEFAULT_AVATAR).centerCrop().into(imageView); } else { requestManager.load(thumbUrl).placeholder(R.drawable.common_shape_img_loading).error(DEFAULT_AVATAR).centerCrop().into(imageView); } } public static void loadAvatar$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, Uri uri, float f, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(30.0f); } imageKit.loadAvatar(requestManager, imageView, uri, f); } public final void loadAvatar(RequestManager requestManager, ImageView imageView, Uri uri, float f) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); if (uri == null) { requestManager.load(DEFAULT_AVATAR).into(imageView); } else { requestManager.load(uri).placeholder(R.drawable.common_shape_img_loading).error(DEFAULT_AVATAR).override((int) f).centerCrop().into(imageView); } } public static void loadAvatar$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, File file, float f, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(30.0f); } imageKit.loadAvatar(requestManager, imageView, file, f); } public final void loadAvatar(RequestManager requestManager, ImageView imageView, File file, float f) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); Intrinsics.checkNotNullParameter(file, "file"); if (!file.exists()) { requestManager.load(DEFAULT_AVATAR).into(imageView); } requestManager.load(file).placeholder(R.drawable.common_shape_img_loading).error(DEFAULT_AVATAR).override((int) f).centerCrop().into(imageView); } public static void preload$default(ImageKit imageKit, RequestManager requestManager, String str, float f, ImageSide imageSide, int i, Object obj) { if ((i & 2) != 0) { f = UIKit.getDp(180.0f); } if ((i & 4) != 0) { imageSide = ImageSide.All; } imageKit.preload(requestManager, str, f, imageSide); } public final void preload(RequestManager requestManager, String str, float f, ImageSide side) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(side, "side"); String thumbUrlBySide = getThumbUrlBySide(str, (int) f, side); if (thumbUrlBySide.length() > 0) { requestManager.load(thumbUrlBySide).preload(); } } public static void loadCardImage$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, String str, float f, ImageSide imageSide, Function1 function1, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(180.0f); } float f2 = f; if ((i & 8) != 0) { imageSide = ImageSide.All; } ImageSide imageSide2 = imageSide; if ((i & 16) != 0) { function1 = null; } imageKit.loadCardImage(requestManager, imageView, str, f2, imageSide2, function1); } public final void loadCardImage(RequestManager requestManager, ImageView imageView, String str, float f, ImageSide side, final Function1<? super Palette, Unit> function1) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); Intrinsics.checkNotNullParameter(side, "side"); String thumbUrlBySide = getThumbUrlBySide(str, (int) f, side); if (thumbUrlBySide.length() == 0) { requestManager.load(Integer.valueOf(R.mipmap.img_load_failed)).into(imageView); return; } LogKit.Companion companion = LogKit.INSTANCE; Intrinsics.checkNotNullExpressionValue("ImageKit", "getSimpleName(...)"); companion.i("ImageKit", "thumbUrl: " + thumbUrlBySide); RequestBuilder<Drawable> load = requestManager.load(thumbUrlBySide); if (function1 != null) { load.listener(GlidePalette.with(str).use(4).intoCallBack(new BitmapPalette.CallBack() { @Override public final void onPaletteLoaded(Palette palette) { ImageKit.loadCardImage$lambda$2$lambda$1(Function1.this, palette); } })); } RequestOptions requestOptions = new RequestOptions(); requestOptions.timeout(10000); load.apply((BaseRequestOptions<?>) requestOptions).transition(DrawableTransitionOptions.withCrossFade().crossFade(80)).placeholder(R.drawable.common_shape_img_loading).error(R.mipmap.img_load_failed).into(imageView); } public static final void loadCardImage$lambda$2$lambda$1(Function1 function1, Palette palette) { if (palette != null) { function1.invoke(palette); } } public static void loadBlurImage$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, String str, float f, int i, ImageSide imageSide, int i2, Object obj) { if ((i2 & 4) != 0) { f = UIKit.getDp(50.0f); } float f2 = f; if ((i2 & 16) != 0) { imageSide = ImageSide.All; } imageKit.loadBlurImage(requestManager, imageView, str, f2, i, imageSide); } public final void loadBlurImage(RequestManager requestManager, ImageView imageView, String str, float f, int i, ImageSide side) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); Intrinsics.checkNotNullParameter(side, "side"); String thumbUrlBySide = getThumbUrlBySide(str, (int) f, side); if (thumbUrlBySide.length() == 0) { requestManager.load(Integer.valueOf(R.mipmap.img_load_failed)).into(imageView); return; } LogKit.Companion companion = LogKit.INSTANCE; Intrinsics.checkNotNullExpressionValue("ImageKit", "getSimpleName(...)"); companion.i("ImageKit", "thumbUrl: " + thumbUrlBySide); requestManager.load(thumbUrlBySide).apply((BaseRequestOptions<?>) RequestOptions.bitmapTransform(new BlurTransformation(i, 2))).into(imageView); } public static void loadOriginal$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, String str, float f, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(100.0f); } imageKit.loadOriginal(requestManager, imageView, str, f); } public final void loadOriginal(RequestManager requestManager, ImageView imageView, String str, float f) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); int i = (int) f; String thumbUrl = getThumbUrl(str, i); if (thumbUrl.length() == 0) { return; } LogKit.Companion companion = LogKit.INSTANCE; Intrinsics.checkNotNullExpressionValue("ImageKit", "getSimpleName(...)"); companion.i("ImageKit", "thumbUrl: " + thumbUrl); requestManager.load(thumbUrl).override(i).into(imageView); } public static void loadLargeImage$default(ImageKit imageKit, RequestManager requestManager, ImageView imageView, String str, float f, ImageSide imageSide, Function1 function1, int i, Object obj) { if ((i & 4) != 0) { f = UIKit.getDp(400.0f); } float f2 = f; if ((i & 16) != 0) { function1 = null; } imageKit.loadLargeImage(requestManager, imageView, str, f2, imageSide, function1); } public final void loadLargeImage(RequestManager requestManager, ImageView imageView, String str, float f, ImageSide side, final Function1<? super Boolean, Unit> function1) { Intrinsics.checkNotNullParameter(requestManager, "<this>"); Intrinsics.checkNotNullParameter(imageView, "imageView"); Intrinsics.checkNotNullParameter(side, "side"); String thumbUrlBySide = getThumbUrlBySide(str, (int) f, side); if (thumbUrlBySide.length() == 0) { requestManager.load(Integer.valueOf(R.drawable.common_shape_img_loading)).into(imageView); return; } LogKit.Companion companion = LogKit.INSTANCE; Intrinsics.checkNotNullExpressionValue("ImageKit", "getSimpleName(...)"); companion.i("ImageKit", "thumbUrl: " + thumbUrlBySide); requestManager.load(thumbUrlBySide).listener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { Intrinsics.checkNotNullParameter(target, "target"); Function1<Boolean, Unit> function12 = function1; if (function12 != null) { function12.invoke(false); } return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { Intrinsics.checkNotNullParameter(resource, "resource"); Intrinsics.checkNotNullParameter(model, "model"); Intrinsics.checkNotNullParameter(dataSource, "dataSource"); Function1<Boolean, Unit> function12 = function1; if (function12 == null) { return false; } function12.invoke(true); return false; } }).override(Integer.MIN_VALUE, Integer.MIN_VALUE).into(imageView); } }