//package com.sxyz.courtai.base;
//
//import android.content.DialogInterface;
//import android.content.Intent;
//import android.graphics.Bitmap;
//import android.graphics.Color;
//import android.os.Bundle;
//import android.util.Log;
//import android.view.KeyEvent;
//import android.view.View;
//import android.webkit.WebResourceRequest;
//import android.webkit.WebView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import androidx.annotation.Nullable;
//import androidx.appcompat.app.AlertDialog;
//import androidx.appcompat.app.AppCompatActivity;
//import androidx.appcompat.widget.Toolbar;
//
//import com.just.agentweb.AgentWeb;
//import com.just.agentweb.DefaultWebClient;
//import com.just.agentweb.WebChromeClient;
//import com.just.agentweb.WebViewClient;
//import com.sxyz.courtai.R;
//
///**
// * Created by cenxiaozhong on 2017/5/26.
// * <p>
// * source code  https://github.com/Justson/AgentWeb
// */
//
//public class BaseWebActivity extends AppCompatActivity {
//
//
//    protected AgentWeb mAgentWeb;
//    private LinearLayout mLinearLayout;
//    private Toolbar mToolbar;
//    private TextView mTitleTextView;
//    private AlertDialog mAlertDialog;
//
//
//    @Override
//    protected void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//
//        setContentView(R.layout.activity_web);
//
//
//        mLinearLayout = (LinearLayout) this.findViewById(R.id.container);
//        mToolbar = (Toolbar) this.findViewById(R.id.toolbar);
//        mToolbar.setTitleTextColor(Color.WHITE);
//        mToolbar.setTitle("");
//        mTitleTextView = (TextView) this.findViewById(R.id.toolbar_title);
//        this.setSupportActionBar(mToolbar);
//        if (getSupportActionBar() != null) {
//            // Enable the Up button
//            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//        }
//        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                showDialog();
//            }
//        });
//
//
//        long p = System.currentTimeMillis();
//        mAgentWeb.getUrlLoader().loadUrl(getUrl());
//
////        mAgentWeb = AgentWeb.with(this)
////                .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(-1, -1))
////                .useDefaultIndicator()
////                .setWebChromeClient(mWebChromeClient)
////                .setWebViewClient(mWebViewClient)
////                .setMainFrameErrorView(com.just.agentweb.R.layout.agentweb_error_page, -1)
////                .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
//////                .setWebLayout(new WebLayout(this))
////                .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)//打开其他应用时，弹窗咨询用户是否前往其他应用
////                .interceptUnkownUrl() //拦截找不到相关页面的Scheme
////                .createAgentWeb()
////                .ready()
////                .go(getUrl());
//
//        //mAgentWeb.getUrlLoader().loadUrl(getUrl());
//
//        long n = System.currentTimeMillis();
//        Log.i("Info", "init used time:" + (n - p));
//
//
//    }
//
//    private WebViewClient mWebViewClient = new WebViewClient() {
//        @Override
//        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
//            return super.shouldOverrideUrlLoading(view, request);
//        }
//
//        @Override
//        public void onPageStarted(WebView view, String url, Bitmap favicon) {
//            //do you  work
//            Log.i("Info", "BaseWebActivity onPageStarted");
//        }
//    };
//    private WebChromeClient mWebChromeClient = new WebChromeClient() {
//        @Override
//        public void onReceivedTitle(WebView view, String title) {
//            super.onReceivedTitle(view, title);
//            if (mTitleTextView != null) {
//                mTitleTextView.setText(title);
//            }
//        }
//    };
//
//    public String getUrl() {
//        return "https://m.jd.com/";
//    }
//
//
//    private void showDialog() {
//
//        if (mAlertDialog == null) {
//            mAlertDialog = new AlertDialog.Builder(this)
//                    .setMessage("您确定要关闭该页面吗?")
//                    .setNegativeButton("再逛逛", new DialogInterface.OnClickListener() {
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//                            if (mAlertDialog != null) {
//                                mAlertDialog.dismiss();
//                            }
//                        }
//                    })//
//                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
//                        @Override
//                        public void onClick(DialogInterface dialog, int which) {
//
//                            if (mAlertDialog != null) {
//                                mAlertDialog.dismiss();
//                            }
//                            BaseWebActivity.this.finish();
//                        }
//                    }).create();
//        }
//        mAlertDialog.show();
//
//    }
//
//    @Override
//    public boolean onKeyDown(int keyCode, KeyEvent event) {
//
//        if (mAgentWeb.handleKeyEvent(keyCode, event)) {
//            return true;
//        }
//        return super.onKeyDown(keyCode, event);
//    }
//
//    @Override
//    protected void onPause() {
//        mAgentWeb.getWebLifeCycle().onPause();
//        super.onPause();
//
//    }
//
//    @Override
//    protected void onResume() {
//        mAgentWeb.getWebLifeCycle().onResume();
//        super.onResume();
//    }
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//
//        Log.i("Info", "onResult:" + requestCode + " onResult:" + resultCode);
//        super.onActivityResult(requestCode, resultCode, data);
//    }
//
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        //mAgentWeb.destroy();
//        mAgentWeb.getWebLifeCycle().onDestroy();
//    }
//}
