91重口 v1.4.7版本的 MD5 值为:b580d7e8a501ee704e75352ed0f5eb0d

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


package e.m.a.e;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import com.danikula.videocache.CacheListener;
import com.danikula.videocache.HttpProxyCacheServer;
import com.danikula.videocache.file.Md5FileNameGenerator;
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.utils.FileUtils;
import com.shuyu.gsyvideoplayer.utils.StorageUtils;
import e.m.a.e.a;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import tv.danmaku.ijk.media.player.IMediaPlayer;
public class b implements a, CacheListener {
    public static b f11875d;
    public HttpProxyCacheServer f11876h;
    public File f11877l;
    public boolean f11878m;
    public a.InterfaceC0135a f11879n;
    public c o = new c();

    public static HttpProxyCacheServer a(Context context, File file) {
        if (file == null) {
            HttpProxyCacheServer httpProxyCacheServer = b().f11876h;
            if (httpProxyCacheServer == null) {
                b b2 = b();
                b b3 = b();
                Objects.requireNonNull(b3);
                HttpProxyCacheServer build = new HttpProxyCacheServer.Builder(context.getApplicationContext()).headerInjector(b3.o).build();
                b2.f11876h = build;
                return build;
            }
            return httpProxyCacheServer;
        } else if (b().f11877l != null && !b().f11877l.getAbsolutePath().equals(file.getAbsolutePath())) {
            HttpProxyCacheServer httpProxyCacheServer2 = b().f11876h;
            if (httpProxyCacheServer2 != null) {
                httpProxyCacheServer2.shutdown();
            }
            b b4 = b();
            HttpProxyCacheServer c2 = b().c(context, file);
            b4.f11876h = c2;
            return c2;
        } else {
            HttpProxyCacheServer httpProxyCacheServer3 = b().f11876h;
            if (httpProxyCacheServer3 == null) {
                b b5 = b();
                HttpProxyCacheServer c3 = b().c(context, file);
                b5.f11876h = c3;
                return c3;
            }
            return httpProxyCacheServer3;
        }
    }

    public static synchronized b b() {
        b bVar;
        synchronized (b.class) {
            if (f11875d == null) {
                f11875d = new b();
            }
            bVar = f11875d;
        }
        return bVar;
    }

    public HttpProxyCacheServer c(Context context, File file) {
        if (!file.exists()) {
            file.mkdirs();
        }
        HttpProxyCacheServer.Builder builder = new HttpProxyCacheServer.Builder(context);
        builder.cacheDirectory(file);
        builder.headerInjector(this.o);
        this.f11877l = file;
        return builder.build();
    }

    @Override
    public boolean cachePreview(Context context, File file, String str) {
        HttpProxyCacheServer a = a(context.getApplicationContext(), file);
        if (a != null) {
            str = a.getProxyUrl(str);
        }
        return !str.startsWith("http");
    }

    @Override
    public void clearCache(Context context, File file, String str) {
        if (TextUtils.isEmpty(str)) {
            FileUtils.deleteFiles(new File(StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath()));
            return;
        }
        String generate = new Md5FileNameGenerator().generate(str);
        if (file != null) {
            StringBuilder sb = new StringBuilder();
            sb.append(file.getAbsolutePath());
            String str2 = File.separator;
            CommonUtil.deleteFile(e.a.a.a.a.D(sb, str2, generate, ".download"));
            CommonUtil.deleteFile(file.getAbsolutePath() + str2 + generate);
            return;
        }
        StringBuilder sb2 = new StringBuilder();
        sb2.append(StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath());
        String str3 = File.separator;
        CommonUtil.deleteFile(e.a.a.a.a.D(sb2, str3, generate, ".download"));
        CommonUtil.deleteFile(StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath() + str3 + generate);
    }

    @Override
    public void doCacheLogic(Context context, IMediaPlayer iMediaPlayer, String str, Map<String, String> map, File file) {
        Map<String, String> map2 = c.a;
        map2.clear();
        if (map != null) {
            map2.putAll(map);
        }
        if (str.startsWith("http") && !str.contains("127.0.0.1") && !str.contains(".m3u8")) {
            HttpProxyCacheServer a = a(context.getApplicationContext(), file);
            if (a != null) {
                String proxyUrl = a.getProxyUrl(str);
                boolean z = !proxyUrl.startsWith("http");
                this.f11878m = z;
                if (!z) {
                    a.registerCacheListener(this, str);
                }
                str = proxyUrl;
            }
        } else if (!str.startsWith("http") && !str.startsWith("rtmp") && !str.startsWith("rtsp") && !str.contains(".m3u8")) {
            this.f11878m = true;
        }
        try {
            iMediaPlayer.setDataSource(context, Uri.parse(str), map);
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    @Override
    public boolean hadCached() {
        return this.f11878m;
    }

    @Override
    public void onCacheAvailable(File file, String str, int i2) {
        a.InterfaceC0135a interfaceC0135a = this.f11879n;
        if (interfaceC0135a != null) {
            ((e.m.a.b) interfaceC0135a).f11860m = i2;
        }
    }

    @Override
    public void release() {
        HttpProxyCacheServer httpProxyCacheServer = this.f11876h;
        if (httpProxyCacheServer != null) {
            try {
                httpProxyCacheServer.unregisterCacheListener(this);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }

    @Override
    public void setCacheAvailableListener(a.InterfaceC0135a interfaceC0135a) {
        this.f11879n = interfaceC0135a;
    }
}