花瓣 v4.6.12版本的 MD5 值为:6a3515d4d16d98931f1b3d25a91b257e

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


package com.huaban.android.modules.common;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.annotation.RequiresApi;
import androidx.lifecycle.LifecycleOwnerKt;
import com.google.android.exoplayer2.u4.u0.h0;
import com.huaban.android.R;
import com.huaban.android.base.BaseActivity;
import com.huaban.android.g.r;
import com.huaban.android.modules.account.login.LoginActivity;
import com.huaban.android.modules.pin.create.CreatePinActivity;
import java.util.HashMap;
import kotlin.a1;
import kotlin.c0;
import kotlin.f0;
import kotlin.f2;
import kotlin.s2.n.a.o;
import kotlin.x2.v.p;
import kotlin.x2.w.k0;
import kotlin.x2.w.m0;
import kotlin.x2.w.w;
import kotlin.z;
import kotlinx.coroutines.n;
import kotlinx.coroutines.n1;
import kotlinx.coroutines.w0;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.json.JSONObject;
@f0(bv = {1, 0, 3}, d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u0000 #2\u00020\u0001:\u0002#$B\u0007¢\u0006\u0004\b\"\u0010\u0004J\u000f\u0010\u0003\u001a\u00020\u0002H\u0002¢\u0006\u0004\b\u0003\u0010\u0004J\u0013\u0010\u0006\u001a\u00020\u0005H\u0082@ø\u0001\u0000¢\u0006\u0004\b\u0006\u0010\u0007J\u001b\u0010\t\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u0005H\u0082@ø\u0001\u0000¢\u0006\u0004\b\t\u0010\nJ\u0019\u0010\r\u001a\u00020\u00022\b\u0010\f\u001a\u0004\u0018\u00010\u000bH\u0015¢\u0006\u0004\b\r\u0010\u000eR\u0016\u0010\u000f\u001a\u00020\u00058\u0002@\u0002X\u0082D¢\u0006\u0006\n\u0004\b\u000f\u0010\u0010R\u0018\u0010\u0012\u001a\u0004\u0018\u00010\u00118\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0012\u0010\u0013R\u001d\u0010\u0018\u001a\u00020\u00058B@\u0002X\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0014\u0010\u0015\u001a\u0004\b\u0016\u0010\u0017R\u001d\u0010\u001b\u001a\u00020\u00058B@\u0002X\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0019\u0010\u0015\u001a\u0004\b\u001a\u0010\u0017R\u0016\u0010\u001d\u001a\u00020\u001c8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u001d\u0010\u001eR\u0018\u0010 \u001a\u0004\u0018\u00010\u001f8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b \u0010!\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006%"}, d2 = {"Lcom/huaban/android/modules/common/ImageCollectActivity;", "Lcom/huaban/android/base/BaseActivity;", "", "addImageButton4ImageElement", "()V", "", "getFinalJsString", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "jsUrl", "loadJsContent", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Landroid/os/Bundle;", "savedInstanceState", "onCreate", "(Landroid/os/Bundle;)V", "jsLink", "Ljava/lang/String;", "Landroid/widget/FrameLayout;", "loading", "Landroid/widget/FrameLayout;", "mTitle$delegate", "Lkotlin/Lazy;", "getMTitle", "()Ljava/lang/String;", "mTitle", "mUrl$delegate", "getMUrl", "mUrl", "Lcom/huaban/android/modules/common/ImageCollectActivity$MyJavaScriptInterface;", "myInterface", "Lcom/huaban/android/modules/common/ImageCollectActivity$MyJavaScriptInterface;", "Landroid/webkit/WebView;", "webView", "Landroid/webkit/WebView;", "<init>", "Companion", "MyJavaScriptInterface", "container.HuabanApp_release"}, k = 1, mv = {1, 1, 15}, pn = "", xi = 0, xs = "")
public final class ImageCollectActivity extends BaseActivity {
    private static final String j = "extra_url";
    private static final String k = "extra_title";
    @h.c.a.d
    public static final a l = new a(null);
    private final z c;
    private final z f9011d;
    private WebView f9012e;
    private FrameLayout f9013f;
    private b f9014g;
    private final String f9015h;
    private HashMap f9016i;

    public static final class a {
        private a() {
        }

        public static void b(a aVar, Context context, String str, String str2, int i2, Object obj) {
            if ((i2 & 4) != 0) {
                str2 = null;
            }
            aVar.a(context, str, str2);
        }

        public final void a(@h.c.a.e Context context, @h.c.a.d String str, @h.c.a.e String str2) {
            k0.p(str, "url");
            Intent intent = new Intent(context, ImageCollectActivity.class);
            intent.putExtra(ImageCollectActivity.j, str);
            intent.putExtra(ImageCollectActivity.k, str2);
            if (context != null) {
                context.startActivity(intent);
            }
        }

        public a(w wVar) {
            this();
        }
    }

    public static final class b {
        private final Context a;
        private final String b;
        private final String c;

        public b(@h.c.a.d Context context, @h.c.a.d String str, @h.c.a.d String str2) {
            k0.p(context, "context");
            k0.p(str, "url");
            k0.p(str2, "title");
            this.a = context;
            this.b = str;
            this.c = str2;
        }

        public final void a(@h.c.a.e String str, @h.c.a.d String str2) {
            String str3;
            k0.p(str2, "description");
            com.huaban.android.c.a.d p = com.huaban.android.c.a.d.p();
            k0.o(p, "HBAuthManager.sharedManager()");
            if (!p.i()) {
                LoginActivity.f8921f.a(this.a);
                com.huaban.android.j.d.a.a("请登录后再采集", this.a);
            } else if (str != null && (str3 = this.b) != null) {
                CreatePinActivity.B.i(this.a, str, str3, str2);
            } else {
                com.huaban.android.j.d.a.a("抓取图片失败", this.a);
            }
        }

        @JavascriptInterface
        public final void onImageClick(@h.c.a.d String str, @h.c.a.d String str2) {
            k0.p(str, "url");
            k0.p(str2, "description");
            a(str, str2);
        }
    }

    @kotlin.s2.n.a.f(c = "com.huaban.android.modules.common.ImageCollectActivity$addImageButton4ImageElement$1", f = "ImageCollectActivity.kt", i = {}, l = {103}, m = "invokeSuspend", n = {}, s = {})
    public static final class c extends o implements p<w0, kotlin.s2.d<? super f2>, Object> {
        int a;

        c(kotlin.s2.d dVar) {
            super(2, dVar);
        }

        @Override
        @h.c.a.d
        public final kotlin.s2.d<f2> create(@h.c.a.e Object obj, @h.c.a.d kotlin.s2.d<?> dVar) {
            k0.p(dVar, "completion");
            return new c(dVar);
        }

        @Override
        public final Object invoke(w0 w0Var, kotlin.s2.d<? super f2> dVar) {
            return ((c) create(w0Var, dVar)).invokeSuspend(f2.a);
        }

        @Override
        @h.c.a.e
        public final Object invokeSuspend(@h.c.a.d Object obj) {
            Object h2;
            h2 = kotlin.s2.m.d.h();
            int i2 = this.a;
            if (i2 == 0) {
                a1.n(obj);
                ImageCollectActivity imageCollectActivity = ImageCollectActivity.this;
                this.a = 1;
                obj = imageCollectActivity.d0(this);
                if (obj == h2) {
                    return h2;
                }
            } else if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            } else {
                a1.n(obj);
            }
            String str = (String) obj;
            WebView webView = ImageCollectActivity.this.f9012e;
            if (webView != null) {
                webView.evaluateJavascript(str, null);
            }
            return f2.a;
        }
    }

    @kotlin.s2.n.a.f(c = "com.huaban.android.modules.common.ImageCollectActivity$getFinalJsString$2", f = "ImageCollectActivity.kt", i = {}, l = {h0.G}, m = "invokeSuspend", n = {}, s = {})
    public static final class d extends o implements p<w0, kotlin.s2.d<? super String>, Object> {
        int a;

        d(kotlin.s2.d dVar) {
            super(2, dVar);
        }

        @Override
        @h.c.a.d
        public final kotlin.s2.d<f2> create(@h.c.a.e Object obj, @h.c.a.d kotlin.s2.d<?> dVar) {
            k0.p(dVar, "completion");
            return new d(dVar);
        }

        @Override
        public final Object invoke(w0 w0Var, kotlin.s2.d<? super String> dVar) {
            return ((d) create(w0Var, dVar)).invokeSuspend(f2.a);
        }

        @Override
        @h.c.a.e
        public final Object invokeSuspend(@h.c.a.d Object obj) {
            Object h2;
            String string;
            h2 = kotlin.s2.m.d.h();
            int i2 = this.a;
            if (i2 == 0) {
                a1.n(obj);
                Request build = new Request.Builder().url("https://grocery-cdn.huaban.com/huaban/cxvuetez0x8.json?env=prod").build();
                String str = ImageCollectActivity.this.f9015h;
                try {
                    Response execute = new OkHttpClient().newCall(build).execute();
                    ResponseBody body = execute.body();
                    String string2 = body != null ? body.string() : null;
                    if (execute.isSuccessful() && string2 != null && (string = new JSONObject(string2).getString("js")) != null) {
                        if (string.length() > 0) {
                            str = string;
                        }
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                }
                ImageCollectActivity imageCollectActivity = ImageCollectActivity.this;
                this.a = 1;
                obj = imageCollectActivity.g0(str, this);
                if (obj == h2) {
                    return h2;
                }
            } else if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            } else {
                a1.n(obj);
            }
            return obj;
        }
    }

    @kotlin.s2.n.a.f(c = "com.huaban.android.modules.common.ImageCollectActivity$loadJsContent$2", f = "ImageCollectActivity.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    public static final class e extends o implements p<w0, kotlin.s2.d<? super String>, Object> {
        int a;
        final String b;

        e(String str, kotlin.s2.d dVar) {
            super(2, dVar);
            this.b = str;
        }

        @Override
        @h.c.a.d
        public final kotlin.s2.d<f2> create(@h.c.a.e Object obj, @h.c.a.d kotlin.s2.d<?> dVar) {
            k0.p(dVar, "completion");
            return new e(this.b, dVar);
        }

        @Override
        public final Object invoke(w0 w0Var, kotlin.s2.d<? super String> dVar) {
            return ((e) create(w0Var, dVar)).invokeSuspend(f2.a);
        }

        @Override
        @h.c.a.e
        public final Object invokeSuspend(@h.c.a.d Object obj) {
            kotlin.s2.m.d.h();
            if (this.a == 0) {
                a1.n(obj);
                try {
                    Response execute = new OkHttpClient().newCall(new Request.Builder().url(this.b).build()).execute();
                    ResponseBody body = execute.body();
                    String string = body != null ? body.string() : null;
                    return (!execute.isSuccessful() || string == null) ? "" : string;
                } catch (Throwable th) {
                    th.printStackTrace();
                    return "";
                }
            }
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }

    static final class f extends m0 implements kotlin.x2.v.a<String> {
        f() {
            super(0);
        }

        @Override
        @h.c.a.d
        public final String invoke() {
            String stringExtra = ImageCollectActivity.this.getIntent().getStringExtra(WebViewActivity.l.b());
            return stringExtra != null ? stringExtra : "";
        }
    }

    static final class g extends m0 implements kotlin.x2.v.a<String> {
        g() {
            super(0);
        }

        @Override
        @h.c.a.d
        public final String invoke() {
            String stringExtra = ImageCollectActivity.this.getIntent().getStringExtra(WebViewActivity.l.c());
            return stringExtra != null ? stringExtra : "";
        }
    }

    public static final class h extends WebChromeClient {
        h() {
        }

        @Override
        public boolean onConsoleMessage(@h.c.a.e ConsoleMessage consoleMessage) {
            return super.onConsoleMessage(consoleMessage);
        }
    }

    public static final class i extends WebViewClient {
        i() {
        }

        @Override
        public void onPageFinished(@h.c.a.e WebView webView, @h.c.a.e String str) {
            super.onPageFinished(webView, str);
            ImageCollectActivity.this.c0();
        }
    }

    static final class j implements View.OnLongClickListener {
        j() {
        }

        @Override
        public final boolean onLongClick(View view) {
            WebView webView = (WebView) ImageCollectActivity.this.N(R.id.webview);
            k0.o(webView, "webview");
            WebView.HitTestResult hitTestResult = webView.getHitTestResult();
            k0.o(hitTestResult, "webview.hitTestResult");
            int type = hitTestResult.getType();
            if (type == 5 || type == 8) {
                ImageCollectActivity.Y(ImageCollectActivity.this).a(hitTestResult.getExtra(), "来自网络");
                return true;
            }
            return false;
        }
    }

    public ImageCollectActivity() {
        z c2;
        z c3;
        c2 = c0.c(new g());
        this.c = c2;
        c3 = c0.c(new f());
        this.f9011d = c3;
        this.f9015h = "https://cdn.dancf.com/fe-assets/20230412/huaban-app/dist/e8b257440e22c611cfb51990520c96fa.cjs";
    }

    public static final b Y(ImageCollectActivity imageCollectActivity) {
        b bVar = imageCollectActivity.f9014g;
        if (bVar == null) {
            k0.S("myInterface");
        }
        return bVar;
    }

    public final void c0() {
        kotlinx.coroutines.p.f(LifecycleOwnerKt.getLifecycleScope(this), null, null, new c(null), 3, null);
    }

    private final String e0() {
        return (String) this.f9011d.getValue();
    }

    private final String f0() {
        return (String) this.c.getValue();
    }

    @Override
    public void M() {
        HashMap hashMap = this.f9016i;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    @Override
    public View N(int i2) {
        if (this.f9016i == null) {
            this.f9016i = new HashMap();
        }
        View view = (View) this.f9016i.get(Integer.valueOf(i2));
        if (view == null) {
            View findViewById = findViewById(i2);
            this.f9016i.put(Integer.valueOf(i2), findViewById);
            return findViewById;
        }
        return view;
    }

    final Object d0(kotlin.s2.d<? super String> dVar) {
        return n.h(n1.c(), new d(null), dVar);
    }

    final Object g0(String str, kotlin.s2.d<? super String> dVar) {
        return n.h(n1.c(), new e(str, null), dVar);
    }

    @Override
    @RequiresApi(23)
    public void onCreate(@h.c.a.e Bundle bundle) {
        WebSettings settings;
        WebSettings settings2;
        WebSettings settings3;
        WebSettings settings4;
        WebSettings settings5;
        WebSettings settings6;
        WebSettings settings7;
        WebSettings settings8;
        super.onCreate(bundle);
        setContentView(R.layout.activity_image_collect);
        LinearLayout linearLayout = (LinearLayout) N(R.id.mRootView);
        k0.o(linearLayout, "mRootView");
        r.a(linearLayout, this, (r15 & 2) != 0 ? "" : "选择要采集的图片", (r15 & 4) == 0 ? null : "", (r15 & 8) != 0 ? Integer.valueOf(R.drawable.ic_back) : Integer.valueOf(R.drawable.ic_back), (r15 & 16) != 0 ? null : null, (r15 & 32) != 0 ? null : null, (r15 & 64) == 0 ? null : null);
        this.f9013f = (FrameLayout) findViewById(R.id.layout_loading);
        this.f9012e = (WebView) findViewById(R.id.webview);
        if (Build.VERSION.SDK_INT >= 19) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
        WebView webView = this.f9012e;
        if (webView != null && (settings8 = webView.getSettings()) != null) {
            settings8.setJavaScriptEnabled(true);
        }
        WebView webView2 = this.f9012e;
        if (webView2 != null && (settings7 = webView2.getSettings()) != null) {
            settings7.setAllowFileAccess(true);
        }
        WebView webView3 = this.f9012e;
        if (webView3 != null && (settings6 = webView3.getSettings()) != null) {
            settings6.setAllowContentAccess(true);
        }
        WebView webView4 = this.f9012e;
        if (webView4 != null && (settings5 = webView4.getSettings()) != null) {
            settings5.setDomStorageEnabled(true);
        }
        WebView webView5 = this.f9012e;
        if (webView5 != null && (settings4 = webView5.getSettings()) != null) {
            settings4.setUseWideViewPort(true);
        }
        WebView webView6 = this.f9012e;
        if (webView6 != null && (settings3 = webView6.getSettings()) != null) {
            settings3.setLoadWithOverviewMode(true);
        }
        WebView webView7 = this.f9012e;
        if (webView7 != null && (settings2 = webView7.getSettings()) != null) {
            settings2.setSupportZoom(true);
        }
        WebView webView8 = this.f9012e;
        if (webView8 != null && (settings = webView8.getSettings()) != null) {
            settings.setMixedContentMode(0);
        }
        String f0 = f0();
        k0.o(f0, "mUrl");
        String e0 = e0();
        k0.o(e0, "mTitle");
        b bVar = new b(this, f0, e0);
        this.f9014g = bVar;
        WebView webView9 = this.f9012e;
        if (webView9 != null) {
            if (bVar == null) {
                k0.S("myInterface");
            }
            webView9.addJavascriptInterface(bVar, "Android");
        }
        WebView webView10 = this.f9012e;
        if (webView10 != null) {
            webView10.setWebChromeClient(new h());
        }
        WebView webView11 = this.f9012e;
        if (webView11 != null) {
            webView11.setWebViewClient(new i());
        }
        WebView webView12 = this.f9012e;
        if (webView12 != null) {
            webView12.setOnLongClickListener(new j());
        }
        WebView webView13 = this.f9012e;
        if (webView13 != null) {
            webView13.loadUrl(f0());
        }
    }
}