Jelajahi Sumber

1.修改代码为android代码
2.增加loading
3.增加网络监听

FailedToRead 4 tahun lalu
induk
melakukan
d3fc4588a8
30 mengubah file dengan 1088 tambahan dan 40 penghapusan
  1. 1 0
      .idea/codeStyles/Project.xml
  2. 1 0
      .idea/gradle.xml
  3. 1 1
      app/build.gradle
  4. 51 7
      app/src/main/AndroidManifest.xml
  5. 118 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/activity/MainActivity.java
  6. 27 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/application/MyApplication.java
  7. 56 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/base/BaseActivity.java
  8. 12 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/base/BaseMVP.java
  9. 44 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/base/BasePresenter.java
  10. 4 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IModel.java
  11. 14 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IPresenter.java
  12. 14 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IView.java
  13. 64 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/model/MainModel.java
  14. 162 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/presenter/MainPersenter.java
  15. 15 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/view/MainView.java
  16. 96 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/receiver/NetworkChangeReceiver.java
  17. 35 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/util/ContextUtil.java
  18. 171 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/util/DeviceUtil.java
  19. 54 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/util/DeviceUuidFactory.java
  20. 17 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/util/Logger.java
  21. 106 0
      app/src/main/java/com/edufound/ott/zijie/yuwen/util/SharedPerfenceUtil.java
  22. TEMPAT SAMPAH
      app/src/main/res/drawable-hdpi/loading.png
  23. TEMPAT SAMPAH
      app/src/main/res/drawable-ldpi/loading.png
  24. TEMPAT SAMPAH
      app/src/main/res/drawable-mdpi/loading.png
  25. 0 30
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  26. TEMPAT SAMPAH
      app/src/main/res/drawable/efunbox_window_bg.jpg
  27. 15 0
      app/src/main/res/layout/activity_main.xml
  28. 1 1
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  29. 1 1
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  30. 8 0
      app/src/main/res/values/styles.xml

+ 1 - 0
.idea/codeStyles/Project.xml

@@ -1,5 +1,6 @@
 <component name="ProjectCodeStyleConfiguration">
   <code_scheme name="Project" version="173">
+    <option name="RIGHT_MARGIN" value="150" />
     <JetCodeStyleSettings>
       <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
     </JetCodeStyleSettings>

+ 1 - 0
.idea/gradle.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>

+ 1 - 1
app/build.gradle

@@ -8,7 +8,7 @@ android {
 
     defaultConfig {
         applicationId "com.edufound.ott.zijie.yuwen"
-        minSdkVersion 24
+        minSdkVersion 23
         targetSdkVersion 30
         versionCode 1
         versionName "1.0"

+ 51 - 7
app/src/main/AndroidManifest.xml

@@ -1,12 +1,56 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.edufound.ott.zijie.yuwen">
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.edufound.ott.zijie.yuwen">
+
+    <uses-permission
+        android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
+        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
+    <uses-permission android:name="com.xiaomi.permission.AUTH_THIRDPAY" />
+    <uses-permission android:name="com.xiaomi.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="com.xiaomi.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="com.xiaomi.permission.WRITE_SETTINGS" />
 
     <application
-            android:allowBackup="true"
-            android:icon="@mipmap/ic_launcher"
-            android:label="@string/app_name"
-            android:roundIcon="@mipmap/ic_launcher_round"
-            android:supportsRtl="true"
-            android:theme="@style/AppTheme" />
+        android:name=".application.MyApplication"
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:roundIcon="@mipmap/ic_launcher_round"
+        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+        android:usesCleartextTraffic="true">
+
+        <activity
+            android:name=".activity.MainActivity"
+            android:screenOrientation="landscape"
+            android:theme="@style/AppStartTheme">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+
+                <data
+                    android:host="com.edufound.ott.zijie.yuwen"
+                    android:path="/main"
+                    android:scheme="efunbox" />
+            </intent-filter>
+
+        </activity>
+    </application>
+
 
 </manifest>

+ 118 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/activity/MainActivity.java

@@ -0,0 +1,118 @@
+package com.edufound.ott.zijie.yuwen.activity;
+
+import android.animation.ObjectAnimator;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
+import android.webkit.WebView;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+
+import androidx.annotation.Nullable;
+
+import com.edufound.ott.zijie.yuwen.R;
+import com.edufound.ott.zijie.yuwen.base.BaseActivity;
+import com.edufound.ott.zijie.yuwen.mvp.model.MainModel;
+import com.edufound.ott.zijie.yuwen.mvp.presenter.MainPersenter;
+import com.edufound.ott.zijie.yuwen.mvp.view.MainView;
+import com.edufound.ott.zijie.yuwen.util.ContextUtil;
+
+public class MainActivity extends BaseActivity<MainModel, MainView, MainPersenter> implements MainView {
+
+    FrameLayout mMainFrame;
+    Activity mActivity;
+    WebView mWebView;
+    ImageView mLoading;
+    ObjectAnimator mLoadingAnim;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        mActivity = this;
+        init();
+    }
+
+
+    void init() {
+        mMainFrame = findViewById(R.id.MainFrame);
+        mLoading = findViewById(R.id.MainLoading);
+        mWebView = new WebView(ContextUtil.getmApplicationContext());
+        mMainFrame.setBackgroundColor(Color.parseColor("#5CC9FF"));
+        mWebView.setBackgroundColor(Color.parseColor("#5CC9FF"));
+        mLoadingAnim = ObjectAnimator.ofFloat(mLoading, "rotation", 0.0F, 359.0F);//设置Y轴的立体旋转动画
+        mLoadingAnim.setRepeatCount(-1);
+        mLoadingAnim.setDuration(1000);
+        LinearInterpolator interpolator = new LinearInterpolator();
+        mLoadingAnim.setInterpolator(interpolator); //设置匀速旋转,不卡顿 icon_anim.start();
+        //設置webview
+        mPresenter.initWeb();
+        mPresenter.openWeb(getIntent());
+        mMainFrame.addView(getWebView());
+    }
+
+
+    @Override
+    public MainView createView() {
+        return this;
+    }
+
+    @Override
+    public MainModel createModel() {
+        return new MainModel();
+    }
+
+    @Override
+    public MainPersenter createPresenter() {
+        return new MainPersenter();
+    }
+
+
+    @Override
+    public Activity getActivity() {
+        return mActivity;
+    }
+
+    @Override
+    public void showProgressDialog() {
+        mLoading.setVisibility(View.VISIBLE);
+        mLoading.bringToFront();
+        mLoadingAnim.start();
+    }
+
+    @Override
+    public void dismissProgressDialog() {
+        mLoading.setVisibility(View.INVISIBLE);
+        mLoadingAnim.pause();
+    }
+
+    @Override
+    public void loadJsMehtod(String method) {
+        mWebView.loadUrl("javascript:" + method + "");
+    }
+
+    @Override
+    public void loadJsMethodPost(final String method) {
+        mWebView.post(new Runnable() {
+            @Override
+            public void run() {
+                mWebView.loadUrl("javascript:" + method + "");
+            }
+        });
+    }
+
+    @Override
+    public void loadUrl(String url) {
+        mWebView.loadUrl(url);
+    }
+
+    @Override
+    public WebView getWebView() {
+        return mWebView;
+    }
+}

+ 27 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/application/MyApplication.java

@@ -0,0 +1,27 @@
+package com.edufound.ott.zijie.yuwen.application;
+
+import android.app.Application;
+import android.content.IntentFilter;
+
+import com.edufound.ott.zijie.yuwen.receiver.NetworkChangeReceiver;
+import com.edufound.ott.zijie.yuwen.util.ContextUtil;
+
+public class MyApplication extends Application {
+    //网络异常监听
+    NetworkChangeReceiver mNetworkReceiver;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        ContextUtil.setAppStartTime(System.currentTimeMillis());
+        ContextUtil.setmApplicationContext(this);
+        initBoardCastReceiver();
+    }
+
+    void initBoardCastReceiver() {
+        mNetworkReceiver = new NetworkChangeReceiver();
+        IntentFilter netFilter = new IntentFilter();
+        netFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
+        registerReceiver(mNetworkReceiver, netFilter);
+    }
+}

+ 56 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/base/BaseActivity.java

@@ -0,0 +1,56 @@
+package com.edufound.ott.zijie.yuwen.base;
+
+import android.app.Activity;
+import android.content.IntentFilter;
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+
+import com.edufound.ott.zijie.yuwen.mvp.IModel;
+import com.edufound.ott.zijie.yuwen.mvp.IView;
+import com.edufound.ott.zijie.yuwen.receiver.NetworkChangeReceiver;
+
+public class BaseActivity<M extends IModel, V extends IView, P extends BasePresenter> extends Activity implements BaseMVP<M, V, P> {
+
+
+    protected P mPresenter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        //创建Presenter
+        mPresenter = createPresenter();
+        if (mPresenter != null) {
+            //将Model层注册到Presenter中
+            mPresenter.registerModel(createModel());
+            //将View层注册到Presenter中
+            mPresenter.registerView(createView());
+        }
+    }
+
+
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        if (mPresenter != null) {
+            //Activity销毁时的调用,让具体实现BasePresenter中onViewDestroy()方法做出决定
+            mPresenter.destroy();
+        }
+    }
+
+    @Override
+    public M createModel() {
+        return null;
+    }
+
+    @Override
+    public V createView() {
+        return null;
+    }
+
+    @Override
+    public P createPresenter() {
+        return null;
+    }
+}

+ 12 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/base/BaseMVP.java

@@ -0,0 +1,12 @@
+package com.edufound.ott.zijie.yuwen.base;
+
+import com.edufound.ott.zijie.yuwen.mvp.IModel;
+import com.edufound.ott.zijie.yuwen.mvp.IView;
+
+public interface BaseMVP<M extends IModel, V extends IView, P extends BasePresenter> {
+    M createModel();
+
+    V createView();
+
+    P createPresenter();
+}

+ 44 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/base/BasePresenter.java

@@ -0,0 +1,44 @@
+package com.edufound.ott.zijie.yuwen.base;
+
+import com.edufound.ott.zijie.yuwen.mvp.IModel;
+import com.edufound.ott.zijie.yuwen.mvp.IPresenter;
+import com.edufound.ott.zijie.yuwen.mvp.IView;
+
+import java.lang.ref.WeakReference;
+
+public abstract class BasePresenter<M extends IModel, V extends IView> implements IPresenter<M, V> {
+    /**
+     * 使用弱引用来防止内存泄漏
+     */
+    private WeakReference<V> wrf;
+    protected M model;
+
+    @Override
+    public void registerModel(M model) {
+        this.model = model;
+    }
+
+    @Override
+    public void registerView(V view) {
+        wrf = new WeakReference<V>(view);
+    }
+
+    @Override
+    public V getView() {
+        return wrf == null ? null : wrf.get();
+    }
+
+    /**
+     * 在Activity或Fragment卸载时调用View结束的方法
+     */
+    @Override
+    public void destroy() {
+        if (wrf != null) {
+            wrf.clear();
+            wrf = null;
+        }
+        onViewDestroy();
+    }
+
+    protected abstract void onViewDestroy();
+}

+ 4 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IModel.java

@@ -0,0 +1,4 @@
+package com.edufound.ott.zijie.yuwen.mvp;
+
+public interface IModel {
+}

+ 14 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IPresenter.java

@@ -0,0 +1,14 @@
+package com.edufound.ott.zijie.yuwen.mvp;
+
+import java.lang.ref.SoftReference;
+
+public interface IPresenter<M extends IModel, V extends IView> {
+    void registerModel(M model);
+
+    void registerView(V view);
+
+    V getView();
+
+    void destroy();
+}
+

+ 14 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/IView.java

@@ -0,0 +1,14 @@
+package com.edufound.ott.zijie.yuwen.mvp;
+
+import android.app.Activity;
+
+public interface IView {
+
+    Activity getActivity();
+
+    void showProgressDialog();
+
+    void dismissProgressDialog();
+
+    
+}

+ 64 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/model/MainModel.java

@@ -0,0 +1,64 @@
+package com.edufound.ott.zijie.yuwen.mvp.model;
+
+import android.app.Activity;
+import android.os.Process;
+import android.webkit.JavascriptInterface;
+
+import com.edufound.ott.zijie.yuwen.mvp.IModel;
+import com.edufound.ott.zijie.yuwen.util.ContextUtil;
+import com.edufound.ott.zijie.yuwen.util.DeviceUtil;
+import com.edufound.ott.zijie.yuwen.util.DeviceUuidFactory;
+import com.edufound.ott.zijie.yuwen.util.SharedPerfenceUtil;
+
+public class MainModel implements MainModelInter {
+    private String LOAD_URL = "https://www.baidu.com/";
+    private DeviceUtil deviceUtil;
+
+    public MainModel() {
+        deviceUtil = new DeviceUtil();
+    }
+
+    @Override
+    public String getDefaultWebUrl() {
+        return LOAD_URL + "?";
+    }
+
+    @Override
+    public String getLoadParams(Activity activity) {
+        String preuuid = SharedPerfenceUtil.getPrefString(ContextUtil.getmApplicationContext(), "", "").toString();
+        if (preuuid == "") {
+            preuuid = new DeviceUuidFactory(ContextUtil.getmApplicationContext()).getUuid().toString();
+        }
+        ContextUtil.setUuid(preuuid);
+        StringBuffer params = new StringBuffer();
+        params.append("&uuid=" + preuuid.toString());
+        params.append("&width=" + deviceUtil.getWidth(activity));
+        params.append("&height=" + deviceUtil.getHeight(activity));
+        params.append("&model=" + deviceUtil.getSystemModel());
+        params.append("&versionCode=" + deviceUtil.getVersionCode(activity));
+        params.append("&versionName=" + deviceUtil.getVersionName(activity));
+        return params.toString();
+    }
+
+    @Override
+    public void setWebBackGroundColor(int color) {
+
+    }
+
+    @JavascriptInterface
+    @Override
+    public void closeApp() {
+        android.os.Process.killProcess(Process.myPid());
+    }
+}
+
+
+interface MainModelInter extends IModel {
+    String getDefaultWebUrl();
+
+    String getLoadParams(Activity activity);
+
+    void setWebBackGroundColor(int color);
+
+    void closeApp();
+}

+ 162 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/presenter/MainPersenter.java

@@ -0,0 +1,162 @@
+package com.edufound.ott.zijie.yuwen.mvp.presenter;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.os.Build;
+import android.view.View;
+import android.webkit.JavascriptInterface;
+import android.webkit.JsResult;
+import android.webkit.WebChromeClient;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebResourceResponse;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import com.edufound.ott.zijie.yuwen.base.BasePresenter;
+import com.edufound.ott.zijie.yuwen.mvp.model.MainModel;
+import com.edufound.ott.zijie.yuwen.mvp.view.MainView;
+import com.edufound.ott.zijie.yuwen.util.Logger;
+
+public class MainPersenter extends BasePresenter<MainModel, MainView> {
+
+    private String mLoadUrl;
+
+    @SuppressLint("JavascriptInterface")
+    public void initWeb() {
+        if (Build.VERSION.SDK_INT >= 19) {
+            getView().getWebView().getSettings().setLoadsImagesAutomatically(true);
+        } else {
+            getView().getWebView().getSettings().setLoadsImagesAutomatically(false);
+        }
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            getView().getWebView().getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
+        }
+        getView().getWebView().requestFocus(View.FOCUS_DOWN);
+        getView().getWebView().getSettings().setJavaScriptEnabled(true);
+        getView().getWebView().getSettings().setJavaScriptCanOpenWindowsAutomatically(true);//允许js弹出窗口
+        getView().getWebView().getSettings().setDomStorageEnabled(true);
+//        webview.getSettings().setMediaPlaybackRequiresUserGesture(false);
+        getView().getWebView().getSettings().setBlockNetworkImage(false);
+        // webview.getSettings().set
+        getView().getWebView().setBackgroundColor(Color.TRANSPARENT);
+//       webview.setBackgroundResource();
+        getView().getWebView().getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
+        getView().getWebView().getSettings().setUseWideViewPort(true);
+        getView().getWebView().getSettings().setLoadWithOverviewMode(true);
+        getView().getWebView().getSettings().setTextZoom(100);
+//        mVideoBitmap = BitmapFactory.decodeResource(mView.getActivity().getResources(),
+//                R.drawable.videoposterblack);
+        getView().getWebView().setWebChromeClient(new WebChromeClient() {
+
+            @Override
+            public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
+
+                return super.onJsAlert(view, url, message, result);
+            }
+
+            @Override
+            public void onShowCustomView(View view, CustomViewCallback callback) {
+
+                super.onShowCustomView(view, callback);
+            }
+
+            @Override
+            public void onProgressChanged(WebView view, int newProgress) {
+
+                if (newProgress >= 100) {
+                }
+                super.onProgressChanged(view, newProgress);
+            }
+
+            @Override
+            public Bitmap getDefaultVideoPoster() {
+//                return mVideoBitmap;
+                return null;
+            }
+        });
+
+        getView().getWebView().setWebViewClient(new WebViewClient() {
+
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, String url) {
+//                webview.removeAllViews();
+                view.loadUrl(url);
+                return true;
+            }
+
+            @Override
+            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
+                super.onReceivedError(view, errorCode, description, failingUrl);
+                view.loadUrl("");
+//                showDisConnNeWorkWindow();
+            }
+
+            @Override
+            public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
+                super.onReceivedHttpError(view, request, errorResponse);
+//                int statusCode = 0;
+//                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+//                    statusCode = errorResponse.getStatusCode();
+//                }
+//                System.out.println("onReceivedHttpError code = " + statusCode);
+//                if (404 == statusCode) {
+//                    view.loadUrl("about:blank");// 避免出现默认的错误界面
+//                    showDisConnNeWorkWindow();
+//                }
+
+            }
+
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                super.onPageStarted(view, url, favicon);
+                getView().showProgressDialog();
+            }
+
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                if (!view.getSettings().getLoadsImagesAutomatically()) {
+                    view.getSettings().setLoadsImagesAutomatically(true);
+                }
+                getView().dismissProgressDialog();
+                super.onPageFinished(view, url);
+            }
+
+        });
+        getView().getWebView().addJavascriptInterface(this, "efunboxJS");
+    }
+
+
+    public void openWeb(Intent intent) {
+        getView().getWebView().loadUrl("");
+        mLoadUrl = model.getDefaultWebUrl();
+        String intent_url = intent.getStringExtra("url");
+        Logger.e("-----------------------------");
+        Logger.e("intent_url:" + intent_url);
+        Logger.e("-----------------------------");
+        if (intent_url != null && !intent_url.isEmpty()) {
+            mLoadUrl = intent_url;
+        }
+        mLoadUrl = mLoadUrl + model.getLoadParams(getView().getActivity());
+        getView().getWebView().loadUrl(mLoadUrl);
+    }
+
+
+    @Override
+    protected void onViewDestroy() {
+
+    }
+
+
+    @SuppressLint("JavascriptInterface")
+    @JavascriptInterface
+    public void closeApp() {
+        model.closeApp();
+    }
+
+}
+
+

+ 15 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/mvp/view/MainView.java

@@ -0,0 +1,15 @@
+package com.edufound.ott.zijie.yuwen.mvp.view;
+
+import android.webkit.WebView;
+
+import com.edufound.ott.zijie.yuwen.mvp.IView;
+
+public interface MainView extends IView {
+    void loadJsMehtod(String method);
+
+    void loadJsMethodPost(String method);
+
+    void loadUrl(String url);
+
+    WebView getWebView();
+}

+ 96 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/receiver/NetworkChangeReceiver.java

@@ -0,0 +1,96 @@
+package com.edufound.ott.zijie.yuwen.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.os.Message;
+import android.telephony.TelephonyManager;
+
+import com.edufound.ott.zijie.yuwen.util.Logger;
+
+
+/**
+ * Created by Candy on 2018/4/8.
+ */
+
+public class NetworkChangeReceiver extends BroadcastReceiver {
+    final int DISCONNECT = 0x21;
+    final int CONNECT = 0x22;
+    String strNetworkType;
+
+    public NetworkChangeReceiver() {
+
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        GetNetworkType(context);
+
+    }
+
+    public void GetNetworkType(Context context) {
+        ConnectivityManager connectMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        NetworkInfo networkInfo = connectMgr.getActiveNetworkInfo();
+        if (networkInfo != null && networkInfo.isConnected()) {
+            handler.sendEmptyMessage(CONNECT);
+            if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+                strNetworkType = "WIFI";
+            } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+                String _strSubTypeName = networkInfo.getSubtypeName();
+                Logger.e("Network getSubtypeName : " + _strSubTypeName);
+                int networkType = networkInfo.getSubtype();
+                switch (networkType) {
+                    case TelephonyManager.NETWORK_TYPE_GPRS:
+                    case TelephonyManager.NETWORK_TYPE_EDGE:
+                    case TelephonyManager.NETWORK_TYPE_CDMA:
+                    case TelephonyManager.NETWORK_TYPE_1xRTT:
+                    case TelephonyManager.NETWORK_TYPE_IDEN: //api<8 : replace by 11
+                        strNetworkType = "2G";
+                        break;
+                    case TelephonyManager.NETWORK_TYPE_UMTS:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
+                    case TelephonyManager.NETWORK_TYPE_HSDPA:
+                    case TelephonyManager.NETWORK_TYPE_HSUPA:
+                    case TelephonyManager.NETWORK_TYPE_HSPA:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_B: //api<9 : replace by 14
+                    case TelephonyManager.NETWORK_TYPE_EHRPD:  //api<11 : replace by 12
+                    case TelephonyManager.NETWORK_TYPE_HSPAP:  //api<13 : replace by 15
+                        strNetworkType = "3G";
+                        break;
+                    case TelephonyManager.NETWORK_TYPE_LTE:    //api<11 : replace by 13
+                        strNetworkType = "4G";
+                        break;
+
+                }
+                Logger.e("Network getSubtype : " + Integer.valueOf(networkType).toString());
+//                ToastUtil.showToast("当前网络环境:" + strNetworkType);
+            }
+        } else {
+            strNetworkType = "-1";
+            handler.sendEmptyMessageDelayed(DISCONNECT, 2000);
+
+        }
+        Logger.e("Network Type : " + strNetworkType);
+    }
+
+
+    Handler handler = new Handler(new Handler.Callback() {
+        @Override
+        public boolean handleMessage(Message msg) {
+            switch (msg.what) {
+                case DISCONNECT:
+//                    mView.DisconnNetWork();
+                    break;
+                case CONNECT:
+                    handler.removeMessages(DISCONNECT);
+//                    mView.ConnNeWork();
+                    break;
+            }
+            return false;
+        }
+    });
+}

+ 35 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/util/ContextUtil.java

@@ -0,0 +1,35 @@
+package com.edufound.ott.zijie.yuwen.util;
+
+import android.content.Context;
+
+public class ContextUtil {
+    private static Long APP_START_TIME;
+    private static Context mApplicationContext;
+    private static String Uuid;
+
+    public static Long getAppStartTime() {
+        return APP_START_TIME;
+    }
+
+    public static void setAppStartTime(Long appStartTime) {
+        APP_START_TIME = appStartTime;
+    }
+
+    public static Context getmApplicationContext() {
+        return mApplicationContext;
+    }
+
+    public static void setmApplicationContext(Context mApplicationContext) {
+        ContextUtil.mApplicationContext = mApplicationContext;
+    }
+
+    public static String getUuid() {
+        return Uuid;
+    }
+
+    public static void setUuid(String uuid) {
+        Uuid = uuid;
+    }
+
+
+}

+ 171 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/util/DeviceUtil.java

@@ -0,0 +1,171 @@
+package com.edufound.ott.zijie.yuwen.util;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.util.Locale;
+
+public class DeviceUtil {
+
+    DisplayMetrics metric = new DisplayMetrics();
+
+    /**
+     * @return 序列号 SerialNumber
+     * @author zhangmengjie
+     */
+    public String SerialNumber() {
+
+        return android.os.Build.SERIAL;
+    }
+
+
+    public int getWidth(Activity context) {
+        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
+        return metric.widthPixels; // 屏幕宽度(像素)
+    }
+
+    public int getHeight(Activity context) {
+        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
+        return metric.heightPixels; // 屏幕高度(像素)
+    }
+
+    public float getDensity(Activity context) {
+        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
+        return metric.density; // 屏幕密度(0.75 / 1.0 / 1.5)
+    }
+
+    public int getDensityDpi(Activity context) {
+        context.getWindowManager().getDefaultDisplay().getMetrics(metric);
+        return metric.densityDpi; // // 屏幕密度DPI(120 / 160 / 240)
+    }
+
+    // md5加密
+    public String md5Encode(String inStr) {
+        MessageDigest md5 = null;
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+        } catch (Exception e) {
+            System.out.println(e.toString());
+            e.printStackTrace();
+            return "";
+        }
+
+        byte[] byteArray = null;
+        try {
+            byteArray = inStr.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        byte[] md5Bytes = md5.digest(byteArray);
+        StringBuffer hexValue = new StringBuffer();
+        for (int i = 0; i < md5Bytes.length; i++) {
+            int val = ((int) md5Bytes[i]) & 0xff;
+            if (val < 16) {
+                hexValue.append("0");
+            }
+            hexValue.append(Integer.toHexString(val));
+        }
+        return hexValue.toString();
+    }
+
+    /**
+     * @return VersionCode
+     * @author zhangmengjie
+     */
+    public String getVersionCode(Context context) {
+        PackageManager packageManager = context.getPackageManager();
+        PackageInfo packageInfo;
+        String versionCode = "";
+        try {
+            packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
+            versionCode = packageInfo.versionCode + "";
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        return versionCode;
+    }
+
+    /**
+     * @return VersionName
+     * @author zhangmengjie
+     */
+    public String getVersionName(Context context) {
+        PackageManager packageManager = context.getPackageManager();
+        PackageInfo packageInfo;
+        String versionName = "";
+        try {
+            packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
+            versionName = packageInfo.versionName;
+        } catch (PackageManager.NameNotFoundException e) {
+            e.printStackTrace();
+        }
+        return versionName;
+    }
+
+    /**
+     * 获取当前手机系统语言。
+     *
+     * @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
+     */
+    public String getSystemLanguage() {
+        return Locale.getDefault().getLanguage();
+    }
+
+    /**
+     * 获取当前系统上的语言列表(Locale列表)
+     *
+     * @return 语言列表
+     */
+    public Locale[] getSystemLanguageList() {
+        return Locale.getAvailableLocales();
+    }
+
+    /**
+     * 获取当前手机系统版本号
+     *
+     * @return 系统版本号
+     */
+    public String getSystemVersion() {
+        return android.os.Build.VERSION.RELEASE;
+    }
+
+    /**
+     * 获取手机型号
+     *
+     * @return 手机型号
+     */
+    public String getSystemModel() {
+        return android.os.Build.MODEL;
+    }
+
+    /**
+     * 获取手机厂商
+     *
+     * @return 手机厂商
+     */
+    public String getDeviceBrand() {
+        return android.os.Build.BRAND;
+    }
+
+    /**
+     * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)
+     *
+     * @return 手机IMEI
+     */
+    public String getIMEI(Context ctx) {
+        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
+        if (tm != null) {
+            return tm.getDeviceId();
+        }
+        return null;
+    }
+
+}

+ 54 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/util/DeviceUuidFactory.java

@@ -0,0 +1,54 @@
+package com.edufound.ott.zijie.yuwen.util;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+
+import java.io.UnsupportedEncodingException;
+import java.util.UUID;
+
+public class DeviceUuidFactory {
+    public static final String UUID_SPKEY = "uuid";
+    protected static UUID uuid;
+
+    public DeviceUuidFactory(Context context) {
+        if (uuid == null) {
+            synchronized (DeviceUuidFactory.class) {
+                if (uuid == null) {
+                    try {
+                        final String androidId = Settings.Secure.getString(
+                                context.getContentResolver(), Settings.Secure.ANDROID_ID);
+                        if (!"9774d56d682e549c".equals(androidId)) {
+                            uuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8"));
+                        } else {
+                            @SuppressLint("MissingPermission") final String deviceId = ((TelephonyManager) context
+                                    .getSystemService(Context.TELEPHONY_SERVICE))
+                                    .getDeviceId();
+                            uuid = deviceId != null ? UUID.nameUUIDFromBytes(deviceId
+                                    .getBytes("utf8")) : UUID.randomUUID();
+                            try {
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    } catch (UnsupportedEncodingException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+                SharedPerfenceUtil.setPrefString(context, UUID_SPKEY, uuid.toString());
+            }
+        }
+    }
+
+
+    /**
+     * @return UUID
+     */
+    public static UUID getUuid() {
+        if (uuid == null || uuid.equals("") || uuid.equals("null")) {
+            return null;
+        }
+        return uuid;
+    }
+}

+ 17 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/util/Logger.java

@@ -0,0 +1,17 @@
+package com.edufound.ott.zijie.yuwen.util;
+
+import android.util.Log;
+
+public class Logger {
+
+    static String TAG = "com.edufound.ott.zijie.yuwen";
+
+    public static void e(String message) {
+        Log.e(TAG, message);
+    }
+
+    public static void DebugE(String message) {
+        Log.e(TAG, message);
+    }
+
+}

+ 106 - 0
app/src/main/java/com/edufound/ott/zijie/yuwen/util/SharedPerfenceUtil.java

@@ -0,0 +1,106 @@
+package com.edufound.ott.zijie.yuwen.util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import java.util.List;
+
+public class SharedPerfenceUtil {
+
+    private static final String spName = "efunbox";
+    private static int model = Context.MODE_PRIVATE;
+
+    public static String getPrefString(Context context, String key, final String defaultValue) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.getString(key, defaultValue);
+    }
+
+    public static void setPrefString(Context context, final String key, final String value) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        sp.edit().putString(key, value).commit();
+    }
+
+    public static boolean getPrefBoolean(Context context, final String key, final boolean defaultValue) {
+
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.getBoolean(key, defaultValue);
+    }
+
+    public static boolean hasKey(Context context, final String key) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.contains(key);
+    }
+
+    public static void setPrefBoolean(Context context, final String key, final boolean value) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        sp.edit().putBoolean(key, value).commit();
+    }
+
+    public static void setPrefInt(Context context, final String key, final int value) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        sp.edit().putInt(key, value).commit();
+    }
+
+    public static int getPrefInt(Context context, final String key, final int defaultValue) {
+
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.getInt(key, defaultValue);
+    }
+
+    public static void setPrefFloat(Context context, final String key, final float value) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        sp.edit().putFloat(key, value).commit();
+    }
+
+    public static float getPrefFloat(Context context, final String key, final float defaultValue) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.getFloat(key, defaultValue);
+    }
+
+    public static void setPrefLong(Context context, final String key, final long value) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        sp.edit().putLong(key, value).commit();
+    }
+
+    public static long getPrefLong(Context context, final String key, final long defaultValue) {
+        SharedPreferences sp = context.getSharedPreferences(spName, model);
+        return sp.getLong(key, defaultValue);
+    }
+
+    public static void loadRecourdsArray(Context mContext, List<String> recourds, String name) {
+        SharedPreferences sp = mContext.getSharedPreferences(name, model);
+        recourds.clear();
+        int size = sp.getInt("recourds_size", 0);
+
+        for (int i = 0; i < size; i++) {
+            recourds.add(sp.getString("recourds_" + i, null));
+        }
+    }
+
+    public static boolean saveRecourdsArray(Context context, List<String> recourds, String name) {
+        SharedPreferences sp = context.getSharedPreferences(name, model);
+        SharedPreferences.Editor mEdit1 = sp.edit();
+        mEdit1.putInt("recourds_size", recourds.size()); /* sKey is an array */
+
+        for (int i = 0; i < recourds.size(); i++) {
+            mEdit1.remove("recourds_" + i);
+            mEdit1.putString("recourds_" + i, recourds.get(i));
+        }
+
+        return mEdit1.commit();
+    }
+
+    public static void clearRecourds(Context context, String name) {
+        SharedPreferences sp = context.getSharedPreferences(name, model);
+        SharedPreferences.Editor mEdit1 = sp.edit();
+        mEdit1.clear();
+        mEdit1.commit();
+    }
+
+    public static void removeByKey(Context context, String name, String key) {
+        SharedPreferences sp = context.getSharedPreferences(name, model);
+        SharedPreferences.Editor mEdit1 = sp.edit();
+        mEdit1.remove(key);
+        mEdit1.commit();
+    }
+}

TEMPAT SAMPAH
app/src/main/res/drawable-hdpi/loading.png


TEMPAT SAMPAH
app/src/main/res/drawable-ldpi/loading.png


TEMPAT SAMPAH
app/src/main/res/drawable-mdpi/loading.png


File diff ditekan karena terlalu besar
+ 0 - 30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml


TEMPAT SAMPAH
app/src/main/res/drawable/efunbox_window_bg.jpg


+ 15 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/MainFrame"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+
+    <ImageView
+        android:id="@+id/MainLoading"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:adjustViewBounds="true"
+        android:src="@drawable/loading"></ImageView>
+</FrameLayout>

+ 1 - 1
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
     <background android:drawable="@drawable/ic_launcher_background" />
-    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+    <foreground android:drawable="@drawable/ic_launcher_background" />
 </adaptive-icon>

+ 1 - 1
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
     <background android:drawable="@drawable/ic_launcher_background" />
-    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+    <foreground android:drawable="@drawable/ic_launcher_background" />
 </adaptive-icon>

+ 8 - 0
app/src/main/res/values/styles.xml

@@ -7,4 +7,12 @@
         <item name="colorAccent">@color/colorAccent</item>
     </style>
 
+    <style name="AppStartTheme" parent="Theme.AppCompat.Light.NoActionBar">
+        <!-- <item name="android:windowIsTranslucent">true</item>-->
+        <!-- 兼容API 7-->
+        <item name="android:windowActionBar">false</item>
+        <item name="android:windowBackground">@drawable/efunbox_window_bg</item>
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowFullscreen">true</item>
+    </style>
 </resources>