|
@@ -4,6 +4,7 @@ import android.app.AlertDialog;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
import android.graphics.Color;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
@@ -18,6 +19,7 @@ import android.webkit.WebSettings;
|
|
|
import android.webkit.WebView;
|
|
|
import android.webkit.WebViewClient;
|
|
|
|
|
|
+import com.edufound.bytedance.R;
|
|
|
import com.edufound.bytedance.application.MyApplication;
|
|
|
import com.edufound.bytedance.base.BasePresenter;
|
|
|
import com.edufound.bytedance.mvp.model.MainModel;
|
|
@@ -28,12 +30,18 @@ import com.edufound.bytedance.util.OkHttpUtil;
|
|
|
import com.edufound.bytedance.util.SharedPerfenceUtil;
|
|
|
import com.edufound.bytedance.util.ToastUtil;
|
|
|
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.util.Iterator;
|
|
|
+
|
|
|
import okhttp3.Request;
|
|
|
|
|
|
public class MainPersenter extends BasePresenter<MainModel, MainView> {
|
|
|
|
|
|
private String mLoadUrl;
|
|
|
private MainJsMethod mMainJsMethod;
|
|
|
+ private Bitmap mVideoBitmap;
|
|
|
|
|
|
public void initWeb() {
|
|
|
if (Build.VERSION.SDK_INT >= 19) {
|
|
@@ -54,8 +62,8 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
|
|
|
getView().getWebView().getSettings().setUseWideViewPort(true);
|
|
|
getView().getWebView().getSettings().setLoadWithOverviewMode(true);
|
|
|
getView().getWebView().getSettings().setTextZoom(100);
|
|
|
-
|
|
|
-
|
|
|
+ mVideoBitmap = BitmapFactory.decodeResource(getView().getActivity().getResources(),
|
|
|
+ R.drawable.videoposterblack);
|
|
|
getView().getWebView().setWebChromeClient(new WebChromeClient() {
|
|
|
|
|
|
@Override
|
|
@@ -80,8 +88,7 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
|
|
|
|
|
|
@Override
|
|
|
public Bitmap getDefaultVideoPoster() {
|
|
|
-
|
|
|
- return null;
|
|
|
+ return mVideoBitmap;
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -133,21 +140,36 @@ public class MainPersenter extends BasePresenter<MainModel, MainView> {
|
|
|
|
|
|
|
|
|
public void openWeb(Intent intent) {
|
|
|
- getView().getWebView().loadUrl("");
|
|
|
- mLoadUrl = model.getDefaultWebUrl();
|
|
|
- Uri uri = intent.getData();
|
|
|
- String intent_url = "";
|
|
|
- if (uri != null) {
|
|
|
- intent_url = uri.getQueryParameter("url");
|
|
|
- } else {
|
|
|
- intent_url = intent.getStringExtra("url");
|
|
|
- }
|
|
|
- if (intent_url != null && !intent_url.isEmpty()) {
|
|
|
- mLoadUrl = intent_url;
|
|
|
+ try {
|
|
|
+ getView().getWebView().loadUrl("");
|
|
|
+ mLoadUrl = model.getDefaultWebUrl();
|
|
|
+ Uri uri = intent.getData();
|
|
|
+ String intent_url = "";
|
|
|
+ if (uri != null) {
|
|
|
+ intent_url = uri.getQueryParameter("url");
|
|
|
+ } else {
|
|
|
+ intent_url = intent.getStringExtra("url");
|
|
|
+ }
|
|
|
+ if (intent_url != null && !intent_url.isEmpty()) {
|
|
|
+ mLoadUrl = intent_url;
|
|
|
+ }
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ String intent_params = intent.getStringExtra("params");
|
|
|
+ if (intent_params != null && !intent_params.isEmpty()) {
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ jsonObject = new JSONObject(intent_params);
|
|
|
+ Iterator it = jsonObject.keys();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ String key = it.next().toString();
|
|
|
+ buffer.append("&" + key + "=" + jsonObject.getString(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mLoadUrl = mLoadUrl + model.getLoadParams(getView().getActivity()) + buffer.toString();
|
|
|
+ Logger.e("mLoadUrl:" + mLoadUrl);
|
|
|
+ getView().getWebView().loadUrl(mLoadUrl);
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- mLoadUrl = mLoadUrl + model.getLoadParams(getView().getActivity());
|
|
|
- Logger.e("mLoadUrl:" + mLoadUrl);
|
|
|
- getView().getWebView().loadUrl(mLoadUrl);
|
|
|
}
|
|
|
|
|
|
|