CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f
以下内容为反编译后的 BookDownloadManager.java 源代码,内容仅作参考
package org.godfootsteps.book.util;
import android.view.View;
import androidx.lifecycle.Lifecycle;
import com.blankj.utilcode.util.ReflectUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.google.android.gms.common.internal.ServiceSpecificExtraArgs;
import com.liulishuo.filedownloader.FileDownloadList;
import com.richpath.RichPath;
import d.c.a.j.s;
import e.q.i;
import e.q.n;
import i.c.a.c.l;
import i.c.a.c.w;
import i.c.a.c.y;
import i.m.a.a;
import i.m.a.c;
import i.m.a.k;
import i.m.a.p;
import i.r.d;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import kotlin.Metadata;
import n.i.b.e;
import n.i.b.h;
import org.commons.screenadapt.recyclerview.ScreenViewHolder;
import org.godfootsteps.arch.R$string;
import org.godfootsteps.arch.api.AppClient;
import org.godfootsteps.arch.api.model.BookCaseBook;
import org.godfootsteps.arch.api.model.BookCaseModel;
import org.godfootsteps.arch.view.BookStateView;
import org.godfootsteps.book.BookCaseFragment;
import org.godfootsteps.book.R$id;
import org.godfootsteps.book.lucene.BookIndexService;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\u0018\u0000 \u00032\u00020\u0001:\u0001\u0003B\u0005¢\u0006\u0002\u0010\u0002¨\u0006\u0004"}, d2 = {"Lorg/godfootsteps/book/util/BookDownloadManager;", "", "()V", "Companion", "book_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class BookDownloadManager {
public static final Companion a = new Companion(null);
public static final ArrayList<a.b> b = (ArrayList) ReflectUtils.l(FileDownloadList.getImpl()).b("mList").b;
public static final a c = new a();
@Metadata(d1 = {"\u0000K\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000*\u0001\u0004\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000eJ\u0016\u0010\u000f\u001a\u00020\f2\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0012\u001a\u00020\u0013J\u0010\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0010\u001a\u00020\u0011H\u0002J\u0010\u0010\u0016\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0010\u001a\u00020\u0011J\u0016\u0010\u0017\u001a\u00020\f2\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0012\u001a\u00020\u0013J\b\u0010\u0018\u001a\u00020\fH\u0007J\u0012\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u00130\u001a*\u00020\u0015H\u0002R\u0010\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0005R8\u0010\u0006\u001a,\u0012\u0004\u0012\u00020\b \n*\u0016\u0012\u0004\u0012\u00020\b\u0018\u00010\u0007j\n\u0012\u0004\u0012\u00020\b\u0018\u0001`\t0\u0007j\b\u0012\u0004\u0012\u00020\b`\tX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u001b"}, d2 = {"Lorg/godfootsteps/book/util/BookDownloadManager$Companion;", "Landroidx/lifecycle/LifecycleObserver;", "()V", ServiceSpecificExtraArgs.CastExtraArgs.LISTENER, "org/godfootsteps/book/util/BookDownloadManager$Companion$listener$1", "Lorg/godfootsteps/book/util/BookDownloadManager$Companion$listener$1;", "taskList", "Ljava/util/ArrayList;", "Lcom/liulishuo/filedownloader/BaseDownloadTask$IRunningTask;", "Lkotlin/collections/ArrayList;", "kotlin.jvm.PlatformType", "bind", "", "lifecycleOwner", "Landroidx/lifecycle/LifecycleOwner;", "download", "bookId", "", "holder", "Lorg/commons/screenadapt/recyclerview/ScreenViewHolder;", "existOrCreateTask", "Lcom/liulishuo/filedownloader/BaseDownloadTask;", "getTask", "onBindVH", "onDestroy", "existOrCreateTag", "Ljava/util/concurrent/CopyOnWriteArrayList;", "book_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public static final class Companion implements i {
private Companion() {
}
public Companion(e eVar) {
this();
}
public final void c(String str, ScreenViewHolder screenViewHolder) {
h.e(str, "bookId");
h.e(screenViewHolder, "holder");
i.m.a.a g2 = g(str);
c cVar = g2;
if (g2 == null) {
BookCaseModel bookCaseModel = BookCaseFragment.f15645r;
String bookPath = bookCaseModel == null ? null : bookCaseModel.getBookPath();
if (bookPath == null) {
StringBuilder J = i.a.b.a.a.J("/medias/");
J.append((Object) s.a());
J.append("/books/");
bookPath = J.toString();
}
StringBuilder sb = new StringBuilder();
Objects.requireNonNull(AppClient.a);
sb.append("https://appservercn.kingdomsalvation.org");
sb.append(bookPath);
sb.append(str);
sb.append(".zip");
String sb2 = sb.toString();
Object obj = p.c;
Objects.requireNonNull(p.a.a);
c cVar2 = new c(sb2);
cVar2.k(y.J().getFilesDir().getAbsolutePath() + "/books/" + str + ".zip");
cVar2.f13085m = true;
cVar2.f13084l = 100;
cVar2.j(100);
cVar2.f13081i = BookDownloadManager.c;
h.d(cVar2, "getImpl().create(url)\n … .setListener(listener)");
cVar = cVar2;
}
c cVar3 = (c) cVar;
if (cVar3.h()) {
return;
}
cVar3.l();
if (!f(cVar).contains(screenViewHolder)) {
f(cVar).add(screenViewHolder);
}
View view = screenViewHolder.f15173i;
BookStateView bookStateView = (BookStateView) (view != null ? view.findViewById(R$id.book_state) : null);
if (bookStateView != null && bookStateView.f15274o == 0) {
bookStateView.f15274o = 1;
d dVar = bookStateView.f15275p;
if (dVar != null) {
dVar.a();
}
RichPath[] richPathArr = {bookStateView.f15278s, bookStateView.f15279t, bookStateView.f15277r};
d dVar2 = new d();
i.r.a aVar = new i.r.a(dVar2, richPathArr);
dVar2.a.add(aVar);
aVar.a("translationY", 0.0f, 10.0f, 0.0f);
i.r.a b = aVar.b(bookStateView.f15278s, bookStateView.f15279t);
b.a("trimPathStart", 0.0f, 1.0f);
i.r.a b2 = b.b(bookStateView.f15277r);
b2.a("trimPathStart", 0.0f, 1.0f);
i.r.a b3 = b2.b(bookStateView.f15281v);
b3.a("trimPathEnd", 0.0f, 0.2f);
d.c.a.k.e eVar = new d.c.a.k.e(bookStateView);
d dVar3 = b3.a;
dVar3.f13261e = eVar;
dVar3.c();
bookStateView.f15275p = b3.a;
}
}
public final CopyOnWriteArrayList<ScreenViewHolder> f(i.m.a.a aVar) {
c cVar = (c) aVar;
if (cVar.f13082j == null) {
cVar.f13082j = new CopyOnWriteArrayList();
}
Object obj = cVar.f13082j;
Objects.requireNonNull(obj, "null cannot be cast to non-null type java.util.concurrent.CopyOnWriteArrayList<org.commons.screenadapt.recyclerview.ScreenViewHolder>");
return (CopyOnWriteArrayList) obj;
}
public final i.m.a.a g(String str) {
h.e(str, "bookId");
BookCaseModel bookCaseModel = BookCaseFragment.f15645r;
String bookPath = bookCaseModel == null ? null : bookCaseModel.getBookPath();
if (bookPath == null) {
StringBuilder J = i.a.b.a.a.J("/medias/");
J.append((Object) s.a());
J.append("/books/");
bookPath = J.toString();
}
StringBuilder sb = new StringBuilder();
Objects.requireNonNull(AppClient.a);
sb.append("https://appservercn.kingdomsalvation.org");
sb.append(bookPath);
sb.append(str);
sb.append(".zip");
String sb2 = sb.toString();
a.b bVar = FileDownloadList.getImpl().get(i.m.a.k0.i.e(sb2, y.J().getFilesDir().getAbsolutePath() + "/books/" + str + ".zip"));
if (bVar == null) {
return null;
}
return bVar.t();
}
public final void k(String str, ScreenViewHolder screenViewHolder) {
c cVar;
Object obj;
h.e(str, "bookId");
h.e(screenViewHolder, "holder");
i.m.a.a g2 = g(str);
if (g2 != null) {
View view = screenViewHolder.f15173i;
BookStateView bookStateView = (BookStateView) (view == null ? null : view.findViewById(R$id.book_state));
if (bookStateView != null) {
bookStateView.setDownState(2);
}
c cVar2 = (c) g2;
if (cVar2.e() != 0) {
View view2 = screenViewHolder.f15173i;
BookStateView bookStateView2 = (BookStateView) (view2 != null ? view2.findViewById(R$id.book_state) : null);
if (bookStateView2 != null) {
bookStateView2.setProgress((cVar2.d() * 100) / cVar2.e());
}
}
if (f(g2).contains(screenViewHolder)) {
return;
}
f(g2).add(screenViewHolder);
return;
}
for (BookCaseBook bookCaseBook : BookCaseFragment.L()) {
i.m.a.a g3 = BookDownloadManager.a.g(bookCaseBook.getId());
if (g3 != null && (obj = (cVar = (c) g3).f13082j) != null) {
for (ScreenViewHolder screenViewHolder2 : (CopyOnWriteArrayList) obj) {
if (h.a(screenViewHolder2, screenViewHolder)) {
Object obj2 = cVar.f13082j;
Objects.requireNonNull(obj2, "null cannot be cast to non-null type java.util.concurrent.CopyOnWriteArrayList<org.commons.screenadapt.recyclerview.ScreenViewHolder>");
((CopyOnWriteArrayList) obj2).remove(screenViewHolder);
}
}
}
}
if (n.m.t.a.p.m.e1.a.k1(str)) {
View view3 = screenViewHolder.f15173i;
BookStateView bookStateView3 = (BookStateView) (view3 != null ? view3.findViewById(R$id.book_state) : null);
if (bookStateView3 == null) {
return;
}
bookStateView3.setDownState(3);
return;
}
View view4 = screenViewHolder.f15173i;
BookStateView bookStateView4 = (BookStateView) (view4 != null ? view4.findViewById(R$id.book_state) : null);
if (bookStateView4 == null) {
return;
}
bookStateView4.setDownState(0);
}
@n(Lifecycle.Event.ON_DESTROY)
public final void onDestroy() {
ArrayList<a.b> arrayList = BookDownloadManager.b;
if (arrayList == null) {
return;
}
for (a.b bVar : arrayList) {
((c) bVar.t()).f13081i = null;
((c) bVar.t()).f13082j = null;
}
}
}
@Metadata(d1 = {"\u0000)\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0003\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H\u0014J\u001a\u0010\u0006\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\b\u0010\u0007\u001a\u0004\u0018\u00010\bH\u0014J \u0010\t\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\u000bH\u0014¨\u0006\r"}, d2 = {"org/godfootsteps/book/util/BookDownloadManager$Companion$listener$1", "Lcom/liulishuo/filedownloader/FileDownloadSampleListener;", "completed", "", "task", "Lcom/liulishuo/filedownloader/BaseDownloadTask;", "error", i.d.a.k.e.f9530u, "", "progress", "soFarBytes", "", "totalBytes", "book_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public static final class a extends k {
@Override
public void b(i.m.a.a aVar) {
h.e(aVar, "task");
c cVar = (c) aVar;
String str = cVar.f13077e;
h.d(str, "task.url");
String r2 = n.m.t.a.p.m.e1.a.r(str);
File t2 = n.m.t.a.p.m.e1.a.t(r2);
try {
y.c1(t2, n.m.t.a.p.m.e1.a.u(r2));
n.m.t.a.p.m.e1.a.m0(r2);
BookIndexService.c(w.c(), r2, null);
if (((c) aVar).f13082j != null) {
Object obj = ((c) aVar).f13082j;
if (obj != null) {
for (ScreenViewHolder screenViewHolder : (List) obj) {
View view = screenViewHolder.f15173i;
BookStateView bookStateView = (BookStateView) (view == null ? null : view.findViewById(R$id.book_state));
if (bookStateView != null) {
bookStateView.k();
}
}
return;
}
throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.List<org.commons.screenadapt.recyclerview.ScreenViewHolder>");
}
} catch (Exception e2) {
e2.printStackTrace();
l.f(t2);
ToastUtils.b(R$string.book_download_failed);
Object obj2 = cVar.f13082j;
if (obj2 != null) {
for (ScreenViewHolder screenViewHolder2 : (List) obj2) {
View view2 = screenViewHolder2.f15173i;
BookStateView bookStateView2 = (BookStateView) (view2 == null ? null : view2.findViewById(R$id.book_state));
if (bookStateView2 != null) {
bookStateView2.setDownState(0);
}
}
}
}
}
@Override
public void d(i.m.a.a aVar, Throwable th) {
h.e(aVar, "task");
ToastUtils.b(R$string.book_download_failed);
c cVar = (c) aVar;
String str = cVar.f13077e;
h.d(str, "task.url");
l.f(n.m.t.a.p.m.e1.a.t(n.m.t.a.p.m.e1.a.r(str)));
Object obj = cVar.f13082j;
if (obj != null) {
for (ScreenViewHolder screenViewHolder : (List) obj) {
View view = screenViewHolder.f15173i;
BookStateView bookStateView = (BookStateView) (view == null ? null : view.findViewById(R$id.book_state));
if (bookStateView != null) {
bookStateView.setDownState(0);
}
}
}
}
@Override
public void g(i.m.a.a aVar, int i2, int i3) {
h.e(aVar, "task");
Object obj = ((c) aVar).f13082j;
if (obj != null) {
for (ScreenViewHolder screenViewHolder : (List) obj) {
View view = screenViewHolder.f15173i;
BookStateView bookStateView = (BookStateView) (view == null ? null : view.findViewById(R$id.book_state));
if (bookStateView != null) {
bookStateView.setDownState(2);
}
View view2 = screenViewHolder.f15173i;
BookStateView bookStateView2 = (BookStateView) (view2 != null ? view2.findViewById(R$id.book_state) : null);
if (bookStateView2 != null) {
bookStateView2.setProgress((i2 * 100) / i3);
}
}
}
}
}
}