| | |
| | | package com.secondworld.sdk.utils; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.app.Activity; |
| | | import android.util.DisplayMetrics; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.webkit.WebView; |
| | | import android.webkit.WebViewClient; |
| | | import android.widget.ImageButton; |
| | | import android.widget.RelativeLayout; |
| | | |
| | | import com.secondworld.sdk.GameActivity; |
| | | import com.secondworld.sdk.R; |
| | | |
| | | public class WebViewUtil { |
| | | |
| | | public static WebViewUtil I; |
| | | public static WebViewUtil I = new WebViewUtil(); |
| | | |
| | | RelativeLayout webContainer; |
| | | private WebView webView; |
| | | private WebView btnClose; |
| | | private ImageButton btnClose; |
| | | |
| | | private boolean isShow; |
| | | |
| | |
| | | } |
| | | |
| | | @SuppressLint("SetJavaScriptEnabled") |
| | | public void init(GameActivity gameActivity, RelativeLayout webContainer) { |
| | | public void init(Activity gameActivity, RelativeLayout webContainer) { |
| | | this.webContainer = webContainer; |
| | | webView = webContainer.findViewById(R.id.webView); |
| | | btnClose = webContainer.findViewById(R.id.btnWebClose); |
| | |
| | | public void open(String url, boolean delay) { |
| | | if (!isValid()) |
| | | return; |
| | | webView.loadUrl(url); |
| | | if (!delay) |
| | | show(); |
| | | webView.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | webView.loadUrl(url); |
| | | isShow = true; |
| | | if (!delay) |
| | | show(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void show() { |
| | | isShow = true; |
| | | webContainer.setVisibility(View.VISIBLE); |
| | | } |
| | | |