正在查看: 漫天星 v3.0.2 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 漫天星 v3.0.2 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package f.p.g.g.a.c;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import com.google.gson.reflect.TypeToken;
import com.junyue.basic.app.App;
import com.junyue.basic.config.URLConfig;
import com.junyue.novel.modules.bookshelf.service.DownloadBookService;
import com.junyue.novel.sharebean.BookDownload;
import com.junyue.novel.sharebean.reader.BookChapterBean;
import com.junyue.novel.sharebean.reader.CollBookBean;
import f.p.c.z.c1;
import f.p.c.z.d1;
import f.p.c.z.r;
import f.p.f.a.c;
import i.b0.c.t;
import i.b0.c.u;
import i.i0.n;
import i.w.p;
import i.w.x;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import n.u;
public final class a {
public static final String a = "DownloadManager";
public static ArrayList<BookDownload> b;
public static final ConcurrentLinkedQueue<BookDownload> c;
public static BookDownload d;
public static Disposable e;
public static boolean f113f;
public static File f114g;
public static List<c.b> h;
public static final a i = new a();
public static final class C0096a extends u implements Function1<BookDownload, Boolean> {
public final BookDownload n;
public C0096a(BookDownload bookDownload) {
super(1);
this.n = bookDownload;
}
public final boolean b(BookDownload bookDownload) {
t.d(bookDownload, "it");
return t.a(bookDownload.c(), this.n.c());
}
public Object invoke(Object obj) {
return Boolean.valueOf(b((BookDownload) obj));
}
}
public static final class b extends u implements Function1<BookDownload, Boolean> {
public final BookDownload n;
public b(BookDownload bookDownload) {
super(1);
this.n = bookDownload;
}
public final boolean b(BookDownload bookDownload) {
t.e(bookDownload, "it");
return t.a(bookDownload.c(), this.n.c());
}
public Object invoke(Object obj) {
return Boolean.valueOf(b((BookDownload) obj));
}
}
public static final class c extends TypeToken<List<? extends BookChapterBean>> {
}
public static final class d extends u implements Function0<f.p.g.g.a.b.a> {
public static final d n = new d();
public static final class C0097a extends u implements Function1<u.b, Boolean> {
public static final C0097a n = new C0097a();
public C0097a() {
super(1);
}
public final boolean b(u.b bVar) {
t.e(bVar, "it");
bVar.a(f.p.d.b.d.g.d());
bVar.b(new f.p.d.b.e.e());
bVar.g(f.p.d.c.e.g());
bVar.c(URLConfig.a.b());
return true;
}
public Object invoke(Object obj) {
b((u.b) obj);
return Boolean.TRUE;
}
}
public d() {
super(0);
}
public final f.p.g.g.a.b.a invoke() {
return (f.p.g.g.a.b.a) f.p.d.b.a.b(C0097a.n).b(f.p.g.g.a.b.a.class);
}
}
public static final class e<T> implements ObservableOnSubscribe<Long> {
public static final e a = new e();
public static final class C0098a implements FilenameFilter {
public static final C0098a a = new C0098a();
@Override
public final boolean accept(File file, String str) {
t.d(str, "name");
return n.g(str, ".ds", false, 2, (Object) null);
}
}
@Override
public final void subscribe(io.reactivex.rxjava3.core.ObservableEmitter<java.lang.Long> r11) {
throw new UnsupportedOperationException("Method not decompiled: f.p.g.g.a.c.a.e.subscribe(io.reactivex.rxjava3.core.ObservableEmitter):void");
}
}
public static final class f extends i.b0.c.u implements Function2<Observer<Long>, Long, i.t> {
public static final f n = new f();
public f() {
super(2);
}
public final void b(Observer<Long> observer, Long l) {
t.e(observer, "$receiver");
a.i.startService();
}
public Object invoke(Object obj, Object obj2) {
b((Observer) obj, (Long) obj2);
return i.t.a;
}
}
public static final class g extends i.b0.c.u implements Function2<Observer<Long>, Throwable, i.t> {
public static final g n = new g();
public g() {
super(2);
}
public final void b(Observer<Long> observer, Throwable th) {
t.e(observer, "$receiver");
Log.i(d1.a, String.valueOf(th));
}
public Object invoke(Object obj, Object obj2) {
b((Observer) obj, (Throwable) obj2);
return i.t.a;
}
}
public static final class h<T> implements ObservableOnSubscribe<Long> {
public final BookDownload a;
public final boolean b;
public h(BookDownload bookDownload, boolean z) {
this.a = bookDownload;
this.b = z;
}
@Override
public final void subscribe(ObservableEmitter<Long> observableEmitter) {
File n = a.i.n();
File file = new File(n, this.a.c() + ".tmp");
int i = 1;
while (file.exists()) {
file = new File(n, this.a.c() + ".tmp" + i);
i++;
}
Writer outputStreamWriter = new OutputStreamWriter(f.p.c.p.a.b(new FileOutputStream(file)), i.i0.c.a);
BufferedWriter bufferedWriter = outputStreamWriter instanceof BufferedWriter ? (BufferedWriter) outputStreamWriter : new BufferedWriter(outputStreamWriter, 8192);
try {
try {
bufferedWriter.write(r.a().toJson(this.a));
bufferedWriter.close();
file.renameTo(new File(n, this.a.c() + ".ds"));
} catch (Throwable unused) {
bufferedWriter.close();
}
} catch (Throwable unused2) {
}
if (this.b) {
Writer outputStreamWriter2 = new OutputStreamWriter(f.p.c.p.a.b(new FileOutputStream(file)), i.i0.c.a);
BufferedWriter bufferedWriter2 = outputStreamWriter2 instanceof BufferedWriter ? (BufferedWriter) outputStreamWriter2 : new BufferedWriter(outputStreamWriter2, 8192);
try {
bufferedWriter2.write(r.a().toJson(this.a.e()));
bufferedWriter2.close();
file.renameTo(new File(n, this.a.c() + ".ds_cps"));
} catch (Throwable th) {
th.printStackTrace();
Log.i(a.i.s(), th.toString());
try {
bufferedWriter2.close();
} catch (Throwable unused3) {
Log.i(a.i.s(), th.toString());
}
}
}
}
}
public static final class i<T> implements Consumer<Long> {
public static final i n = new i();
@Override
public final void accept(Long l) {
}
}
static {
c1.b(d.n);
b = new ArrayList<>();
c = new ConcurrentLinkedQueue<>();
h = new ArrayList();
}
public static final ArrayList a(a aVar) {
return b;
}
public final void startService() {
Intent intent = new Intent((Context) App.r(), (Class<?>) DownloadBookService.class);
ConcurrentLinkedQueue<BookDownload> concurrentLinkedQueue = c;
int i2 = 0;
if (!(concurrentLinkedQueue instanceof Collection) || !concurrentLinkedQueue.isEmpty()) {
int i3 = 0;
for (BookDownload bookDownload : concurrentLinkedQueue) {
t.d(bookDownload, "it");
if (((bookDownload.l() || bookDownload.m()) ? false : true) && (i3 = i3 + 1) < 0) {
p.o();
throw null;
}
}
i2 = i3;
}
if (i2 <= 0) {
App.r().stopService(intent);
} else if (Build.VERSION.SDK_INT >= 26) {
App.r().startForegroundService(intent);
} else {
App.r().startService(intent);
}
}
public static void z(a aVar, BookDownload bookDownload, boolean z, int i2, Object obj) {
if ((i2 & 2) != 0) {
z = false;
}
aVar.y(bookDownload, z);
}
public final void A(boolean z) {
f113f = z;
}
public final void B(BookDownload bookDownload) {
d = bookDownload;
}
public final void C(Disposable disposable) {
e = disposable;
}
public final void D() {
i.w.t.r(b);
}
public final void E(c.b bVar) {
t.e(bVar, "listener");
h.remove(bVar);
}
public final void F(CollBookBean collBookBean) {
Object obj;
t.e(collBookBean, "collBookBean");
Iterator<T> it = b.iterator();
while (true) {
if (it.hasNext()) {
obj = it.next();
if (t.a(((BookDownload) obj).c(), collBookBean.w())) {
break;
}
} else {
obj = null;
break;
}
}
BookDownload bookDownload = (BookDownload) obj;
if (bookDownload != null) {
CollBookBean b2 = bookDownload.b();
t.d(b2, "it.bookBean");
if (b2.s() != collBookBean.s()) {
CollBookBean b3 = bookDownload.b();
t.d(b3, "it.bookBean");
b3.X(collBookBean.s());
CollBookBean b4 = bookDownload.b();
t.d(b4, "it.bookBean");
b4.d0(collBookBean.z());
CollBookBean b5 = bookDownload.b();
t.d(b5, "it.bookBean");
b5.T(collBookBean.j());
if (c.contains(bookDownload)) {
return;
}
bookDownload.w(true);
bookDownload.p();
c.add(bookDownload);
i.y(bookDownload, true);
for (c.b bVar : i.m()) {
bVar.E();
}
}
}
}
public final void c(List<? extends BookDownload> list) {
t.e(list, "bookDownload");
b.removeAll(list);
c.removeAll(list);
Iterator<? extends BookDownload> it = list.iterator();
while (it.hasNext()) {
d(it.next());
}
if (x.D(list, d)) {
d = null;
f113f = true;
Disposable disposable = e;
if (disposable != null) {
disposable.dispose();
}
startService();
}
g();
}
public final void d(BookDownload bookDownload) {
String c2 = bookDownload.c();
File n = n();
f.p.c.z.p.a(new File(n, c2 + ".tmp"));
f.p.c.z.p.a(new File(n, c2 + ".ds2"));
f.p.c.z.p.a(new File(n, c2 + ".tmp"));
f.p.c.z.p.a(new File(n, c2 + ".ds"));
f.p.c.z.p.a(new File(n, c2 + ".ds_cps"));
}
public final void e(BookDownload bookDownload) {
Object obj;
t.e(bookDownload, "bookDownload");
Iterator<T> it = b.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
} else {
obj = it.next();
if (t.a(((BookDownload) obj).c(), bookDownload.c())) {
break;
}
}
}
if (((BookDownload) obj) != null) {
f.p.c.z.d.b(c, new C0096a(bookDownload));
f.p.c.z.d.b(b, new b(bookDownload));
d(bookDownload);
}
c.add(bookDownload);
b.add(bookDownload);
startService();
g();
BookDownload.CollBookBeanWithSource f2 = bookDownload.f();
t.d(f2, "bookDownload.collBookBeanWithSource");
x(f2);
y(bookDownload, true);
}
public final void f(BookDownload bookDownload) {
t.e(bookDownload, "bookDownload");
if (bookDownload.o()) {
bookDownload.w(false);
z(this, bookDownload, false, 2, null);
}
c.remove(bookDownload);
}
public final void g() {
i.w.t.r(b);
for (c.b bVar : m()) {
bVar.E();
}
}
public final List<BookDownload> h() {
return x.a0(b);
}
public final BookDownload i(String str) {
Object obj;
t.e(str, "bookId");
Iterator<T> it = b.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
if (t.a(((BookDownload) obj).c(), str)) {
break;
}
}
return (BookDownload) obj;
}
public final BookDownload j(String str) {
Object obj;
t.e(str, "bookId");
BookDownload bookDownload = d;
if (bookDownload != null && t.a(bookDownload.c(), str)) {
return bookDownload;
}
Iterator<T> it = c.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
BookDownload bookDownload2 = (BookDownload) obj;
t.d(bookDownload2, "it");
if (t.a(bookDownload2.c(), str)) {
break;
}
}
return (BookDownload) obj;
}
public final List<BookChapterBean> k(File file) {
t.e(file, "file");
Reader inputStreamReader = new InputStreamReader(f.p.c.p.a.a(new FileInputStream(file)), i.i0.c.a);
try {
List<BookChapterBean> list = (List) r.a().fromJson(inputStreamReader instanceof BufferedReader ? (BufferedReader) inputStreamReader : new BufferedReader(inputStreamReader, 8192), new c().getType());
return list != null ? list : new ArrayList();
} catch (Throwable unused) {
return new ArrayList();
}
}
public final BookDownload l() {
return d;
}
public final c.b[] m() {
Object[] array = h.toArray(new c.b[0]);
if (array != null) {
return (c.b[]) array;
}
throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
}
public final File n() {
File file = f114g;
if (file == null) {
file = new File(f.p.c.z.p.b() + File.separator + "download_infov2");
if (!file.exists()) {
file.mkdirs();
}
f114g = file;
}
return file;
}
public final boolean o() {
return f113f;
}
public final BookDownload p() {
return d;
}
public final Disposable q() {
return e;
}
public final ConcurrentLinkedQueue<BookDownload> r() {
return c;
}
public final String s() {
return a;
}
public final void t(BookDownload bookDownload) {
t.e(bookDownload, "bookDownload");
bookDownload.u(true);
z(this, bookDownload, false, 2, null);
if (t.a(bookDownload, d)) {
d = null;
Disposable disposable = e;
if (disposable != null) {
disposable.dispose();
}
if (f.p.c.s.b.j()) {
startService();
}
}
for (c.b bVar : m()) {
bVar.E();
}
}
public final void u(c.b bVar, boolean z) {
BookDownload bookDownload;
t.e(bVar, "listener");
h.add(bVar);
if (!z || (bookDownload = d) == null) {
return;
}
bVar.j(bookDownload, f.p.g.g.a.c.b.a(bookDownload).get(bookDownload.g()), bookDownload.g(), bookDownload.d(), true);
}
public final void v() {
Observable create = Observable.create(e.a);
t.d(create, "Observable.create<Long> …it.onComplete()\n }");
f.p.d.b.a.e(create).subscribe(f.p.c.w.c.b(null, f.n, g.n, null, false, false, 57, null));
}
public final void w(BookDownload bookDownload) {
t.e(bookDownload, "bookDownload");
bookDownload.u(false);
z(this, bookDownload, false, 2, null);
if (d == null) {
startService();
}
for (c.b bVar : m()) {
bVar.E();
}
}
public final void x(BookDownload.CollBookBeanWithSource collBookBeanWithSource) {
File n = n();
String c2 = collBookBeanWithSource.c();
File file = new File(n, c2 + ".tmp");
Writer outputStreamWriter = new OutputStreamWriter(f.p.c.p.a.b(new FileOutputStream(file)), i.i0.c.a);
BufferedWriter bufferedWriter = outputStreamWriter instanceof BufferedWriter ? (BufferedWriter) outputStreamWriter : new BufferedWriter(outputStreamWriter, 8192);
try {
bufferedWriter.write(r.a().toJson(collBookBeanWithSource));
file.renameTo(new File(n, c2 + ".ds2"));
} catch (Throwable unused) {
}
bufferedWriter.close();
}
public final void y(BookDownload bookDownload, boolean z) {
t.e(bookDownload, "download");
Observable create = Observable.create(new h(bookDownload, z));
t.d(create, "Observable.create<Long> …}\n }\n }");
f.p.d.b.a.e(create).subscribe(i.n);
}
}