得物.apk(点击下载) / a.java


package yq;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.alibaba.sdk.android.oss.ClientConfiguration;
import com.alibaba.sdk.android.oss.OSS;
import com.alibaba.sdk.android.oss.OSSClient;
import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider;
import com.alibaba.sdk.android.oss.internal.OSSAsyncTask;
import com.alibaba.sdk.android.oss.model.PutObjectRequest;
import com.alibaba.sdk.android.oss.model.ResumableUploadRequest;
import com.alibaba.sdk.android.oss.model.ResumableUploadResult;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.libs.upload.IUploadListener;
import com.shizhuang.duapp.libs.upload.RenameIntercept;
import com.shizhuang.duapp.libs.upload.UploadParams;
import com.shizhuang.duapp.libs.upload.upload.IUploadManager;
import io.reactivex.annotations.NonNull;
import io.reactivex.annotations.Nullable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import mj1.j;

/* compiled from: AliUploadManager */
public class a implements IUploadManager {
    public static ChangeQuickRedirect changeQuickRedirect;

    /* renamed from: a  reason: collision with root package name */
    public String f40454a;
    public String b;

    /* renamed from: c  reason: collision with root package name */
    public String f40455c;
    public boolean d;
    public Handler e = new Handler(Looper.getMainLooper());
    public Context f;
    @Nullable

    /* renamed from: g  reason: collision with root package name */
    public OSSAsyncTask<ResumableUploadResult> f40456g;

    /* renamed from: h  reason: collision with root package name */
    public OSS f40457h;

    /* renamed from: yq.a$a  reason: collision with other inner class name */
    /* compiled from: AliUploadManager */
    public class C0749a implements Consumer<List<String>> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public C0749a(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(@NonNull List<String> list) throws Exception {
            List<String> list2 = list;
            if (!PatchProxy.proxy(new Object[]{list2}, this, changeQuickRedirect, false, 36862, new Class[]{List.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onSuccess(list2);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class b implements Consumer<Throwable> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public b(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(Throwable th2) throws Exception {
            Throwable th3 = th2;
            if (!PatchProxy.proxy(new Object[]{th3}, this, changeQuickRedirect, false, 36863, new Class[]{Throwable.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onFailed(th3);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class c implements Consumer<Throwable> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public c(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(Throwable th2) throws Exception {
            Throwable th3 = th2;
            if (!PatchProxy.proxy(new Object[]{th3}, this, changeQuickRedirect, false, 36864, new Class[]{Throwable.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onFailed(th3);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class d implements Function<List<String>, List<String>> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ UploadParams.a b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ RenameIntercept f40461c;
        public final /* synthetic */ String d;
        public final /* synthetic */ IUploadListener e;

        public d(UploadParams.a aVar, RenameIntercept renameIntercept, String str, IUploadListener iUploadListener) {
            this.b = aVar;
            this.f40461c = renameIntercept;
            this.d = str;
            this.e = iUploadListener;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Function
        public List<String> apply(List<String> list) throws Exception {
            List<String> list2 = list;
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{list2}, this, changeQuickRedirect, false, 36865, new Class[]{List.class}, List.class);
            if (proxy.isSupported) {
                return (List) proxy.result;
            }
            ArrayList arrayList = new ArrayList();
            UploadParams.a aVar = this.b;
            OSSStsTokenCredentialProvider oSSStsTokenCredentialProvider = new OSSStsTokenCredentialProvider(aVar.b, aVar.f9501a, aVar.f9502c);
            ClientConfiguration clientConfiguration = new ClientConfiguration();
            clientConfiguration.setConnectionTimeout(15000);
            clientConfiguration.setSocketTimeout(15000);
            clientConfiguration.setMaxConcurrentRequest(5);
            clientConfiguration.setMaxErrorRetry(2);
            a aVar2 = a.this;
            aVar2.f40457h = new OSSClient(aVar2.f, aVar2.b, oSSStsTokenCredentialProvider);
            for (String str : list2) {
                if (a.this.d) {
                    break;
                } else if (str.toLowerCase().startsWith("http")) {
                    arrayList.add(str);
                } else {
                    String str2 = this.f40461c != null ? this.d + this.f40461c.getNewFileName(new File(str)) : this.d + new File(str).getName();
                    PutObjectRequest putObjectRequest = new PutObjectRequest(a.this.f40454a, str2, str);
                    if (list2.size() == 1) {
                        putObjectRequest.setProgressCallback(new b(this));
                    }
                    if (a.this.f40457h.putObject(putObjectRequest).getStatusCode() == 200) {
                        arrayList.add(a.this.f40455c + str2);
                        if (this.e != null && nq.b.c(a.this.f) && list2.size() > 1) {
                            a.this.a(this.e, (((float) (list2.indexOf(str) + 1)) * 1.0f) / ((float) list2.size()));
                        }
                    } else {
                        throw new RuntimeException("ali oss upload images failed~~~~~~~");
                    }
                }
            }
            return arrayList;
        }
    }

    /* compiled from: AliUploadManager */
    public class e implements Consumer<List<String>> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public e(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(@NonNull List<String> list) throws Exception {
            List<String> list2 = list;
            if (!PatchProxy.proxy(new Object[]{list2}, this, changeQuickRedirect, false, 36867, new Class[]{List.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onSuccess(list2);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class f implements Consumer<Throwable> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public f(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(Throwable th2) throws Exception {
            Throwable th3 = th2;
            if (!PatchProxy.proxy(new Object[]{th3}, this, changeQuickRedirect, false, 36868, new Class[]{Throwable.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onFailed(th3);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class g implements Consumer<Throwable> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        public g(IUploadListener iUploadListener) {
            this.b = iUploadListener;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Consumer
        public void accept(Throwable th2) throws Exception {
            Throwable th3 = th2;
            if (!PatchProxy.proxy(new Object[]{th3}, this, changeQuickRedirect, false, 36869, new Class[]{Throwable.class}, Void.TYPE).isSupported && this.b != null && nq.b.c(a.this.f)) {
                this.b.onFailed(th3);
            }
        }
    }

    /* compiled from: AliUploadManager */
    public class h implements Function<List<String>, List<String>> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ UploadParams.a b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ RenameIntercept f40465c;
        public final /* synthetic */ String d;
        public final /* synthetic */ IUploadListener e;

        public h(UploadParams.a aVar, RenameIntercept renameIntercept, String str, IUploadListener iUploadListener) {
            this.b = aVar;
            this.f40465c = renameIntercept;
            this.d = str;
            this.e = iUploadListener;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // io.reactivex.functions.Function
        public List<String> apply(List<String> list) throws Exception {
            List<String> list2 = list;
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{list2}, this, changeQuickRedirect, false, 36870, new Class[]{List.class}, List.class);
            if (proxy.isSupported) {
                return (List) proxy.result;
            }
            ArrayList arrayList = new ArrayList();
            UploadParams.a aVar = this.b;
            OSSStsTokenCredentialProvider oSSStsTokenCredentialProvider = new OSSStsTokenCredentialProvider(aVar.b, aVar.f9501a, aVar.f9502c);
            ClientConfiguration clientConfiguration = new ClientConfiguration();
            clientConfiguration.setConnectionTimeout(15000);
            clientConfiguration.setSocketTimeout(15000);
            clientConfiguration.setMaxConcurrentRequest(5);
            clientConfiguration.setMaxErrorRetry(2);
            a aVar2 = a.this;
            aVar2.f40457h = new OSSClient(aVar2.f, aVar2.b, oSSStsTokenCredentialProvider);
            for (String str : list2) {
                if (a.this.d) {
                    break;
                } else if (str.toLowerCase().startsWith("http")) {
                    arrayList.add(str);
                } else {
                    RenameIntercept renameIntercept = this.f40465c;
                    String newFileName = renameIntercept != null ? renameIntercept.getNewFileName(new File(str)) : this.d + new File(str).getName();
                    File file = new File(a.this.f.getExternalCacheDir(), "du_oss_record");
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    ResumableUploadRequest resumableUploadRequest = new ResumableUploadRequest(a.this.f40454a, newFileName, str, file.getAbsolutePath());
                    resumableUploadRequest.setDeleteUploadOnCancelling(Boolean.FALSE);
                    if (list2.size() == 1) {
                        resumableUploadRequest.setProgressCallback(new c(this));
                    }
                    a aVar3 = a.this;
                    aVar3.f40456g = aVar3.f40457h.asyncResumableUpload(resumableUploadRequest, new d(this, arrayList, newFileName, list2, str));
                    a.this.f40456g.waitUntilFinished();
                }
            }
            return arrayList;
        }
    }

    /* compiled from: AliUploadManager */
    public class i implements Runnable {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ IUploadListener b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ float f40466c;

        public i(a aVar, IUploadListener iUploadListener, float f) {
            this.b = iUploadListener;
            this.f40466c = f;
        }

        public void run() {
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 36874, new Class[0], Void.TYPE).isSupported) {
                this.b.onProgress(this.f40466c);
            }
        }
    }

    public void a(IUploadListener iUploadListener, float f12) {
        if (!PatchProxy.proxy(new Object[]{iUploadListener, new Float(f12)}, this, changeQuickRedirect, false, 36861, new Class[]{IUploadListener.class, Float.TYPE}, Void.TYPE).isSupported) {
            this.e.post(new i(this, iUploadListener, f12));
        }
    }

    @Override // com.shizhuang.duapp.libs.upload.upload.IUploadManager
    public void init(Context context, UploadParams uploadParams) {
        if (!PatchProxy.proxy(new Object[]{context, uploadParams}, this, changeQuickRedirect, false, 36857, new Class[]{Context.class, UploadParams.class}, Void.TYPE).isSupported) {
            this.f = context;
            if (TextUtils.isEmpty(uploadParams.getEndpoint()) || TextUtils.isEmpty(uploadParams.getBucket()) || TextUtils.isEmpty(uploadParams.getCdnUrl())) {
                this.b = "http://oss-cn-shanghai.aliyuncs.com";
                this.f40454a = "du-img";
                this.f40455c = "https://cdn.poizon.com/";
                return;
            }
            this.b = uploadParams.getEndpoint();
            this.f40454a = uploadParams.getBucket();
            this.f40455c = uploadParams.getCdnUrl();
        }
    }

    @Override // com.shizhuang.duapp.libs.upload.upload.IUploadManager
    public void upload(UploadParams.a aVar, String str, List<String> list, IUploadListener iUploadListener, RenameIntercept renameIntercept) {
        if (!PatchProxy.proxy(new Object[]{aVar, str, list, iUploadListener, renameIntercept}, this, changeQuickRedirect, false, 36858, new Class[]{UploadParams.a.class, String.class, List.class, IUploadListener.class, RenameIntercept.class}, Void.TYPE).isSupported) {
            int i3 = bj1.b.b;
            new j(new mj1.i(list).d(Schedulers.io()), new d(aVar, renameIntercept, str, iUploadListener)).d(ej1.a.c()).b(new c(iUploadListener)).e(mj1.f.f35669c).g(new C0749a(iUploadListener), new b(iUploadListener));
        }
    }

    @Override // com.shizhuang.duapp.libs.upload.upload.IUploadManager
    public void uploadResumableVideo(UploadParams.a aVar, String str, List<String> list, IUploadListener iUploadListener, RenameIntercept renameIntercept) {
        if (!PatchProxy.proxy(new Object[]{aVar, str, list, iUploadListener, renameIntercept}, this, changeQuickRedirect, false, 36859, new Class[]{UploadParams.a.class, String.class, List.class, IUploadListener.class, RenameIntercept.class}, Void.TYPE).isSupported) {
            int i3 = bj1.b.b;
            new j(new mj1.i(list).d(Schedulers.io()), new h(aVar, renameIntercept, str, iUploadListener)).d(ej1.a.c()).b(new g(iUploadListener)).e(mj1.f.f35669c).g(new e(iUploadListener), new f(iUploadListener));
        }
    }
}