4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1

以下内容为反编译后的 b.java 源代码,内容仅作参考


package com.m4399.feedback.a;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.GenericTransitionOptions;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.integration.webp.decoder.WebpDrawable;
import com.bumptech.glide.integration.webp.decoder.WebpDrawableTransformation;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.ViewPropertyTransition;
import com.bumptech.glide.signature.ObjectKey;
import com.framework.config.Config;
import com.framework.config.SysConfigKey;
import com.framework.manager.network.NetworkStatusManager;
import com.framework.utils.ActivityStateUtils;
import com.framework.utils.UrlUtils;
import java.io.File;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
import timber.log.Timber;

public class b {
    private BitmapTransformation[] VA;
    private int VC;
    private int VD;
    private a VG;
    private float VH;
    private int Vv;
    private Context mContext;
    private File mFile;
    private String mImageUrl;
    private Drawable mPlaceholderDrawable;
    private int mPlaceholderId;
    private Uri mUri;
    private boolean Vw = true;
    private boolean Vx = true;
    private boolean Vy = true;
    private boolean Vz = true;
    private boolean VB = false;
    private int VE = -1;
    private int VF = 0;
    private Priority VI = Priority.NORMAL;
    private boolean VJ = false;

    public interface a<R> {
        void onBefore();

        boolean onException(Exception exc);

        boolean onResourceReady(R r, boolean z, boolean z2);
    }

    private b(Context context) {
        this.mContext = context;
    }

    public static b with(Context context) {
        return new b(context);
    }

    public b load(String str) {
        this.mImageUrl = str;
        return this;
    }

    public b load(File file) {
        this.mFile = file;
        return this;
    }

    public b load(Uri uri) {
        this.mUri = uri;
        return this;
    }

    public b asBitmap() {
        this.VF = 1;
        return this;
    }

    public b asGif() {
        this.VF = 2;
        return this;
    }

    public b asDrawable() {
        this.VF = 3;
        return this;
    }

    public b asFile() {
        this.VF = 4;
        return this;
    }

    public b placeholder(int i) {
        this.mPlaceholderId = i;
        return this;
    }

    public b placeholder(Drawable drawable) {
        this.mPlaceholderDrawable = drawable;
        return this;
    }

    public b error(int i) {
        this.Vv = i;
        return this;
    }

    public b diskCacheable(boolean z) {
        this.Vw = z;
        return this;
    }

    public b isOnlyCacheSource(boolean z) {
        this.Vx = z;
        return this;
    }

    public b memoryCacheable(boolean z) {
        this.Vy = z;
        return this;
    }

    public b animate(boolean z) {
        this.VB = z;
        return this;
    }

    public b override(int i, int i2) {
        this.VC = i;
        this.VD = i2;
        return this;
    }

    public b listener(a aVar) {
        this.VG = aVar;
        return this;
    }

    public b fitCenter() {
        this.VE = 2;
        return this;
    }

    public b centerCrop() {
        this.VE = 1;
        return this;
    }

    public b transform(BitmapTransformation... bitmapTransformationArr) {
        this.VA = bitmapTransformationArr;
        return this;
    }

    public b wifiLoad(boolean z) {
        this.Vz = z;
        return this;
    }

    public b thumbnail(float f) {
        this.VH = f;
        return this;
    }

    public b priority(Priority priority) {
        if (priority != null) {
            this.VI = priority;
        }
        return this;
    }

    public b into(ImageView imageView) {
        if (imageView == null) {
            return this;
        }
        RequestBuilder requestBuilder = null;
        try {
            requestBuilder = requestPrepare();
        } catch (Throwable th) {
            Timber.e(th.toString(), new Object[0]);
        }
        if (requestBuilder == null) {
            int i = this.Vv;
            if (i > 0) {
                imageView.setImageResource(i);
            } else {
                int i2 = this.mPlaceholderId;
                if (i2 > 0) {
                    imageView.setImageResource(i2);
                } else {
                    Drawable drawable = this.mPlaceholderDrawable;
                    if (drawable != null) {
                        imageView.setImageDrawable(drawable);
                    }
                }
            }
        } else {
            requestBuilder.into(imageView);
        }
        return this;
    }

    public b into(Target target) {
        RequestBuilder requestPrepare = requestPrepare();
        if (requestPrepare != null) {
            requestPrepare.into((RequestBuilder) target);
        }
        return this;
    }

    public b into(int i, int i2) {
        RequestBuilder requestPrepare;
        if (i > 0 && i2 > 0 && (requestPrepare = requestPrepare()) != null) {
            requestPrepare.into(i, i2);
        }
        return this;
    }

    public File downloadFile() throws InterruptedException, ExecutionException, TimeoutException {
        RequestBuilder iF = iF();
        if (iF == null) {
            return null;
        }
        return iF.downloadOnly(this.VC, this.VD).get(60L, TimeUnit.SECONDS);
    }

    public b dontAnimate(boolean z) {
        this.VJ = z;
        return this;
    }

    public void asyncDownloadFile() {
        RequestBuilder iF = iF();
        if (iF == null) {
            return;
        }
        Observable.just(iF).observeOn(Schedulers.io()).map(new Func1<RequestBuilder, File>() {
            @Override
            public File call(RequestBuilder requestBuilder) {
                try {
                    return requestBuilder.downloadOnly(b.this.VC, b.this.VD).get(60L, TimeUnit.SECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    return null;
                } catch (ExecutionException e2) {
                    e2.printStackTrace();
                    return null;
                } catch (TimeoutException e3) {
                    e3.printStackTrace();
                    return null;
                }
            }
        }).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<File>() {
            @Override
            public void call(File file) {
                if (b.this.VG != null) {
                    b.this.VG.onResourceReady(file, false, true);
                }
            }
        });
    }

    private RequestBuilder iF() {
        RequestBuilder asDrawable;
        if ((TextUtils.isEmpty(this.mImageUrl) && this.mFile == null && this.mUri == null) || ActivityStateUtils.isDestroy(this.mContext)) {
            return null;
        }
        if (this.Vz && !TextUtils.isEmpty(this.mImageUrl) && UrlUtils.isHttpUrl(this.mImageUrl)) {
            boolean booleanValue = ((Boolean) Config.getValue(SysConfigKey.IS_WIFI_LOAD_IMAGE)).booleanValue();
            if (!(NetworkStatusManager.getCurrentNetwork().getNetworkType() == 999) && booleanValue) {
                return null;
            }
        }
        RequestManager with = Glide.with(this.mContext);
        int i = this.VF;
        if (i == 1) {
            asDrawable = with.asBitmap();
        } else if (i == 2) {
            asDrawable = with.asGif();
        } else if (i == 3) {
            asDrawable = with.asDrawable();
        } else if (i == 4) {
            asDrawable = with.asFile();
        } else {
            asDrawable = with.asDrawable();
        }
        if (!TextUtils.isEmpty(this.mImageUrl)) {
            if (UrlUtils.isHttpUrl(this.mImageUrl)) {
                asDrawable.load((Object) new GlideUrl(this.mImageUrl, new LazyHeaders.Builder().addHeader("referer", "http://www.4399.com").build()));
            } else {
                asDrawable.load(this.mImageUrl);
            }
        } else {
            Uri uri = this.mUri;
            if (uri != null) {
                asDrawable.load(uri);
            } else {
                asDrawable.load(this.mFile);
            }
        }
        a aVar = this.VG;
        if (aVar != null) {
            aVar.onBefore();
            asDrawable.listener(new RequestListener<Object>() {
                @Override
                public boolean onLoadFailed(GlideException glideException, Object obj, Target<Object> target, boolean z) {
                    return b.this.VG.onException(glideException);
                }

                @Override
                public boolean onResourceReady(Object obj, Object obj2, Target<Object> target, DataSource dataSource, boolean z) {
                    return b.this.VG.onResourceReady(obj, dataSource == DataSource.MEMORY_CACHE, z);
                }
            });
        }
        return asDrawable;
    }

    public RequestBuilder requestPrepare() {
        int i;
        RequestBuilder iF = iF();
        if (iF == null) {
            return null;
        }
        RequestOptions requestOptions = new RequestOptions();
        if (this.Vw) {
            if (this.Vx) {
                requestOptions.diskCacheStrategy(DiskCacheStrategy.DATA);
            } else {
                requestOptions.diskCacheStrategy(DiskCacheStrategy.ALL);
            }
        } else {
            requestOptions.diskCacheStrategy(DiskCacheStrategy.NONE).signature(new ObjectKey(UUID.randomUUID().toString()));
        }
        requestOptions.skipMemoryCache(!this.Vy);
        int i2 = this.VC;
        if (i2 != 0 && (i = this.VD) != 0) {
            requestOptions.override(i2, i);
        }
        int i3 = this.VE;
        if (i3 == 2) {
            requestOptions.transform(Bitmap.class, new FitCenter());
            requestOptions.transform(WebpDrawable.class, new WebpDrawableTransformation(new FitCenter()));
        } else if (i3 == 1) {
            requestOptions.transform(Bitmap.class, new CenterCrop());
            requestOptions.transform(WebpDrawable.class, new WebpDrawableTransformation(new CenterCrop()));
        }
        float f = this.VH;
        if (f > 0.0f) {
            iF.thumbnail(f);
        }
        if (this.VB) {
            iF.transition(GenericTransitionOptions.with(new ViewPropertyTransition.Animator() {
                @Override
                public void animate(View view) {
                    if (Build.VERSION.SDK_INT >= 11) {
                        view.setAlpha(0.0f);
                        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f);
                        ofFloat.setDuration(com.igexin.push.config.c.j);
                        ofFloat.start();
                    }
                }
            }));
        } else {
            iF.transition(GenericTransitionOptions.withNoTransition());
        }
        if (this.VJ) {
            requestOptions.dontAnimate();
        }
        int i4 = this.mPlaceholderId;
        if (i4 > 0) {
            requestOptions.placeholder(i4);
            try {
                if (this.mPlaceholderDrawable == null && this.mContext != null) {
                    this.mPlaceholderDrawable = this.mContext.getResources().getDrawable(this.mPlaceholderId);
                }
            } catch (Throwable th) {
                Timber.e(th.toString(), new Object[0]);
            }
        }
        Drawable drawable = this.mPlaceholderDrawable;
        if (drawable != null) {
            requestOptions.placeholder(drawable);
        }
        int i5 = this.Vv;
        if (i5 > 0) {
            requestOptions.error(i5);
        }
        requestOptions.priority(this.VI);
        BitmapTransformation[] bitmapTransformationArr = this.VA;
        if (bitmapTransformationArr != null) {
            if (bitmapTransformationArr.length > 1) {
                requestOptions.transform(Bitmap.class, new MultiTransformation(bitmapTransformationArr));
                requestOptions.transform(WebpDrawable.class, new WebpDrawableTransformation(new MultiTransformation(this.VA)));
            } else {
                requestOptions.transform(Bitmap.class, bitmapTransformationArr[0]);
                requestOptions.transform(WebpDrawable.class, new WebpDrawableTransformation(this.VA[0]));
            }
        }
        iF.apply(requestOptions);
        return iF;
    }

    public void clear(View view) {
        if (ActivityStateUtils.isDestroy(this.mContext)) {
            return;
        }
        Glide.with(this.mContext).clear(view);
    }
}