package com.iBookStar.utils; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.util.Log; import android.view.View; import android.widget.Toast; import com.iBookStar.YmLoadManager; import com.iBookStar.a.m; import com.iBookStar.activityComm.CoinWebView; import com.iBookStar.activityComm.SurveyWebView; import com.iBookStar.utils.l; import com.iBookStar.views.YmConfig; import java.net.URLEncoder; public class v { private static boolean a = false; private static String b; private static View c; private static YmConfig.MNovelReadObserver d; private static YmConfig.MNovelTaskObserver e; private static int f; private static String g; /* access modifiers changed from: package-private */ public class a implements l.m { final /* synthetic */ boolean a; a(boolean z) { this.a = z; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b(v.b, (String) obj, this.a); return true; } } /* access modifiers changed from: package-private */ public class b implements l.m { final /* synthetic */ String a; final /* synthetic */ String b; final /* synthetic */ boolean c; b(String str, String str2, boolean z) { this.a = str; this.b = str2; this.c = z; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b(this.a, this.b, this.c); return true; } } /* access modifiers changed from: package-private */ public class c implements l.m { final /* synthetic */ String a; final /* synthetic */ String b; final /* synthetic */ boolean c; c(String str, String str2, boolean z) { this.a = str; this.b = str2; this.c = z; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b(this.a, this.b, this.c); return true; } } /* access modifiers changed from: package-private */ public class d implements l.m { final /* synthetic */ String a; final /* synthetic */ boolean b; d(String str, boolean z) { this.a = str; this.b = z; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b((String) null, this.a, this.b); return true; } } /* access modifiers changed from: package-private */ public class e implements l.m { final /* synthetic */ String a; final /* synthetic */ boolean b; final /* synthetic */ boolean c; e(String str, boolean z, boolean z2) { this.a = str; this.b = z; this.c = z2; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b(this.a, this.b, this.c); return true; } } /* access modifiers changed from: package-private */ public class f implements l.m { final /* synthetic */ boolean a; final /* synthetic */ boolean b; f(boolean z, boolean z2) { this.a = z; this.b = z2; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.b((String) null, this.a, this.b); return true; } } /* access modifiers changed from: package-private */ public class g implements l.m { final /* synthetic */ boolean a; final /* synthetic */ boolean b; g(boolean z, boolean z2) { this.a = z; this.b = z2; } @Override // com.iBookStar.utils.l.m public boolean a(int i, int i2, Object obj, Object... objArr) { v.a(this.a, false, this.b); return true; } } public static void a(int i) { com.iBookStar.c.b.b("webview_progress_color", i); } public static void a(int i, int i2) { com.iBookStar.c.b.b("titlebar_bg_color", i); com.iBookStar.c.b.b("titlebar_text_color", i2); } public static void a(Context context, String str, String str2) { String b2 = k.b(context); if (s.a(b2) || context.getApplicationContext().getPackageName().equalsIgnoreCase(b2)) { try { com.iBookStar.b.a.a(context, str, str2, false); com.iBookStar.a.d.a().b(""); } catch (Throwable th) { th.printStackTrace(); } } } public static void a(View view) { c = view; } public static void a(YmConfig.MNovelReadObserver mNovelReadObserver) { d = mNovelReadObserver; } public static void a(YmConfig.MNovelTaskObserver mNovelTaskObserver) { e = mNovelTaskObserver; } public static void a(String str) { a = false; b(b, str, true); } private static void a(String str, String str2, boolean z, boolean z2) { try { if (s.a(str2)) { Toast.makeText(com.iBookStar.b.a.k(), "url不能为空", 0).show(); } else if (str2.contains("sdktype=ymtask")) { String a2 = k.a(Uri.parse(str2.replace("sdktype=ymtask", ""))); g = a2; com.iBookStar.c.b.b("current_url", a2); b((String) null, false, z2); } else { Intent intent = new Intent(com.iBookStar.b.a.k(), SurveyWebView.class); intent.putExtra("url", str2); intent.putExtra("fromTask", z); intent.putExtra("back", z2); intent.addFlags(268435456); com.iBookStar.b.a.k().startActivity(intent); } } catch (Exception e2) { Log.i("xxxxxxxxxxxxxxx", "openReader fail--3 !!!!", e2); Toast.makeText(com.iBookStar.b.a.k(), "打开书籍/书城失败", 0).show(); } } public static void a(String str, boolean z) { String str2; if (!com.iBookStar.b.a.k) { Toast.makeText(com.iBookStar.b.a.k(), "打开失败,请先初始化SDK", 0).show(); } else if (!com.iBookStar.b.a.l) { Toast.makeText(com.iBookStar.b.a.k(), "打开失败,请检查YMSDK是否正确初始化", 0).show(); } else if (!com.iBookStar.b.a.r) { Toast.makeText(com.iBookStar.b.a.k(), "打开失败,请检查是否正确引入了tbs sdk包", 0).show(); } else { if (str != null) { if (str.startsWith(com.iBookStar.b.a.g + ".novel://")) { try { Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(Uri.parse(str)); intent.addFlags(268435456); com.iBookStar.b.a.k().startActivity(intent); return; } catch (Exception e2) { e2.printStackTrace(); return; } } } if (str == null || (!str.startsWith("http://") && !str.startsWith("https://"))) { StringBuilder sb = new StringBuilder(); sb.append("http://tools.ibookeee.com?ymlandpage=1"); if (s.c(str)) { str2 = "&type=" + URLEncoder.encode(str); } else { str2 = ""; } sb.append(str2); a(sb.toString(), z); return; } a = false; b(str); if (str.contains("ymlandpage=1")) { l.b(new a(z)); } else { b(b, str, z); } } } public static void a(boolean z) { a(false, true, z); } public static void a(boolean z, boolean z2) { a = false; b(b, z, z2); } /* access modifiers changed from: private */ public static void a(boolean z, boolean z2, boolean z3) { com.iBookStar.a.g a2 = com.iBookStar.c.b.a(0); if (a2 != null) { int j = a2.j(); if (j == 1) { Intent intent = new Intent(com.iBookStar.b.a.k(), CoinWebView.class); intent.addFlags(268435456); intent.putExtra("back", z3); com.iBookStar.b.a.k().startActivity(intent); return; } else if (j != 6) { if (g == null) { g = com.iBookStar.c.b.a("current_url", (String) null); } if (!s.c(g)) { if (!z) { return; } Toast.makeText(com.iBookStar.b.a.k(), "今天的奖励任务已做完,明天再来!", 1).show(); return; } } else { try { Intent intent2 = new Intent(com.iBookStar.b.a.k(), SurveyWebView.class); intent2.putExtra("url", a2.h()); intent2.putExtra("fromTask", z2); intent2.putExtra("back", z3); intent2.addFlags(268435456); com.iBookStar.b.a.k().startActivity(intent2); return; } catch (Exception e2) { e2.printStackTrace(); return; } } } else { if (g == null) { g = com.iBookStar.c.b.a("current_url", (String) null); } if (!s.c(g)) { if (!z) { return; } Toast.makeText(com.iBookStar.b.a.k(), "今天的奖励任务已做完,明天再来!", 1).show(); return; } } a(null, g, z2, z3); } public static View b() { return c; } public static void b(String str) { com.iBookStar.c.b.a("current_entrance"); String string = k.b(Uri.parse(str).getEncodedQuery()).getString("type"); if (s.c(string)) { com.iBookStar.c.b.b("current_entrance", string); } } /* access modifiers changed from: private */ public static void b(String str, String str2, boolean z) { if (0 == com.iBookStar.c.b.a(com.iBookStar.c.c.b("config_setup"), 0L)) { l.c(new b(str, str2, z)); return; } l.c(null); if (s.a(str2) && s.a(com.iBookStar.c.b.a("current_entrance", (String) null))) { str2 = com.iBookStar.c.b.a(com.iBookStar.c.c.b("putinurl"), (String) null); } if (s.a(str2)) { Toast.makeText(com.iBookStar.b.a.k(), "小说还未配置,请联系商务或运营", 1).show(); } else if (com.iBookStar.c.b.j().c() <= 0 && !a) { l.a(new c(str, str2, z)); a = true; } else if (s.c(str)) { l.a(str, new d(str2, z)); } else { a(str, str2, false, z); } } /* access modifiers changed from: private */ public static void b(String str, boolean z, boolean z2) { if (com.iBookStar.c.b.j().c() <= 0 && !a) { l.a(new e(str, z, z2)); a = true; } else if (s.c(str)) { l.a(str, new f(z, z2)); } else { com.iBookStar.c.b.f(); l.d(new g(z, z2)); } } public static String c() { return d.b(); } public static void c(String str) { b = str; } public static YmLoadManager d() { return m.a(); } public static String e() { return b; } public static String f() { return "3.0"; } public static int g() { int a2 = com.iBookStar.c.b.a("config_titlebar_bg_color", 0); return a2 == 0 ? com.iBookStar.c.b.a("titlebar_bg_color", -1) : a2; } public static int h() { int a2 = com.iBookStar.c.b.a("config_titlebar_text_color", 0); return a2 == 0 ? com.iBookStar.c.b.a("titlebar_text_color", -16777216) : a2; } public static int i() { return com.iBookStar.c.b.a("webview_progress_color", -32768); } public static void j() { YmConfig.MNovelReadObserver mNovelReadObserver = d; if (mNovelReadObserver != null) { int i = f - 1; f = i; if (i == 0) { try { mNovelReadObserver.close(); } catch (Throwable th) { th.printStackTrace(); } } } } public static void k() { YmConfig.MNovelReadObserver mNovelReadObserver = d; if (mNovelReadObserver != null) { int i = f; f = i + 1; if (i == 0) { try { mNovelReadObserver.open(); } catch (Throwable th) { th.printStackTrace(); } } } } public static void l() { if (e != null) { try { long a2 = com.iBookStar.c.b.a(com.iBookStar.c.c.b("task_complete_notify"), 0L); if (a2 != 0 && k.a(a2)) { e.onTaskComplete(); com.iBookStar.c.b.a(com.iBookStar.c.c.b("task_complete_notify")); } } catch (Throwable th) { th.printStackTrace(); } } } public static void m() { u.a(); } }