翰林优商.apk(点击下载) / SjmDspPageActivity.java


package com.sjm.sjmdsp;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.webkit.WebView;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.sjm.sjmdsp.adCore.model.SjmDspAdItemData;
import com.sjm.sjmdsp.adCore.report.SjmDspReport;
import com.sjm.sjmdsp.web.SjmAdPageWebViewSetting;
import java.util.HashMap;

public class SjmDspPageActivity extends AppCompatActivity {
    private static final String TAG = "SjmDspPageActivity";
    private ActionBar actionBar;
    boolean isGoBack = false;
    SjmDspAdItemData itemData;
    private long resumeTime = 0;
    private WebView webView;

    /* access modifiers changed from: protected */
    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.fragment.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_sjm_dsp_page);
        ActionBar supportActionBar = getSupportActionBar();
        this.actionBar = supportActionBar;
        if (supportActionBar != null) {
            supportActionBar.setHomeButtonEnabled(true);
            this.actionBar.setDisplayHomeAsUpEnabled(true);
        }
        setTitle("");
        this.webView = (WebView) findViewById(R.id.sjm_webView_dsp_ad_page);
        new SjmAdPageWebViewSetting().setting(this, this.webView);
        SjmDspAdItemData sjmDspAdItemData = (SjmDspAdItemData) getIntent().getExtras().get("adData");
        this.itemData = sjmDspAdItemData;
        if (sjmDspAdItemData != null) {
            HashMap hashMap = new HashMap();
            hashMap.put("Referer", this.itemData.adAction.page);
            this.webView.loadUrl(this.itemData.adAction.page, hashMap);
            SjmDspAdItemData sjmDspAdItemData2 = this.itemData;
            SjmDspReport.eventReport(sjmDspAdItemData2, "EVENT_PAGE_OPEN", sjmDspAdItemData2.adAction.page);
        }
    }

    private void pageClose(Boolean bool) {
        if (!bool.booleanValue()) {
            SjmDspAdItemData sjmDspAdItemData = this.itemData;
            if (sjmDspAdItemData != null) {
                SjmDspReport.eventReport(sjmDspAdItemData, "EVENT_PAGE_CLOSE", sjmDspAdItemData.adAction.page);
            }
            finish();
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        if (this.webView.canGoBack()) {
            this.isGoBack = true;
            this.webView.goBack();
            return true;
        }
        pageClose(false);
        return true;
    }

    @Override // androidx.appcompat.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4 || !this.webView.canGoBack()) {
            pageClose(true);
            return super.onKeyDown(i, keyEvent);
        }
        this.isGoBack = true;
        this.resumeTime = System.currentTimeMillis();
        this.webView.goBack();
        return true;
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onDestroy() {
        WebView webView2 = this.webView;
        if (webView2 != null) {
            webView2.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
            ((ViewGroup) this.webView.getParent()).removeView(this.webView);
            this.webView.destroy();
            this.webView = null;
        }
        super.onDestroy();
    }
}