APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Web Browser Beta Pro-Fastest Browser
版本号:2.5.7
包名称:com.webbrowserbeta

MD5 校验值:195005882709ac21163d7a1b97aeec73

反编译源代码说明

DevYBImageLoader.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.devyb.devybimageloader;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesLibraries;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.HVArrangement;
import com.google.appinventor.components.runtime.Image;
import com.google.appinventor.components.runtime.util.MediaUtil;
import com.google.appinventor.components.runtime.util.ViewUtil;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import kawa.lang.SyntaxForms;

@SimpleObject(external = SyntaxForms.DEBUGGING)
@UsesPermissions(permissionNames = "android.permission.INTERNET, android.permission.WRITE_EXTERNAL_STORAGE, android.permission.READ_EXTERNAL_STORAGE")
@DesignerComponent(category = ComponentCategory.EXTENSION, description = "DevYB Image Loader developed by DevYB.\nExtension for image loading and caching.", iconName = "https://res.cloudinary.com/dujfnjfcz/image/upload/v1596225104/icon16.png", nonVisible = SyntaxForms.DEBUGGING, version = 6)
@UsesLibraries(libraries = "universal-image-loader-1.9.5.jar")
public class DevYBImageLoader extends AndroidNonvisibleComponent {
    private Activity activity;
    private boolean cacheInMemory;
    private boolean cacheOnDisk;
    private ComponentContainer container;
    private Context context;
    private DisplayImageOptions displayImageOptions;
    private Drawable imageError;
    private ImageLoader imageLoader;
    private Drawable imageLoading;

    public DevYBImageLoader(ComponentContainer componentContainer) {
        super(componentContainer.$form());
        this.cacheOnDisk = true;
        this.cacheInMemory = true;
        this.container = componentContainer;
        this.activity = componentContainer.$context();
        this.context = componentContainer.$context();
    }

    private boolean checkWriteExternalPermission() {
        return this.context.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0;
    }

    public static void copyFile(File file, File file2) throws IOException {
        if (!file2.getParentFile().exists()) {
            file2.getParentFile().mkdirs();
        }
        if (!file2.exists()) {
            file2.createNewFile();
        }
        FileChannel fileChannel = null;
        FileChannel fileChannel2 = null;
        try {
            fileChannel = new FileInputStream(file).getChannel();
            fileChannel2 = new FileOutputStream(file2).getChannel();
            fileChannel2.transferFrom(fileChannel, 0L, fileChannel.size());
            if (fileChannel != null) {
                fileChannel.close();
            }
            if (fileChannel2 != null) {
                fileChannel2.close();
            }
        } catch (Throwable th) {
            if (fileChannel != null) {
                fileChannel.close();
            }
            if (fileChannel2 != null) {
                fileChannel2.close();
            }
            throw th;
        }
    }

    @SimpleFunction
    public void CacheImage(String str) {
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        this.displayImageOptions = new DisplayImageOptions.Builder().cacheInMemory(this.cacheInMemory).cacheOnDisk(this.cacheOnDisk).build();
        this.imageLoader.loadImage(str, this.displayImageOptions, new SimpleImageLoadingListener() {
            @Override
            public void onLoadingCancelled(String str2, View view) {
            }

            @Override
            public void onLoadingComplete(String str2, View view, Bitmap bitmap) {
                DevYBImageLoader.this.OnLoadingComplete(str2);
            }

            @Override
            public void onLoadingFailed(String str2, View view, FailReason failReason) {
                DevYBImageLoader.this.OnLoadingFailed(str2);
            }

            @Override
            public void onLoadingStarted(String str2, View view) {
                DevYBImageLoader.this.OnLoadingStarted(str2);
            }
        });
    }

    @SimpleFunction
    public Object CachedImageExists(String str) {
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        ImageLoader imageLoader = this.imageLoader;
        return Boolean.valueOf(ImageLoader.getInstance().getDiskCache().get(str).exists());
    }

    @SimpleFunction
    public void ClearDiskCache() {
        try {
            this.imageLoader.clearDiskCache();
        } catch (Exception e) {
        }
    }

    @SimpleFunction
    public void ClearMemoryCache() {
        try {
            this.imageLoader.clearMemoryCache();
        } catch (Exception e) {
        }
    }

    @SimpleFunction
    public void DeleteCachedImage(String str) {
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        ImageLoader imageLoader = this.imageLoader;
        ImageLoader.getInstance().getDiskCache().get(str).delete();
    }

    @SimpleProperty(description = "", userVisible = false)
    @DesignerProperty(defaultValue = "false", editorType = "boolean")
    public void DisableCacheInMemory(boolean z) {
        if (z) {
            this.cacheInMemory = false;
        } else {
            this.cacheInMemory = true;
        }
    }

    @SimpleProperty(description = "", userVisible = false)
    @DesignerProperty(defaultValue = "false", editorType = "boolean")
    public void DisableCacheOnDisk(boolean z) {
        if (z) {
            this.cacheOnDisk = false;
        } else {
            this.cacheOnDisk = true;
        }
    }

    @SimpleProperty
    @DesignerProperty(defaultValue = "", editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET)
    public void ErrorImage(String str) {
        try {
            this.imageError = MediaUtil.getBitmapDrawable(this.container.$form(), str == null ? "" : str);
        } catch (IOException e) {
            this.imageError = null;
        }
    }

    @SimpleFunction
    public void ExtractCachedImage(String str, String str2, String str3) {
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        ImageLoader imageLoader = this.imageLoader;
        if (ImageLoader.getInstance().getDiskCache().get(str).exists()) {
            StringBuilder append = new StringBuilder().append(str2);
            ImageLoader imageLoader2 = this.imageLoader;
            File file = new File(append.append(ImageLoader.getInstance().getDiskCache().get(str).getName()).append(str3).toString());
            try {
                ImageLoader imageLoader3 = this.imageLoader;
                copyFile(ImageLoader.getInstance().getDiskCache().get(str), file);
                if (file.exists()) {
                    OnExtractedCachedImage(file.getPath());
                }
            } catch (IOException e) {
            }
        }
    }

    @SimpleFunction
    public void LoadImage(Image image, String str) {
        ImageView imageView = (ImageView) image.getView();
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        this.displayImageOptions = new DisplayImageOptions.Builder().cacheInMemory(this.cacheInMemory).cacheOnDisk(this.cacheOnDisk).showImageOnLoading(this.imageLoading).showImageOnFail(this.imageError).build();
        this.imageLoader.displayImage(str, imageView, this.displayImageOptions, new ImageLoadingListener() {
            @Override
            public void onLoadingCancelled(String str2, View view) {
            }

            @Override
            public void onLoadingComplete(String str2, View view, Bitmap bitmap) {
                DevYBImageLoader.this.OnLoadingComplete(str2);
            }

            @Override
            public void onLoadingFailed(String str2, View view, FailReason failReason) {
                DevYBImageLoader.this.OnLoadingFailed(str2);
            }

            @Override
            public void onLoadingStarted(String str2, View view) {
                DevYBImageLoader.this.OnLoadingStarted(str2);
            }
        }, new ImageLoadingProgressListener() {
            @Override
            public void onProgressUpdate(String str2, View view, int i, int i2) {
                DevYBImageLoader.this.OnProgress(str2, i, i2);
            }
        });
    }

    @SimpleFunction
    public void LoadImageAsync(Image image, String str) {
        ImageView imageView = (ImageView) image.getView();
        ImageLoaderConfiguration build = new ImageLoaderConfiguration.Builder(this.context).threadPoolSize(3).threadPriority(3).denyCacheImageMultipleSizesInMemory().build();
        DisplayImageOptions build2 = new DisplayImageOptions.Builder().cacheInMemory(this.cacheInMemory).cacheOnDisk(this.cacheOnDisk).showImageOnLoading(this.imageLoading).showImageOnFail(this.imageError).build();
        ImageLoader imageLoader = this.imageLoader;
        ImageLoader.getInstance().init(build);
        ImageLoader imageLoader2 = this.imageLoader;
        ImageLoader.getInstance().displayImage(str, imageView, build2, new SimpleImageLoadingListener() {
            @Override
            public void onLoadingCancelled(String str2, View view) {
            }

            @Override
            public void onLoadingComplete(String str2, View view, Bitmap bitmap) {
                DevYBImageLoader.this.OnLoadingComplete(str2);
            }

            @Override
            public void onLoadingFailed(String str2, View view, FailReason failReason) {
                DevYBImageLoader.this.OnLoadingFailed(str2);
            }

            @Override
            public void onLoadingStarted(String str2, View view) {
                DevYBImageLoader.this.OnLoadingStarted(str2);
            }
        }, new ImageLoadingProgressListener() {
            @Override
            public void onProgressUpdate(String str2, View view, int i, int i2) {
                DevYBImageLoader.this.OnProgress(str2, i, i2);
            }
        });
    }

    @SimpleFunction
    public void LoadImageAsyncInArrangement(final HVArrangement hVArrangement, String str) {
        ImageLoaderConfiguration build = new ImageLoaderConfiguration.Builder(this.context).threadPoolSize(3).threadPriority(3).denyCacheImageMultipleSizesInMemory().build();
        DisplayImageOptions build2 = new DisplayImageOptions.Builder().cacheInMemory(this.cacheInMemory).cacheOnDisk(this.cacheOnDisk).build();
        ImageLoader imageLoader = this.imageLoader;
        ImageLoader.getInstance().init(build);
        ImageLoader imageLoader2 = this.imageLoader;
        ImageLoader.getInstance().loadImage(str, build2, new SimpleImageLoadingListener() {
            @Override
            public void onLoadingCancelled(String str2, View view) {
            }

            @Override
            public void onLoadingComplete(String str2, View view, Bitmap bitmap) {
                DevYBImageLoader.this.OnLoadingComplete(str2);
                ViewUtil.setBackgroundDrawable(((ViewGroup) hVArrangement.getView()).getChildAt(0), new BitmapDrawable(bitmap));
            }

            @Override
            public void onLoadingFailed(String str2, View view, FailReason failReason) {
                DevYBImageLoader.this.OnLoadingFailed(str2);
                ViewUtil.setBackgroundImage(((ViewGroup) hVArrangement.getView()).getChildAt(0), DevYBImageLoader.this.imageError);
            }

            @Override
            public void onLoadingStarted(String str2, View view) {
                DevYBImageLoader.this.OnLoadingStarted(str2);
                ViewUtil.setBackgroundImage(((ViewGroup) hVArrangement.getView()).getChildAt(0), DevYBImageLoader.this.imageLoading);
            }
        });
    }

    @SimpleFunction
    public void LoadImageInArrangement(final HVArrangement hVArrangement, String str) {
        this.imageLoader = ImageLoader.getInstance();
        this.imageLoader.init(new ImageLoaderConfiguration.Builder(this.context).build());
        this.displayImageOptions = new DisplayImageOptions.Builder().cacheInMemory(this.cacheInMemory).cacheOnDisk(this.cacheOnDisk).build();
        this.imageLoader.loadImage(str, this.displayImageOptions, new SimpleImageLoadingListener() {
            @Override
            public void onLoadingCancelled(String str2, View view) {
            }

            @Override
            public void onLoadingComplete(String str2, View view, Bitmap bitmap) {
                DevYBImageLoader.this.OnLoadingComplete(str2);
                ViewUtil.setBackgroundDrawable(((ViewGroup) hVArrangement.getView()).getChildAt(0), new BitmapDrawable(bitmap));
            }

            @Override
            public void onLoadingFailed(String str2, View view, FailReason failReason) {
                DevYBImageLoader.this.OnLoadingFailed(str2);
                ViewUtil.setBackgroundImage(((ViewGroup) hVArrangement.getView()).getChildAt(0), DevYBImageLoader.this.imageError);
            }

            @Override
            public void onLoadingStarted(String str2, View view) {
                DevYBImageLoader.this.OnLoadingStarted(str2);
                ViewUtil.setBackgroundImage(((ViewGroup) hVArrangement.getView()).getChildAt(0), DevYBImageLoader.this.imageLoading);
            }
        });
    }

    @SimpleProperty
    @DesignerProperty(defaultValue = "", editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET)
    public void LoadingImage(String str) {
        try {
            this.imageLoading = MediaUtil.getBitmapDrawable(this.container.$form(), str == null ? "" : str);
        } catch (IOException e) {
            this.imageLoading = null;
        }
    }

    @SimpleEvent
    public void OnExtractedCachedImage(String str) {
        EventDispatcher.dispatchEvent(this, "OnExtractedCachedImage", str);
    }

    @SimpleEvent
    public void OnLoadingComplete(String str) {
        EventDispatcher.dispatchEvent(this, "OnLoadingComplete", str);
    }

    @SimpleEvent
    public void OnLoadingFailed(String str) {
        EventDispatcher.dispatchEvent(this, "OnLoadingFailed", str);
    }

    @SimpleEvent
    public void OnLoadingStarted(String str) {
        EventDispatcher.dispatchEvent(this, "OnLoadingStarted", str);
    }

    @SimpleEvent
    public void OnProgress(String str, int i, int i2) {
        EventDispatcher.dispatchEvent(this, "OnProgress", str, Integer.valueOf(i), Integer.valueOf(i2));
    }

    @SimpleFunction
    public void PauseLoading() {
        this.imageLoader.pause();
    }

    @SimpleFunction
    public void ResumeLoading() {
        this.imageLoader.resume();
    }

    @SimpleFunction
    public void StopLoading() {
        this.imageLoader.stop();
    }
}