导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - PaymentWebViewActivity.java 源代码

正在查看: Clash Legends v0.0.1 应用的 PaymentWebViewActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.clash.legends.ui.activities;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.clash.legends.ui.activities.PaymentWebViewActivity;

public class PaymentWebViewActivity extends AppCompatActivity {
    private long backPressedTime = 0;
    private ProgressBar progressBar;
    private WebView webView;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558471);
        this.webView = (WebView) findViewById(2131363784);
        this.progressBar = (ProgressBar) findViewById(2131363072);
        String paymentUrl = getIntent().getStringExtra("payment_url");
        String redirectUrl = getIntent().getStringExtra("redirect_url");
        setupWebView(paymentUrl, redirectUrl);
    }

    class AnonymousClass1 extends WebViewClient {
        final String val$redirectUrl;

        AnonymousClass1(String str) {
            this.val$redirectUrl = str;
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            if (request.getUrl().toString().startsWith(this.val$redirectUrl)) {
                PaymentWebViewActivity.this.finish();
                return true;
            }
            return super.shouldOverrideUrlLoading(view, request);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, final String description, String failingUrl) {
            PaymentWebViewActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    PaymentWebViewActivity.AnonymousClass1.this.m147x128e3d96(description);
                }
            });
        }

        void m147x128e3d96(String description) {
            Toast.makeText((Context) PaymentWebViewActivity.this, (CharSequence) ("Payment Error: " + description), 0).show();
            PaymentWebViewActivity.this.finish();
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            PaymentWebViewActivity.this.progressBar.setVisibility(0);
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            PaymentWebViewActivity.this.progressBar.setVisibility(8);
            super.onPageFinished(view, url);
        }
    }

    private void setupWebView(String paymentUrl, String redirectUrl) {
        this.webView.setWebViewClient(new AnonymousClass1(redirectUrl));
        WebSettings webSettings = this.webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        this.webView.loadUrl(paymentUrl);
    }

    public void onBackPressed() {
        if (this.backPressedTime + 2000 > System.currentTimeMillis()) {
            super.onBackPressed();
            setResult(0);
            finish();
        } else {
            Toast.makeText((Context) this, (CharSequence) "Press back again to cancel payment", 0).show();
            this.backPressedTime = System.currentTimeMillis();
        }
    }
}