Ver Fonte

补充webview js回调

Ryan8057 há 2 anos atrás
pai
commit
67190f8f87
46 ficheiros alterados com 8032 adições e 403 exclusões
  1. 1 0
      BaseLibrary/build.gradle
  2. 1 0
      BaseLibrary/src/main/java/com/cooleshow/base/router/RouterPath.kt
  3. 17 4
      student/src/main/AndroidManifest.xml
  4. 1 0
      student/src/main/java/com/cooleshow/student/App.java
  5. 17 0
      student/src/main/java/com/cooleshow/student/contract/AccompanyContract.java
  6. 14 0
      student/src/main/java/com/cooleshow/student/presenter/web/AccompanyPresenter.java
  7. 15 2
      student/src/main/java/com/cooleshow/student/ui/main/MainActivity.java
  8. 317 0
      student/src/main/java/com/cooleshow/student/ui/main/MallFragment.java
  9. 107 0
      student/src/main/java/com/cooleshow/student/ui/mine/SelectAddressListActivity.java
  10. 377 0
      student/src/main/java/com/cooleshow/student/ui/web/AccompanyActivity.java
  11. 2131 0
      student/src/main/java/com/cooleshow/student/ui/web/AccompanyFragment.java
  12. 334 119
      student/src/main/java/com/cooleshow/student/ui/web/HtmlActivity.java
  13. 351 0
      student/src/main/java/com/cooleshow/student/ui/web/HtmlHorizontalScreenActivity.java
  14. 1 1
      student/src/main/java/com/cooleshow/student/ui/web/WebActivity.java
  15. 1626 0
      student/src/main/java/com/cooleshow/student/widgets/FileUtils.java
  16. 33 0
      student/src/main/java/com/cooleshow/student/widgets/LollipopFixedWebView.java
  17. 574 0
      student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceAccomPanyUtils.java
  18. 78 63
      student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceUtils.java
  19. 4 0
      student/src/main/java/com/cooleshow/student/wxapi/WXPayEntryActivity.java
  20. BIN
      student/src/main/res/drawable-xhdpi/flash_off.png
  21. BIN
      student/src/main/res/drawable-xhdpi/ic_accompany_record.png
  22. BIN
      student/src/main/res/drawable-xhdpi/ic_video_record_play.png
  23. BIN
      student/src/main/res/drawable-xhdpi/switch_camera.png
  24. BIN
      student/src/main/res/drawable-xxhdpi/ic_accompany_back.png
  25. BIN
      student/src/main/res/drawable-xxhdpi/ic_accompany_record.png
  26. BIN
      student/src/main/res/drawable-xxhdpi/ic_accompany_video_record_save.png
  27. 20 0
      student/src/main/res/layout/activity_accompany.xml
  28. 126 0
      student/src/main/res/layout/activity_html1.xml
  29. 35 0
      student/src/main/res/layout/activity_select_address_list.xml
  30. 14 0
      student/src/main/res/layout/fragment_accompany.xml
  31. 126 0
      student/src/main/res/layout/fragment_mall.xml
  32. 140 0
      student/src/main/res/layout/record_video_layout.xml
  33. 8 1
      teacher/src/main/AndroidManifest.xml
  34. 2 2
      teacher/src/main/java/com/cooleshow/teacher/ui/main/MainActivity.java
  35. 310 0
      teacher/src/main/java/com/cooleshow/teacher/ui/main/MallFragment.java
  36. 106 0
      teacher/src/main/java/com/cooleshow/teacher/ui/mine/SelectAddressListActivity.java
  37. 32 5
      teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyActivity.java
  38. 150 0
      teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyFragment.java
  39. 0 10
      teacher/src/main/java/com/cooleshow/teacher/ui/web/AddAccompanimentActivity.java
  40. 212 47
      teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlActivity.java
  41. 351 0
      teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlHorizontalScreenActivity.java
  42. 164 147
      teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceAccomPanyUtils.java
  43. 55 2
      teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceUtils.java
  44. 19 0
      teacher/src/main/res/layout/activity_add_accompaniment.xml
  45. 35 0
      teacher/src/main/res/layout/activity_select_address_list.xml
  46. 128 0
      teacher/src/main/res/layout/fragment_mall.xml

+ 1 - 0
BaseLibrary/build.gradle

@@ -180,4 +180,5 @@ dependencies {
     api project(path: ':camerakit')
     api 'org.java-websocket:Java-WebSocket:1.5.1'
     api project(path: ':midiplaylib')
+    api 'org.greenrobot:eventbus:3.1.1'
 }

+ 1 - 0
BaseLibrary/src/main/java/com/cooleshow/base/router/RouterPath.kt

@@ -118,6 +118,7 @@ object RouterPath {
             const val MINE_MODIFY_PASSWORD = "/teacher/ui/mine/ModifyPasswordActivity"
             const val MINE_PERSONAL_CERTIFICATION = "/teacher/ui/mine/PersonalCertificationActivity"
             const val MINE_ADDRESS_LIST = "/teacher/ui/mine/AddressListActivity"
+            const val MINE_SELECT_ADDRESS_LIST = "/teacher/ui/mine/SelectAddressListActivity"
             const val MINE_EDIT_ADDRESS = "/teacher/ui/mine/EditAddressActivity"
             const val MINE_ABOUT = "/teacher/ui/mine/AboutActivity"
             const val MINE_FEEDBACK = "/teacher/ui/mine/FeedBackActivity"

+ 17 - 4
student/src/main/AndroidManifest.xml

@@ -50,10 +50,6 @@
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:screenOrientation="portrait" />
         <activity
-            android:name=".ui.web.HtmlActivity"
-            android:configChanges="orientation|screenSize|keyboardHidden"
-            android:screenOrientation="portrait" />
-        <activity
             android:name=".ui.mine.SettingActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:screenOrientation="portrait" />
@@ -176,6 +172,23 @@
             android:configChanges="keyboardHidden|orientation|screenSize"
             android:exported="true"
             android:theme="@android:style/Theme.Translucent.NoTitleBar"/>-->
+
+        <activity
+            android:name=".ui.web.AccompanyActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".ui.web.HtmlActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".ui.web.HtmlHorizontalScreenActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="landscape" />
+        <activity
+            android:name=".ui.mine.SelectAddressListActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
     </application>
 
 </manifest>

+ 1 - 0
student/src/main/java/com/cooleshow/student/App.java

@@ -30,6 +30,7 @@ import io.rong.push.pushconfig.PushConfig;
  * 类说明:
  */
 public class App extends BaseApplication {
+    public static boolean isRefresh = false;
     @Override
     public void onCreate() {
         super.onCreate();

+ 17 - 0
student/src/main/java/com/cooleshow/student/contract/AccompanyContract.java

@@ -0,0 +1,17 @@
+package com.cooleshow.student.contract;
+
+import com.cooleshow.base.presenter.view.BaseView;
+
+/**
+ * 创建日期:2022/6/8 14:22
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public interface AccompanyContract {
+    interface AccompanyView extends BaseView {
+
+    }
+    interface Presenter {
+    }
+}

+ 14 - 0
student/src/main/java/com/cooleshow/student/presenter/web/AccompanyPresenter.java

@@ -0,0 +1,14 @@
+package com.cooleshow.student.presenter.web;
+
+import com.cooleshow.base.presenter.BasePresenter;
+import com.cooleshow.student.contract.AccompanyContract;
+
+/**
+ * 创建日期:2022/6/8 14:22
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class AccompanyPresenter extends BasePresenter<AccompanyContract.AccompanyView> implements AccompanyContract.Presenter {
+
+}

+ 15 - 2
student/src/main/java/com/cooleshow/student/ui/main/MainActivity.java

@@ -1,5 +1,6 @@
 package com.cooleshow.student.ui.main;
 
+import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.view.MenuItem;
@@ -40,7 +41,7 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
     private ArrayList<Fragment> mFragments = new ArrayList<>();
     private HomeFragment mHomeFragment;
     private MineFragment mMineFragment;
-    private ShopMallFragment shopMallFragment;
+    private MallFragment shopMallFragment;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -54,7 +55,7 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
         mHomeFragment = new HomeFragment();
         CourseTableFragment courseTableFragment = new CourseTableFragment();
         MessageFragment messageFragment = new MessageFragment();
-        shopMallFragment = new ShopMallFragment();
+        shopMallFragment = new MallFragment();
         mMineFragment = new MineFragment();
         mFragments.add(mHomeFragment);
         mFragments.add(courseTableFragment);
@@ -178,4 +179,16 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
         return new MainPresenter();
     }
 
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (resultCode==RESULT_OK){
+            if (requestCode==1011){
+                String selectAddress = data.getStringExtra("selectAddress");
+                if (null!=shopMallFragment){
+                    shopMallFragment.selectAddress(selectAddress);
+                }
+            }
+        }
+    }
 }

Diff do ficheiro suprimidas por serem muito extensas
+ 317 - 0
student/src/main/java/com/cooleshow/student/ui/main/MallFragment.java


+ 107 - 0
student/src/main/java/com/cooleshow/student/ui/mine/SelectAddressListActivity.java

@@ -0,0 +1,107 @@
+package com.cooleshow.student.ui.mine;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.listener.OnItemClickListener;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.student.R;
+import com.cooleshow.student.adapter.AddressListAdapter;
+import com.cooleshow.student.bean.AddressBean;
+import com.cooleshow.student.contract.AddressListContract;
+import com.cooleshow.student.databinding.ActivityAddressListBinding;
+import com.cooleshow.student.databinding.ActivitySelectAddressListBinding;
+import com.cooleshow.student.presenter.mine.AddressListPresenter;
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.rong.imkit.utils.StatusBarUtil;
+
+/**
+ * 创建日期:2022/6/9 10:39
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+public class SelectAddressListActivity extends BaseMVPActivity<ActivitySelectAddressListBinding, AddressListPresenter> implements AddressListContract.AddressListView, View.OnClickListener {
+
+    private AddressListAdapter addressListAdapter;
+
+    @Override
+    public void onClick(View view) {
+        switch (view.getId()) {
+            case R.id.tv_add:
+                ARouter.getInstance().build(RouterPath.MineCenter.MINE_EDIT_ADDRESS)
+                        .withBoolean("isAdd",true)
+                        .navigation();
+                break;
+        }
+    }
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        StatusBarUtil.setStatusBarDarkTheme(this, true);
+    }
+
+    private List<AddressBean> dataList = new ArrayList<>();
+
+    @Override
+    protected void initView() {
+        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "地址列表");
+        viewBinding.tvAdd.setOnClickListener(this);
+        RecyclerView rvAddress = viewBinding.rvAddress;
+        LinearLayoutManager manager = new LinearLayoutManager(this);
+        rvAddress.setLayoutManager(manager);
+        addressListAdapter = new AddressListAdapter(dataList);
+        rvAddress.setAdapter(addressListAdapter);
+        addressListAdapter.setOnItemClickListener(new OnItemClickListener() {
+            @Override
+            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
+                AddressBean item = (AddressBean) adapter.getItem(position);
+                Gson gson=new Gson();
+                String s = gson.toJson(item);
+                Intent intent=new Intent();
+                intent.putExtra("selectAddress",s);
+                setResult(RESULT_OK,intent);
+                finish();
+
+            }
+        });
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        presenter.companyAddressList();
+    }
+
+    @Override
+    protected ActivitySelectAddressListBinding getLayoutView() {
+        return ActivitySelectAddressListBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected AddressListPresenter createPresenter() {
+        return new AddressListPresenter();
+    }
+
+    @Override
+    public void companyAddressListSuccess(List<AddressBean> data) {
+        dataList.clear();
+        dataList.addAll(data);
+        addressListAdapter.notifyDataSetChanged();
+    }
+}

+ 377 - 0
student/src/main/java/com/cooleshow/student/ui/web/AccompanyActivity.java

@@ -0,0 +1,377 @@
+package com.cooleshow.student.ui.web;
+
+import static com.cooleshow.base.common.WebConstants.WEB_URL;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Handler;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.FrameLayout;
+
+import androidx.annotation.Nullable;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.service.PlayMusicService;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.ToastUtils;
+import com.cooleshow.base.utils.helper.upload.UploadHelper;
+import com.cooleshow.student.R;
+import com.cooleshow.student.databinding.ActivityAccompanyBinding;
+import com.cooleshow.student.presenter.web.AccompanyPresenter;
+import com.cooleshow.student.widgets.FileUtils;
+import com.cooleshow.usercenter.helper.UserHelper;
+import com.gyf.immersionbar.ImmersionBar;
+import com.wonderkiln.camerakit.CameraKit;
+import com.wonderkiln.camerakit.CameraView;
+import com.wonderkiln.camerakit.events.CameraKitError;
+import com.wonderkiln.camerakit.events.CameraKitEvent;
+import com.wonderkiln.camerakit.events.CameraKitEventListener;
+import com.wonderkiln.camerakit.events.CameraKitImage;
+import com.wonderkiln.camerakit.events.CameraKitVideo;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import io.rong.imkit.utils.StatusBarUtil;
+
+/**
+ * 创建日期:2022/6/8 14:19
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
+public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding, AccompanyPresenter> {
+    FrameLayout camera;
+    FrameLayout fl_webview;
+
+    private final int PORTRAIT_REQUEST_CODE = 1002;
+    private final int ADD_ACCOMPANIMENT_CODE = 1003;
+    private String authorization;
+    private String webViewUrl;
+
+    CameraView cameraView;
+    private String filePath;
+    private String videoDerectoryName = "/guanyuemiTaskVideo";
+    private View cameraGroupView;
+    private String recordVideFilePath; //评测视频
+    private AccompanyFragment accompanyFragment;
+    private JSONObject baseJsonObject;
+    private Intent intentOne;
+
+    @Override
+    protected void initView() {
+        camera = viewBinding.camera;
+        fl_webview = viewBinding.flWebview;
+        Intent intent = getIntent();
+        String url = intent.getStringExtra(WEB_URL);
+
+        int orientation = intent.getIntExtra("orientation", -1);
+        boolean isOpenLight = intent.getBooleanExtra("isOpenLight", false);
+
+        if (isOpenLight) {
+            getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+        }
+        if (orientation >= 0) {
+            setRequestedOrientation(orientation);
+        }
+
+        setStatusBarTextColor(intent.getBooleanExtra("statusBarTextColor", true));
+        String userToken = UserHelper.getUserToken();
+        String Authorization = TextUtils.isEmpty(userToken) ? null : userToken;
+        if (!TextUtils.isEmpty(Authorization)) {
+            try {
+                authorization = URLEncoder.encode(Authorization, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+            boolean status = url.contains("?");
+            if (status) {
+                webViewUrl = (url + "&Authorization=" + authorization);
+            } else {
+                webViewUrl = (url + "?Authorization=" + authorization);
+            }
+        }
+
+        accompanyFragment = AccompanyFragment.newInstance(webViewUrl);
+        accompanyFragment.setOnAccompanyListener(new AccompanyFragment.onListener() {
+
+
+            @Override
+            public void setStatusBarTextColor(boolean statusBarTextColor) {
+//                setStatusBarTextColor(statusBarTextColor);
+            }
+
+            /**
+             * 打开相机
+             */
+            @Override
+            public void openCamera() {
+                if (cameraView == null) {
+                    cameraGroupView = LayoutInflater.from(AccompanyActivity.this).inflate(R.layout.record_video_layout, camera, false);
+                    camera.addView(cameraGroupView);
+                    cameraView = cameraGroupView.findViewById(R.id.camera);
+                    cameraView.setVideoQuality(CameraKit.Constants.VIDEO_QUALITY_HIGHEST);
+                    cameraView.start();
+                    cameraView.addCameraKitListener(new CameraKitEventListener() {
+
+                        @Override
+                        public void onEvent(CameraKitEvent cameraKitEvent) {
+
+                        }
+
+                        @Override
+                        public void onError(CameraKitError cameraKitError) {
+
+                        }
+
+                        @Override
+                        public void onImage(CameraKitImage cameraKitImage) {
+
+                        }
+
+                        @Override
+                        public void onVideo(CameraKitVideo cameraKitVideo) {
+                            try {
+                                File file = cameraKitVideo.getVideoFile();
+                                filePath = file.getPath();
+                                sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(filePath))));
+                                hideLoading();
+                                ToastUtils.showShort("保存成功");
+                            } catch (Exception e) {
+                            }
+
+                        }
+                    });
+                }
+            }
+
+            /**
+             * 关闭相机
+             */
+            @Override
+            public void closeCamera() {
+                if (cameraView != null) {
+                    cameraView.stop();
+                    cameraView.destroyDrawingCache();
+                    camera.removeView(cameraGroupView);
+                    cameraGroupView = null;
+                    cameraView = null;
+                }
+            }
+
+            /**
+             * 录视频
+             */
+            @Override
+            public void startCapture() {
+                if (cameraView != null) {
+                    recordVideFilePath = FileUtils.getPublicDirectory(videoDerectoryName) + File.separator
+                            + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".mp4";
+                    cameraView.captureVideo(new File(recordVideFilePath));//开始录像
+                }
+
+            }
+
+            @Override
+            public void videoUpdate(JSONObject jsonObject) {
+                baseJsonObject = jsonObject;
+                File file = new File(recordVideFilePath);
+
+                if (!file.exists()) {
+                    ToastUtils.showShort("未找到该视频,请重试");
+                    FileUtils.deleteFile(recordVideFilePath);
+                }
+                UploadHelper uploadHelper = new UploadHelper(AccompanyActivity.this);
+                uploadHelper.uploadFile(file);
+                uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
+                    @Override
+                    public void onSuccess(String url) {
+                        try {
+                            JSONObject contentObj = baseJsonObject.getJSONObject("content");
+                            String uuid = contentObj.getString("uuid");
+                            contentObj.put("type", "success");
+                            contentObj.put("fileUrl", url);
+                            contentObj.put("uuid", uuid);
+                            contentObj.put("message", "上传成功");
+                            accompanyFragment.onSendMessage(baseJsonObject.toString());
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+
+                    @Override
+                    public void onFailure() {
+                        upLoadFileFaile();
+                        ToastUtils.showShort("上传失败,请重新选择");
+                    }
+                });
+
+            }
+
+            /**
+             * 停止录视频
+             */
+            @Override
+            public void endCapture() {
+                if (cameraView != null && cameraView.getVisibility() == View.VISIBLE) {
+                    new Handler().postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            cameraView.stopVideo();//结束录像
+
+                        }
+                    }, 1000);
+                }
+            }
+        });
+
+        getSupportFragmentManager().beginTransaction()
+                .add(R.id.fl_webview, accompanyFragment)
+                .commitAllowingStateLoss();
+
+
+        intentOne = new Intent(this, PlayMusicService.class);
+        startService(intentOne);
+    }
+
+    public void setStatusBarTextColor(boolean statusBarTextColor) {
+        if (statusBarTextColor) {
+            setStatusBarColor();
+        } else {
+            setStatusBlackBarColor();
+        }
+    }
+
+    public void setStatusBarColor() {
+        ImmersionBar.with(this)
+                .keyboardEnable(true)
+                .transparentStatusBar()
+                .statusBarDarkFont(false, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
+                .autoDarkModeEnable(false)
+                .flymeOSStatusBarFontColor(R.color.white)  //修改flyme OS状态栏字体颜色
+                .init();  //必须调用方可沉浸
+
+    }
+
+    public void setStatusBlackBarColor() {
+        ImmersionBar.with(this)
+                .keyboardEnable(true)
+                .transparentStatusBar()
+                .statusBarDarkFont(true, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
+                .autoDarkModeEnable(false)
+                .flymeOSStatusBarFontColor(com.cooleshow.base.R.color.common_black)  //修改flyme OS状态栏字体颜色
+                .init();  //必须调用方可沉浸
+    }
+
+    @Override
+    protected ActivityAccompanyBinding getLayoutView() {
+        return ActivityAccompanyBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected AccompanyPresenter createPresenter() {
+        return new AccompanyPresenter();
+    }
+
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        if (cameraView != null) {
+            cameraView.setVisibility(View.VISIBLE);
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    if (cameraView != null) {
+                        cameraView.start();
+                    }
+                }
+            }, 1000);
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (intentOne != null) {
+            stopService(intentOne);
+        }
+    }
+
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == ADD_ACCOMPANIMENT_CODE) {
+            try {
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("api", "reload");
+//                onSendMessage(jsonObject.toString());
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        } else if (requestCode == 1000) {
+            if (data != null) {
+                try {
+                    String filePath = data.getStringExtra("filePath");
+                    JSONObject jsonObject = new JSONObject();
+
+                    jsonObject.put("api", "uploadVideo");
+
+                    jsonObject.put("url", filePath);
+//                    webView.evaluateJavascript("sendMessage('" + jsonObject.toString() + "')", new ValueCallback<String>() {
+//                        @Override
+//                        public void onReceiveValue(String s) {
+//                        }
+//                    });
+
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+            }
+        } else if (requestCode == 1011) {
+            String selectAddress = data.getStringExtra("selectAddress");
+            if (null!=accompanyFragment){
+                accompanyFragment.selectAddress(selectAddress);
+            }
+        }
+    }
+
+    @Override
+    protected void onStop() {
+        if (cameraView != null) {
+            cameraView.stop();
+            cameraView.destroyDrawingCache();
+        }
+
+        super.onStop();
+
+    }
+
+    private void upLoadFileFaile() {
+        try {
+            JSONObject contentObj = baseJsonObject.getJSONObject("content");
+            String uuid = contentObj.getString("uuid");
+            contentObj.put("type", "error");
+            contentObj.put("uuid", uuid);
+            contentObj.put("message", "上传失败");
+            accompanyFragment.onSendMessage(baseJsonObject.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+}

+ 2131 - 0
student/src/main/java/com/cooleshow/student/ui/web/AccompanyFragment.java

@@ -0,0 +1,2131 @@
+package com.cooleshow.student.ui.web;
+
+import static com.luck.picture.lib.thread.PictureThreadUtils.runOnUiThread;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothHeadset;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.media.AudioDeviceInfo;
+import android.media.AudioManager;
+import android.media.SoundPool;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.SystemClock;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.webkit.ValueCallback;
+import android.webkit.WebResourceError;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.alipay.sdk.app.PayTask;
+import com.cooleshow.base.common.WebConstants;
+import com.cooleshow.base.constanst.Constants;
+import com.cooleshow.base.data.net.RetrofitClientNoToken;
+import com.cooleshow.base.recorder.AudioChunk;
+import com.cooleshow.base.recorder.AudioRecordConfig;
+import com.cooleshow.base.recorder.MsRecorder;
+import com.cooleshow.base.recorder.PullTransport;
+import com.cooleshow.base.recorder.Recorder;
+import com.cooleshow.base.ui.fragment.BaseMVPFragment;
+import com.cooleshow.base.utils.HeadsetPlugListener;
+import com.cooleshow.base.utils.HeadsetPlugReceiver;
+import com.cooleshow.base.utils.PermissionUtils;
+import com.cooleshow.base.utils.ToastUtils;
+import com.cooleshow.base.websocket.JWebSocketClient;
+import com.cooleshow.base.widgets.BaseDialog;
+import com.cooleshow.base.widgets.CommonDialog;
+import com.cooleshow.base.widgets.DialogUtil;
+import com.cooleshow.base.widgets.ViewConvertListener;
+import com.cooleshow.base.widgets.ViewHolder;
+import com.cooleshow.student.BuildConfig;
+import com.cooleshow.student.api.APIService;
+import com.cooleshow.student.bean.alipay.AuthResult;
+import com.cooleshow.student.bean.alipay.PayResult;
+import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
+import com.cooleshow.student.databinding.FragmentAccompanyBinding;
+import com.cooleshow.student.presenter.web.AccompanyPresenter;
+import com.cooleshow.student.widgets.FileUtils;
+import com.cooleshow.student.widgets.LollipopFixedWebView;
+import com.cooleshow.student.widgets.helper.JsInterfaceAccomPanyUtils;
+import com.cooleshow.usercenter.helper.UserHelper;
+import com.google.gson.Gson;
+import com.jinmingyunle.midiplaylib.MidiPlayerUtils;
+import com.tbruyelle.rxpermissions3.RxPermissions;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+import org.java_websocket.enums.ReadyState;
+import org.java_websocket.handshake.ServerHandshake;
+import org.jetbrains.annotations.NotNull;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.File;
+import java.net.URI;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
+import io.reactivex.rxjava3.annotations.NonNull;
+import io.reactivex.rxjava3.core.Observable;
+import io.reactivex.rxjava3.core.ObservableEmitter;
+import io.reactivex.rxjava3.core.ObservableOnSubscribe;
+import io.reactivex.rxjava3.core.Observer;
+import io.reactivex.rxjava3.disposables.Disposable;
+import io.reactivex.rxjava3.schedulers.Schedulers;
+import okhttp3.ResponseBody;
+
+/**
+ * 创建日期:2022/6/8 14:32
+ *
+ * @author Ryan
+ * 类说明:
+ */
+public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding, AccompanyPresenter> implements JsInterfaceAccomPanyUtils.onGetMethodsListener {
+    private final static String TAG = "AccompanyFragmenttag";
+    private IWXAPI api;
+    private static final int SDK_PAY_FLAG = 1;
+    private static final int SDK_AUTH_FLAG = 2;
+
+    FrameLayout viewParent;
+    WebView webView;
+    //    private UMShareListener mShareListener;
+    private String url;
+    private Recorder wavRecorder;
+    private JWebSocketClient webSocketClient;
+    //    private ShareAction mShareAction;
+    private URI webSocketUri = URI.create("BuildConfig.BASE_STU_SOCKET_URL");
+
+    public static AccompanyFragment newInstance(String url) {
+        AccompanyFragment fragment = new AccompanyFragment();
+        Bundle args = new Bundle();
+        args.putString("url", url);
+        fragment.setArguments(args);
+        return fragment;
+    }
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        EventBus.getDefault().register(this);
+        api = WXAPIFactory.createWXAPI(getContext(), null);
+        api.registerApp("wx149a928c415c137a");
+    }
+
+    @Override
+    protected FragmentAccompanyBinding getLayoutView() {
+        return FragmentAccompanyBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected AccompanyPresenter createPresenter() {
+        return new AccompanyPresenter();
+    }
+
+    @Override
+    protected void initView(View rootView) {
+        viewParent = mViewBinding.viewParent;
+        if (getArguments() != null) {
+            url = getArguments().getString("url");
+        }
+        String localUserId = UserHelper.getUserId();
+        webSocketUri = URI.create("ws://192.168.3.119:8090/audioAnalysis" + "/" + localUserId);
+        try {
+            if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) {
+                webView = new LollipopFixedWebView(getActivity());
+            } else {
+                webView = new WebView(getActivity());
+            }
+        } catch (Exception e) {
+
+        }
+        if (null == webView) {
+            return;
+        }
+        JsInterfaceAccomPanyUtils jsInterfaceUtils = new JsInterfaceAccomPanyUtils(getActivity());
+        jsInterfaceUtils.setOnGetMethodsListener(this);
+        webView.addJavascriptInterface(jsInterfaceUtils, WebConstants.WEB_JS_INTERFACE);
+        viewParent.addView(webView, new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.MATCH_PARENT,
+                FrameLayout.LayoutParams.MATCH_PARENT));
+        webView.setBackgroundColor(0);
+        initWebView();
+        webView.setWebViewClient(new WebClient());
+        webView.loadUrl(url);
+
+    }
+
+
+    @Override
+    protected void initData() {
+//        mShareListener = new CustomShareListener(getActivity());
+    }
+
+
+    private void initWebView() {
+        //声明WebSettings子类
+        WebSettings webSettings = webView.getSettings();
+        webSettings.setUserAgentString(webSettings.getUserAgentString() + ";DAYAAPPA");
+        webSettings.setGeolocationDatabasePath(getContext().getFilesDir().getPath());
+        webSettings.setGeolocationEnabled(true);
+        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
+        //如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
+        webSettings.setJavaScriptEnabled(true);
+        webSettings.setMediaPlaybackRequiresUserGesture(false);//false允许自动播放音视频
+        //是否启用缓存
+        webSettings.setAppCacheEnabled(true);
+
+        // 开启DOM缓存,默认状态下是不支持LocalStorage的
+        webSettings.setDomStorageEnabled(true);
+        // 开启数据库缓存
+        webSettings.setDatabaseEnabled(true);
+
+        //设置自适应屏幕,两者合用
+        webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
+        webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
+        //缩放操作
+        webSettings.setSupportZoom(false); //支持缩放,默认为true。是下面那个的前提。
+        // 设置允许JS弹窗
+        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
+        //其他细节操作
+        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
+        webSettings.setAllowFileAccess(true); //设置可以访问文件
+        webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
+        webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
+        webSettings.setDefaultTextEncodingName("UTF-8");//设置编码格式
+
+        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);  //富文本适配
+        webSettings.setAppCacheMaxSize(Long.MAX_VALUE);
+        webSettings.setAppCachePath(getActivity().getDir("appcache", 0).getPath());
+        webSettings.setDatabasePath(getActivity().getDir("databases", 0).getPath());
+        webSettings.setGeolocationDatabasePath(getActivity().getDir("geolocation", 0)
+                .getPath());
+        webSettings.setPluginState(WebSettings.PluginState.ON_DEMAND);
+        if (BuildConfig.DEBUG) {
+            webView.setWebContentsDebuggingEnabled(true);
+        }
+        webSettings.setTextZoom(100);//设置字体默认的缩放比例,以避免手机系统的字体修改对页面字体及布局造成影响。
+        webView.setHorizontalScrollBarEnabled(false);
+        webView.setVerticalScrollBarEnabled(false);
+
+
+    }
+
+    @Override
+    public void onSendMessage(String message) {
+        webView.evaluateJavascript("postMessage('" + message + "')", new ValueCallback<String>() {
+            @Override
+            public void onReceiveValue(String s) {
+            }
+        });
+    }
+
+    private int setColorCount = 0;
+
+    @Override
+    public void setStatusBarTextColor(boolean statusBarTextColor, JSONObject message) {
+        setColorCount++;
+        if (setColorCount == 1) {
+            if (onAccompanyListener != null)
+                onAccompanyListener.setStatusBarTextColor(false);
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    onSendMessage(message.toString());
+                }
+            }, 1500);
+        }
+
+    }
+
+    boolean isSendStartEvaluatingMessage = false;
+    boolean isWiredHeadsetOn = false;
+
+    /**
+     * 开始评测
+     *
+     * @param message
+     */
+    @SuppressLint("CheckResult")
+    @Override
+    public void startEvaluating(JSONObject message) {
+        isWiredHeadsetOn = false;
+        isSendStartEvaluatingMessage = true;
+        new RxPermissions(this)
+                .request(Manifest.permission.RECORD_AUDIO)
+                .subscribe(permission -> {
+                    if (permission) {
+//                        startWebSocketClient(message);
+                        if (webSocketClient != null) {
+                            if (webSocketClient.getReadyState() == ReadyState.NOT_YET_CONNECTED) {
+                                if (webSocketClient.isClosed()) {
+                                    webSocketClient.reconnectBlocking();
+                                } else {
+                                    webSocketClient.connectBlocking();
+                                }
+                            } else if (webSocketClient.getReadyState() == ReadyState.CLOSED) {
+                                webSocketClient.reconnectBlocking();
+                            }
+                            onSendMessage(message.toString());
+                            try {
+                                JSONObject jsonObject = new JSONObject();
+                                JSONObject headerObject = new JSONObject();
+                                headerObject.put("commond", "musicXml");
+                                headerObject.put("type", "SOUND_COMPARE");
+                                headerObject.put("status", 200);
+                                jsonObject.put("header", headerObject);
+                                jsonObject.put("body", message.getJSONObject("content"));
+                                webSocketClient.send(jsonObject.toString());
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        } else {
+                            startWebSocketClient(message);
+                        }
+
+
+                    } else {
+                        try {
+                            JSONObject content = message.getJSONObject("content");
+                            content.put("reson", "没有麦克风权限");
+                            onSendMessage(message.toString());
+                            isSendStartEvaluatingMessage = false;
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                        DialogUtil.showInCenter(getChildFragmentManager(), com.cooleshow.base.R.layout.accompany_permissions_popu, (holder, dialog) -> {
+                            TextView tvTitle = holder.getView(com.cooleshow.base.R.id.tv_title);
+                            TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                            TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                            TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
+                            tvTitle.setText("提示");
+                            tvContent.setText("请开启麦克风访问权限");
+                            btncancel.setOnClickListener(view1 -> {
+
+                                dialog.dismiss();
+
+                            });
+                            btnCommit.setOnClickListener(view1 -> {
+                                PermissionUtils.toSelfSetting(getContext());
+                                dialog.dismiss();
+                            });
+                        });
+                    }
+                });
+
+    }
+
+    JSONObject msg = null;
+
+    private void startWebSocketClient(JSONObject message) throws JSONException {
+        msg = message;
+        if (webSocketClient == null) {
+            Observable.create(new ObservableOnSubscribe<String>() {
+                        @Override
+                        public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Exception {
+                            Map<String, String> httpHeaders = new HashMap<String, String>();
+                            httpHeaders.put("Authorization", UserHelper.getUserToken());
+                            webSocketClient = new JWebSocketClient(webSocketUri, httpHeaders) {
+                                @Override
+                                public void onMessage(String message) {
+                                    emitter.onNext(message);
+                                }
+
+                                @Override
+                                public void onError(Exception ex) {
+                                    super.onError(ex);
+                                    emitter.onNext("-2");
+                                }
+
+                                @Override
+                                public void onOpen(ServerHandshake handshakedata) {
+                                    super.onOpen(handshakedata);
+                                    emitter.onNext("-1");
+
+                                }
+
+                                @Override
+                                public void onClose(int code, String reason, boolean remote) {
+                                    super.onClose(code, reason, remote);
+                                    emitter.onNext("-2");
+                                }
+                            };
+                            webSocketClient.setConnectionLostTimeout(60 * 1000);
+                            webSocketClient.connect();
+                        }
+                    }).subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new Observer<String>() {
+                        @Override
+                        public void onSubscribe(@NonNull Disposable d) {
+
+                        }
+
+                        @Override
+                        public void onNext(@NonNull String serverMsg) {
+
+                            if ("-1".equals(serverMsg) && isWiredHeadsetOn) {
+                                if (msg != null) {
+                                    onSendMessage(msg.toString());
+                                }
+
+                            } else if ("-1".equals(serverMsg) && isSendStartEvaluatingMessage) {
+
+                                if (msg != null) {
+                                    onSendMessage(msg.toString());
+                                }
+                                try {
+                                    JSONObject jsonObject = new JSONObject();
+                                    JSONObject headerObject = new JSONObject();
+                                    headerObject.put("commond", "musicXml");
+                                    jsonObject.put("header", headerObject);
+                                    jsonObject.put("body", msg.getJSONObject("content"));
+                                    webSocketClient.send(jsonObject.toString());
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            } else if ("-2".equals(serverMsg)) {
+                                if (isSendStartEvaluatingMessage) {
+                                    isSendStartEvaluatingMessage = false;
+
+                                    try {
+                                        if (msg != null) {
+                                            JSONObject content = msg.getJSONObject("content");
+                                            content.put("reson", "服务异常,请重试");
+                                            onSendMessage(msg.toString());
+                                            msg = null;
+                                        }
+                                    } catch (Exception e3) {
+                                        e3.printStackTrace();
+                                    }
+                                } else if (isWiredHeadsetOn) {
+                                    isWiredHeadsetOn = false;
+                                    return;
+                                }
+//                                } else {
+//                                    LOG.i(TAG, "onNext: serverMsg333" + isWiredHeadsetOn);
+//                                    JSONObject object = new JSONObject();
+//                                    JSONObject reson = new JSONObject();
+//                                    try {
+//                                        reson.put("reson", "服务异常,请重试");
+//                                        object.put("api", "cancelEvaluating");
+//                                        object.put("content", reson);
+//                                        onSendMessage(object.toString());
+//                                    } catch (JSONException e2) {
+//                                        e2.printStackTrace();
+//                                    }
+//                                }
+                            } else {
+                                JSONObject object = new JSONObject();
+                                try {
+                                    object.put("api", "sendResult");
+                                    object.put("content", new JSONObject(serverMsg));
+                                    onSendMessage(object.toString());
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+
+                            msg = null;
+
+                        }
+
+                        @Override
+                        public void onError(@NonNull Throwable e) {
+
+                            if (isSendStartEvaluatingMessage) {
+                                isSendStartEvaluatingMessage = false;
+                                try {
+                                    JSONObject content = msg.getJSONObject("content");
+                                    content.put("reson", "服务异常,请重试");
+                                    onSendMessage(msg.toString());
+                                    msg = null;
+                                } catch (Exception e3) {
+                                    e3.printStackTrace();
+                                }
+                            } else if (isWiredHeadsetOn) {
+                                isWiredHeadsetOn = false;
+                            } else {
+                                JSONObject object = new JSONObject();
+                                JSONObject reson = new JSONObject();
+                                try {
+                                    reson.put("reson", "服务异常,请重试");
+                                    object.put("api", "cancelEvaluating");
+                                    object.put("content", reson);
+                                    onSendMessage(object.toString());
+                                } catch (Exception e2) {
+                                    e.printStackTrace();
+                                }
+                            }
+                            msg = null;
+                        }
+
+                        @Override
+                        public void onComplete() {
+
+                        }
+                    });
+
+
+        } else if (webSocketClient.isClosed() || webSocketClient.isClosing()) {
+
+            if (isWiredHeadsetOn) {
+                isSendStartEvaluatingMessage = false;
+            } else {
+                isSendStartEvaluatingMessage = true;
+            }
+            webSocketClient.reconnect();
+        } else {
+            if (isWiredHeadsetOn) {
+                isSendStartEvaluatingMessage = false;
+            } else if (isSendStartEvaluatingMessage) {
+                isWiredHeadsetOn = false;
+                try {
+                    JSONObject jsonObject = new JSONObject();
+                    JSONObject headerObject = new JSONObject();
+                    headerObject.put("commond", "musicXml");
+                    jsonObject.put("header", headerObject);
+                    jsonObject.put("body", message.getJSONObject("content"));
+                    webSocketClient.send(jsonObject.toString());
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+            onSendMessage(message.toString());
+
+
+        }
+    }
+
+    boolean isSendRecordStartTime = false;
+
+    /**
+     * 开始录音
+     *
+     * @param message
+     */
+    public void startRecording(JSONObject message) {
+        onSendMessage(message.toString());
+
+        isSendRecordStartTime = true;
+        if (webSocketClient != null && webSocketClient.isOpen()) {
+            try {
+                JSONObject jsonObject = new JSONObject();
+                JSONObject headerObject = new JSONObject();
+                headerObject.put("commond", "recordStart");
+                headerObject.put("type", "SOUND_COMPARE");
+                headerObject.put("status", 200);
+                jsonObject.put("header", headerObject);
+                webSocketClient.send(jsonObject.toString());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        if (wavRecorder != null) {
+            wavRecorder.stopRecording();
+            FileUtils.deleteFile(getVoicePath());
+            wavRecorder.startRecording(getContext());
+        } else {
+            Observable.create((ObservableOnSubscribe<String>) emitter -> {
+                        wavRecorder = MsRecorder.wav(
+                                new File(getVoicePath()),
+                                new AudioRecordConfig(),
+                                // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
+                                new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
+                                    @Override
+                                    public void onAudioChunkPulled(AudioChunk audioChunk) {
+                                        if (webSocketClient != null && webSocketClient.isOpen()) {
+                                            webSocketClient.send(audioChunk.toBytes());
+                                            if (isSendRecordStartTime) {
+                                                isSendRecordStartTime = false;
+                                                emitter.onNext("-2");
+                                            }
+                                        } else {
+                                            emitter.onNext("-1");
+                                        }
+                                    }
+                                }));
+                        if (wavRecorder != null) {
+                            wavRecorder.startRecording(getContext());
+                        }
+                        emitter.onNext("1");
+                    }).subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new Observer<String>() {
+                        @Override
+                        public void onSubscribe(@NonNull Disposable d) {
+
+                        }
+
+                        @Override
+                        public void onNext(@NonNull String recorder) {
+                            if ("-2".equals(recorder) && isSendStartEvaluatingMessage) {
+                                try {
+                                    JSONObject json = new JSONObject();
+                                    JSONObject content = new JSONObject();
+                                    content.put("inteveral", System.currentTimeMillis());
+                                    json.put("api", "recordStartTime");
+                                    json.put("content", content);
+                                    onSendMessage(json.toString());
+
+                                } catch (JSONException e) {
+                                    e.printStackTrace();
+                                }
+                            } else if ("1".equals(recorder)) {
+//                                onSendMessage(message.toString());
+                            } else {
+                                JSONObject object = new JSONObject();
+                                JSONObject reson = new JSONObject();
+                                try {
+                                    reson.put("reson", "服务异常,请重试");
+                                    object.put("api", "cancelEvaluating");
+                                    object.put("content", reson);
+                                    onSendMessage(object.toString());
+                                    if (wavRecorder != null) {
+                                        wavRecorder.stopRecording();
+                                    }
+                                } catch (JSONException e2) {
+                                    e2.printStackTrace();
+                                }
+                            }
+                        }
+
+                        @Override
+                        public void onError(@NonNull Throwable e) {
+                            JSONObject object = new JSONObject();
+                            JSONObject reson = new JSONObject();
+                            try {
+                                reson.put("reson", "录制错误,请重试");
+                                object.put("api", "cancelEvaluating");
+                                object.put("content", reson);
+                                onSendMessage(object.toString());
+                                if (wavRecorder != null) {
+                                    wavRecorder.stopRecording();
+                                }
+                            } catch (JSONException e2) {
+                                e2.printStackTrace();
+                            }
+                        }
+
+                        @Override
+                        public void onComplete() {
+
+                        }
+                    });
+
+
+        }
+    }
+
+    /**
+     * 结束录音
+     *
+     * @param message
+     */
+    @Override
+    public void endRecording(JSONObject message) {
+        if (wavRecorder == null) {
+            return;
+        }
+        wavRecorder.stopRecording();
+        if (webSocketClient != null) {
+            webSocketClient.close();
+        }
+        onSendMessage(message.toString());
+    }
+
+
+    @Override
+    public void keepScreenLongLight(JSONObject message) {
+        onSendMessage(message.toString());
+        isWiredHeadsetOn = true;
+        if (webSocketClient == null) {
+            new RxPermissions(this)
+                    .request(Manifest.permission.RECORD_AUDIO)
+                    .subscribe(permission -> {
+                        if (permission) {
+                            startWebSocketClient(message);
+                        } else {
+                            DialogUtil.showInCenter(getChildFragmentManager(), com.cooleshow.base.R.layout.accompany_permissions_popu, (holder, dialog) -> {
+                                TextView tvTitle = holder.getView(com.cooleshow.base.R.id.tv_title);
+                                TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                                TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                                TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
+                                tvTitle.setText("提示");
+                                tvContent.setText("请开启麦克风访问权限");
+                                btncancel.setOnClickListener(view1 -> {
+
+                                    dialog.dismiss();
+
+                                });
+                                btnCommit.setOnClickListener(view1 -> {
+                                    PermissionUtils.toSelfSetting(getContext());
+                                    dialog.dismiss();
+                                });
+                            });
+                        }
+                    });
+        }
+    }
+
+    boolean isSoundCheckStartTime = false;
+
+    /**
+     * 开始校音
+     *
+     * @param message
+     */
+    @Override
+    public void startSoundCheck(JSONObject message) {
+        //开录制 实时把给后台传音频数据
+        onSendMessage(message.toString());
+        isSoundCheckStartTime = true;
+        if (webSocketClient != null && webSocketClient.isOpen()) {
+            try {
+                JSONObject jsonObject2 = new JSONObject();
+                JSONObject headerObject2 = new JSONObject();
+                headerObject2.put("commond", "start");
+                headerObject2.put("type", "PITCH_DETECTION");
+                headerObject2.put("status", 200);
+                jsonObject2.put("header", headerObject2);
+                webSocketClient.send(jsonObject2.toString());
+            } catch (Exception e) {
+
+            }
+        }
+
+        if (wavRecorder != null) {
+            wavRecorder.stopRecording();
+            FileUtils.deleteFile(getVoicePath());
+            wavRecorder.startRecording(getContext());
+        } else {
+            Observable.create((ObservableOnSubscribe<String>) emitter -> {
+                        wavRecorder = MsRecorder.wav(
+                                new File(getVoicePath()),
+                                new AudioRecordConfig(),
+                                // AudioRecordConfig(MediaRecorder.AudioSource.MIC, AudioFormat.ENCODING_PCM_16BIT, AudioFormat.CHANNEL_IN_MONO, 44100),
+                                new PullTransport.Default().setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
+                                    @Override
+                                    public void onAudioChunkPulled(AudioChunk audioChunk) {
+                                        if (webSocketClient != null && webSocketClient.isOpen()) {
+                                            webSocketClient.send(audioChunk.toBytes());
+                                            if (isSoundCheckStartTime) {
+                                                isSoundCheckStartTime = false;
+                                                emitter.onNext("-2");
+                                            }
+                                        } else {
+                                            emitter.onNext("-1");
+                                        }
+                                    }
+                                }));
+                        if (wavRecorder != null) {
+                            wavRecorder.startRecording(getContext());
+                        }
+                        emitter.onNext("1");
+                    }).subscribeOn(Schedulers.newThread())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new Observer<String>() {
+                        @Override
+                        public void onSubscribe(@NonNull Disposable d) {
+                        }
+
+                        @Override
+                        public void onNext(@NonNull String recorder) {
+                            if ("-2".equals(recorder)) {
+                                try {
+                                    JSONObject json = new JSONObject();
+                                    JSONObject content = new JSONObject();
+                                    content.put("inteveral", System.currentTimeMillis());
+                                    json.put("api", "recordStartTime");
+                                    json.put("content", content);
+                                    onSendMessage(json.toString());
+
+                                } catch (JSONException e) {
+                                    e.printStackTrace();
+                                }
+                            } else if ("1".equals(recorder)) {
+//                                onSendMessage(message.toString());
+                            } else {
+                                JSONObject object = new JSONObject();
+                                JSONObject reson = new JSONObject();
+                                try {
+                                    reson.put("reson", "服务异常,请重试");
+                                    object.put("api", "cancelEvaluating");
+                                    object.put("content", reson);
+                                    onSendMessage(object.toString());
+                                    if (wavRecorder != null) {
+                                        wavRecorder.stopRecording();
+                                    }
+                                } catch (JSONException e2) {
+                                    e2.printStackTrace();
+                                }
+                            }
+                        }
+
+                        @Override
+                        public void onError(@NonNull Throwable e) {
+                            JSONObject object = new JSONObject();
+                            JSONObject reson = new JSONObject();
+                            try {
+                                reson.put("reson", "录制错误,请重试");
+                                object.put("api", "cancelEvaluating");
+                                object.put("content", reson);
+                                onSendMessage(object.toString());
+                                if (wavRecorder != null) {
+                                    wavRecorder.stopRecording();
+                                }
+                            } catch (JSONException e2) {
+                                e2.printStackTrace();
+                            }
+                        }
+
+                        @Override
+                        public void onComplete() {
+                        }
+                    });
+
+
+        }
+    }
+
+    /**
+     * 结束校音
+     *
+     * @param message
+     */
+    @Override
+    public void endSoundCheck(JSONObject message) {
+        //结束校音  校音结束 这个就是结束给后台传音频 停止录音
+        onSendMessage(message.toString());
+        if (wavRecorder == null) {
+            return;
+        }
+        wavRecorder.stopRecording();
+        wavRecorder = null;
+
+    }
+
+    // 录音文件存储名称
+    private String getVoicePath() {
+        return FileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
+    }
+
+    /**
+     * 结束评测
+     *
+     * @param jsonObject
+     */
+    @Override
+    public void endEvaluating(JSONObject jsonObject) {
+        if (wavRecorder == null) {
+            return;
+        }
+        wavRecorder.stopRecording();
+        wavRecorder = null;
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                if (webSocketClient != null && webSocketClient.isOpen()) {
+                    try {
+                        JSONObject jsonObject = new JSONObject();
+                        JSONObject headerObject = new JSONObject();
+                        headerObject.put("commond", "recordEnd");
+                        headerObject.put("type", "SOUND_COMPARE");
+                        headerObject.put("status", 200);
+                        jsonObject.put("header", headerObject);
+                        webSocketClient.send(jsonObject.toString());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                onSendMessage(jsonObject.toString());
+            }
+        }, 1000);
+
+//        Map<String, RequestBody> data = new HashMap<>();
+//        try {
+//            JSONObject content = jsonObject.getJSONObject("content");
+//            data.put("musicScoreId", RequestBodyUtil.convertToRequestBody(content.getString("musicScoreId")));
+//        } catch (JSONException e) {
+//            e.printStackTrace();
+//        }
+//        presenter.soundCompare(RequestBodyUtil.filesToMultipartBodyParts(new File(getVoicePath()), "record", "audio/wav"), data, jsonObject);
+    }
+
+    /**
+     * 取消评测
+     */
+    @Override
+    public void cancelEvaluating() {
+        if (wavRecorder == null) {
+            return;
+        }
+        wavRecorder.stopRecording();
+        FileUtils.deleteFile(getVoicePath());
+    }
+
+    /**
+     * 恢复录音
+     *
+     * @param jsonObject
+     */
+    @Override
+    public void resumeRecording(JSONObject jsonObject) {
+        if (wavRecorder != null) {
+            wavRecorder.resumeRecording(getContext());
+            onSendMessage(jsonObject.toString());
+        }
+    }
+
+    /**
+     * 暂停
+     *
+     * @param jsonObject
+     */
+    @Override
+    public void pauseRecording(JSONObject jsonObject) {
+        if (wavRecorder != null) {
+            wavRecorder.pauseRecording();
+            onSendMessage(jsonObject.toString());
+        }
+    }
+
+    /**
+     * 检测 耳机或者其他设备
+     *
+     * @param jsonObject
+     */
+    @SuppressLint("CheckResult")
+    @Override
+    public void isWiredHeadsetOn(JSONObject jsonObject) {
+
+
+        try {
+            JSONObject content = jsonObject.getJSONObject("content");
+            content.put("checkIsWired", !TextUtils.isEmpty(checkType()));
+            content.put("type", checkType());
+            onSendMessage(jsonObject.toString());
+
+            if (webSocketClient != null) {
+                if (webSocketClient.getReadyState() == ReadyState.NOT_YET_CONNECTED) {
+                    if (webSocketClient.isClosed()) {
+                        webSocketClient.reconnectBlocking();
+                    } else {
+                        webSocketClient.connectBlocking();
+                    }
+                } else if (webSocketClient.getReadyState() == ReadyState.CLOSED) {
+                    webSocketClient.reconnectBlocking();
+                }
+            } else {
+                startWebSocketClient(jsonObject);
+            }
+
+        } catch (JSONException | InterruptedException e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    @Override
+    public void proxyMessage(JSONObject jsonObject) {
+        if (webSocketClient != null && webSocketClient.isOpen()) {
+            try {
+                JSONObject json = new JSONObject();
+                JSONObject headerObject = new JSONObject();
+                headerObject.put("commond", "proxyMessage");
+                json.put("header", headerObject);
+                json.put("body", jsonObject.getJSONObject("content"));
+                webSocketClient.send(json.toString());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void proxyServiceMessage(JSONObject mesage) {
+        // 直接把H5那边返回的 content转成string 给socket服务
+        try {
+            JSONObject content = null;
+            content = mesage.getJSONObject("content");
+            String type = content.getJSONObject("header").getString("type");
+            if ("SOUND_CHECK".equals(type)) {
+                return;
+            } else {
+                new Handler().postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (webSocketClient != null && webSocketClient.isOpen()) {
+                            try {
+                                JSONObject content = null;
+                                content = mesage.getJSONObject("content");
+                                webSocketClient.send(content.toString());
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+                        onSendMessage(mesage.toString());
+                    }
+                }, 1000);
+            }
+        } catch (JSONException e) {
+        }
+
+    }
+
+    /**
+     * 打开相册
+     *
+     * @param message
+     */
+    @Override
+    public void openCamera(JSONObject message) {
+        new RxPermissions(this)
+                .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE)
+                .subscribe(permission -> {
+                    if (permission) {
+                        if (onAccompanyListener != null)
+                            onAccompanyListener.openCamera();
+                        onSendMessage(message.toString());
+                    } else {
+                        try {
+                            JSONObject content = message.getJSONObject("content");
+                            content.put("reson", "没有摄像头,麦克风,储存权限");
+                            onSendMessage(message.toString());
+                            isSendStartEvaluatingMessage = false;
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                        DialogUtil.showInCenter(getChildFragmentManager(), com.cooleshow.base.R.layout.accompany_permissions_popu, (holder, dialog) -> {
+                            TextView tvTitle = holder.getView(com.cooleshow.base.R.id.tv_title);
+                            TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                            TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                            TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
+                            tvTitle.setText("提示");
+                            tvContent.setText("请开启摄像头、麦克风、储存访问权限");
+                            btncancel.setOnClickListener(view1 -> {
+
+                                dialog.dismiss();
+
+                            });
+                            btnCommit.setOnClickListener(view1 -> {
+                                PermissionUtils.toSelfSetting(getContext());
+                                dialog.dismiss();
+                            });
+                        });
+                    }
+                });
+
+    }
+
+    @Override
+    public void closeCamera(JSONObject jsonObject) {
+        if (onAccompanyListener != null) {
+            onAccompanyListener.closeCamera();
+            onSendMessage(jsonObject.toString());
+        }
+    }
+
+    @Override
+    public void startCapture(JSONObject message) {
+        new RxPermissions(this)
+                .request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE)
+                .subscribe(permission -> {
+                    if (permission) {
+                        if (onAccompanyListener != null) {
+                            onAccompanyListener.startCapture();
+                            onSendMessage(message.toString());
+                        }
+                    } else {
+                        try {
+                            JSONObject content = message.getJSONObject("content");
+                            content.put("reson", "没有摄像头,麦克风,储存权限");
+                            onSendMessage(message.toString());
+                            isSendStartEvaluatingMessage = false;
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                        DialogUtil.showInCenter(getChildFragmentManager(), com.cooleshow.base.R.layout.accompany_permissions_popu, (holder, dialog) -> {
+                            TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                            TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                            TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
+                            tvContent.setText("请开启摄像头、麦克风、储存访问权限");
+                            btncancel.setOnClickListener(view1 -> {
+
+                                dialog.dismiss();
+                            });
+                            btnCommit.setOnClickListener(view1 -> {
+                                PermissionUtils.toSelfSetting(getContext());
+                                dialog.dismiss();
+                            });
+                        });
+                    }
+                });
+
+    }
+
+    @Override
+    public void endCapture(JSONObject jsonObject) {
+        if (onAccompanyListener != null)
+            onAccompanyListener.endCapture();
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                onSendMessage(jsonObject.toString());
+            }
+        }, 1500);
+    }
+
+    private String checkType() {
+        AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
+            for (AudioDeviceInfo device : devices) {
+                int deviceType = device.getType();
+                if (deviceType == AudioDeviceInfo.TYPE_WIRED_HEADSET || deviceType == AudioDeviceInfo.TYPE_WIRED_HEADPHONES) {
+                    return "有线耳机";
+                }
+                if (deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
+                        || deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
+                    return "蓝牙耳机";
+                }
+                if (deviceType == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
+                    if (Constants.HEADSET_PLUE_TAG.isEmpty()) {
+                        return null;
+                    } else {
+                        return "有线耳机";
+                    }
+                }
+            }
+        } else {
+            if (audioManager.isWiredHeadsetOn()) {
+                return "有线耳机";
+            }
+            if (audioManager.isBluetoothScoOn() || audioManager.isBluetoothA2dpOn()) {
+                return "蓝牙耳机";
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void videoUpdate(JSONObject jsonObject) {
+        if (onAccompanyListener != null)
+            onAccompanyListener.videoUpdate(jsonObject);
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                onSendMessage(jsonObject.toString());
+            }
+        }, 1500);
+    }
+
+    private class WebClient extends WebViewClient {
+        //页面开始载入时调用
+        private int webViewPreviousState;
+        private final int PAGE_STARTED = 0x1;
+        private final int PAGE_REDIRECTED = 0x2;
+
+        @Override
+        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+            super.onPageStarted(view, url, favicon);
+            webViewPreviousState = PAGE_STARTED;
+        }
+
+        //页面载入结束时调用
+        @Override
+        public void onPageFinished(WebView view, String url) {
+            super.onPageFinished(view, url);
+            if (webViewPreviousState == PAGE_STARTED) {
+                if (listener != null) {
+                    listener.onPageFinished();
+                }
+            }
+        }
+
+        //截取url请求,在当前视图加载,避免在跳转到自带浏览器
+        @Override
+        public boolean shouldOverrideUrlLoading(WebView view, String request) {
+            webViewPreviousState = PAGE_REDIRECTED;
+            view.loadUrl(request);
+            return true;
+        }
+
+        //处理报错信息
+        @Override
+        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
+            super.onReceivedError(view, request, error);
+        }
+    }
+
+
+    public void sendMessage(String message) {
+        webView.evaluateJavascript("postMessage('" + message + "','*')", new ValueCallback<String>() {
+            @Override
+            public void onReceiveValue(String s) {
+            }
+        });
+    }
+
+
+    //注册蓝牙连接状态
+    public void registRecevier() {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
+        intentFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
+        mContext.registerReceiver(new HeadsetPlugReceiver(new HeadsetPlugListener() {
+            @Override
+            public void onHeadsetPlug(boolean isPlug, String type) {
+                getActivity().runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        JSONObject jsonObject = new JSONObject();
+                        try {
+                            jsonObject.put("api", "listenerWiredStatus");
+                            JSONObject content = new JSONObject();
+                            content.put("checkIsWired", isPlug);
+                            content.put("type", type);
+                            jsonObject.put("content", content);
+                            onSendMessage(jsonObject.toString());
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+            }
+        }), intentFilter);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+
+        if (webView != null) {
+            try {
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("api", "suspendPlay");
+                onSendMessage(jsonObject.toString());
+            } catch (JSONException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (null != webView) {
+            webView.destroy();
+        }
+        if (wavRecorder != null) {
+            wavRecorder.stopRecording();
+        }
+        if (webSocketClient != null) {
+            webSocketClient.close();
+        }
+        EventBus.getDefault().unregister(this);
+        MidiPlayerUtils.getInstance().stopPlay();
+//        UMShareAPI.get(mContext).release();
+
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        isReady = true;
+        if (null != soundpool) {
+            soundpool.release();
+        }
+        loopHandler.removeMessages(1);
+        //取消评测
+        if (MidiPlayerUtils.getInstance().isPlaying()) {
+            MidiPlayerUtils.getInstance().stopPlay();
+            try {
+                JSONObject content = new JSONObject();
+                content.put("songID", midiSongId);
+                JSONObject json = new JSONObject();
+                json.put("api", "cloudplayed");
+                json.put("content", content);
+                onSendMessage(json.toString());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public onListener onAccompanyListener;
+
+    public void setOnAccompanyListener(onListener onAccompanyListener) {
+        this.onAccompanyListener = onAccompanyListener;
+    }
+
+    public interface onListener {
+        void setStatusBarTextColor(boolean statusBarTextColor);
+
+        void openCamera();
+
+
+        void closeCamera();
+
+        void startCapture();
+
+        void endCapture();
+
+
+        void videoUpdate(JSONObject jsonObject);
+
+    }
+
+    public WebViewListener listener;
+
+    public void setOnWebViewListener(WebViewListener listener) {
+        this.listener = listener;
+    }
+
+    public interface WebViewListener {
+        void onPageFinished();
+
+    }
+
+
+    @Override
+    public void shareAchievements(JSONObject message) {
+        JSONObject content = null;
+        try {
+            content = message.getJSONObject("content");
+
+            String shareTitle = content.getString("title");
+            String shareDesc = content.getString("desc");
+            if ("video".equals(content.getString("type"))) {
+                String videoUrl = content.getString("video");
+                /*增加自定义按钮的分享面板*/
+               /* mShareAction = new ShareAction(getActivity()).setDisplayList(
+                                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.SINA)
+                        .setShareboardclickCallback(new ShareBoardlistener() {
+                            @Override
+                            public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
+                                UMWeb video = new UMWeb(videoUrl);
+                                video.setDescription(shareDesc.isEmpty() ? shareTitle : shareDesc);
+                                new ShareAction(getActivity()).withMedia(video)
+                                        .setPlatform(share_media)
+                                        .setCallback(mShareListener)
+                                        .share();
+
+                            }
+                        });
+                mShareAction.open();*/
+            } else {
+                String imageBase64 = content.getString("image");
+                /*增加自定义按钮的分享面板*/
+              /*  mShareAction = new ShareAction(getActivity()).setDisplayList(
+                                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.SINA)
+                        .setShareboardclickCallback(new ShareBoardlistener() {
+                            @Override
+                            public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
+                                UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                image.setThumb(image);
+                                image.compressStyle = UMImage.CompressStyle.SCALE;
+                                new ShareAction(getActivity()).withMedia(image)
+                                        .setPlatform(share_media)
+                                        .setCallback(mShareListener)
+                                        .share();
+
+                            }
+                        });
+                mShareAction.open();*/
+            }
+        } catch (JSONException e) {
+
+        }
+    }
+
+
+  /*  private static class CustomShareListener implements UMShareListener {
+
+        private WeakReference<AccompanyActivity> mActivity;
+
+        private CustomShareListener(Activity activity) {
+            mActivity = new WeakReference(activity);
+        }
+
+        @Override
+        public void onStart(SHARE_MEDIA platform) {
+
+        }
+
+        @Override
+        public void onResult(SHARE_MEDIA platform) {
+
+            if (platform.name().equals("WEIXIN_FAVORITE")) {
+                ToastUtil.getInstance().show(mActivity.get(), "收藏成功啦");
+            } else {
+                if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
+                        && platform != SHARE_MEDIA.EMAIL
+                        && platform != SHARE_MEDIA.FLICKR
+                        && platform != SHARE_MEDIA.FOURSQUARE
+                        && platform != SHARE_MEDIA.TUMBLR
+                        && platform != SHARE_MEDIA.POCKET
+                        && platform != SHARE_MEDIA.PINTEREST
+
+                        && platform != SHARE_MEDIA.INSTAGRAM
+                        && platform != SHARE_MEDIA.GOOGLEPLUS
+                        && platform != SHARE_MEDIA.YNOTE
+                        && platform != SHARE_MEDIA.EVERNOTE) {
+                    ToastUtil.getInstance().show(mActivity.get(), "分享成功啦");
+                }
+
+            }
+        }
+
+        @Override
+        public void onError(SHARE_MEDIA platform, Throwable t) {
+            if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
+                    && platform != SHARE_MEDIA.EMAIL
+                    && platform != SHARE_MEDIA.FLICKR
+                    && platform != SHARE_MEDIA.FOURSQUARE
+                    && platform != SHARE_MEDIA.TUMBLR
+                    && platform != SHARE_MEDIA.POCKET
+                    && platform != SHARE_MEDIA.PINTEREST
+
+                    && platform != SHARE_MEDIA.INSTAGRAM
+                    && platform != SHARE_MEDIA.GOOGLEPLUS
+                    && platform != SHARE_MEDIA.YNOTE
+                    && platform != SHARE_MEDIA.EVERNOTE) {
+                ToastUtil.getInstance().show(mActivity.get(), "分享失败啦");
+
+            }
+
+        }
+
+        @Override
+        public void onCancel(SHARE_MEDIA platform) {
+            ToastUtil.getInstance().show(mActivity.get(), "分享取消了");
+        }
+    }*/
+
+    @Override
+    public void onConfigurationChanged(@androidx.annotation.NonNull @NotNull Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+      /*  if (mShareAction != null) {
+            mShareAction.close();
+        }*/
+
+    }
+
+    /**
+     * 分段上传
+     *
+     * @param message
+     */
+    @Override
+    public void measureStart(JSONObject message) {
+
+    }
+
+    /**
+     * 结束分段
+     *
+     * @param message
+     */
+    @Override
+    public void allMeasureEnd(JSONObject message) {
+    }
+
+    /**
+     * h5传递的midi文件地址
+     */
+    private String midiFilePath = null;
+    /**
+     * 初始速度
+     */
+    private int midiFileOriginalSpeed = 120;
+    /**
+     * 设定后速度,默认与初始速度一致
+     */
+    private int midiFileSpeed = 120;
+    /**
+     * 全曲时长,用以同步播放进度的基数
+     */
+    private long midiFileDuration = 0;
+
+    /**
+     * 回报进度间隔
+     */
+    int processInterval = 16;
+    /**
+     * 曲目id
+     */
+    private String midiSongId = null;
+
+    private int hertz = 440;
+
+    private SoundPool soundpool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
+    private boolean isReady = true;
+
+    @Override
+    public void cloudDetail(JSONObject message) {
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            String midiFile = obj.optString("midi");
+            midiFileOriginalSpeed = obj.optInt("originalSpeed", 120);
+            midiFileSpeed = midiFileOriginalSpeed;
+            midiFileDuration = obj.optLong("duration");
+            processInterval = obj.optInt("interval", 16);
+            if (TextUtils.isEmpty(midiFile)) {
+                ToastUtils.showShort("文件异常");
+                return;
+            }
+            new RxPermissions(this)
+                    .request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
+                    .subscribe(permission -> {
+                        if (permission) {
+                            try {
+                                String type = midiFile.substring(midiFile.lastIndexOf(".") + 1);
+                                if (TextUtils.isEmpty(type)) {
+                                    ToastUtils.showShort("文件异常");
+                                    return;
+                                }
+                                String path = FileUtils.getPublicDirectory("file");
+                                String name = hashKeyForDisk(midiFile) + "." + type;
+                                File file = new File(path + "/" + name);
+                                if (file.exists() && file.length() > 0) {
+                                    //本地文件存在
+                                    midiFilePath = file.getAbsolutePath();
+                                    MidiPlayerUtils.getInstance().init(getActivity().getApplication(), midiFilePath);
+                                    double tempDuration = MidiPlayerUtils.getInstance().getTotalLength2Second();
+                                    if (Math.abs(midiFileDuration - tempDuration * 1000) > 2000) {
+                                        midiFileDuration = (long) (tempDuration * 1000);
+                                    }
+                                    message.optJSONObject("content").put("midiDuration", midiFileDuration);
+                                    onSendMessage(message.toString());
+                                } else {
+                                    RetrofitClientNoToken.getInstance().getRetrofit().create(APIService.class)
+                                            .downloadFileWithFixedUrl(midiFile)
+                                            .subscribeOn(Schedulers.io())
+                                            .observeOn(Schedulers.io())
+                                            .subscribeWith(new Observer<ResponseBody>() {
+                                                @Override
+                                                public void onSubscribe(Disposable d) {
+
+                                                }
+
+                                                @Override
+                                                public void onNext(ResponseBody response) {
+                                                    if (FileUtils.writeFileToSDCard(response, path, name)) {
+                                                        runOnUiThread(() -> {
+                                                            midiFilePath = path + File.separator + name;
+                                                            MidiPlayerUtils.getInstance().init(getActivity().getApplication(), midiFilePath);
+                                                            double tempDuration = MidiPlayerUtils.getInstance().getTotalLength2Second();
+                                                            if (Math.abs(midiFileDuration - tempDuration * 1000) > 2000) {
+                                                                midiFileDuration = (long) (tempDuration * 1000);
+                                                            }
+                                                            try {
+                                                                message.optJSONObject("content").put("midiDuration", midiFileDuration);
+                                                            } catch (JSONException e) {
+                                                                e.printStackTrace();
+                                                            } finally {
+                                                                onSendMessage(message.toString());
+                                                            }
+
+                                                        });
+                                                    } else {
+                                                        runOnUiThread(() -> {
+                                                            ToastUtils.showShort("获取文件失败");
+                                                            midiFilePath = null;
+                                                            onSendMessage(message.toString());
+                                                        });
+                                                    }
+                                                }
+
+                                                @Override
+                                                public void onError(Throwable e) {
+                                                    runOnUiThread(() -> {
+                                                        hideLoading();
+                                                        ToastUtils.showShort("文件异常");
+                                                        midiFilePath = null;
+                                                        onSendMessage(message.toString());
+                                                    });
+                                                }
+
+                                                @Override
+                                                public void onComplete() {
+
+                                                }
+                                            });
+                                }
+
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        } else {
+                            DialogUtil.showInCenter(getChildFragmentManager(), com.cooleshow.base.R.layout.accompany_permissions_popu, (holder, dialog) -> {
+                                TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                                TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                                TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
+                                tvContent.setText("请开启储存访问权限");
+                                btncancel.setOnClickListener(view1 -> {
+                                    dialog.dismiss();
+                                });
+                                btnCommit.setOnClickListener(view1 -> {
+                                    PermissionUtils.toSelfSetting(getContext());
+                                    dialog.dismiss();
+                                });
+                            });
+                        }
+                    });
+        } catch (Exception e) {
+
+        }
+    }
+
+    private String hashKeyForDisk(String key) {
+        String cacheKey;
+        try {
+            final MessageDigest mDigest = MessageDigest.getInstance("MD5");
+            mDigest.update(key.getBytes());
+            cacheKey = bytesToHexString(mDigest.digest());
+        } catch (NoSuchAlgorithmException e) {
+            cacheKey = String.valueOf(key.hashCode());
+        }
+        return cacheKey;
+    }
+
+    private String bytesToHexString(byte[] bytes) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < bytes.length; i++) {
+            String hex = Integer.toHexString(0xFF & bytes[i]);
+            if (hex.length() == 1) {
+                sb.append('0');
+            }
+            sb.append(hex);
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public void cloudPlay(JSONObject message) {
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            midiFileSpeed = obj.optInt("speed", 120);
+            midiSongId = obj.optString("songID");
+            hertz = obj.optInt("hertz", 440);
+            if (MidiPlayerUtils.getInstance().isPause()) {
+                MidiPlayerUtils.getInstance().resumePlay();
+                loopHandler.sendEmptyMessage(1);
+                onSendMessage(message.toString());
+            } else {
+                loopHandler.removeMessages(1);
+                MidiPlayerUtils.getInstance().playSound(
+                        (float) midiFileSpeed / (float) midiFileOriginalSpeed,
+                        hertz,
+                        fp -> {
+                            onSendMessage(message.toString());
+                            loopHandler.sendEmptyMessage(1);
+                        },
+                        fp -> {
+                            loopHandler.removeMessages(1);
+                            try {
+                                JSONObject content = new JSONObject();
+                                content.put("songID", obj.optString("songID"));
+                                JSONObject json = new JSONObject();
+                                json.put("api", "cloudplayed");
+                                json.put("content", content);
+                                onSendMessage(json.toString());
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        });
+                onSendMessage(message.toString());
+                loopHandler.sendEmptyMessage(1);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void cloudSuspend(JSONObject message) {
+        try {
+            MidiPlayerUtils.getInstance().pausePlay();
+            loopHandler.removeMessages(1);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                message.optJSONObject("content").put("currentTime", MidiPlayerUtils.getInstance().getCurrentPosition() * (midiFileDuration == 0 ? MidiPlayerUtils.getInstance().midiTotalTime : midiFileDuration) / MidiPlayerUtils.getInstance().getTotalLength());
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            onSendMessage(message.toString());
+        }
+
+
+    }
+
+    @Override
+    public void cloudSetCurrentTime(JSONObject message) {
+        try {
+            MidiPlayerUtils.getInstance().seekTo(message.optJSONObject("content").optInt("currentTime") * MidiPlayerUtils.getInstance().getTotalLength() / midiFileDuration);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            onSendMessage(message.toString());
+        }
+    }
+
+    @Override
+    public void cloudChangeSpeed(JSONObject message) {
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            midiFileSpeed = obj.optInt("speed", 120);
+            MidiPlayerUtils.getInstance().setSpeed((float) midiFileSpeed / (float) midiFileOriginalSpeed);
+        } catch (Exception e) {
+
+        }
+    }
+
+    @Override
+    public void cloudSwitch(JSONObject message) {
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            JSONArray array = obj.optJSONArray("parts");
+            for (int i = 0; i < MidiPlayerUtils.getInstance().getMidiTracks().size(); i++) {
+                MidiPlayerUtils.getInstance().setTrackVolume(i, 0.7f);
+            }
+            for (int i = 0; i < array.length(); i++) {
+                MidiPlayerUtils.getInstance().setTrackVolumeByName(array.optString(i), 0);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void cloudVolume(JSONObject message) {
+
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            JSONArray array = obj.optJSONArray("parts");
+            for (int i = 0; i < array.length(); i++) {
+                MidiPlayerUtils.getInstance().setTrackVolumeByName(array.optJSONObject(i).optString("name"), (float) array.optJSONObject(i).optInt("volume", 70) / 100f);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            sendMessage(message.toString());
+        } finally {
+            for (int i = 0; i < MidiPlayerUtils.getInstance().getMidiTracks().size(); i++) {
+                Log.i(TAG, "track " + i + " vol is " + MidiPlayerUtils.getInstance().getTrackVolume(i));
+            }
+        }
+    }
+
+    @Override
+    public void cloudGetMediaStatus(JSONObject message) {
+        try {
+            if (MidiPlayerUtils.getInstance().isPlaying()) {
+                message.optJSONObject("content").put("status", "play");
+            } else if (MidiPlayerUtils.getInstance().isPause()) {
+                message.optJSONObject("content").put("status", "suspend");
+            } else if (MidiPlayerUtils.getInstance().isStop()) {
+                message.optJSONObject("content").put("status", "suspend");
+            } else {
+                message.optJSONObject("content").put("status", "suspend");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            sendMessage(message.toString());
+        }
+    }
+
+    @Override
+    public void cloudDestroy(JSONObject message) {
+        try {
+            MidiPlayerUtils.getInstance().stopPlay();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            sendMessage(message.toString());
+        }
+    }
+
+    @Override
+    public void joinLiveRoom(String roomId, String teacherId) {
+
+    }
+
+    @Override
+    public void joinChatGroup(String type, String id) {
+
+    }
+
+
+    public void selectAddress(String addressJson) {
+        onSendMessage("'getAddress'," + addressJson);
+    }
+
+    @Override
+    public void paymentOrder(String orderNo, String payChannel, String payInfo) {
+        if (payChannel.equals("ali_app")) {
+            String orderInfo = payInfo;
+            final Runnable payRunnable = new Runnable() {
+                @Override
+                public void run() {
+                    PayTask alipay = new PayTask(getActivity());
+                    Map<String, String> result = alipay.payV2(orderInfo, true);
+                    Log.i("msp", result.toString());
+
+                    Message msg = new Message();
+                    msg.what = SDK_PAY_FLAG;
+                    msg.obj = result;
+                    mHandler.sendMessage(msg);
+                }
+            };
+
+            // 必须异步调用
+            Thread payThread = new Thread(payRunnable);
+            payThread.start();
+        } else {
+            //微信
+            Gson gson = new Gson();
+            WeixinPayInfo weixinPayInfo = gson.fromJson(payInfo, WeixinPayInfo.class);
+            PayReq req = new PayReq();
+            req.appId = weixinPayInfo.getAppid();
+            req.partnerId = weixinPayInfo.getPartnerid();
+            req.prepayId = weixinPayInfo.getPrepayid();
+            req.nonceStr = weixinPayInfo.getNoncestr();
+            req.timeStamp = weixinPayInfo.getTimestamp();
+            req.packageValue = weixinPayInfo.getPackageValue();
+            req.sign = weixinPayInfo.getSign();
+
+//                    req.extData			= "app data"; // optional
+            //正在前往微信支付
+            // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信
+            goPay = true;
+            api.sendReq(req);
+        }
+    }
+
+    private boolean goPay = false;
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void loadEventBus(final String event) {
+        if (goPay) {
+            if (event.equals("PAY_SUCCESS")) {
+                onSendMessage("'paymentOperation',result:SUCCESS");
+            } else if (event.equals("PAY_ERROR")) {
+                onSendMessage("'paymentOperation',result:ERROR");
+            }
+            goPay = false;
+        }
+
+    }
+
+    @SuppressLint("HandlerLeak")
+    private Handler mHandler = new Handler() {
+        @SuppressWarnings("unused")
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case SDK_PAY_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
+                    /**
+                     * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
+                     */
+                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
+                    String resultStatus = payResult.getResultStatus();
+                    // 判断resultStatus 为9000则代表支付成功
+                    if (TextUtils.equals(resultStatus, "9000")) {
+                        // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
+//                        isAlipayOk = true;
+                        ToastUtils.showShort("支付成功");
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+//                        isAlipayOk = false;
+                        // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
+//                        showAlert(VipInfoActivity.this, getString(R.string.pay_failed) + payResult.getMemo());
+                        ToastUtils.showShort("支付失败" + resultStatus);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                case SDK_AUTH_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    AuthResult authResult = new AuthResult((Map<String, String>) msg.obj, true);
+                    String resultStatus = authResult.getResultStatus();
+
+                    // 判断resultStatus 为“9000”且result_code
+                    // 为“200”则代表授权成功,具体状态码代表含义可参考授权接口文档
+                    if (TextUtils.equals(resultStatus, "9000") && TextUtils.equals(authResult.getResultCode(), "200")) {
+                        // 获取alipay_open_id,调支付时作为参数extern_token 的value
+                        // 传入,则支付账户为该授权账户
+//                        showAlert(MainActivity.this, getString(R.string.auth_success) + authResult);
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+                        // 其他状态值则为授权失败
+//                        showAlert(MainActivity.this, getString(R.string.auth_failed) + authResult);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+
+    };
+
+
+
+    @Override
+    public void cloudMetronome(JSONObject message) {
+        try {
+            JSONObject obj = message.optJSONObject("content");
+            int repeat = obj.optInt("repeat", 1);
+            int denominator = obj.optInt("denominator", 4);
+            int numerator = obj.optInt("repeat", 4);
+            if (soundpool != null) {
+                soundpool.release();
+                soundpool = null;
+            }
+            isReady = false;
+            HashMap<Integer, Integer> map = new HashMap<>();
+            if (numerator == 2) {
+                soundpool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
+                map.put(0, soundpool.load(getContext(), com.cooleshow.base.R.raw.midstrong, 1));
+                map.put(1, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+            } else if (numerator == 3) {
+                soundpool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
+                map.put(0, soundpool.load(getContext(), com.cooleshow.base.R.raw.midstrong, 1));
+                map.put(1, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(2, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+            } else if (numerator == 6) {
+                soundpool = new SoundPool(6, AudioManager.STREAM_MUSIC, 0);
+                map.put(0, soundpool.load(getContext(), com.cooleshow.base.R.raw.midstrong, 1));
+                map.put(1, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(2, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(3, soundpool.load(getContext(), com.cooleshow.base.R.raw.midstrong, 1));
+                map.put(4, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(5, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+            } else {
+                soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
+                map.put(0, soundpool.load(getContext(), com.cooleshow.base.R.raw.midstrong, 1));
+                map.put(1, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(2, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+                map.put(3, soundpool.load(getContext(), com.cooleshow.base.R.raw.feeble, 1));
+            }
+            int speed;
+            if (denominator == 4) {
+                if (midiFileSpeed > 0) {
+                    speed = midiFileSpeed;
+                } else {
+                    speed = 60;
+                }
+            } else {
+                if (midiFileSpeed * 2 > 0) {
+                    speed = midiFileSpeed * 2;
+                } else {
+                    speed = 60;
+                }
+            }
+            long sleepTime = (long) (60000.0 / (speed));
+            showCountDownDialog(map.size(), message);
+            new Thread(() -> {
+                playPreSound(map, sleepTime, repeat);
+                //播放完成开始录音
+                runOnUiThread(() -> {
+                    if (null != preCountDialog) {
+                        preCountDialog.dismiss();
+                    }
+                    if (soundpool != null) {
+                        try {
+                            message.optJSONObject("content").put("status", "finish");
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                        onSendMessage(message.toString());
+                    }
+                });
+            }).start();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private CommonDialog preCountDialog;
+    private ImageView iv1;
+    private ImageView iv2;
+    private ImageView iv3;
+    private ImageView iv4;
+    private ImageView iv5;
+    private ImageView iv6;
+
+    private void showCountDownDialog(int count, JSONObject message) {
+        //弹出预备拍
+        preCountDialog = CommonDialog.init().setLayoutId(com.cooleshow.base.R.layout.dialog_student_precount);
+        preCountDialog.setConvertListener(new ViewConvertListener() {
+                    @Override
+                    public void convertView(ViewHolder holder, BaseDialog dialog) {
+                        if (count == 2) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv3.setVisibility(View.INVISIBLE);
+                            iv4.setVisibility(View.INVISIBLE);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        } else if (count == 3) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv4.setVisibility(View.INVISIBLE);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        } else if (count == 4) {
+                            iv1 = holder.getView(com.cooleshow.base.R.id.iv_2);
+                            iv2 = holder.getView(com.cooleshow.base.R.id.iv_3);
+                            iv3 = holder.getView(com.cooleshow.base.R.id.iv_4);
+                            iv4 = holder.getView(com.cooleshow.base.R.id.iv_5);
+                            iv5 = holder.getView(com.cooleshow.base.R.id.iv_1);
+                            iv6 = holder.getView(com.cooleshow.base.R.id.iv_6);
+                            iv5.setVisibility(View.INVISIBLE);
+                            iv6.setVisibility(View.INVISIBLE);
+                        }
+                        iv1.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv2.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv3.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv4.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv5.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        iv6.setImageResource(com.cooleshow.base.R.drawable.bg_play_metronome_gray_dots_shape);
+                        ImageView iv_dialog_student_precount = holder.getView(com.cooleshow.base.R.id.iv_dialog_student_precount);
+                        iv_dialog_student_precount.setOnClickListener(v -> {
+                            dialog.dismiss();
+                            if (soundpool != null) {
+                                soundpool.release();
+                                soundpool = null;
+                            }
+                            try {
+                                message.optJSONObject("content").put("status", "cancel");
+                            } catch (JSONException e) {
+                                e.printStackTrace();
+                            }
+                            onSendMessage(message.toString());
+                        });
+                    }
+                })
+                .setDimAmount(0.6f)
+                .setOutCancel(true)
+                .setGravity(Gravity.CENTER)
+                .show(getChildFragmentManager());
+    }
+
+    private void changeImageState(int size, int now) {
+        if (null != preCountDialog && preCountDialog.isVisible()) {
+            int resId = -1;
+            if (now < size) {
+                resId = com.cooleshow.base.R.drawable.bg_play_metronome_white_dots_shape;
+            }
+            now = now % size;
+            if (now == 0) {
+                iv1.setImageResource( com.cooleshow.base.R.drawable.bg_play_metronome_green_dots_shape);
+            } else if (now == 1) {
+                iv2.setImageResource(resId);
+            } else if (now == 2) {
+                iv3.setImageResource(resId);
+            } else if (now == 3) {
+                iv4.setImageResource(resId);
+            } else if (now == 4) {
+                iv5.setImageResource(resId);
+            } else if (now == 5) {
+                iv6.setImageResource(resId);
+            }
+        }
+    }
+
+    private void playPreSound(HashMap<Integer, Integer> map, long sleepTime, int repeat) {
+        SystemClock.sleep(500);
+        repeat--;
+        for (int i = 0; i < map.size(); i++) {
+            if (!isReady) {
+                SystemClock.sleep(sleepTime);
+                if (soundpool != null) {
+                    soundpool.play(map.get(i), 1, 1, 0, 0, 1);
+                    int finalI = i;
+                    runOnUiThread(() -> changeImageState(map.size(), finalI));
+                } else {
+                    return;
+                }
+            }
+        }
+        if (repeat > 0) {
+            playPreSound(map, sleepTime, repeat);
+        } else {
+            SystemClock.sleep(sleepTime);
+        }
+    }
+
+
+    private Handler loopHandler = new Handler() {
+        @Override
+        public void handleMessage(@NotNull Message msg) {
+            super.handleMessage(msg);
+            if (msg.what == 1) {
+                checkPrecess();
+                loopHandler.removeMessages(1);
+                loopHandler.sendEmptyMessageDelayed(1, processInterval);
+            }
+        }
+    };
+
+    private void checkPrecess() {
+        if (!MidiPlayerUtils.getInstance().isPlaying()) {
+            return;
+        }
+        long dur = MidiPlayerUtils.getInstance().getCurrentPosition() * (midiFileDuration == 0 ? MidiPlayerUtils.getInstance().midiTotalTime : midiFileDuration) / MidiPlayerUtils.getInstance().getTotalLength();
+        try {
+            if (TextUtils.isEmpty(midiSongId)) {
+                return;
+            }
+            JSONObject content = new JSONObject();
+            content.put("currentTime", dur);
+            content.put("songID", midiSongId);
+            JSONObject json = new JSONObject();
+            json.put("api", "cloudTimeUpdae");
+            json.put("content", content);
+            onSendMessage(json.toString());
+        } catch (Exception e) {
+
+        }
+
+    }
+}

+ 334 - 119
student/src/main/java/com/cooleshow/student/ui/web/HtmlActivity.java

@@ -3,14 +3,16 @@ package com.cooleshow.student.ui.web;
 import static com.cooleshow.base.common.WebConstants.WEB_URL;
 
 import android.Manifest;
-import android.content.ActivityNotFoundException;
+import android.annotation.SuppressLint;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
 import android.text.TextUtils;
 import android.util.Base64;
 import android.util.Log;
@@ -33,29 +35,34 @@ import android.widget.ProgressBar;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
-import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.constraintlayout.widget.ConstraintLayout;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
-import com.alibaba.android.arouter.launcher.ARouter;
+import com.alipay.sdk.app.PayTask;
+import com.cooleshow.base.BuildConfig;
+import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseActivity;
-import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
-import com.cooleshow.base.utils.SPUtils;
 import com.cooleshow.base.utils.ToastUtils;
+import com.cooleshow.base.utils.UriUtils;
+import com.cooleshow.base.utils.helper.upload.UploadHelper;
 import com.cooleshow.base.widgets.DialogUtil;
-import com.cooleshow.base.widgets.LollipopFixedWebView;
+import com.cooleshow.student.App;
 import com.cooleshow.student.R;
 import com.cooleshow.student.api.APIService;
-import com.cooleshow.student.databinding.ActivityHtmlBinding;
-import com.cooleshow.student.databinding.ActivityHtmlWebBinding;
-import com.cooleshow.student.utils.JsInterfaceUtils;
-import com.cooleshow.student.widgets.helper.JsInterfaceHelper;
+import com.cooleshow.student.bean.alipay.AuthResult;
+import com.cooleshow.student.bean.alipay.PayResult;
+import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
+import com.cooleshow.student.databinding.ActivityHtml1Binding;
+import com.cooleshow.student.widgets.FileUtils;
+import com.cooleshow.student.widgets.LollipopFixedWebView;
+import com.cooleshow.student.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.daya.live_teaching.utils.GlideEngine;
+import com.google.gson.Gson;
 import com.gyf.immersionbar.ImmersionBar;
 import com.luck.picture.lib.PictureSelector;
 import com.luck.picture.lib.config.PictureConfig;
@@ -63,34 +70,38 @@ import com.luck.picture.lib.config.PictureMimeType;
 import com.luck.picture.lib.entity.LocalMedia;
 import com.luck.picture.lib.tools.PictureFileUtils;
 import com.tbruyelle.rxpermissions3.RxPermissions;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
-import org.jetbrains.annotations.NotNull;
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.UnsupportedEncodingException;
-import java.lang.ref.WeakReference;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 import okhttp3.ResponseBody;
 
-/**
- * 创建日期:2022/6/7 14:45
- *
- * @author Ryan
- * 类说明:
- */
-
-public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implements JsInterfaceUtils.onGetMethodsListener {
+@Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
+public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements JsInterfaceUtils.onGetMethodsListener {
+    private static final int REQUEST_CODE_FILE_CHOOSER = 500;
+    public static final String TAG = "HtmlActivity";
+    private IWXAPI api;
+    private static final int SDK_PAY_FLAG = 1;
+    private static final int SDK_AUTH_FLAG = 2;
 
     ConstraintLayout headerBbarView;
     View view;
@@ -106,6 +117,30 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
     RelativeLayout rl_activity_html;
     LinearLayout ll_activity_html;
 
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        EventBus.getDefault().register(this);
+        api = WXAPIFactory.createWXAPI(this, null);
+        api.registerApp("wx149a928c415c137a");
+    }
+
+    private void initViewLayout() {
+        headerBbarView = viewBinding.headerBarView;
+        view = viewBinding.view;
+        viewStatusbar = viewBinding.viewStatusbar;
+        btnBack = viewBinding.btnBack;
+        btnClose = viewBinding.btnClose;
+        ivAction = viewBinding.ivAction;
+        tvTitle = viewBinding.tvTitle;
+        tvAction = viewBinding.tvAction;
+        viewParent = viewBinding.viewParent;
+        mLayout = viewBinding.flVideo;
+        progressBar = viewBinding.progressBar;
+        rl_activity_html = viewBinding.rlActivityHtml;
+        ll_activity_html = viewBinding.llActivityHtml;
+    }
+
     WebView webView;
     private String url;
     private String webViewUrl;
@@ -117,29 +152,18 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
     private String authorization;
     private final int PORTRAIT_REQUEST_CODE = 1002;
     private final int ADD_ACCOMPANIMENT_CODE = 1003;
-//    private ShareAction mShareAction;
+    //    private ShareAction mShareAction;
     int ivActionIcon = -1;
     int startType = -1;
 
-
-
+    @Override
+    protected ActivityHtml1Binding getLayoutView() {
+        return ActivityHtml1Binding.inflate(getLayoutInflater());
+    }
 
     @Override
     protected void initView() {
-        headerBbarView=viewBinding.headerBarView;
-        view=viewBinding.view;
-        viewStatusbar=viewBinding.viewStatusbar;
-        btnBack=viewBinding.btnBack;
-        btnClose=viewBinding.btnClose;
-        ivAction=viewBinding.ivAction;
-        tvTitle=viewBinding.tvTitle;
-        tvAction=viewBinding.tvAction;
-        viewParent=viewBinding.viewParent;
-        mLayout=viewBinding.flVideo;
-        progressBar=viewBinding.progressBar;
-        rl_activity_html=viewBinding.rlActivityHtml;
-        ll_activity_html=viewBinding.llActivityHtml;
-
+        initViewLayout();
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
         Intent intent = getIntent();
@@ -147,17 +171,12 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         String titleStr = intent.getStringExtra("title");
         ivActionIcon = intent.getIntExtra("ivAction", -1);
         startType = intent.getIntExtra("startType", -1);
-      /*  if (ivActionIcon > 0 && 1000 == startType) {
-            ivAction.setImageResource(ivActionIcon);
-            ivAction.setVisibility(View.VISIBLE);
-            ivAction.setOnClickListener(v -> startActivityForResult(new Intent(this, AddAccompanimentActivity.class), ADD_ACCOMPANIMENT_CODE));
-        }*/
         content = intent.getStringExtra("content");
         //        bean = (PayBean) intent.getSerializableExtra("bean");
         isGoback = intent.getBooleanExtra("isGoback", true);
         boolean isHideTitle = intent.getBooleanExtra("isHideTitle", false);
         if (intent.getBooleanExtra("is_refresh", false)) {
-//            BaseApplication.isRefresh = true;
+            App.isRefresh = true;
         }
         boolean isOpenLight = intent.getBooleanExtra("isOpenLight", false);
 
@@ -212,13 +231,12 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         JsInterfaceUtils jsInterfaceUtils = new JsInterfaceUtils(HtmlActivity.this);
         jsInterfaceUtils.setOnItemClickListener(this);
 
-        webView.addJavascriptInterface(jsInterfaceUtils, "DAYA");
+        webView.addJavascriptInterface(jsInterfaceUtils, WebConstants.WEB_JS_INTERFACE);
         webView.setWebViewClient(new WebClient());
         webView.setWebChromeClient(new MyWebChromeClient());
 
-        String tokenType = SPUtils.getInstance().getString(UserHelper.USER_TOKEN_TYPE,"bearer");
-        String accessType = UserHelper.getUserToken();
-        Authorization = TextUtils.isEmpty(tokenType) ? null : tokenType + " " + accessType;
+        String userToken = UserHelper.getUserToken();
+        Authorization = TextUtils.isEmpty(userToken) ? null : userToken;
         if (!TextUtils.isEmpty(Authorization)) {
             try {
                 authorization = URLEncoder.encode(Authorization, "UTF-8");
@@ -236,17 +254,18 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
             webView.loadUrl(url);
         }
 //        mShareListener = new CustomShareListener(this);
-
     }
+
+
 //    private UMShareListener mShareListener;
 
+
     @Override
     protected void onResume() {
         super.onResume();
-       /* if (null != webView && BaseApplication.isRefresh) {
-            String tokenType = SharedPreferenceUtil.read(Constants.TOKEN_TYPE, "");
-            String accessType = SharedPreferenceUtil.read(Constants.ACCESS_TOKEN, "");
-            Authorization = TextUtils.isEmpty(tokenType) ? null : tokenType + " " + accessType;
+        if (null != webView && App.isRefresh) {
+            String userToken = UserHelper.getUserToken();
+            Authorization = TextUtils.isEmpty(userToken) ? null : userToken;
             if (!TextUtils.isEmpty(Authorization)) {
                 try {
                     authorization = URLEncoder.encode(Authorization, "UTF-8");
@@ -261,15 +280,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                 }
             }
             webView.loadUrl(webViewUrl);
-            BaseApplication.isRefresh = false;
-            Log.d("MainActivityTAG", "Htmlactivity() called  MyAPP.isRefresh==  " + BaseApplication.isRefresh);
-        }*/
+            App.isRefresh = false;
+        }
     }
 
     private void initWebView() {
         //声明WebSettings子类
         WebSettings webSettings = webView.getSettings();
-        webSettings.setUserAgentString(webSettings.getUserAgentString() + ";DAYAAPPA");
+        webSettings.setUserAgentString(webSettings.getUserAgentString() + WebConstants.WEB_UA_PARAMS);
         webSettings.setGeolocationDatabasePath(getApplicationContext().getFilesDir().getPath());
         webSettings.setGeolocationEnabled(true);
         webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
@@ -308,23 +326,16 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         webSettings.setGeolocationDatabasePath(this.getDir("geolocation", 0)
                 .getPath());
         webSettings.setPluginState(WebSettings.PluginState.ON_DEMAND);
-      /*  if (BaseApplication.isDebug || "debug".equals(BaseApplication.channel)) {
+        if (BuildConfig.DEBUG) {
             webView.setWebContentsDebuggingEnabled(true);
-        }*/
-        webView.setWebContentsDebuggingEnabled(true);
+        }
         webSettings.setTextZoom(100);//设置字体默认的缩放比例,以避免手机系统的字体修改对页面字体及布局造成影响。
         webView.setHorizontalScrollBarEnabled(false);
         webView.setVerticalScrollBarEnabled(false);
         webView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> {
             downloadFile(url);
-
         });
     }
-    @Override
-    protected ActivityHtmlWebBinding getLayoutView() {
-        return ActivityHtmlWebBinding.inflate(getLayoutInflater());
-    }
-
 
     @Override
     public void downloadFile(String url) {
@@ -344,17 +355,16 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                                     ToastUtils.showShort("文件异常");
                                     return;
                                 }
-                                String path = MyFileUtils.getPublicDirectory("file");
+                                String path = FileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
-
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
+                                String type = FileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
-                                    ToastUtils.showShort("文件异暂不支持该文件保存");
+                                    ToastUtils.showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -369,14 +379,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -399,11 +409,11 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                 String imageBase64 = content.getString("image");
                 /*增加自定义按钮的分享面板*/
                /* mShareAction = new ShareAction(HtmlActivity.this).setDisplayList(
-                                SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.SINA)
+                        SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.SINA)
                         .setShareboardclickCallback(new ShareBoardlistener() {
                             @Override
                             public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
-                                UMImage image = new UMImage(mContext, MyFileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
                                 image.setThumb(image);
                                 image.compressStyle = UMImage.CompressStyle.SCALE;
                                 new ShareAction(HtmlActivity.this).withMedia(image)
@@ -499,17 +509,169 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
     }
 
     @Override
-    public void openMusicEvaluate(JSONObject message) {
-      /*  try {
-            String teacherRole = message.getJSONObject("content").optString("masterTeacherFlag");
-            ARouter.getInstance().build(ARouterTeacher.ACTIVITY_TEACHER_SIGN_BANK)
-                    .withString("courseID", message.getJSONObject("content").optString("courseScheduleId"))
-                    .withString("teacherRole",  "1".equals(teacherRole)?"BISHOP":"")
-                    .withString("ASSIGN_HOMEWORK","")
-                    .navigation();
+    public void joinLiveRoom(String roomId, String teacherId) {
+
+    }
+
+    @Override
+    public void joinChatGroup(String type, String id) {
+
+    }
+
+
+    public void selectAddress(String addressJson) {
+        onSendMessage("'getAddress'," + addressJson);
+    }
+
+    @Override
+    public void paymentOrder(String orderNo, String payChannel, String payInfo) {
+        if (payChannel.equals("ali_app")) {
+            String orderInfo = payInfo;
+            final Runnable payRunnable = new Runnable() {
+                @Override
+                public void run() {
+                    PayTask alipay = new PayTask(HtmlActivity.this);
+                    Map<String, String> result = alipay.payV2(orderInfo, true);
+                    Log.i("msp", result.toString());
+
+                    Message msg = new Message();
+                    msg.what = SDK_PAY_FLAG;
+                    msg.obj = result;
+                    mHandler.sendMessage(msg);
+                }
+            };
+
+            // 必须异步调用
+            Thread payThread = new Thread(payRunnable);
+            payThread.start();
+        } else {
+            //微信
+            Gson gson = new Gson();
+            WeixinPayInfo weixinPayInfo = gson.fromJson(payInfo, WeixinPayInfo.class);
+            PayReq req = new PayReq();
+            req.appId = weixinPayInfo.getAppid();
+            req.partnerId = weixinPayInfo.getPartnerid();
+            req.prepayId = weixinPayInfo.getPrepayid();
+            req.nonceStr = weixinPayInfo.getNoncestr();
+            req.timeStamp = weixinPayInfo.getTimestamp();
+            req.packageValue = weixinPayInfo.getPackageValue();
+            req.sign = weixinPayInfo.getSign();
+
+//                    req.extData			= "app data"; // optional
+            //正在前往微信支付
+            // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信
+            goPay = true;
+            api.sendReq(req);
+        }
+    }
+
+    private boolean goPay = false;
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void loadEventBus(final String event) {
+        if (goPay) {
+            if (event.equals("PAY_SUCCESS")) {
+                onSendMessage("'paymentOperation',result:SUCCESS");
+            } else if (event.equals("PAY_ERROR")) {
+                onSendMessage("'paymentOperation',result:ERROR");
+            }
+            goPay = false;
+        }
+
+    }
+
+
+    @SuppressLint("HandlerLeak")
+    private Handler mHandler = new Handler() {
+        @SuppressWarnings("unused")
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case SDK_PAY_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
+                    /**
+                     * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
+                     */
+                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
+                    String resultStatus = payResult.getResultStatus();
+                    // 判断resultStatus 为9000则代表支付成功
+                    if (TextUtils.equals(resultStatus, "9000")) {
+                        // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
+//                        isAlipayOk = true;
+                        ToastUtils.showShort("支付成功");
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+//                        isAlipayOk = false;
+                        // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
+//                        showAlert(VipInfoActivity.this, getString(R.string.pay_failed) + payResult.getMemo());
+                        ToastUtils.showShort("支付失败" + resultStatus);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                case SDK_AUTH_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    AuthResult authResult = new AuthResult((Map<String, String>) msg.obj, true);
+                    String resultStatus = authResult.getResultStatus();
+
+                    // 判断resultStatus 为“9000”且result_code
+                    // 为“200”则代表授权成功,具体状态码代表含义可参考授权接口文档
+                    if (TextUtils.equals(resultStatus, "9000") && TextUtils.equals(authResult.getResultCode(), "200")) {
+                        // 获取alipay_open_id,调支付时作为参数extern_token 的value
+                        // 传入,则支付账户为该授权账户
+//                        showAlert(MainActivity.this, getString(R.string.auth_success) + authResult);
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+                        // 其他状态值则为授权失败
+//                        showAlert(MainActivity.this, getString(R.string.auth_failed) + authResult);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+
+    };
+
+
+    @Override
+    public void chooseFile(JSONObject message) {
+        baseJsonObject = message;
+        showFileChooser();
+
+    }
+
+    private JSONObject baseJsonObject;
+
+    private void showFileChooser() {
+        JSONObject content = (JSONObject) baseJsonObject.opt("content");
+        String type = "";
+        try {
+            type = content.getString("type");
         } catch (JSONException e) {
             e.printStackTrace();
-        }*/
+        }
+        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+//       type: "img" | "video" | "file" | "midi" | "mp3" | "xml"
+        if (type.equals("img")) {
+            intent.setType("image/*");
+        } else if (type.equals("video")) {
+            intent.setType("video/*");
+        } else if (type.equals("mp3")) {
+            intent.setType("audio/*");
+        } else if (type.equals("xml")) {
+            intent.setType("text/xml");
+        } else if (type.equals("midi")) {
+            intent.setType("audio/midi");
+        } else {
+            intent.setType("*/*");
+        }
+        intent.addCategory(Intent.CATEGORY_OPENABLE);
+        intent.putExtra(Intent.EXTRA_TITLE, "File Chooser");
+        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+        startActivityForResult(intent, REQUEST_CODE_FILE_CHOOSER);
     }
 
     public void decoderBase64File(String base64Code, String savePath, String type) {
@@ -529,7 +691,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
 
 
     private void upDateNewsVideoFile(String filePath, String fileName, String url, String type) {
-        showLoading();
+//        showUploadLoading("下载中");
         RetrofitClientNoToken.getInstance().getRetrofit().create(APIService.class)
                 .downloadFileWithFixedUrl(url)
                 .subscribeOn(Schedulers.io())
@@ -542,7 +704,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -563,7 +725,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = MyFileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
+                                            Intent intent = FileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {
@@ -638,9 +800,9 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         public void onPageFinished(WebView view, String url) {
             super.onPageFinished(view, url);
             webViewUrl = url;
-            if (!TextUtils.isEmpty(Authorization)) {
-                String js = "window.localStorage.setItem('Authorization','" + Authorization + "');";
-                String jsUrl = "javascript:(function({var localStorage = window.localStorage; localStorage.setItem('Authorization','" + Authorization + "') })()";
+            if (!TextUtils.isEmpty(authorization)) {
+                String js = "window.localStorage.setItem('Authorization','" + authorization + "');";
+                String jsUrl = "javascript:(function({var localStorage = window.localStorage; localStorage.setItem('Authorization','" + authorization + "') })()";
                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                     view.evaluateJavascript(js, null);
                 } else {
@@ -649,15 +811,6 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                 }
             }
 
-            //            if (!TextUtils.isEmpty(vipGroupId)) {
-            //                bean.setVipGroupId(vipGroupId);
-            //                LOG.e(new Gson().toJson(bean));
-            //                webView.evaluateJavascript("javascript:sendMessage(" + new Gson().toJson(bean) + ")", value -> {
-            //                });
-            //
-            //            }
-
-
         }
 
         //截取url请求,在当前视图加载,避免在跳转到自带浏览器
@@ -668,9 +821,9 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                     Intent intent = new Intent();
                     intent.setAction(Intent.ACTION_VIEW);
                     intent.setData(Uri.parse(request));
-                    startActivity(intent);
-                } catch (ActivityNotFoundException e) {
-                    ToastUtils.showShort("未安装该应用");
+                    view.getContext().startActivity(intent);
+                } catch (Exception e) {
+                    e.printStackTrace();
                 }
                 return true;
             } else {
@@ -711,7 +864,6 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
 
         @Override
         public void onProgressChanged(WebView view, int newProgress) {
-
             if (newProgress == 100 && null != progressBar) {
                 if (null != progressBar) {
                     progressBar.setVisibility(View.GONE);//加载完网页进度条消失
@@ -819,10 +971,10 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                                 .forResult(PictureConfig.CHOOSE_REQUEST);
                     } else {
                         DialogUtil.showInCenter(getSupportFragmentManager(), com.cooleshow.base.R.layout.common_popu, (holder, dialog) -> {
-                            TextView tvTitle = holder.getView(R.id.tv_title);
-                            TextView tvContent = holder.getView(R.id.tv_content);
-                            TextView btncancel = holder.getView(R.id.btn_cancel);
-                            TextView btnCommit = holder.getView(R.id.btn_commit);
+                            TextView tvTitle = holder.getView(com.cooleshow.base.R.id.tv_title);
+                            TextView tvContent = holder.getView(com.cooleshow.base.R.id.tv_content);
+                            TextView btncancel = holder.getView(com.cooleshow.base.R.id.btn_cancel);
+                            TextView btnCommit = holder.getView(com.cooleshow.base.R.id.btn_commit);
                             tvTitle.setText("提示");
                             tvContent.setText("选择照片需要相机、储存权限,去设置?");
                             btncancel.setOnClickListener(view1 -> {
@@ -850,9 +1002,8 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
             } catch (JSONException e) {
                 e.printStackTrace();
             }
-        }
-        if (data != null) {
-            if (requestCode == 1000) {
+        } else if (requestCode == 1000) {
+            if (data != null) {
                 try {
                     String filePath = data.getStringExtra("filePath");
                     JSONObject jsonObject = new JSONObject();
@@ -881,13 +1032,71 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                     mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
                 }
                 mUploadCallbackAboveL = null;
+
+            } else {
+                if (mUploadCallbackAboveL != null)
+                    mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
             }
-        } else {
-            if (mUploadCallbackAboveL != null)
-                mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
+        } else if (requestCode == REQUEST_CODE_FILE_CHOOSER) {
+            Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
+            if (result != null) {
+                File file = UriUtils.uri2File(result);
+                if (file != null && file.exists()) {
+                    UploadHelper uploadHelper = new UploadHelper(HtmlActivity.this);
+                    uploadHelper.uploadFile(file);
+                    uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
+                        @Override
+                        public void onSuccess(String url) {
+                            try {
+                                JSONObject jsonObject = new JSONObject();
+                                JSONObject contentObj = baseJsonObject.getJSONObject("content");
+                                String uuid = contentObj.getString("uuid");
+                                jsonObject.put("type", "success");
+                                jsonObject.put("fileUrl", url);
+                                jsonObject.put("uuid", uuid);
+                                jsonObject.put("message", "上传成功");
+                                onSendMessage(jsonObject.toString());
+                            } catch (JSONException e) {
+                                e.printStackTrace();
+                            }
+                        }
+
+                        @Override
+                        public void onFailure() {
+                            ToastUtils.showShort("上传失败,请重新选择");
+                            upLoadFileFaile();
+                        }
+                    });
+                } else {
+                    ToastUtils.showShort("文件损坏或不存在,请重新选择");
+                    upLoadFileFaile();
+                }
+            } else {
+                ToastUtils.showShort("上传失败,请重新选择");
+                upLoadFileFaile();
+            }
+//            clearUploadMessage();
+            return;
+        } else if (requestCode == 1011) {
+            String selectAddress = data.getStringExtra("selectAddress");
+            selectAddress(selectAddress);
         }
+
     }
 
+    private void upLoadFileFaile() {
+        try {
+            JSONObject contentObj = baseJsonObject.getJSONObject("content");
+            String uuid = contentObj.getString("uuid");
+            contentObj.put("type", "error");
+            contentObj.put("uuid", uuid);
+            contentObj.put("message", "上传失败");
+            onSendMessage(baseJsonObject.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
 
     @Override
     protected void onDestroy() {
@@ -895,6 +1104,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         if (null != webView) {
             webView.destroy();
         }
+        EventBus.getDefault().unregister(this);
 //        UMShareAPI.get(HtmlActivity.this).release();
     }
 
@@ -915,6 +1125,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
             setStatusBlackBarColor();
         }
     }
+
     public void setStatusBarColor() {
         ImmersionBar.with(this)
                 .keyboardEnable(true)
@@ -925,13 +1136,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                 .init();  //必须调用方可沉浸
 
     }
+
     public void setStatusBlackBarColor() {
         ImmersionBar.with(this)
                 .keyboardEnable(true)
                 .transparentStatusBar()
                 .statusBarDarkFont(true, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
                 .autoDarkModeEnable(false)
-                .flymeOSStatusBarFontColor(R.color.black)  //修改flyme OS状态栏字体颜色
+                .flymeOSStatusBarFontColor(com.cooleshow.base.R.color.common_black)  //修改flyme OS状态栏字体颜色
                 .init();  //必须调用方可沉浸
     }
 
@@ -955,7 +1167,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         return super.onKeyDown(keyCode, event);
     }
 
-   /* private static class CustomShareListener implements UMShareListener {
+    /*private static class CustomShareListener implements UMShareListener {
 
         private WeakReference<HtmlActivity> mActivity;
 
@@ -972,7 +1184,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         public void onResult(SHARE_MEDIA platform) {
 
             if (platform.name().equals("WEIXIN_FAVORITE")) {
-                ToastUtils.showShort("收藏成功啦");
+                ToastUtil.getInstance().show(mActivity.get(), "收藏成功啦");
             } else {
                 if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
                         && platform != SHARE_MEDIA.EMAIL
@@ -986,7 +1198,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                         && platform != SHARE_MEDIA.GOOGLEPLUS
                         && platform != SHARE_MEDIA.YNOTE
                         && platform != SHARE_MEDIA.EVERNOTE) {
-                    ToastUtils.showShort("分享成功啦");
+                    ToastUtil.getInstance().show(mActivity.get(), "分享成功啦");
                 }
 
             }
@@ -1006,7 +1218,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
                     && platform != SHARE_MEDIA.GOOGLEPLUS
                     && platform != SHARE_MEDIA.YNOTE
                     && platform != SHARE_MEDIA.EVERNOTE) {
-                ToastUtils.showShort("分享失败啦");
+                ToastUtil.getInstance().show(mActivity.get(), "分享失败啦");
 
             }
 
@@ -1014,7 +1226,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
 
         @Override
         public void onCancel(SHARE_MEDIA platform) {
-            ToastUtils.showShort("分享取消了");
+            ToastUtil.getInstance().show(mActivity.get(), "分享取消了");
         }
     }
 
@@ -1026,4 +1238,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtmlWebBinding> implement
         }
     }*/
 
+
 }
+
+

Diff do ficheiro suprimidas por serem muito extensas
+ 351 - 0
student/src/main/java/com/cooleshow/student/ui/web/HtmlHorizontalScreenActivity.java


+ 1 - 1
student/src/main/java/com/cooleshow/student/ui/web/WebActivity.java

@@ -63,7 +63,7 @@ import java.util.List;
 /**
  * Author by pq, Date on 2022/4/24.
  */
-@Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
+
 public class WebActivity extends BaseActivity<ActivityHtmlBinding> implements JsInterfaceHelper.OnJsMethodCallListener, View.OnClickListener {
     private static final int REQUEST_CODE_FILE_CHOOSER = 500;
     private WebView webView;

+ 1626 - 0
student/src/main/java/com/cooleshow/student/widgets/FileUtils.java

@@ -0,0 +1,1626 @@
+package com.cooleshow.student.widgets;
+
+import static android.os.Environment.DIRECTORY_DOWNLOADS;
+
+import android.annotation.SuppressLint;
+import android.content.ContentUris;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Matrix;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Environment;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import android.provider.OpenableColumns;
+import android.text.TextUtils;
+import android.util.Base64;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.core.content.FileProvider;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import okhttp3.ResponseBody;
+
+/**
+ * Description:
+ * Copyright  : Copyright (c) 2019
+ * Company    : 大雅乐盟
+ * Author     : r
+ * Date       : 2019/9/6 15:07
+ */
+public class FileUtils {
+    private static final String TAG = "FileUtil";
+    private static final String filesDirectory = "guanyuemi";
+    public static final String examDownloadDirectory = "examDownload";
+
+    public static String getCacheDir(Context context) {
+        String cacheDir = context.getExternalCacheDir().getAbsolutePath();
+        return cacheDir;
+    }
+
+    public static String getCacheDir(Context context, String directory) {
+        String fileDir;
+        try {
+            File file = new File(context.getExternalCacheDir() + File.separator + directory);
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            fileDir = file.getAbsolutePath();
+            return fileDir;
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String getFilesDir(Context context) {
+        try {
+            File file = context.getExternalFilesDir(filesDirectory);
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            String fileDir = file.getAbsolutePath();
+            return fileDir;
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String getFilesDir(Context context, String directory) {
+        try {
+            File file = context.getExternalFilesDir(filesDirectory + File.separator + directory);
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            String fileDir = file.getAbsolutePath();
+            return fileDir;
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String getPublicDirectory(String path) {
+        String fileDir = null;
+        try {
+            File file = new File(Environment.getExternalStorageDirectory() + File.separator + filesDirectory);
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            fileDir = file.getAbsolutePath();
+            if (!TextUtils.isEmpty(path)) {
+                File filePath = new File(file.getPath() + File.separator + path);
+                if (!filePath.exists()) {
+                    filePath.mkdirs();
+                }
+                fileDir = filePath.getAbsolutePath();
+            }
+            return fileDir;
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String getPublicDirectoryDownload() {
+        try {
+            File file = Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS);
+            return file.getAbsolutePath();
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    /**
+     * 获取该路径下全部的文件名
+     *
+     * @param path
+     * @return
+     */
+    public static List<String> getFilesAllName(String path) {
+        File file = new File(path);
+        File[] files = file.listFiles();
+        if (files == null) {
+            Log.e("error", "空目录");
+            return null;
+        }
+        List<String> s = new ArrayList<>();
+        for (int i = 0; i < files.length; i++) {
+            s.add(files[i].getAbsolutePath());
+        }
+        return s;
+    }
+
+    public static String getBase64Type(String str) {
+        if (TextUtils.isEmpty(str)) {
+            return "";
+        }
+        String type = "";
+        switch (str) {
+            case "data:application/msword;base64":
+                type = "doc";
+            case "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64":
+                type = "docx";
+            case "data:application/vnd.ms-excel;base64":
+                type = "xls";
+            case "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64":
+                type = "xlsx";
+            case "data:application/pdf;base64":
+                type = "pdf";
+            case "data:application/vnd.ms-powerpoint;base64":
+                type = "ppt";
+            case "data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64":
+                type = "pptx";
+            case "data:text/plain;base64":
+                type = "txt";
+            case "data:image/png;base64":
+                type = "png";
+            case "data:image/jpeg;base64":
+                type = "jpg";
+        }
+        return type;
+    }
+
+    /**
+     * 从sd卡取文件
+     *
+     * @param filename
+     * @return
+     */
+    public String getFileFromSdcard(String filename) {
+        ByteArrayOutputStream outputStream = null;
+        FileInputStream fis = null;
+        try {
+            outputStream = new ByteArrayOutputStream();
+            File file = new File(Environment.getExternalStorageDirectory(), filename);
+            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
+                fis = new FileInputStream(file);
+                int len = 0;
+                byte[] data = new byte[1024];
+                while ((len = fis.read(data)) != -1) {
+                    outputStream.write(data, 0, len);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                outputStream.close();
+                fis.close();
+            } catch (IOException e) {
+            }
+        }
+        return new String(outputStream.toByteArray());
+    }
+
+    /**
+     * 保存文件到sd
+     *
+     * @param filename
+     * @param content
+     * @return
+     */
+    public static boolean saveContentToSdcard(String filename, String content) {
+        boolean flag;
+        FileOutputStream fos = null;
+        content += "\r\n";
+        try {
+            File file = new File(filename);
+            if (file.exists()) {
+                file.mkdirs();
+            }
+            fos = new FileOutputStream(file, true);
+            fos.write(content.getBytes());
+            flag = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            flag = false;
+        } finally {
+            try {
+                if (fos != null) {
+                    fos.close();
+                }
+            } catch (IOException e) {
+            }
+        }
+        return flag;
+    }
+
+    /**
+     * 保存文件到sd
+     *
+     * @param
+     * @param
+     * @return
+     */
+    public static boolean saveFileToSdcard(String mPath, InputStream inputStream) {
+        byte[] mData = null;
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            int len = 0;
+            byte[] bytes = new byte[1024];
+            while ((len = inputStream.read(bytes)) != -1) {
+                baos.write(bytes, 0, len);
+            }
+            mData = baos.toByteArray();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            FileOutputStream fos = new FileOutputStream(new File(mPath));
+            fos.write(mData, 0, mData.length);
+            return true;
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    /**
+     * 取得文件大小
+     *
+     * @param f
+     * @return
+     */
+    public static long getFileSizes(File f) {
+        long size = 0;
+        try {
+            if (f.exists()) {
+                FileInputStream fis = null;
+                fis = new FileInputStream(f);
+                size = fis.available();
+            } else {
+                f.createNewFile();
+            }
+        } catch (Exception e) {
+        }
+
+        return size;
+    }
+
+    /**
+     * 递归取得文件夹大小
+     *
+     * @param dir
+     * @return
+     * @throws Exception
+     */
+    public static long getFileSize(File dir) throws Exception {
+        long size = 0;
+        File flist[] = dir.listFiles();
+        for (int i = 0; i < flist.length; i++) {
+            if (flist[i].isDirectory()) {
+                size = size + getFileSize(flist[i]);
+            } else {
+                size = size + flist[i].length();
+            }
+        }
+        return size;
+    }
+
+    /**
+     * 转换文件大小
+     *
+     * @param fileS
+     * @return
+     */
+    public static String FormetFileSize(long fileS) {
+        DecimalFormat df = new DecimalFormat("#.00");
+        String fileSizeString = "";
+        if (fileS < 1024) {
+            fileSizeString = df.format((double) fileS) + "B";
+        } else if (fileS < 1048576) {
+            fileSizeString = df.format((double) fileS / 1024) + "K";
+        } else if (fileS < 1073741824) {
+            fileSizeString = df.format((double) fileS / 1048576) + "M";
+        } else {
+            fileSizeString = df.format((double) fileS / 1073741824) + "G";
+        }
+        return fileSizeString;
+    }
+
+    /**
+     * 递归求取目录文件个数
+     *
+     * @param f
+     * @return
+     */
+    public static long getlist(File f) {
+        long size = 0;
+        File flist[] = f.listFiles();
+        size = flist.length;
+        for (int i = 0; i < flist.length; i++) {
+            if (flist[i].isDirectory()) {
+                size = size + getlist(flist[i]);
+                size--;
+            }
+        }
+        return size;
+    }
+
+    /**
+     * 在根目录下搜索文件
+     *
+     * @param keyword
+     * @return
+     */
+    public static String searchFile(String keyword) {
+        String result = "";
+        File[] files = new File("/").listFiles();
+        for (File file : files) {
+            if (file.getName().indexOf(keyword) >= 0) {
+                result += file.getPath() + "\n";
+            }
+        }
+        if (result.equals("")) {
+            result = "找不到文件!!";
+        }
+        return result;
+    }
+
+    /**
+     *
+     */
+    public static List<String> search(File file, String[] ext) {
+        List<String> list = new ArrayList<String>();
+        if (file != null) {
+            if (file.isDirectory()) {
+                File[] listFile = file.listFiles();
+                if (listFile != null) {
+                    for (int i = 0; i < listFile.length; i++) {
+                        search(listFile[i], ext);
+                    }
+                }
+            } else {
+                String filename = file.getAbsolutePath();
+                for (int i = 0; i < ext.length; i++) {
+                    if (filename.endsWith(ext[i])) {
+                        list.add(filename);
+                        break;
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 查询文件
+     *
+     * @param file
+     * @param keyword
+     * @return
+     */
+    public static List<File> FindFile(File file, String keyword) {
+        List<File> list = new ArrayList<File>();
+        if (file.isDirectory()) {
+            File[] files = file.listFiles();
+            if (files != null) {
+                for (File tempf : files) {
+                    if (tempf.isDirectory()) {
+                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
+                            list.add(tempf);
+                        }
+                        list.addAll(FindFile(tempf, keyword));
+                    } else {
+                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
+                            list.add(tempf);
+                        }
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * searchFile 查找文件并加入到ArrayList 当中去
+     *
+     * @param context
+     * @param keyword
+     * @param filepath
+     * @return
+     */
+    public static List<Map<String, Object>> searchFile(Context context, String keyword, File filepath) {
+        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+        Map<String, Object> rowItem = null;
+        int index = 0;
+        // 判断SD卡是否存在
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+            File[] files = filepath.listFiles();
+            if (files.length > 0) {
+                for (File file : files) {
+                    if (file.isDirectory()) {
+                        if (file.getName().toLowerCase().lastIndexOf(keyword) > -1) {
+                            rowItem = new HashMap<String, Object>();
+                            rowItem.put("number", index); // 加入序列号
+                            rowItem.put("fileName", file.getName());// 加入名称
+                            rowItem.put("path", file.getPath()); // 加入路径
+                            rowItem.put("size", file.length() + ""); // 加入文件大小
+                            list.add(rowItem);
+                        }
+                        // 如果目录可读就执行(一定要加,不然会挂掉)
+                        if (file.canRead()) {
+                            list.addAll(searchFile(context, keyword, file)); // 如果是目录,递归查找
+                        }
+                    } else {
+                        // 判断是文件,则进行文件名判断
+                        try {
+                            if (file.getName().indexOf(keyword) > -1 || file.getName().indexOf(keyword.toUpperCase()) > -1) {
+                                rowItem = new HashMap<String, Object>();
+                                rowItem.put("number", index); // 加入序列号
+                                rowItem.put("fileName", file.getName());// 加入名称
+                                rowItem.put("path", file.getPath()); // 加入路径
+                                rowItem.put("size", file.length() + ""); // 加入文件大小
+                                list.add(rowItem);
+                                index++;
+                            }
+                        } catch (Exception e) {
+                        }
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 根据后缀得到文件类型
+     *
+     * @param fileName
+     * @param pointIndex
+     * @return
+     */
+    public static String getFileType(String fileName, int pointIndex) {
+        String type = fileName.substring(pointIndex + 1).toLowerCase();
+        if ("m4a".equalsIgnoreCase(type) || "xmf".equalsIgnoreCase(type) || "ogg".equalsIgnoreCase(type) || "wav".equalsIgnoreCase(type)
+                || "m4a".equalsIgnoreCase(type) || "aiff".equalsIgnoreCase(type) || "midi".equalsIgnoreCase(type)
+                || "vqf".equalsIgnoreCase(type) || "aac".equalsIgnoreCase(type) || "flac".equalsIgnoreCase(type)
+                || "tak".equalsIgnoreCase(type) || "wv".equalsIgnoreCase(type)) {
+            type = "file_audio";
+        } else if ("mp3".equalsIgnoreCase(type) || "mid".equalsIgnoreCase(type)) {
+            type = "file_mp3";
+        } else if ("avi".equalsIgnoreCase(type) || "mp4".equalsIgnoreCase(type) || "dvd".equalsIgnoreCase(type)
+                || "mid".equalsIgnoreCase(type) || "mov".equalsIgnoreCase(type) || "mkv".equalsIgnoreCase(type)
+                || "mp2v".equalsIgnoreCase(type) || "mpe".equalsIgnoreCase(type) || "mpeg".equalsIgnoreCase(type)
+                || "mpg".equalsIgnoreCase(type) || "asx".equalsIgnoreCase(type) || "asf".equalsIgnoreCase(type)
+                || "flv".equalsIgnoreCase(type) || "navi".equalsIgnoreCase(type) || "divx".equalsIgnoreCase(type)
+                || "rm".equalsIgnoreCase(type) || "rmvb".equalsIgnoreCase(type) || "dat".equalsIgnoreCase(type)
+                || "mpa".equalsIgnoreCase(type) || "vob".equalsIgnoreCase(type) || "3gp".equalsIgnoreCase(type)
+                || "swf".equalsIgnoreCase(type) || "wmv".equalsIgnoreCase(type)) {
+            type = "file_video";
+        } else if ("bmp".equalsIgnoreCase(type) || "pcx".equalsIgnoreCase(type) || "tiff".equalsIgnoreCase(type)
+                || "gif".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type) || "tga".equalsIgnoreCase(type)
+                || "exif".equalsIgnoreCase(type) || "fpx".equalsIgnoreCase(type) || "psd".equalsIgnoreCase(type)
+                || "cdr".equalsIgnoreCase(type) || "raw".equalsIgnoreCase(type) || "eps".equalsIgnoreCase(type)
+                || "gif".equalsIgnoreCase(type) || "jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)
+                || "png".equalsIgnoreCase(type) || "hdri".equalsIgnoreCase(type) || "ai".equalsIgnoreCase(type)) {
+            type = "file_image";
+        } else if ("ppt".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type) || "xls".equalsIgnoreCase(type)
+                || "pps".equalsIgnoreCase(type) || "xlsx".equalsIgnoreCase(type) || "xlsm".equalsIgnoreCase(type)
+                || "pptx".equalsIgnoreCase(type) || "pptm".equalsIgnoreCase(type) || "ppsx".equalsIgnoreCase(type)
+                || "maw".equalsIgnoreCase(type) || "mdb".equalsIgnoreCase(type) || "pot".equalsIgnoreCase(type)
+                || "msg".equalsIgnoreCase(type) || "oft".equalsIgnoreCase(type) || "xlw".equalsIgnoreCase(type)
+                || "wps".equalsIgnoreCase(type) || "rtf".equalsIgnoreCase(type) || "ppsm".equalsIgnoreCase(type)
+                || "potx".equalsIgnoreCase(type) || "potm".equalsIgnoreCase(type) || "ppam".equalsIgnoreCase(type)) {
+            type = "ic_file_office";
+        } else if ("txt".equalsIgnoreCase(type) || "text".equalsIgnoreCase(type) || "chm".equalsIgnoreCase(type)
+                || "hlp".equalsIgnoreCase(type) || "pdf".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type)
+                || "docx".equalsIgnoreCase(type) || "docm".equalsIgnoreCase(type) || "dotx".equalsIgnoreCase(type)) {
+            type = "file_text";
+        } else if ("ini".equalsIgnoreCase(type) || "sys".equalsIgnoreCase(type) || "dll".equalsIgnoreCase(type)
+                || "adt".equalsIgnoreCase(type)) {
+            type = "file_system";
+        } else if ("rar".equalsIgnoreCase(type) || "zip".equalsIgnoreCase(type) || "arj".equalsIgnoreCase(type)
+                || "gz".equalsIgnoreCase(type) || "z".equalsIgnoreCase(type) || "7Z".equalsIgnoreCase(type) || "GZ".equalsIgnoreCase(type)
+                || "BZ".equalsIgnoreCase(type) || "ZPAQ".equalsIgnoreCase(type)) {
+            type = "ic_file_rar";
+        } else if ("html".equalsIgnoreCase(type) || "htm".equalsIgnoreCase(type) || "java".equalsIgnoreCase(type)
+                || "php".equalsIgnoreCase(type) || "asp".equalsIgnoreCase(type) || "aspx".equalsIgnoreCase(type)
+                || "jsp".equalsIgnoreCase(type) || "shtml".equalsIgnoreCase(type) || "xml".equalsIgnoreCase(type)) {
+            type = "file_web";
+        } else if ("exe".equalsIgnoreCase(type) || "com".equalsIgnoreCase(type) || "bat".equalsIgnoreCase(type)
+                || "iso".equalsIgnoreCase(type) || "msi".equalsIgnoreCase(type)) {
+            type = "file_exe";
+        } else if ("apk".equalsIgnoreCase(type)) {
+            type = "ic_file_apk";
+        } else {
+            type = "ic_file_normal";
+        }
+        return type;
+    }
+
+    /**
+     * 改变文件大小显示的内容
+     *
+     * @param size
+     * @return
+     */
+    public static String changeFileSize(String size) {
+        if (Integer.parseInt(size) > 1024) {
+            size = Integer.parseInt(size) / 1024 + "K";
+        } else if (Integer.parseInt(size) > (1024 * 1024)) {
+            size = Integer.parseInt(size) / (1024 * 1024) + "M";
+        } else if (Integer.parseInt(size) > (1024 * 1024 * 1024)) {
+            size = Integer.parseInt(size) / (1024 * 1024 * 1024) + "G";
+        } else {
+            size += "B";
+        }
+        return size;
+    }
+
+    /**
+     * 得到所有文件
+     *
+     * @param dir
+     * @return
+     */
+    public static ArrayList<File> getAllFiles(File dir) {
+        ArrayList<File> allFiles = new ArrayList<File>();
+        // 递归取得目录下的所有文件及文件夹
+        File[] files = dir.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            File file = files[i];
+            allFiles.add(file);
+            if (file.isDirectory()) {
+                getAllFiles(file);
+            }
+        }
+        return allFiles;
+    }
+
+    /**
+     * 判断文件MimeType 类型
+     *
+     * @param f
+     * @return
+     */
+    public static String getMIMEType(File f) {
+        String type = "";
+        String fName = f.getName();
+        /* 取得扩展名 */
+        String end = fName.substring(fName.lastIndexOf(".") + 1, fName.length()).toLowerCase();
+        /* 依扩展名的类型决定MimeType */
+        if (end.equalsIgnoreCase("m4a") || end.equalsIgnoreCase("mp3") || end.equalsIgnoreCase("mid") || end.equalsIgnoreCase("xmf")
+                || end.equalsIgnoreCase("ogg") || end.equalsIgnoreCase("wav")) {
+            type = "audio";
+        } else if (end.equalsIgnoreCase("3gp") || end.equalsIgnoreCase("mp4")) {
+            type = "video";
+        } else if (end.equalsIgnoreCase("jpg") || end.equalsIgnoreCase("gif") || end.equalsIgnoreCase("png")
+                || end.equalsIgnoreCase("jpeg") || end.equalsIgnoreCase("bmp")) {
+            type = "image";
+        } else if (end.equalsIgnoreCase("apk")) {
+            /* android.permission.INSTALL_PACKAGES */
+            type = "application/vnd.android.package-archive";
+        } else if (end.equalsIgnoreCase("txt") || end.equalsIgnoreCase("java")) {
+            /* android.permission.INSTALL_PACKAGES */
+            type = "text";
+        } else {
+            type = "*";
+        }
+        /* 如果无法直接打开,就跳出软件列表给用户选择 */
+        if (end.equalsIgnoreCase("apk")) {
+        } else {
+            type += "/*";
+        }
+        return type;
+    }
+
+    /**
+     * 拷贝文件
+     *
+     * @param fromFile
+     * @param toFile
+     * @throws IOException
+     */
+    public static void copyFile(File fromFile, String toFile) throws IOException {
+        FileInputStream from = null;
+        FileOutputStream to = null;
+        try {
+            from = new FileInputStream(fromFile);
+            to = new FileOutputStream(toFile);
+            byte[] buffer = new byte[1024];
+            int bytesRead;
+            while ((bytesRead = from.read(buffer)) != -1)
+                to.write(buffer, 0, bytesRead); // write
+        } finally {
+            if (from != null)
+                try {
+                    from.close();
+                } catch (IOException e) {
+                    Log.e(TAG, "", e);
+                }
+            if (to != null)
+                try {
+                    to.close();
+                } catch (IOException e) {
+                    Log.e(TAG, "", e);
+                }
+        }
+    }
+
+    /**
+     * 创建文件
+     *
+     * @param file
+     * @return
+     */
+    public static File createNewFile(File file) {
+        try {
+            if (file.exists()) {
+                return file;
+            }
+            File dir = file.getParentFile();
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            if (!file.exists()) {
+                file.createNewFile();
+            }
+        } catch (IOException e) {
+            Log.e(TAG, "", e);
+            return null;
+        }
+        return file;
+    }
+
+    /**
+     * 创建文件
+     *
+     * @param path
+     */
+    public static File createNewFile(String path) {
+        File file = new File(path);
+        return createNewFile(file);
+    }// end method createText()
+
+    /**
+     * 删除文件
+     *
+     * @param path
+     */
+    public static void deleteFile(String path) {
+        if (TextUtils.isEmpty(path)) {
+            return;
+        }
+        File file = new File(path);
+        deleteFile(file);
+    }
+
+    /**
+     * 删除文件
+     *
+     * @param file
+     */
+    public static void deleteFile(File file) {
+        try {
+            if (!file.exists()) {
+                return;
+            }
+            if (file.isFile()) {
+                file.delete();
+            } else if (file.isDirectory()) {
+                File files[] = file.listFiles();
+                for (int i = 0; i < files.length; i++) {
+                    deleteFile(files[i]);
+                }
+            }
+            file.delete();
+        } catch (Exception e) {
+        }
+
+    }
+
+    /**
+     * 向Text文件中写入内容
+     *
+     * @param content
+     * @return
+     */
+    public static boolean write(String path, String content) {
+        return write(path, content, false);
+    }
+
+    public static boolean write(String path, String content, boolean append) {
+        return write(new File(path), content, append);
+    }
+
+    public static boolean write(File file, String content) {
+        return write(file, content, false);
+    }
+
+    /**
+     * 写入文件
+     *
+     * @param file
+     * @param content
+     * @param append
+     * @return
+     */
+    public static boolean write(File file, String content, boolean append) {
+        if (file == null || TextUtils.isEmpty(content)) {
+            return false;
+        }
+        if (!file.exists()) {
+            file = createNewFile(file);
+        }
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(file, append);
+            fos.write(content.getBytes());
+        } catch (Exception e) {
+            Log.e(TAG, "", e);
+            return false;
+        } finally {
+            try {
+                fos.close();
+            } catch (IOException e) {
+                Log.e(TAG, "", e);
+            }
+            fos = null;
+        }
+        return true;
+    }
+
+    /**
+     * 获得文件名
+     *
+     * @param path
+     * @return
+     */
+    public static String getFileName(String path) {
+        if (TextUtils.isEmpty(path)) {
+            return null;
+        }
+        File f = new File(path);
+        String name = f.getName();
+        f = null;
+        return name;
+    }
+
+    /**
+     * 读取文件内容,从第startLine行开始,读取lineCount行
+     *
+     * @param file
+     * @param startLine
+     * @param lineCount
+     * @return 读到文字的list, 如果list.size<lineCount则说明读到文件末尾了
+     */
+    public static List<String> readFile(File file, int startLine, int lineCount) {
+        if (file == null || startLine < 1 || lineCount < 1) {
+            return null;
+        }
+        if (!file.exists()) {
+            return null;
+        }
+        FileReader fileReader = null;
+        List<String> list = null;
+        try {
+            list = new ArrayList<String>();
+            fileReader = new FileReader(file);
+            LineNumberReader lineReader = new LineNumberReader(fileReader);
+            boolean end = false;
+            for (int i = 1; i < startLine; i++) {
+                if (lineReader.readLine() == null) {
+                    end = true;
+                    break;
+                }
+            }
+            if (end == false) {
+                for (int i = startLine; i < startLine + lineCount; i++) {
+                    String line = lineReader.readLine();
+                    if (line == null) {
+                        break;
+                    }
+                    list.add(line);
+                }
+            }
+        } catch (Exception e) {
+            Log.e(TAG, "read log error!", e);
+        } finally {
+            if (fileReader != null) {
+                try {
+                    fileReader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 创建文件夹
+     *
+     * @param dir
+     * @return
+     */
+    public static boolean createDir(File dir) {
+        try {
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            return true;
+        } catch (Exception e) {
+            Log.e(TAG, "create dir error", e);
+            return false;
+        }
+    }
+
+    /**
+     * 在SD卡上创建目录
+     *
+     * @param dirName
+     */
+    public static File creatSDDir(String dirName) {
+        File dir = new File(dirName);
+        dir.mkdir();
+        return dir;
+    }
+
+    /**
+     * 判断SD卡上的文件是否存在
+     */
+    public static boolean isFileExist(String fileName) {
+        File file = new File(fileName);
+
+        return file == null ? false : file.exists();
+    }
+
+    /**
+     * 将一个InputStream里面的数据写入到SD卡中
+     */
+    public static File write2SDFromInput(String path, String fileName, InputStream input) {
+        File file = null;
+        OutputStream output = null;
+        try {
+            creatSDDir(path);
+            file = createNewFile(path + "/" + fileName);
+            output = new FileOutputStream(file);
+            byte buffer[] = new byte[1024];
+            int len = -1;
+            while ((len = input.read(buffer)) != -1) {
+                output.write(buffer, 0, len);
+            }
+            output.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                output.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return file;
+    }
+
+    /**
+     * 读取文件内容 从文件中一行一行的读取文件
+     *
+     * @param file
+     * @return
+     */
+    public static String readFile(File file) {
+        FileReader read = null;
+        String content = "";
+        String result = "";
+        BufferedReader br = null;
+        try {
+            read = new FileReader(file);
+            br = new BufferedReader(read);
+            while ((content = br.readLine().toString().trim()) != null) {
+                result += content + "\r\n";
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                read.close();
+                br.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 将图片保存到本地时进行压缩, 即将图片从Bitmap形式变为File形式时进行压缩,
+     * 特点是: File形式的图片确实被压缩了, 但是当你重新读取压缩后的file为 Bitmap是,它占用的内存并没有改变
+     *
+     * @param bmp
+     * @param file
+     */
+    public static void compressBmpToFile(Bitmap bmp, File file) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        int options = 100;// 个人喜欢从80开始,
+        bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
+        while (baos.toByteArray().length / 1024 > 100) {
+            baos.reset();
+            options -= 10;
+            bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
+        }
+        try {
+            FileOutputStream fos = new FileOutputStream(file);
+            fos.write(baos.toByteArray());
+            fos.flush();
+            fos.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 将图片从本地读到内存时,进行压缩 ,即图片从File形式变为Bitmap形式
+     * 特点: 通过设置采样率, 减少图片的像素, 达到对内存中的Bitmap进行压缩
+     *
+     * @param srcPath
+     * @return
+     */
+    public static Bitmap compressImageFromFile(String srcPath, float pixWidth, float pixHeight) {
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inJustDecodeBounds = true;// 只读边,不读内容
+        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
+        options.inJustDecodeBounds = false;
+        int w = options.outWidth;
+        int h = options.outHeight;
+        //float pixWidth = 800f;//
+        //float pixHeight = 480f;//
+        int scale = 1;
+        if (w > h && w > pixWidth) {
+            scale = (int) (options.outWidth / pixWidth);
+        } else if (w < h && h > pixHeight) {
+            scale = (int) (options.outHeight / pixHeight);
+        }
+        if (scale <= 0)
+            scale = 1;
+        options.inSampleSize = scale;// 设置采样率
+        options.inPreferredConfig = Bitmap.Config.ARGB_8888;// 该模式是默认的,可不设
+        options.inPurgeable = true;// 同时设置才会有效
+        options.inInputShareable = true;// 。当系统内存不够时候图片自动被回收
+        bitmap = BitmapFactory.decodeFile(srcPath, options);
+        // return compressBmpFromBmp(bitmap);//原来的方法调用了这个方法企图进行二次压缩
+        // 其实是无效的,大家尽管尝试
+        return bitmap;
+    }
+
+    /**
+     * 指定分辨率和清晰度的图片压缩
+     */
+    public void transImage(String fromFile, String toFile, int width, int height, int quality) {
+        try {
+            Bitmap bitmap = BitmapFactory.decodeFile(fromFile);
+            int bitmapWidth = bitmap.getWidth();
+            int bitmapHeight = bitmap.getHeight();
+            // 缩放图片的尺寸
+            float scaleWidth = (float) width / bitmapWidth;
+            float scaleHeight = (float) height / bitmapHeight;
+            Matrix matrix = new Matrix();
+            matrix.postScale(scaleWidth, scaleHeight);
+            // 产生缩放后的Bitmap对象
+            Bitmap resizeBitmap = (Bitmap) Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, false);
+            // save file
+            File myCaptureFile = new File(toFile);
+            FileOutputStream out = new FileOutputStream(myCaptureFile);
+            if (resizeBitmap.compress(Bitmap.CompressFormat.JPEG, quality, out)) {
+                out.flush();
+                out.close();
+            }
+            if (!bitmap.isRecycled()) {
+                bitmap.recycle();//记得释放资源,否则会内存溢出
+            }
+            if (!resizeBitmap.isRecycled()) {
+                resizeBitmap.recycle();
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    public static String getFilePath(Bitmap bitmap) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        bitmap.compress(Bitmap.CompressFormat.PNG, 80, baos);
+        String path = Environment.getExternalStorageDirectory() + "/dayaWhiteBroad";
+        File dir = new File(path);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        File file = new File(path + "/" + System.currentTimeMillis() + ".png");
+        try {
+            file.createNewFile();
+            FileOutputStream fos = new FileOutputStream(file);
+            InputStream is = new ByteArrayInputStream(baos.toByteArray());
+            int x = 0;
+            byte[] b = new byte[1024 * 100];
+            while ((x = is.read(b)) != -1) {
+                fos.write(b, 0, x);
+            }
+            fos.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return file.getPath();
+    }
+
+    /**
+     * 保存图片到图库
+     *
+     * @param bmp
+     */
+    public static void saveImageToGallery(Bitmap bmp, String path) {
+        // 首先保存图片
+        File file = new File(path);
+        try {
+            FileOutputStream fos = new FileOutputStream(file);
+            bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
+            fos.flush();
+            fos.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static boolean writeFileToSDCard(ResponseBody body, String filePath, String fileName) {
+        if (null == body) {
+            return false;
+        }
+        try {
+            File futureStudioIconFile = new File(filePath + File.separator + fileName);
+            InputStream inputStream = null;
+            OutputStream outputStream = null;
+            try {
+                byte[] fileReader = new byte[4096];
+                long fileSize = body.contentLength();
+                long fileSizeDownloaded = 0;
+                inputStream = body.byteStream();
+                outputStream = new FileOutputStream(futureStudioIconFile);
+                while (true) {
+                    int read = inputStream.read(fileReader);
+                    if (read == -1) {
+                        break;
+                    }
+                    outputStream.write(fileReader, 0, read);
+                    fileSizeDownloaded += read;
+                }
+                outputStream.flush();
+                return true;
+            } catch (IOException e) {
+                return false;
+            } finally {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+                if (outputStream != null) {
+                    outputStream.close();
+                }
+            }
+        } catch (IOException e) {
+            return false;
+        }
+    }
+
+    public static String uriToFile(Context context, Uri uri, String filePath) {
+        File privateFile = new File(filePath);
+        File fileParent = privateFile.getParentFile();
+        if (!fileParent.exists()) {
+            fileParent.mkdirs();
+        }
+        if (privateFile.exists()) return privateFile.getAbsolutePath();
+        InputStream ist = null;
+        OutputStream ost = null;
+        try {
+            privateFile.createNewFile();
+            ist = context.getContentResolver().openInputStream(uri);
+            ost = new FileOutputStream(privateFile);
+            byte[] buffer = new byte[4096];
+            int byteCount = 0;
+            while ((byteCount = ist.read(buffer)) != -1) {  // 循环从输入流读取 buffer字节
+                ost.write(buffer, 0, byteCount);        // 将读取的输入流写入到输出流
+            }
+        } catch (IOException e) {
+            return "";
+        } finally {
+            try {
+                if (ist != null) {
+                    ist.close();
+                }
+                if (ost != null) {
+                    ost.close();
+                }
+            } catch (IOException e) {
+                return "";
+            }
+        }
+        return privateFile.getAbsolutePath();
+    }
+
+    public static Intent startIntent(Context context, String path) {
+        if (TextUtils.isEmpty(path)) {
+            return null;
+        }
+        Intent intent = null;
+        switch (path.substring(path.lastIndexOf(".") + 1)) {
+            case "pdf":
+                intent = getPdfFileIntent(context, path);
+                break;
+            case "text":
+                intent = getTextFileIntent(context, path);
+                break;
+            case "html":
+                intent = getHtmlFileIntent(path);
+                break;
+            case "doc":
+            case "docx":
+                intent = getWordFileIntent(context, path);
+                break;
+            case "xls":
+            case "xlsx":
+                intent = getHtmlFileIntent(path);
+                break;
+        }
+        return intent;
+    }
+
+    //android获取一个用于打开HTML文件的intent
+    public static Intent getHtmlFileIntent(String Path) {
+        File file = new File(Path);
+        Uri uri = Uri.parse(file.toString()).buildUpon().encodedAuthority("com.android.htmlfileprovider").scheme("content").encodedPath(file.toString()).build();
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.setDataAndType(uri, "text/html");
+        return intent;
+    }
+
+    //android获取一个用于打开图片文件的intent
+    public static Intent getImageFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "image/*");
+        return intent;
+    }
+
+    //android获取一个用于打开PDF文件的intent
+    public static Intent getPdfFileIntent(Context context, String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = null;
+        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+        if (isN) {
+            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
+        } else {
+            uri = Uri.fromFile(file);
+        }
+        intent.setDataAndType(uri, "application/pdf");
+        return intent;
+    }
+
+    //android获取一个用于打开文本文件的intent
+    public static Intent getTextFileIntent(Context context, String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = null;
+        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+        if (isN) {
+            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
+        } else {
+            uri = Uri.fromFile(file);
+
+        }
+        intent.setDataAndType(uri, "text/plain");
+        return intent;
+    }
+
+    //android获取一个用于打开音频文件的intent
+    public static Intent getAudioFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        intent.putExtra("oneshot", 0);
+        intent.putExtra("configchange", 0);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "audio/*");
+        return intent;
+    }
+
+    //android获取一个用于打开视频文件的intent
+    public static Intent getVideoFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        intent.putExtra("oneshot", 0);
+        intent.putExtra("configchange", 0);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "video/*");
+        return intent;
+    }
+
+
+    //android获取一个用于打开CHM文件的intent
+    public static Intent getChmFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "application/x-chm");
+        return intent;
+    }
+
+
+    //android获取一个用于打开Word文件的intent
+    public static Intent getWordFileIntent(Context context, String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = null;
+        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+        if (isN) {
+            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
+        } else {
+            uri = Uri.fromFile(file);
+
+        }
+        intent.setDataAndType(uri, "application/msword");
+        return intent;
+    }
+
+    //android获取一个用于打开Excel文件的intent
+    public static Intent getExcelFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "application/vnd.ms-excel");
+        return intent;
+    }
+
+    //android获取一个用于打开PPT文件的intent
+    public static Intent getPPTFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent("android.intent.action.VIEW");
+        intent.addCategory("android.intent.category.DEFAULT");
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        Uri uri = Uri.fromFile(file);
+        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
+        return intent;
+    }
+
+    //android获取一个用于打开apk文件的intent
+    public static Intent getApkFileIntent(String Path) {
+        File file = new File(Path);
+        Intent intent = new Intent();
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.setAction(Intent.ACTION_VIEW);
+        intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
+        return intent;
+    }
+
+
+    public static final String DOCUMENTS_DIR = "documents";
+
+    @SuppressLint("NewApi")
+    public static String getPath(final Context context, final Uri uri) {
+
+        final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
+
+        // DocumentProvider
+        if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
+            // ExternalStorageProvider
+            if (isExternalStorageDocument(uri)) {
+                final String docId = DocumentsContract.getDocumentId(uri);
+                final String[] split = docId.split(":");
+                final String type = split[0];
+
+                if ("primary".equalsIgnoreCase(type)) {
+                    return Environment.getExternalStorageDirectory() + "/" + split[1];
+                }
+            }
+            // DownloadsProvider
+            else if (isDownloadsDocument(uri)) {
+
+                final String id = DocumentsContract.getDocumentId(uri);
+
+                if (id != null && id.startsWith("raw:")) {
+                    return id.substring(4);
+                }
+
+                String[] contentUriPrefixesToTry = new String[]{
+                        "content://downloads/public_downloads",
+                        "content://downloads/my_downloads"
+                };
+
+                for (String contentUriPrefix : contentUriPrefixesToTry) {
+                    Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
+                    try {
+                        String path = getDataColumn(context, contentUri, null, null);
+                        if (path != null && !path.equals("")) {
+                            return path;
+                        }
+                    } catch (Exception e) {
+                    }
+                }
+
+                // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
+                String fileName = getFileName(context, uri);
+                File cacheDir = getDocumentCacheDir(context);
+                File file = generateFileName(fileName, cacheDir);
+                String destinationPath = null;
+                if (file != null) {
+                    destinationPath = file.getAbsolutePath();
+                    saveFileFromUri(context, uri, destinationPath);
+                }
+
+                return destinationPath;
+            }
+            // MediaProvider
+            else if (isMediaDocument(uri)) {
+                final String docId = DocumentsContract.getDocumentId(uri);
+                final String[] split = docId.split(":");
+                final String type = split[0];
+
+                Uri contentUri = null;
+                if ("image".equals(type)) {
+                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+                } else if ("video".equals(type)) {
+                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+                } else if ("audio".equals(type)) {
+                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+                }
+
+                final String selection = "_id=?";
+                final String[] selectionArgs = new String[]{split[1]};
+
+                return getDataColumn(context, contentUri, selection, selectionArgs);
+            }
+        }
+        // MediaStore (and general)
+        else if ("content".equalsIgnoreCase(uri.getScheme())) {
+            String path = getDataColumn(context, uri, null, null);
+            if (path != null && !path.equals("")) return path;
+
+            // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
+            String fileName = getFileName(context, uri);
+            File cacheDir = getDocumentCacheDir(context);
+            File file = generateFileName(fileName, cacheDir);
+            String destinationPath = null;
+            if (file != null) {
+                destinationPath = file.getAbsolutePath();
+                saveFileFromUri(context, uri, destinationPath);
+            }
+            return destinationPath;
+        }
+        // File
+        else if ("file".equalsIgnoreCase(uri.getScheme())) {
+            return uri.getPath();
+        }
+        return null;
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is ExternalStorageProvider.
+     */
+    public static boolean isExternalStorageDocument(Uri uri) {
+        return "com.android.externalstorage.documents".equals(uri.getAuthority());
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is DownloadsProvider.
+     */
+    public static boolean isDownloadsDocument(Uri uri) {
+        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is MediaProvider.
+     */
+    public static boolean isMediaDocument(Uri uri) {
+        return "com.android.providers.media.documents".equals(uri.getAuthority());
+    }
+
+    public static String getDataColumn(Context context, Uri uri, String selection,
+                                       String[] selectionArgs) {
+
+        Cursor cursor = null;
+        final String column = "_data";
+        final String[] projection = {column};
+        String path = "";
+        try {
+            cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
+                    null);
+            if (cursor != null && cursor.moveToFirst()) {
+                final int column_index = cursor.getColumnIndexOrThrow(column);
+                path = cursor.getString(column_index);
+                return path;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (cursor != null)
+                cursor.close();
+        }
+        return path;
+    }
+
+    public static String getFileName(@NonNull Context context, Uri uri) {
+        String mimeType = context.getContentResolver().getType(uri);
+        String filename = null;
+
+        if (mimeType == null && context != null) {
+            String path = getPath(context, uri);
+            if (path == null) {
+                filename = getName(uri.toString());
+            } else {
+                File file = new File(path);
+                filename = file.getName();
+            }
+        } else {
+            Cursor returnCursor = context.getContentResolver().query(uri, null,
+                    null, null, null);
+            if (returnCursor != null) {
+                int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
+                returnCursor.moveToFirst();
+                filename = returnCursor.getString(nameIndex);
+                returnCursor.close();
+            }
+        }
+
+        return filename;
+    }
+
+    public static String getName(String filename) {
+        if (filename == null) {
+            return null;
+        }
+        int index = filename.lastIndexOf('/');
+        return filename.substring(index + 1);
+    }
+
+    public static File getDocumentCacheDir(@NonNull Context context) {
+        File dir = new File(context.getCacheDir(), DOCUMENTS_DIR);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+
+        return dir;
+    }
+
+    @Nullable
+    public static File generateFileName(@Nullable String name, File directory) {
+        if (name == null) {
+            return null;
+        }
+
+        File file = new File(directory, name);
+
+        if (file.exists()) {
+            String fileName = name;
+            String extension = "";
+            int dotIndex = name.lastIndexOf('.');
+            if (dotIndex > 0) {
+                fileName = name.substring(0, dotIndex);
+                extension = name.substring(dotIndex);
+            }
+
+            int index = 0;
+
+            while (file.exists()) {
+                index++;
+                name = fileName + '(' + index + ')' + extension;
+                file = new File(directory, name);
+            }
+        }
+
+        try {
+            if (!file.createNewFile()) {
+                return null;
+            }
+        } catch (IOException e) {
+            return null;
+        }
+
+        return file;
+    }
+
+
+    private static void saveFileFromUri(Context context, Uri uri, String destinationPath) {
+        InputStream is = null;
+        BufferedOutputStream bos = null;
+        try {
+            is = context.getContentResolver().openInputStream(uri);
+            bos = new BufferedOutputStream(new FileOutputStream(destinationPath, false));
+            byte[] buf = new byte[1024];
+            is.read(buf);
+            do {
+                bos.write(buf);
+            } while (is.read(buf) != -1);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (is != null) is.close();
+                if (bos != null) bos.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    //bitmap转为base64
+    public static String bitmapToBase64(Bitmap bitmap) {
+
+        String result = null;
+        ByteArrayOutputStream baos = null;
+        try {
+            if (bitmap != null) {
+                baos = new ByteArrayOutputStream();
+                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
+
+                baos.flush();
+                baos.close();
+
+                byte[] bitmapBytes = baos.toByteArray();
+                result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (baos != null) {
+                    baos.flush();
+                    baos.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+    //base64转为bitmap
+    public static Bitmap base64ToBitmap(String base64Data) {
+        byte[] bytes = Base64.decode(base64Data, Base64.NO_WRAP);
+        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
+    }
+}
+

+ 33 - 0
student/src/main/java/com/cooleshow/student/widgets/LollipopFixedWebView.java

@@ -0,0 +1,33 @@
+package com.cooleshow.student.widgets;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.webkit.WebView;
+
+public class LollipopFixedWebView extends WebView {
+    public LollipopFixedWebView(Context context) {
+        super(getFixedContext(context));
+    }
+
+    public LollipopFixedWebView(Context context, AttributeSet attrs) {
+        super(getFixedContext(context), attrs);
+    }
+
+    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(getFixedContext(context), attrs, defStyleAttr);
+    }
+
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+    public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
+    }
+
+    public static Context getFixedContext(Context context) {
+        if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
+            return context.createConfigurationContext(new Configuration());
+        return context;
+    }
+}

+ 574 - 0
student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -0,0 +1,574 @@
+package com.cooleshow.student.widgets.helper;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.view.Window;
+import android.view.WindowManager;
+import android.webkit.JavascriptInterface;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.usercenter.UserConstants;
+import com.cooleshow.usercenter.helper.UserHelper;
+import com.gyf.immersionbar.ImmersionBar;
+
+import org.json.JSONObject;
+
+import io.rong.imkit.RongIM;
+import io.rong.imlib.model.UserInfo;
+
+/**
+ * Description:
+ * Copyright  : Copyright (c) 2016
+ * Company    : 大雅
+ * Author     : 刘瑞
+ * Date       : 2018/11/12 15:23
+ */
+public class JsInterfaceAccomPanyUtils extends Object {
+    private static final String TAG = "JsInterfaceAccomPanyUtils";
+
+    private Activity activity;
+    JSONObject resultJson;
+
+    public JsInterfaceAccomPanyUtils(Activity activity) {
+        this.activity = activity;
+
+    }
+
+    /*
+     *统一方法
+     */
+    @JavascriptInterface
+    public void postMessage(String message) {
+        activity.runOnUiThread(() -> {
+            try {
+                JSONObject jsonObject = new JSONObject(message);
+                String api = jsonObject.getString("api");
+                if ("back".equals(api)) {
+                    activity.finish();
+                } else if ("login".equals(api)) {
+                    UserHelper.saveUserToken("");
+                    ARouter.getInstance().build(RouterPath.UserCenter.PATH_VERIFY_LOGIN)
+                            .withString(UserConstants.PHONE_NUM_KEY, UserHelper.getUserPhone())
+                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
+                            .navigation();
+                    activity.finish();
+                } else if ("openConversationActivity".equals(api)) {
+                    JSONObject contentBean = jsonObject.getJSONObject("content");
+                    if (null != contentBean) {
+                        RongIM.getInstance().startPrivateChat(activity, contentBean.getString("userId"), contentBean.getString("name"));
+                        if (!TextUtils.isEmpty(contentBean.getString("img"))) {
+                            RongIM.getInstance().refreshUserInfoCache(new UserInfo(contentBean.getString("userId"),
+                                    contentBean.getString("name"),
+                                    Uri.parse(contentBean.getString("img"))));
+                        }
+                    }
+                } else if ("videoUpdate".equals(api)) {
+                    if (onListener != null) {
+                        onListener.videoUpdate(jsonObject);
+                    }
+                } else if ("setRequestedOrientation".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    int orientation = content.getInt("orientation");
+                    activity.setRequestedOrientation(orientation);
+                    if (onListener != null)
+                        onListener.onSendMessage(content.toString());
+                } else if ("keepScreenLongLight".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    boolean isOpenLight = content.getBoolean("isOpenLight");
+                    keepScreenLongLight(isOpenLight);
+                    if (onListener != null)
+                        onListener.onSendMessage(content.toString());
+                } else if ("setStatusBarTextColor".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    boolean statusBarTextColor = content.getBoolean("statusBarTextColor");
+                    if (onListener != null)
+                        onListener.setStatusBarTextColor(statusBarTextColor, jsonObject);
+                } else if ("isSpecialShapedScreen".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    content.put("isSpecialShapedScreen", ImmersionBar.hasNotchScreen(activity));
+                    content.put("notchHeight", ImmersionBar.getNotchHeight(activity));
+                    if (onListener != null)
+                        onListener.onSendMessage(jsonObject.toString());
+                } else if ("openWebView".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    boolean isHideTitle = false;
+                    boolean statusBarTextColor = false;
+                    boolean isOpenLight = false;
+                    int orientation = -1;
+                    try {
+                        isHideTitle = content.getBoolean("isHideTitle");
+                        statusBarTextColor = content.getBoolean("statusBarTextColor");
+                        isOpenLight = content.getBoolean("isOpenLight");
+                        orientation = content.getInt("orientation");
+                    } catch (Exception e) {
+                    }
+
+                    String path = RouterPath.WebCenter.ACTIVITY_HTML;
+                    if (orientation == 0) {
+                        path = RouterPath.WebCenter.ACTIVITY_HORIZONTAL_SCREEN_HTML;
+                    }
+                    ARouter.getInstance().build(path)
+                            .withString("url", content.getString("url"))
+                            .withBoolean("isHideTitle", isHideTitle)
+                            .withBoolean("statusBarTextColor", statusBarTextColor)
+                            .withBoolean("isOpenLight", isOpenLight)
+                            .withInt("orientation", orientation)
+                            .navigation();
+                } else if ("openAccompanyWebView".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    boolean isHideTitle = false;
+                    boolean statusBarTextColor = false;
+                    boolean isOpenLight = false;
+                    int orientation = -1;
+                    try {
+                        isHideTitle = content.getBoolean("isHideTitle");
+                        statusBarTextColor = content.getBoolean("statusBarTextColor");
+                        isOpenLight = content.getBoolean("isOpenLight");
+                        orientation = content.getInt("orientation");
+                    } catch (Exception e) {
+                    }
+
+                    ARouter.getInstance().build(RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
+                            .withString("url", content.getString("url"))
+                            .withBoolean("isHideTitle", isHideTitle)
+                            .withBoolean("statusBarTextColor", statusBarTextColor)
+                            .withBoolean("isOpenLight", isOpenLight)
+                            .withInt("orientation", orientation)
+                            .navigation();
+
+                } else if ("startEvaluating".equals(api)) {
+                    if (onListener != null) {
+                        onListener.startEvaluating(jsonObject);
+                    }
+                } else if ("endEvaluating".equals(api)) {
+                    if (onListener != null) {
+                        onListener.endEvaluating(jsonObject);
+                    }
+                } else if ("cancelEvaluating".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cancelEvaluating();
+                        onListener.onSendMessage(message);
+                    }
+                } else if ("startRecording".equals(api)) {
+                    if (onListener != null) {
+                        onListener.startRecording(jsonObject);
+                    }
+                } else if ("pauseRecording".equals(api)) {
+                    if (onListener != null) {
+                        onListener.pauseRecording(jsonObject);
+                    }
+                } else if ("resumeRecording".equals(api)) {
+                    if (onListener != null) {
+                        onListener.resumeRecording(jsonObject);
+                    }
+                } else if ("isWiredHeadsetOn".equals(api)) {
+                    if (onListener != null) {
+                        onListener.isWiredHeadsetOn(jsonObject);
+                    }
+                } else if ("proxyMessage".equals(api)) {
+                    if (onListener != null) {
+                        onListener.proxyMessage(jsonObject);
+                    }
+                } else if ("openCamera".equals(api)) {
+                    if (onListener != null) {
+                        onListener.openCamera(jsonObject);
+                    }
+                } else if ("closeCamera".equals(api)) {
+                    if (onListener != null) {
+                        onListener.closeCamera(jsonObject);
+                    }
+                } else if ("startCapture".equals(api)) {
+                    if (onListener != null) {
+                        onListener.startCapture(jsonObject);
+                    }
+                } else if ("endCapture".equals(api)) {
+                    if (onListener != null) {
+                        onListener.endCapture(jsonObject);
+                    }
+                } else if ("endRecording".equals(api)) {
+                    if (onListener != null) {
+                        onListener.endRecording(jsonObject);
+                    }
+                } else if ("startSoundCheck".equals(api)) {
+                    if (onListener != null) {
+                        onListener.startSoundCheck(jsonObject);
+                    }
+                } else if ("endSoundCheck".equals(api)) {
+                    if (onListener != null) {
+                        onListener.endSoundCheck(jsonObject);
+                    }
+                } else if ("proxyServiceMessage".equals(api)) {
+                    if (onListener != null) {
+                        onListener.proxyServiceMessage(jsonObject);
+                    }
+                } else if ("keepScreenLongLight".equals(api)) {
+                    if (onListener != null) {
+                        onListener.keepScreenLongLight(jsonObject);
+                    }
+                }
+                //分享
+                else if ("shareAchievements".equals(api)) {
+                    if (onListener != null) {
+                        onListener.shareAchievements(jsonObject);
+                    }
+                }
+                // 分段上传
+                else if ("measureStart".equals(api)) {
+                    if (onListener != null) {
+                        onListener.measureStart(jsonObject);
+                    }
+                }
+                //分段上传结束
+                else if ("allMeasureEnd".equals(api)) {
+                    if (onListener != null) {
+                        onListener.allMeasureEnd(jsonObject);
+                    }
+                }
+                //初始化
+                else if ("cloudDetail".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudDetail(jsonObject);
+                    }
+                }
+                //开始播放
+                else if ("cloudPlay".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudPlay(jsonObject);
+                    }
+                }
+                //播放暂停
+                else if ("cloudSuspend".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudSuspend(jsonObject);
+                    }
+                }
+                //播放进度跳转
+                else if ("cloudSetCurrentTime".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudSetCurrentTime(jsonObject);
+                    }
+                }
+                //调速
+                else if ("cloudChangeSpeed".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudChangeSpeed(jsonObject);
+                    }
+                }
+                //实现原音伴奏切换,基于传入参数控制声道
+                else if ("cloudSwitch".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudSwitch(jsonObject);
+                    }
+                }
+                //实现音量控制基于传入参数控制声道
+                else if ("cloudVolume".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudVolume(jsonObject);
+                    }
+                } else if ("cloudGetMediaStatus".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudGetMediaStatus(jsonObject);
+                    }
+                } else if ("cloudMetronome".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudMetronome(jsonObject);
+                    }
+                } else if ("cloudDestroy".equals(api)) {
+                    if (onListener != null) {
+                        onListener.cloudDestroy(jsonObject);
+                    }
+                } else if ("joinLiveRoom".equals(api)) {
+                    //进入直播间
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinLiveRoom(content.getString("roomId"), content.getString("teacherId"));
+                    }
+                } else if ("joinChatGroup".equals(api)) {
+                    //进入聊天
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinChatGroup(content.getString("type"), content.getString("id"));
+                    }
+                } else if ("setAddress".equals(api)) {
+                    //跳转地址页面
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+                            .navigation(activity, 1011);
+                } else if ("paymentOrder".equals(api)) {
+                    //支付
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.paymentOrder(content.getString("orderNo"), content.getString("payChannel"), content.getString("payInfo"));
+                    }
+                }
+            } catch (Exception e) {
+
+            }
+        });
+
+    }
+
+    private void keepScreenLongLight(boolean isOpenLight) {
+        Window window = activity.getWindow();
+        if (isOpenLight) {
+            window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+        } else {
+            window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+
+        }
+
+    }
+
+    public onGetMethodsListener onListener;
+
+    public void setOnGetMethodsListener(onGetMethodsListener onListener) {
+        this.onListener = onListener;
+    }
+
+    public interface onGetMethodsListener {
+        void onSendMessage(String message);
+
+        void setStatusBarTextColor(boolean statusBarTextColor, JSONObject message);
+
+        void startEvaluating(JSONObject message);
+
+
+        void startRecording(JSONObject message);
+
+        void endRecording(JSONObject message);
+
+        void keepScreenLongLight(JSONObject message);
+
+        /**
+         * 开始校音
+         *
+         * @param message
+         */
+        void startSoundCheck(JSONObject message);
+
+        void endSoundCheck(JSONObject message);
+
+        void endEvaluating(JSONObject jsonObject);
+
+        void cancelEvaluating();
+
+        void resumeRecording(JSONObject jsonObject);
+
+        void pauseRecording(JSONObject jsonObject);
+
+        void isWiredHeadsetOn(JSONObject jsonObject);
+
+        void proxyMessage(JSONObject jsonObject);
+
+        void proxyServiceMessage(JSONObject jsonObject);
+
+        void openCamera(JSONObject jsonObject);
+
+        void closeCamera(JSONObject jsonObject);
+
+        void startCapture(JSONObject jsonObject);
+
+        void endCapture(JSONObject jsonObject);
+
+        void videoUpdate(JSONObject jsonObject);
+
+        void shareAchievements(JSONObject message);
+
+        void measureStart(JSONObject message);
+
+        void allMeasureEnd(JSONObject message);
+
+        /**
+         * 进入页面初始化方法
+         * 初始化midi文件,初始速度,默认拍号的分子和分母
+         * {
+         * api: 'cloudDetail',
+         * content: {
+         * midi: '',
+         * denominator: 4,
+         * numerator: 4,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * }
+         *
+         * @param message
+         */
+        void cloudDetail(JSONObject message);
+
+        /**
+         * 播放
+         * {
+         * api: 'cloudPlay',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * // 当前选择速度
+         * speed: 90,
+         * // 开始时间(ms)
+         * startTime: 0
+         * }
+         * })
+         * <p>
+         * // 返回数据
+         * <p>
+         * {
+         * api: 'cloudPlay',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * // 当前选择速度
+         * speed: 90,
+         * // 开始时间(ms)
+         * startTime: 0
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudPlay(JSONObject message);
+
+        /**
+         * 暂停
+         * {
+         * api: 'cloudSuspend',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * }
+         * })
+         * <p>
+         * // 返回数据
+         * {
+         * api: 'cloudSuspend',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 暂停位置时间(ms)
+         * currentTime: 0
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudSuspend(JSONObject message);
+
+
+        /**
+         * 跳转指定位置
+         * {
+         * api: 'cloudSetCurrentTime',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 指定位置时间(ms)
+         * currentTime: 0
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudSetCurrentTime(JSONObject message);
+
+        /**
+         * 调速 范围(45-270整数)
+         * {
+         * api: 'cloudChangeSpeed',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 调整速度
+         * speed: 90
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudChangeSpeed(JSONObject message);
+
+        /**
+         * 原声/伴奏切换
+         * {
+         * api: 'cloudSwitch',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 需要静音的渠道,为空全部不静音
+         * parts: [
+         * ''
+         * ]
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudSwitch(JSONObject message);
+
+        void cloudVolume(JSONObject message);
+
+        /**
+         * 获取播放状态
+         * {
+         * api: 'cloudGetMediaStatus'
+         * })
+         * <p>
+         * // 返回
+         * <p>
+         * {
+         * api: 'cloudGetMediaStatus',
+         * content: {
+         * status: 'init' | 'play' | 'suspend'
+         * }
+         * }
+         *
+         * @param message
+         */
+        void cloudGetMediaStatus(JSONObject message);
+
+        /**
+         * 节拍器控制
+         *
+         * @param message
+         */
+        void cloudMetronome(JSONObject message);
+
+        /**
+         * 销毁
+         *
+         * @param message
+         */
+        void cloudDestroy(JSONObject message);
+        /**
+         * 进入直播间
+         *
+         * @param roomId
+         * @param teacherId
+         */
+        void joinLiveRoom(String roomId, String teacherId);
+
+        /**
+         * 进入聊天
+         *
+         * @param type // single 单人 multi 多人
+         * @param id
+         */
+        void joinChatGroup(String type, String id);
+
+        /**
+         * 支付
+         *
+         * @param orderNo
+         * @param payChannel
+         * @param payInfo
+         */
+        void paymentOrder(String orderNo, String payChannel, String payInfo);
+    }
+
+}

+ 78 - 63
student/src/main/java/com/cooleshow/student/utils/JsInterfaceUtils.java → student/src/main/java/com/cooleshow/student/widgets/helper/JsInterfaceUtils.java

@@ -1,4 +1,6 @@
-package com.cooleshow.student.utils;
+package com.cooleshow.student.widgets.helper;
+
+import static com.cooleshow.base.common.WebConstants.WEB_URL;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -10,11 +12,9 @@ import android.webkit.JavascriptInterface;
 
 import com.alibaba.android.arouter.launcher.ARouter;
 import com.cooleshow.base.router.RouterPath;
-import com.cooleshow.base.utils.SPUtils;
 import com.cooleshow.usercenter.UserConstants;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.gyf.immersionbar.ImmersionBar;
-import com.rong.io.live.bean.User;
 
 import org.json.JSONObject;
 
@@ -71,28 +71,13 @@ public class JsInterfaceUtils extends Object {
                         }
                     }
                 }
-                if ("uploadVideo".equals(api)) {
-                   /* Intent intent = new Intent(activity, UploadVideoctivity.class);
-                    intent.putExtra("payload", jsonObject.getString("payload"));
-                    intent.putExtra("callbackUrl", jsonObject.getString("callbackUrl"));
-                    intent.putExtra("reload", jsonObject.getBoolean("reload"));
-                    if (!TextUtils.isEmpty(jsonObject.getString("url"))) {
-                        intent.putExtra("url", jsonObject.getString("url"));
-                        activity.startActivityForResult(intent, 1000);
-                    } else {
-                        activity.startActivity(intent);
-                    }*/
-                }
-                if ("recordVideo".equals(api)) {
-                    JSONObject content = jsonObject.getJSONObject("content");
-                 /*   ARouter.getInstance().build(ARouterConstace.ACTIVITY_VIDEO_RECORD_KIT)
-                            .withString("musicUrl", content.getString("url"))
-                            .withString("musicName", content.getString("name"))
-                            .withString("directoryName", "accompanyVideo")
-                            .withInt("videoQuality", CameraKit.Constants.VIDEO_QUALITY_HIGHEST)
-                            .navigation();*/
+                if (TextUtils.equals("chooseFile", api)) {
+                    //选择文件
+                    if (onListener != null) {
+                        onListener.chooseFile(jsonObject);
+                    }
+                    return;
                 }
-
                 if ("setRequestedOrientation".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     int orientation = content.getInt("orientation");
@@ -124,15 +109,17 @@ public class JsInterfaceUtils extends Object {
                 }
                 if ("getToken".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
-                    //tokentype
-                    content.put("tokenType", SPUtils.getInstance().getString(UserHelper.USER_TOKEN_TYPE,"bearer"));
-                    content.put("accessToken", UserHelper.getUserToken());
+                    String userToken = UserHelper.getUserToken();
+                    String[] s = userToken.split(" ");
+                    content.put("tokenType", s[0]);
+                    content.put("accessToken", s[1]);
+
                     if (onListener != null)
                         onListener.onSendMessage(jsonObject.toString());
                 }
 
                 if ("openWebView".equals(api)) {
-                  /*  JSONObject content = jsonObject.getJSONObject("content");
+                    JSONObject content = jsonObject.getJSONObject("content");
                     boolean isHideTitle = false;
                     boolean statusBarTextColor = false;
                     boolean isOpenLight = false;
@@ -144,20 +131,20 @@ public class JsInterfaceUtils extends Object {
                         orientation = content.getInt("orientation");
                     } catch (Exception e) {
                     }
-                    String path = ARouterConstace.ACTIVITY_HTML;
+                    String path = RouterPath.WebCenter.ACTIVITY_HTML;
                     if (orientation == 0) {
-                        path = ARouterConstace.ACTIVITY_HORIZONTAL_SCREEN_HTML;
+                        path = RouterPath.WebCenter.ACTIVITY_HORIZONTAL_SCREEN_HTML;
                     }
                     ARouter.getInstance().build(path)
-                            .withString("url", content.getString("url"))
+                            .withString(WEB_URL, content.getString("url"))
                             .withBoolean("isHideTitle", isHideTitle)
                             .withBoolean("statusBarTextColor", statusBarTextColor)
                             .withBoolean("isOpenLight", isOpenLight)
                             .withInt("orientation", orientation)
-                            .navigation();*/
+                            .navigation();
                 }
                 if ("openAccompanyWebView".equals(api)) {
-                  /*  JSONObject content = jsonObject.getJSONObject("content");
+                    JSONObject content = jsonObject.getJSONObject("content");
                     boolean isHideTitle = false;
                     boolean statusBarTextColor = false;
                     boolean isOpenLight = false;
@@ -169,13 +156,13 @@ public class JsInterfaceUtils extends Object {
                         orientation = content.getInt("orientation");
                     } catch (Exception e) {
                     }
-                    ARouter.getInstance().build(ARouterConstace.ACTIVITY_ACCOMPANY_HTML)
-                            .withString("url", content.getString("url"))
+                    ARouter.getInstance().build(RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
+                            .withString(WEB_URL, content.getString("url"))
                             .withBoolean("isHideTitle", isHideTitle)
                             .withBoolean("statusBarTextColor", statusBarTextColor)
                             .withBoolean("isOpenLight", isOpenLight)
                             .withInt("orientation", orientation)
-                            .navigation();*/
+                            .navigation();
 
                 }
 
@@ -193,28 +180,6 @@ public class JsInterfaceUtils extends Object {
                     }
 
                 }
-                if ("createRightNavButton".equals(api)) {
-                   /* JSONObject content = jsonObject.getJSONObject("content");
-                    if ("native".equals(content.getString("type"))) {
-                        if (null != onListener) {
-                            if ("shareFunction".equals(content.getString("url"))) {
-                                //分享
-                                onListener.createRightNavToShareButton(content.getString("buttonImage"), content.getString("url"));
-                            } else {
-                                //历史
-//                                onListener.createNavButton(content.getString("title"), content.getString("musicGroupId"), content.getString("url"));
-                            }
-                        }
-                    } else {
-                        ARouter.getInstance().build(ARouterConstace.ACTIVITY_HTML)
-                                .withString("url", content.getString("url"))
-                                .navigation();
-                    }
-
-                    if (onListener != null) {
-                        onListener.onSendMessage(jsonObject.toString());
-                    }*/
-                }
 
                 //分享
                 if ("shareAchievements".equals(api)) {
@@ -241,16 +206,39 @@ public class JsInterfaceUtils extends Object {
                         onListener.setBarStatus(jsonObject);
                     }
                 }
-                if("authToBack".equalsIgnoreCase(api)){
+                if ("authToBack".equalsIgnoreCase(api)) {
                     if (onListener != null) {
                         onListener.authToBack(jsonObject);
                     }
                 }
-                if("openMusicEvaluate".equalsIgnoreCase(api)){
+                //进入直播间
+                if ("joinLiveRoom".equals(api)){
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinLiveRoom(content.getString("roomId"),content.getString("teacherId"));
+                    }
+                }
+                //进入聊天
+                if ("joinChatGroup".equals(api)){
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinChatGroup(content.getString("type"),content.getString("id"));
+                    }
+                }
+                //跳转地址页面
+                if ("setAddress".equals(api)){
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+                            .navigation(activity,1011);
+                }
+                //支付
+                if ("paymentOrder".equals(api)){
+                    JSONObject content = jsonObject.getJSONObject("content");
                     if (onListener != null) {
-                        onListener.openMusicEvaluate(jsonObject);
+                        onListener.paymentOrder(content.getString("orderNo"),content.getString("payChannel"),content.getString("payInfo"));
                     }
                 }
+
+
             } catch (Exception e) {
             }
         });
@@ -282,7 +270,12 @@ public class JsInterfaceUtils extends Object {
         void onAccompanySelecResult(String id, String name);
 
         void downloadFile(String url);
-
+        /**
+         * 选择文件
+         *
+         * @param message
+         */
+        void chooseFile(JSONObject message);
         //分享
         void createRightNavToShareButton(String image, String url);
 
@@ -311,8 +304,30 @@ public class JsInterfaceUtils extends Object {
          * @param message
          */
         void setBarStatus(JSONObject message);
+
         void authToBack(JSONObject message);
-        void openMusicEvaluate(JSONObject message);
+
+        /**
+         * 进入直播间
+         * @param roomId
+         * @param teacherId
+         */
+        void joinLiveRoom(String roomId,String teacherId);
+
+        /**
+         * 进入聊天
+         * @param type // single 单人 multi 多人
+         * @param id
+         */
+        void joinChatGroup(String type,String id);
+
+        /**
+         * 支付
+         * @param orderNo
+         * @param payChannel
+         * @param payInfo
+         */
+        void paymentOrder(String orderNo,String payChannel,String payInfo);
     }
 
 }

+ 4 - 0
student/src/main/java/com/cooleshow/student/wxapi/WXPayEntryActivity.java

@@ -14,6 +14,8 @@ import com.tencent.mm.opensdk.openapi.IWXAPI;
 import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
 import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
+import org.greenrobot.eventbus.EventBus;
+
 public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
 
     private static final String TAG = "MicroMsg.SDKSample.WXPayEntryActivity";
@@ -48,9 +50,11 @@ public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
             if (resp.errCode == 0) {
                 //成功
                 ToastUtils.showShort("支付成功");
+                EventBus.getDefault().post("PAY_SUCCESS");
 
             } else {
                 ToastUtils.showShort("支付失败:" + resp.errCode);
+                EventBus.getDefault().post("PAY_ERROR");
             }
 			/*AlertDialog.Builder builder = new AlertDialog.Builder(this);
 			builder.setTitle("提示");

BIN
student/src/main/res/drawable-xhdpi/flash_off.png


BIN
student/src/main/res/drawable-xhdpi/ic_accompany_record.png


BIN
student/src/main/res/drawable-xhdpi/ic_video_record_play.png


BIN
student/src/main/res/drawable-xhdpi/switch_camera.png


BIN
student/src/main/res/drawable-xxhdpi/ic_accompany_back.png


BIN
student/src/main/res/drawable-xxhdpi/ic_accompany_record.png


BIN
student/src/main/res/drawable-xxhdpi/ic_accompany_video_record_save.png


+ 20 - 0
student/src/main/res/layout/activity_accompany.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/activity_record"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white">
+
+    <FrameLayout
+        android:id="@+id/camera"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+    <FrameLayout
+        android:id="@+id/fl_webview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+
+</FrameLayout>

+ 126 - 0
student/src/main/res/layout/activity_html1.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/rl_activity_html"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/fl_video"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="gone" />
+
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/view_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scrollbars="none" />
+    <LinearLayout
+        android:id="@+id/ll_activity_html"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+        <View
+            android:id="@+id/view_statusbar"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/statusbar_view_height"
+            android:background="@color/white"
+            android:visibility="gone" />
+
+        <ProgressBar
+            android:id="@+id/progressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="match_parent"
+            android:layout_height="2dip"
+            android:progressDrawable="@drawable/pg_stu" />
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:id="@+id/header_bar_view"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <View
+                android:id="@+id/view"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/statusbar_view_height"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent" />
+
+            <ImageView
+                android:id="@+id/btn_back"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_back"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/btn_close"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_html_close_stu"
+                app:layout_constraintStart_toEndOf="@id/btn_back"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_title"
+                android:layout_width="0dp"
+                android:layout_height="@dimen/dp_40"
+                android:layout_marginStart="@dimen/dp_90"
+                android:layout_marginEnd="@dimen/dp_90"
+                android:ellipsize="marquee"
+                android:focusable="true"
+                android:focusableInTouchMode="true"
+                android:gravity="center"
+                android:paddingStart="@dimen/dp_15"
+                android:paddingEnd="@dimen/dp_15"
+                android:singleLine="true"
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_18"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_action"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_40"
+                android:gravity="center"
+                android:paddingEnd="@dimen/dp_15"
+                android:text=""
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_16"
+                android:visibility="invisible"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/iv_action"
+                android:layout_width="@dimen/dp_44"
+                android:layout_height="@dimen/dp_44"
+                android:layout_marginEnd="@dimen/dp_10"
+                android:scaleType="center"
+                android:padding="@dimen/dp_5"
+                android:src="@drawable/ic_delete"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+    </LinearLayout>
+
+
+
+</RelativeLayout>

+ 35 - 0
student/src/main/res/layout/activity_select_address_list.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/color_f6f8f9"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout" />
+
+
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/rv_address"
+        android:layout_below="@+id/toolbar_include"
+        android:layout_width="match_parent"
+        android:layout_marginTop="15dp"
+        android:layout_marginBottom="80dp"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:id="@+id/tv_add"
+        android:layout_width="match_parent"
+        android:layout_height="44dp"
+        android:layout_alignParentBottom="true"
+        android:layout_marginLeft="28dp"
+        android:layout_marginTop="27dp"
+        android:layout_marginRight="28dp"
+        android:layout_marginBottom="48dp"
+        android:background="@drawable/shape_course_status_ing"
+        android:gravity="center"
+        android:text="添加新地址"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_14" />
+</RelativeLayout>

+ 14 - 0
student/src/main/res/layout/fragment_accompany.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <FrameLayout
+        android:id="@+id/view_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scrollbars="none" />
+
+</LinearLayout>

+ 126 - 0
student/src/main/res/layout/fragment_mall.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/rl_activity_html"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/fl_video"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="gone" />
+
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/view_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scrollbars="none" />
+    <LinearLayout
+        android:id="@+id/ll_activity_html"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+        <View
+            android:id="@+id/view_statusbar"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/statusbar_view_height"
+            android:background="#BCF1EB"
+            android:visibility="gone" />
+
+        <ProgressBar
+            android:id="@+id/progressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="match_parent"
+            android:layout_height="2dip"
+            android:progressDrawable="@drawable/pg_stu" />
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:id="@+id/header_bar_view"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <View
+                android:id="@+id/view"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/statusbar_view_height"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent" />
+
+            <ImageView
+                android:id="@+id/btn_back"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_back"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/btn_close"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_html_close_stu"
+                app:layout_constraintStart_toEndOf="@id/btn_back"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_title"
+                android:layout_width="0dp"
+                android:layout_height="@dimen/dp_40"
+                android:layout_marginStart="@dimen/dp_90"
+                android:layout_marginEnd="@dimen/dp_90"
+                android:ellipsize="marquee"
+                android:focusable="true"
+                android:focusableInTouchMode="true"
+                android:gravity="center"
+                android:paddingStart="@dimen/dp_15"
+                android:paddingEnd="@dimen/dp_15"
+                android:singleLine="true"
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_18"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_action"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_40"
+                android:gravity="center"
+                android:paddingEnd="@dimen/dp_15"
+                android:text=""
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_16"
+                android:visibility="invisible"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/iv_action"
+                android:layout_width="@dimen/dp_44"
+                android:layout_height="@dimen/dp_44"
+                android:layout_marginEnd="@dimen/dp_10"
+                android:scaleType="center"
+                android:padding="@dimen/dp_5"
+                android:src="@drawable/ic_delete"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+    </LinearLayout>
+
+
+
+</RelativeLayout>

+ 140 - 0
student/src/main/res/layout/record_video_layout.xml

@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/activity_record"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/black">
+
+    <com.wonderkiln.camerakit.CameraView
+        android:id="@+id/camera"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_gravity="center_vertical"
+        android:adjustViewBounds="true"
+        app:ckCropOutput="true"
+        app:ckFacing="front"
+        app:ckFlash="off"
+        app:ckFocus="tapWithMarker"
+        app:ckMethod="standard"
+        app:ckVideoQuality="max720p"
+        app:deviceOrientation="horizontal" />
+
+    <FrameLayout
+        android:id="@+id/fl_webview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="70dp"
+        android:visibility="gone"
+        android:layout_gravity="bottom"
+        android:background="#2E000000">
+
+        <ImageView
+            android:id="@+id/btn_back"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentStart="true"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="@dimen/dp_24"
+            android:padding="12dp"
+            android:scaleType="center"
+            android:src="@drawable/ic_accompany_back" />
+
+        <ImageView
+            android:id="@+id/video_flash_light"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentLeft="true"
+            android:layout_marginLeft="20dp"
+            android:layout_marginBottom="10dp"
+            android:padding="@dimen/dp_10"
+            android:src="@drawable/flash_off"
+            android:visibility="gone" />
+
+        <Chronometer
+            android:id="@+id/video_time"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="10dp"
+            android:layout_marginBottom="10dp"
+            android:textColor="#FFFFFF"
+            android:textSize="16sp"
+            android:visibility="gone" />
+
+        <ImageView
+            android:id="@+id/swicth_camera"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:layout_gravity="right"
+            android:layout_marginRight="20dp"
+            android:padding="@dimen/dp_10"
+            android:src="@drawable/switch_camera"
+            android:textColor="#FFFFFF"
+            android:visibility="gone" />
+
+
+        <ImageView
+            android:id="@+id/record_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:padding="@dimen/dp_10"
+            android:src="@drawable/ic_accompany_record" />
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/rl_preview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/black_444"
+        android:visibility="gone">
+
+        <ImageView
+            android:id="@+id/iv_video"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_alignParentStart="true"
+            android:layout_alignParentTop="true"
+            android:background="@color/black" />
+
+        <ImageView
+            android:id="@+id/iv_del"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentStart="true"
+            android:layout_alignParentBottom="true"
+            android:layout_marginBottom="@dimen/dp_20"
+            android:padding="@dimen/dp_15"
+            android:scaleType="centerCrop"
+            android:src="@drawable/ic_accompany_back" />
+
+        <ImageView
+            android:id="@+id/iv_save"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true"
+            android:layout_alignParentBottom="true"
+            android:layout_marginBottom="@dimen/dp_20"
+            android:padding="@dimen/dp_15"
+            android:scaleType="centerCrop"
+            android:src="@drawable/ic_accompany_video_record_save" />
+
+        <ImageView
+            android:id="@+id/iv_play"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:layout_marginTop="@dimen/dp_20"
+            android:padding="@dimen/dp_15"
+            android:scaleType="centerCrop"
+            android:src="@drawable/ic_video_record_play" />
+    </RelativeLayout>
+
+</FrameLayout>

+ 8 - 1
teacher/src/main/AndroidManifest.xml

@@ -63,6 +63,10 @@
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:screenOrientation="portrait" />
         <activity
+            android:name=".ui.web.HtmlHorizontalScreenActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="landscape" />
+        <activity
             android:name=".ui.web.AccompanyActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:screenOrientation="portrait" />
@@ -249,7 +253,10 @@
             android:name=".ui.income.EarningStatisticsActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"
             android:screenOrientation="portrait" />
-
+        <activity
+            android:name=".ui.mine.SelectAddressListActivity"
+            android:configChanges="orientation|screenSize|keyboardHidden"
+            android:screenOrientation="portrait" />
         <activity
             android:name=".ui.live.LiveRoomActivity"
             android:configChanges="orientation|screenSize|keyboardHidden"

+ 2 - 2
teacher/src/main/java/com/cooleshow/teacher/ui/main/MainActivity.java

@@ -38,7 +38,7 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
     private ArrayList<Fragment> mFragments = new ArrayList<>();
     private HomeFragment mHomeFragment;
     private MineFragment mMineFragment;
-    private ShopMallFragment shopMallFragment;
+    private MallFragment shopMallFragment;
 
 
     @Override
@@ -59,7 +59,7 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
         mHomeFragment = new HomeFragment();
         CourseTableFragment courseTableFragment = new CourseTableFragment();
         MessageFragment messageFragment = new MessageFragment();
-        shopMallFragment = new ShopMallFragment();
+        shopMallFragment = new MallFragment();
         mMineFragment = new MineFragment();
         mFragments.add(mHomeFragment);
         mFragments.add(courseTableFragment);

Diff do ficheiro suprimidas por serem muito extensas
+ 310 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/main/MallFragment.java


+ 106 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/mine/SelectAddressListActivity.java

@@ -0,0 +1,106 @@
+package com.cooleshow.teacher.ui.mine;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.listener.OnItemClickListener;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.teacher.R;
+import com.cooleshow.teacher.adapter.AddressListAdapter;
+import com.cooleshow.teacher.bean.AddressBean;
+import com.cooleshow.teacher.contract.AddressListContract;
+import com.cooleshow.teacher.databinding.ActivitySelectAddressListBinding;
+import com.cooleshow.teacher.presenter.mine.AddressListPresenter;
+import com.google.gson.Gson;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.rong.imkit.utils.StatusBarUtil;
+
+/**
+ * 创建日期:2022/6/9 10:39
+ *
+ * @author Ryan
+ * 类说明:
+ */
+@Route(path = RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+public class SelectAddressListActivity extends BaseMVPActivity<ActivitySelectAddressListBinding, AddressListPresenter> implements AddressListContract.AddressListView, View.OnClickListener {
+
+    private AddressListAdapter addressListAdapter;
+
+    @Override
+    public void onClick(View view) {
+        switch (view.getId()) {
+            case R.id.tv_add:
+                ARouter.getInstance().build(RouterPath.MineCenter.MINE_EDIT_ADDRESS)
+                        .withBoolean("isAdd",true)
+                        .navigation();
+                break;
+        }
+    }
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        StatusBarUtil.setStatusBarDarkTheme(this, true);
+    }
+
+    private List<AddressBean> dataList = new ArrayList<>();
+
+    @Override
+    protected void initView() {
+        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "地址列表");
+        viewBinding.tvAdd.setOnClickListener(this);
+        RecyclerView rvAddress = viewBinding.rvAddress;
+        LinearLayoutManager manager = new LinearLayoutManager(this);
+        rvAddress.setLayoutManager(manager);
+        addressListAdapter = new AddressListAdapter(dataList);
+        rvAddress.setAdapter(addressListAdapter);
+        addressListAdapter.setOnItemClickListener(new OnItemClickListener() {
+            @Override
+            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
+                AddressBean item = (AddressBean) adapter.getItem(position);
+                Gson gson=new Gson();
+                String s = gson.toJson(item);
+                Intent intent=new Intent();
+                intent.putExtra("selectAddress",s);
+                setResult(RESULT_OK,intent);
+                finish();
+
+            }
+        });
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        presenter.companyAddressList();
+    }
+
+    @Override
+    protected ActivitySelectAddressListBinding getLayoutView() {
+        return ActivitySelectAddressListBinding.inflate(getLayoutInflater());
+    }
+
+    @Override
+    protected AddressListPresenter createPresenter() {
+        return new AddressListPresenter();
+    }
+
+    @Override
+    public void companyAddressListSuccess(List<AddressBean> data) {
+        dataList.clear();
+        dataList.addAll(data);
+        addressListAdapter.notifyDataSetChanged();
+    }
+}

+ 32 - 5
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyActivity.java

@@ -28,6 +28,7 @@ import com.cooleshow.teacher.presenter.web.AccompanyPresenter;
 import com.cooleshow.teacher.widgets.FileUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.daya.live_teaching.model.FileUploadBean;
+import com.gyf.immersionbar.ImmersionBar;
 import com.wonderkiln.camerakit.CameraKit;
 import com.wonderkiln.camerakit.CameraView;
 import com.wonderkiln.camerakit.events.CameraKitError;
@@ -251,11 +252,33 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
 
     public void setStatusBarTextColor(boolean statusBarTextColor) {
         if (statusBarTextColor) {
-            StatusBarUtil.setStatusBarColor(this,com.cooleshow.base.R.color.white);
+            setStatusBarColor();
         } else {
-            StatusBarUtil.setStatusBarColor(this,com.cooleshow.base.R.color.common_black);
+            setStatusBlackBarColor();
         }
     }
+
+    public void setStatusBarColor() {
+        ImmersionBar.with(this)
+                .keyboardEnable(true)
+                .transparentStatusBar()
+                .statusBarDarkFont(false, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
+                .autoDarkModeEnable(false)
+                .flymeOSStatusBarFontColor(R.color.white)  //修改flyme OS状态栏字体颜色
+                .init();  //必须调用方可沉浸
+
+    }
+
+    public void setStatusBlackBarColor() {
+        ImmersionBar.with(this)
+                .keyboardEnable(true)
+                .transparentStatusBar()
+                .statusBarDarkFont(true, 0.2f) //原理:如果当前设备支持状态栏字体变色,会设置状态栏字体为黑色,如果当前设备不支持状态栏字体变色,会使当前状态栏加上透明度,否则不执行透明度
+                .autoDarkModeEnable(false)
+                .flymeOSStatusBarFontColor(com.cooleshow.base.R.color.common_black)  //修改flyme OS状态栏字体颜色
+                .init();  //必须调用方可沉浸
+    }
+
     @Override
     protected ActivityAccompanyBinding getLayoutView() {
         return ActivityAccompanyBinding.inflate(getLayoutInflater());
@@ -305,9 +328,8 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             } catch (JSONException e) {
                 e.printStackTrace();
             }
-        }
-        if (data != null) {
-            if (requestCode == 1000) {
+        }else if (requestCode == 1000) {
+                if (data != null) {
                 try {
                     String filePath = data.getStringExtra("filePath");
                     JSONObject jsonObject = new JSONObject();
@@ -325,6 +347,11 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
                     e.printStackTrace();
                 }
             }
+        } else if (requestCode == 1011) {
+            String selectAddress = data.getStringExtra("selectAddress");
+            if (null!=accompanyFragment){
+                accompanyFragment.selectAddress(selectAddress);
+            }
         }
     }
 

+ 150 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyFragment.java

@@ -33,6 +33,7 @@ import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.alipay.sdk.app.PayTask;
 import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.constanst.Constants;
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
@@ -55,6 +56,9 @@ import com.cooleshow.base.widgets.ViewConvertListener;
 import com.cooleshow.base.widgets.ViewHolder;
 import com.cooleshow.teacher.BuildConfig;
 import com.cooleshow.teacher.api.APIService;
+import com.cooleshow.teacher.bean.alipay.AuthResult;
+import com.cooleshow.teacher.bean.alipay.PayResult;
+import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.FragmentAccompanyBinding;
 import com.cooleshow.teacher.databinding.FragmentMineLayoutBinding;
 import com.cooleshow.teacher.presenter.main.MinePresenter;
@@ -63,9 +67,16 @@ import com.cooleshow.teacher.widgets.FileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceAccomPanyUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
+import com.google.gson.Gson;
 import com.jinmingyunle.midiplaylib.MidiPlayerUtils;
 import com.tbruyelle.rxpermissions3.RxPermissions;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 import org.java_websocket.enums.ReadyState;
 import org.java_websocket.handshake.ServerHandshake;
 import org.jetbrains.annotations.NotNull;
@@ -99,6 +110,10 @@ import okhttp3.ResponseBody;
  */
 public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding, AccompanyPresenter> implements JsInterfaceAccomPanyUtils.onGetMethodsListener {
     private final static String TAG = "AccompanyFragmenttag";
+    private IWXAPI api;
+    private static final int SDK_PAY_FLAG = 1;
+    private static final int SDK_AUTH_FLAG = 2;
+
     FrameLayout viewParent;
     WebView webView;
     //    private UMShareListener mShareListener;
@@ -115,6 +130,13 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         fragment.setArguments(args);
         return fragment;
     }
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        EventBus.getDefault().register(this);
+        api = WXAPIFactory.createWXAPI(getContext(), null);
+        api.registerApp("wx149a928c415c137a");
+    }
 
 
     @Override
@@ -1230,6 +1252,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         if (webSocketClient != null) {
             webSocketClient.close();
         }
+        EventBus.getDefault().unregister(this);
         MidiPlayerUtils.getInstance().stopPlay();
 //        UMShareAPI.get(mContext).release();
 
@@ -1757,6 +1780,133 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
     }
 
     @Override
+    public void joinLiveRoom(String roomId, String teacherId) {
+
+    }
+
+    @Override
+    public void joinChatGroup(String type, String id) {
+
+    }
+
+
+    public void selectAddress(String addressJson) {
+        onSendMessage("'getAddress'," + addressJson);
+    }
+
+    @Override
+    public void paymentOrder(String orderNo, String payChannel, String payInfo) {
+        if (payChannel.equals("ali_app")) {
+            String orderInfo = payInfo;
+            final Runnable payRunnable = new Runnable() {
+                @Override
+                public void run() {
+                    PayTask alipay = new PayTask(getActivity());
+                    Map<String, String> result = alipay.payV2(orderInfo, true);
+                    Log.i("msp", result.toString());
+
+                    Message msg = new Message();
+                    msg.what = SDK_PAY_FLAG;
+                    msg.obj = result;
+                    mHandler.sendMessage(msg);
+                }
+            };
+
+            // 必须异步调用
+            Thread payThread = new Thread(payRunnable);
+            payThread.start();
+        } else {
+            //微信
+            Gson gson = new Gson();
+            WeixinPayInfo weixinPayInfo = gson.fromJson(payInfo, WeixinPayInfo.class);
+            PayReq req = new PayReq();
+            req.appId = weixinPayInfo.getAppid();
+            req.partnerId = weixinPayInfo.getPartnerid();
+            req.prepayId = weixinPayInfo.getPrepayid();
+            req.nonceStr = weixinPayInfo.getNoncestr();
+            req.timeStamp = weixinPayInfo.getTimestamp();
+            req.packageValue = weixinPayInfo.getPackageValue();
+            req.sign = weixinPayInfo.getSign();
+
+//                    req.extData			= "app data"; // optional
+            //正在前往微信支付
+            // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信
+            goPay = true;
+            api.sendReq(req);
+        }
+    }
+
+    private boolean goPay = false;
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void loadEventBus(final String event) {
+        if (goPay) {
+            if (event.equals("PAY_SUCCESS")) {
+                onSendMessage("'paymentOperation',result:SUCCESS");
+            } else if (event.equals("PAY_ERROR")) {
+                onSendMessage("'paymentOperation',result:ERROR");
+            }
+            goPay = false;
+        }
+
+    }
+
+    @SuppressLint("HandlerLeak")
+    private Handler mHandler = new Handler() {
+        @SuppressWarnings("unused")
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case SDK_PAY_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
+                    /**
+                     * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
+                     */
+                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
+                    String resultStatus = payResult.getResultStatus();
+                    // 判断resultStatus 为9000则代表支付成功
+                    if (TextUtils.equals(resultStatus, "9000")) {
+                        // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
+//                        isAlipayOk = true;
+                        ToastUtils.showShort("支付成功");
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+//                        isAlipayOk = false;
+                        // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
+//                        showAlert(VipInfoActivity.this, getString(R.string.pay_failed) + payResult.getMemo());
+                        ToastUtils.showShort("支付失败" + resultStatus);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                case SDK_AUTH_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    AuthResult authResult = new AuthResult((Map<String, String>) msg.obj, true);
+                    String resultStatus = authResult.getResultStatus();
+
+                    // 判断resultStatus 为“9000”且result_code
+                    // 为“200”则代表授权成功,具体状态码代表含义可参考授权接口文档
+                    if (TextUtils.equals(resultStatus, "9000") && TextUtils.equals(authResult.getResultCode(), "200")) {
+                        // 获取alipay_open_id,调支付时作为参数extern_token 的value
+                        // 传入,则支付账户为该授权账户
+//                        showAlert(MainActivity.this, getString(R.string.auth_success) + authResult);
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+                        // 其他状态值则为授权失败
+//                        showAlert(MainActivity.this, getString(R.string.auth_failed) + authResult);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+
+    };
+
+
+    @Override
     public void cloudMetronome(JSONObject message) {
         try {
             JSONObject obj = message.optJSONObject("content");

+ 0 - 10
teacher/src/main/java/com/cooleshow/teacher/ui/web/AddAccompanimentActivity.java

@@ -1,10 +0,0 @@
-package com.cooleshow.teacher.ui.web;
-
-/**
- * 创建日期:2022/6/8 15:17
- *
- * @author Ryan
- * 类说明:
- */
-public class AddAccompanimentActivity {
-}

+ 212 - 47
teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlActivity.java

@@ -3,15 +3,19 @@ package com.cooleshow.teacher.ui.web;
 import static com.cooleshow.base.common.WebConstants.WEB_URL;
 
 import android.Manifest;
-import android.content.ActivityNotFoundException;
+import android.annotation.SuppressLint;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
 import android.text.TextUtils;
 import android.util.Base64;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.ViewGroup;
@@ -35,6 +39,7 @@ import androidx.annotation.Nullable;
 import androidx.constraintlayout.widget.ConstraintLayout;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alipay.sdk.app.PayTask;
 import com.cooleshow.base.BuildConfig;
 import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
@@ -48,12 +53,16 @@ import com.cooleshow.base.widgets.DialogUtil;
 import com.cooleshow.teacher.App;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.api.APIService;
+import com.cooleshow.teacher.bean.alipay.AuthResult;
+import com.cooleshow.teacher.bean.alipay.PayResult;
+import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.ActivityHtml1Binding;
 import com.cooleshow.teacher.widgets.FileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.daya.live_teaching.utils.GlideEngine;
+import com.google.gson.Gson;
 import com.gyf.immersionbar.ImmersionBar;
 import com.luck.picture.lib.PictureSelector;
 import com.luck.picture.lib.config.PictureConfig;
@@ -61,7 +70,13 @@ import com.luck.picture.lib.config.PictureMimeType;
 import com.luck.picture.lib.entity.LocalMedia;
 import com.luck.picture.lib.tools.PictureFileUtils;
 import com.tbruyelle.rxpermissions3.RxPermissions;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 import org.json.JSONException;
 import org.json.JSONObject;
 
@@ -73,15 +88,20 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 import okhttp3.ResponseBody;
+
 @Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
 public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements JsInterfaceUtils.onGetMethodsListener {
     private static final int REQUEST_CODE_FILE_CHOOSER = 500;
     public static final String TAG = "HtmlActivity";
+    private IWXAPI api;
+    private static final int SDK_PAY_FLAG = 1;
+    private static final int SDK_AUTH_FLAG = 2;
 
     ConstraintLayout headerBbarView;
     View view;
@@ -97,6 +117,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
     RelativeLayout rl_activity_html;
     LinearLayout ll_activity_html;
 
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        EventBus.getDefault().register(this);
+        api = WXAPIFactory.createWXAPI(this, null);
+        api.registerApp("wx149a928c415c137a");
+    }
+
     private void initViewLayout() {
         headerBbarView = viewBinding.headerBarView;
         view = viewBinding.view;
@@ -143,11 +171,6 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         String titleStr = intent.getStringExtra("title");
         ivActionIcon = intent.getIntExtra("ivAction", -1);
         startType = intent.getIntExtra("startType", -1);
-        if (ivActionIcon > 0 && 1000 == startType) {
-            ivAction.setImageResource(ivActionIcon);
-            ivAction.setVisibility(View.VISIBLE);
-            ivAction.setOnClickListener(v -> startActivityForResult(new Intent(this, AddAccompanimentActivity.class), ADD_ACCOMPANIMENT_CODE));
-        }
         content = intent.getStringExtra("content");
         //        bean = (PayBean) intent.getSerializableExtra("bean");
         isGoback = intent.getBooleanExtra("isGoback", true);
@@ -485,6 +508,132 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         HtmlActivity.this.finish();
     }
 
+    @Override
+    public void joinLiveRoom(String roomId, String teacherId) {
+
+    }
+
+    @Override
+    public void joinChatGroup(String type, String id) {
+
+    }
+
+    public void selectAddress(String addressJson) {
+        onSendMessage("'getAddress'," + addressJson);
+    }
+
+    @Override
+    public void paymentOrder(String orderNo, String payChannel, String payInfo) {
+        if (payChannel.equals("ali_app")) {
+            String orderInfo = payInfo;
+            final Runnable payRunnable = new Runnable() {
+                @Override
+                public void run() {
+                    PayTask alipay = new PayTask(HtmlActivity.this);
+                    Map<String, String> result = alipay.payV2(orderInfo, true);
+                    Log.i("msp", result.toString());
+
+                    Message msg = new Message();
+                    msg.what = SDK_PAY_FLAG;
+                    msg.obj = result;
+                    mHandler.sendMessage(msg);
+                }
+            };
+
+            // 必须异步调用
+            Thread payThread = new Thread(payRunnable);
+            payThread.start();
+        } else {
+            //微信
+            Gson gson = new Gson();
+            WeixinPayInfo weixinPayInfo = gson.fromJson(payInfo, WeixinPayInfo.class);
+            PayReq req = new PayReq();
+            req.appId = weixinPayInfo.getAppid();
+            req.partnerId = weixinPayInfo.getPartnerid();
+            req.prepayId = weixinPayInfo.getPrepayid();
+            req.nonceStr = weixinPayInfo.getNoncestr();
+            req.timeStamp = weixinPayInfo.getTimestamp();
+            req.packageValue = weixinPayInfo.getPackageValue();
+            req.sign = weixinPayInfo.getSign();
+
+//                    req.extData			= "app data"; // optional
+            //正在前往微信支付
+            // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信
+            goPay = true;
+            api.sendReq(req);
+        }
+    }
+
+    private boolean goPay = false;
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void loadEventBus(final String event) {
+        if (goPay) {
+            if (event.equals("PAY_SUCCESS")) {
+                onSendMessage("'paymentOperation',result:SUCCESS");
+            } else if (event.equals("PAY_ERROR")) {
+                onSendMessage("'paymentOperation',result:ERROR");
+            }
+            goPay = false;
+        }
+
+    }
+
+
+    @SuppressLint("HandlerLeak")
+    private Handler mHandler = new Handler() {
+        @SuppressWarnings("unused")
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case SDK_PAY_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    PayResult payResult = new PayResult((Map<String, String>) msg.obj);
+                    /**
+                     * 对于支付结果,请商户依赖服务端的异步通知结果。同步通知结果,仅作为支付结束的通知。
+                     */
+                    String resultInfo = payResult.getResult();// 同步返回需要验证的信息
+                    String resultStatus = payResult.getResultStatus();
+                    // 判断resultStatus 为9000则代表支付成功
+                    if (TextUtils.equals(resultStatus, "9000")) {
+                        // 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
+//                        isAlipayOk = true;
+                        ToastUtils.showShort("支付成功");
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+//                        isAlipayOk = false;
+                        // 该笔订单真实的支付结果,需要依赖服务端的异步通知。
+//                        showAlert(VipInfoActivity.this, getString(R.string.pay_failed) + payResult.getMemo());
+                        ToastUtils.showShort("支付失败" + resultStatus);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                case SDK_AUTH_FLAG: {
+                    @SuppressWarnings("unchecked")
+                    AuthResult authResult = new AuthResult((Map<String, String>) msg.obj, true);
+                    String resultStatus = authResult.getResultStatus();
+
+                    // 判断resultStatus 为“9000”且result_code
+                    // 为“200”则代表授权成功,具体状态码代表含义可参考授权接口文档
+                    if (TextUtils.equals(resultStatus, "9000") && TextUtils.equals(authResult.getResultCode(), "200")) {
+                        // 获取alipay_open_id,调支付时作为参数extern_token 的value
+                        // 传入,则支付账户为该授权账户
+//                        showAlert(MainActivity.this, getString(R.string.auth_success) + authResult);
+                        onSendMessage("'paymentOperation',result:SUCCESS");
+                    } else {
+                        // 其他状态值则为授权失败
+//                        showAlert(MainActivity.this, getString(R.string.auth_failed) + authResult);
+                        onSendMessage("'paymentOperation',result:ERROR");
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+
+    };
+
 
     @Override
     public void chooseFile(JSONObject message) {
@@ -492,7 +641,9 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         showFileChooser();
 
     }
+
     private JSONObject baseJsonObject;
+
     private void showFileChooser() {
         JSONObject content = (JSONObject) baseJsonObject.opt("content");
         String type = "";
@@ -509,6 +660,10 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
             intent.setType("video/*");
         } else if (type.equals("mp3")) {
             intent.setType("audio/*");
+        } else if (type.equals("xml")) {
+            intent.setType("text/xml");
+        } else if (type.equals("midi")) {
+            intent.setType("audio/midi");
         } else {
             intent.setType("*/*");
         }
@@ -846,9 +1001,8 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
             } catch (JSONException e) {
                 e.printStackTrace();
             }
-        }
-        if (data != null) {
-            if (requestCode == 1000) {
+        } else if (requestCode == 1000) {
+            if (data != null) {
                 try {
                     String filePath = data.getStringExtra("filePath");
                     JSONObject jsonObject = new JSONObject();
@@ -877,51 +1031,58 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                     mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
                 }
                 mUploadCallbackAboveL = null;
-            }
 
-            if (requestCode == REQUEST_CODE_FILE_CHOOSER) {
-                Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
-                if (result != null) {
-                    File file = UriUtils.uri2File(result);
-                    if (file != null && file.exists()) {
-                        UploadHelper uploadHelper = new UploadHelper(HtmlActivity.this);
-                        uploadHelper.uploadFile(file);
-                        uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
-                            @Override
-                            public void onSuccess(String url) {
-                                try {
-                                    JSONObject jsonObject = new JSONObject();
-                                    JSONObject contentObj = baseJsonObject.getJSONObject("content");
-                                    String uuid = contentObj.getString("uuid");
-                                    jsonObject.put("type", "success");
-                                    jsonObject.put("fileUrl", url);
-                                    jsonObject.put("uuid", uuid);
-                                    jsonObject.put("message", "上传成功");
-                                    onSendMessage(jsonObject.toString());
-                                } catch (JSONException e) {
-                                    e.printStackTrace();
-                                }
+            } else {
+                if (mUploadCallbackAboveL != null)
+                    mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
+            }
+        } else if (requestCode == REQUEST_CODE_FILE_CHOOSER) {
+            Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
+            if (result != null) {
+                File file = UriUtils.uri2File(result);
+                if (file != null && file.exists()) {
+                    UploadHelper uploadHelper = new UploadHelper(HtmlActivity.this);
+                    uploadHelper.uploadFile(file);
+                    uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
+                        @Override
+                        public void onSuccess(String url) {
+                            try {
+                                JSONObject jsonObject = new JSONObject();
+                                JSONObject contentObj = baseJsonObject.getJSONObject("content");
+                                String uuid = contentObj.getString("uuid");
+                                jsonObject.put("type", "success");
+                                jsonObject.put("fileUrl", url);
+                                jsonObject.put("uuid", uuid);
+                                jsonObject.put("message", "上传成功");
+                                onSendMessage(jsonObject.toString());
+                            } catch (JSONException e) {
+                                e.printStackTrace();
                             }
+                        }
 
-                            @Override
-                            public void onFailure() {
-                                ToastUtils.showShort("上传失败,请重新选择");
-                                upLoadFileFaile();
-                            }
-                        });
-                    } else {
-                        ToastUtils.showShort("文件损坏或不存在,请重新选择");
-                        upLoadFileFaile();
-                    }
+                        @Override
+                        public void onFailure() {
+                            ToastUtils.showShort("上传失败,请重新选择");
+                            upLoadFileFaile();
+                        }
+                    });
+                } else {
+                    ToastUtils.showShort("文件损坏或不存在,请重新选择");
+                    upLoadFileFaile();
                 }
-//            clearUploadMessage();
-                return;
+            } else {
+                ToastUtils.showShort("上传失败,请重新选择");
+                upLoadFileFaile();
             }
-        } else {
-            if (mUploadCallbackAboveL != null)
-                mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
+//            clearUploadMessage();
+            return;
+        } else if (requestCode == 1011) {
+            String selectAddress = data.getStringExtra("selectAddress");
+            selectAddress(selectAddress);
         }
+
     }
+
     private void upLoadFileFaile() {
         try {
             JSONObject contentObj = baseJsonObject.getJSONObject("content");
@@ -942,6 +1103,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
         if (null != webView) {
             webView.destroy();
         }
+        EventBus.getDefault().unregister(this);
 //        UMShareAPI.get(HtmlActivity.this).release();
     }
 
@@ -962,6 +1124,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
             setStatusBlackBarColor();
         }
     }
+
     public void setStatusBarColor() {
         ImmersionBar.with(this)
                 .keyboardEnable(true)
@@ -972,6 +1135,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                 .init();  //必须调用方可沉浸
 
     }
+
     public void setStatusBlackBarColor() {
         ImmersionBar.with(this)
                 .keyboardEnable(true)
@@ -981,6 +1145,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                 .flymeOSStatusBarFontColor(com.cooleshow.base.R.color.common_black)  //修改flyme OS状态栏字体颜色
                 .init();  //必须调用方可沉浸
     }
+
     @Override
     public void onAccompanySelecResult(String id, String name) {
         Intent intent = new Intent();

Diff do ficheiro suprimidas por serem muito extensas
+ 351 - 0
teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlHorizontalScreenActivity.java


+ 164 - 147
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceAccomPanyUtils.java

@@ -48,16 +48,14 @@ public class JsInterfaceAccomPanyUtils extends Object {
                 String api = jsonObject.getString("api");
                 if ("back".equals(api)) {
                     activity.finish();
-                }
-                else if ("login".equals(api)) {
+                } else if ("login".equals(api)) {
                     UserHelper.saveUserToken("");
                     ARouter.getInstance().build(RouterPath.UserCenter.PATH_VERIFY_LOGIN)
                             .withString(UserConstants.PHONE_NUM_KEY, UserHelper.getUserPhone())
                             .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
                             .navigation();
                     activity.finish();
-                }
-                else if ("openConversationActivity".equals(api)) {
+                } else if ("openConversationActivity".equals(api)) {
                     JSONObject contentBean = jsonObject.getJSONObject("content");
                     if (null != contentBean) {
                         RongIM.getInstance().startPrivateChat(activity, contentBean.getString("userId"), contentBean.getString("name"));
@@ -67,44 +65,34 @@ public class JsInterfaceAccomPanyUtils extends Object {
                                     Uri.parse(contentBean.getString("img"))));
                         }
                     }
-                }
-
-                else if ("videoUpdate".equals(api)) {
+                } else if ("videoUpdate".equals(api)) {
                     if (onListener != null) {
                         onListener.videoUpdate(jsonObject);
                     }
-                }
-                else if ("setRequestedOrientation".equals(api)) {
+                } else if ("setRequestedOrientation".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     int orientation = content.getInt("orientation");
                     activity.setRequestedOrientation(orientation);
                     if (onListener != null)
                         onListener.onSendMessage(content.toString());
-                }
-
-                else if ("keepScreenLongLight".equals(api)) {
+                } else if ("keepScreenLongLight".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     boolean isOpenLight = content.getBoolean("isOpenLight");
                     keepScreenLongLight(isOpenLight);
                     if (onListener != null)
                         onListener.onSendMessage(content.toString());
-                }
-
-                else if ("setStatusBarTextColor".equals(api)) {
+                } else if ("setStatusBarTextColor".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     boolean statusBarTextColor = content.getBoolean("statusBarTextColor");
                     if (onListener != null)
                         onListener.setStatusBarTextColor(statusBarTextColor, jsonObject);
-                }
-
-                else if ("isSpecialShapedScreen".equals(api)) {
+                } else if ("isSpecialShapedScreen".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     content.put("isSpecialShapedScreen", ImmersionBar.hasNotchScreen(activity));
                     content.put("notchHeight", ImmersionBar.getNotchHeight(activity));
                     if (onListener != null)
                         onListener.onSendMessage(jsonObject.toString());
-                }
-                else if ("openWebView".equals(api)) {
+                } else if ("openWebView".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     boolean isHideTitle = false;
                     boolean statusBarTextColor = false;
@@ -120,7 +108,7 @@ public class JsInterfaceAccomPanyUtils extends Object {
 
                     String path = RouterPath.WebCenter.ACTIVITY_HTML;
                     if (orientation == 0) {
-                        path =RouterPath.WebCenter.ACTIVITY_HORIZONTAL_SCREEN_HTML;
+                        path = RouterPath.WebCenter.ACTIVITY_HORIZONTAL_SCREEN_HTML;
                     }
                     ARouter.getInstance().build(path)
                             .withString("url", content.getString("url"))
@@ -129,8 +117,7 @@ public class JsInterfaceAccomPanyUtils extends Object {
                             .withBoolean("isOpenLight", isOpenLight)
                             .withInt("orientation", orientation)
                             .navigation();
-                }
-                else if ("openAccompanyWebView".equals(api)) {
+                } else if ("openAccompanyWebView".equals(api)) {
                     JSONObject content = jsonObject.getJSONObject("content");
                     boolean isHideTitle = false;
                     boolean statusBarTextColor = false;
@@ -152,95 +139,72 @@ public class JsInterfaceAccomPanyUtils extends Object {
                             .withInt("orientation", orientation)
                             .navigation();
 
-                }
-
-                else if ("startEvaluating".equals(api)) {
+                } else if ("startEvaluating".equals(api)) {
                     if (onListener != null) {
                         onListener.startEvaluating(jsonObject);
                     }
-                }
-
-                else if ("endEvaluating".equals(api)) {
+                } else if ("endEvaluating".equals(api)) {
                     if (onListener != null) {
                         onListener.endEvaluating(jsonObject);
                     }
-                }
-                else if ("cancelEvaluating".equals(api)) {
+                } else if ("cancelEvaluating".equals(api)) {
                     if (onListener != null) {
                         onListener.cancelEvaluating();
                         onListener.onSendMessage(message);
                     }
-                }
-
-
-                else if ("startRecording".equals(api)) {
+                } else if ("startRecording".equals(api)) {
                     if (onListener != null) {
                         onListener.startRecording(jsonObject);
                     }
-                }
-
-                else if ("pauseRecording".equals(api)) {
+                } else if ("pauseRecording".equals(api)) {
                     if (onListener != null) {
                         onListener.pauseRecording(jsonObject);
                     }
-                }
-                else if ("resumeRecording".equals(api)) {
+                } else if ("resumeRecording".equals(api)) {
                     if (onListener != null) {
                         onListener.resumeRecording(jsonObject);
                     }
-                }
-                else if ("isWiredHeadsetOn".equals(api)) {
+                } else if ("isWiredHeadsetOn".equals(api)) {
                     if (onListener != null) {
                         onListener.isWiredHeadsetOn(jsonObject);
                     }
-                }
-                else if ("proxyMessage".equals(api)) {
+                } else if ("proxyMessage".equals(api)) {
                     if (onListener != null) {
                         onListener.proxyMessage(jsonObject);
                     }
-                }
-                else if ("openCamera".equals(api)) {
+                } else if ("openCamera".equals(api)) {
                     if (onListener != null) {
                         onListener.openCamera(jsonObject);
                     }
-                }
-                else if ("closeCamera".equals(api)) {
+                } else if ("closeCamera".equals(api)) {
                     if (onListener != null) {
                         onListener.closeCamera(jsonObject);
                     }
-                }
-                else if ("startCapture".equals(api)) {
+                } else if ("startCapture".equals(api)) {
                     if (onListener != null) {
                         onListener.startCapture(jsonObject);
                     }
-                }
-                else if ("endCapture".equals(api)) {
+                } else if ("endCapture".equals(api)) {
                     if (onListener != null) {
                         onListener.endCapture(jsonObject);
                     }
-                }
-
-                else if ("endRecording".equals(api)) {
+                } else if ("endRecording".equals(api)) {
                     if (onListener != null) {
                         onListener.endRecording(jsonObject);
                     }
-                }
-                else if ("startSoundCheck".equals(api)) {
+                } else if ("startSoundCheck".equals(api)) {
                     if (onListener != null) {
                         onListener.startSoundCheck(jsonObject);
                     }
-                }
-                else if ("endSoundCheck".equals(api)) {
+                } else if ("endSoundCheck".equals(api)) {
                     if (onListener != null) {
                         onListener.endSoundCheck(jsonObject);
                     }
-                }
-                else if ("proxyServiceMessage".equals(api)) {
+                } else if ("proxyServiceMessage".equals(api)) {
                     if (onListener != null) {
                         onListener.proxyServiceMessage(jsonObject);
                     }
-                }
-                else if ("keepScreenLongLight".equals(api)) {
+                } else if ("keepScreenLongLight".equals(api)) {
                     if (onListener != null) {
                         onListener.keepScreenLongLight(jsonObject);
                     }
@@ -304,21 +268,40 @@ public class JsInterfaceAccomPanyUtils extends Object {
                     if (onListener != null) {
                         onListener.cloudVolume(jsonObject);
                     }
-                }
-                else if("cloudGetMediaStatus".equals(api)){
+                } else if ("cloudGetMediaStatus".equals(api)) {
                     if (onListener != null) {
                         onListener.cloudGetMediaStatus(jsonObject);
                     }
-                }
-                else if("cloudMetronome".equals(api)){
-                    if(onListener != null){
+                } else if ("cloudMetronome".equals(api)) {
+                    if (onListener != null) {
                         onListener.cloudMetronome(jsonObject);
                     }
-                }
-                else if("cloudDestroy".equals(api)){
-                    if(onListener != null){
+                } else if ("cloudDestroy".equals(api)) {
+                    if (onListener != null) {
                         onListener.cloudDestroy(jsonObject);
                     }
+                } else if ("joinLiveRoom".equals(api)) {
+                    //进入直播间
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinLiveRoom(content.getString("roomId"), content.getString("teacherId"));
+                    }
+                } else if ("joinChatGroup".equals(api)) {
+                    //进入聊天
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinChatGroup(content.getString("type"), content.getString("id"));
+                    }
+                } else if ("setAddress".equals(api)) {
+                    //跳转地址页面
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+                            .navigation(activity, 1011);
+                } else if ("paymentOrder".equals(api)) {
+                    //支付
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.paymentOrder(content.getString("orderNo"), content.getString("payChannel"), content.getString("payInfo"));
+                    }
                 }
             } catch (Exception e) {
 
@@ -402,13 +385,14 @@ public class JsInterfaceAccomPanyUtils extends Object {
          * 初始化midi文件,初始速度,默认拍号的分子和分母
          * {
          * api: 'cloudDetail',
-         * 	content: {
-         * 		midi: '',
-         * 		denominator: 4,
-         * 		numerator: 4,
-         * 		// xml整体原始速度
-         * 		originalSpeed: 90,
-         *        }
+         * content: {
+         * midi: '',
+         * denominator: 4,
+         * numerator: 4,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * }
+         *
          * @param message
          */
         void cloudDetail(JSONObject message);
@@ -416,34 +400,35 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 播放
          * {
-         * 	api: 'cloudPlay',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// xml整体原始速度
-         * 		originalSpeed: 90,
-         * 		// 当前选择速度
-         * 		speed: 90,
-         * 		// 开始时间(ms)
-         * 		startTime: 0
-         *        }
+         * api: 'cloudPlay',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * // 当前选择速度
+         * speed: 90,
+         * // 开始时间(ms)
+         * startTime: 0
+         * }
          * })
-         *
+         * <p>
          * // 返回数据
-         *
+         * <p>
          * {
-         * 	api: 'cloudPlay',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// xml整体原始速度
-         * 		originalSpeed: 90,
-         * 		// 当前选择速度
-         * 		speed: 90,
-         * 		// 开始时间(ms)
-         * 		startTime: 0
-         *    }
+         * api: 'cloudPlay',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * // 当前选择速度
+         * speed: 90,
+         * // 开始时间(ms)
+         * startTime: 0
+         * }
          * }
+         *
          * @param message
          */
         void cloudPlay(JSONObject message);
@@ -451,23 +436,24 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 暂停
          * {
-         * 	api: 'cloudSuspend',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         *        }
+         * api: 'cloudSuspend',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * }
          * })
-         *
+         * <p>
          * // 返回数据
          * {
-         * 	api: 'cloudSuspend',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// 暂停位置时间(ms)
-         * 		currentTime: 0
-         *    }
+         * api: 'cloudSuspend',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 暂停位置时间(ms)
+         * currentTime: 0
          * }
+         * }
+         *
          * @param message
          */
         void cloudSuspend(JSONObject message);
@@ -476,14 +462,15 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 跳转指定位置
          * {
-         * 	api: 'cloudSetCurrentTime',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// 指定位置时间(ms)
-         * 		currentTime: 0
-         *        }
+         * api: 'cloudSetCurrentTime',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 指定位置时间(ms)
+         * currentTime: 0
+         * }
          * }
+         *
          * @param message
          */
         void cloudSetCurrentTime(JSONObject message);
@@ -491,16 +478,17 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 调速 范围(45-270整数)
          * {
-         * 	api: 'cloudChangeSpeed',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// 调整速度
-         * 		speed: 90
-         * 		// xml整体原始速度
-         * 		originalSpeed: 90,
-         *        }
+         * api: 'cloudChangeSpeed',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 调整速度
+         * speed: 90
+         * // xml整体原始速度
+         * originalSpeed: 90,
+         * }
          * }
+         *
          * @param message
          */
         void cloudChangeSpeed(JSONObject message);
@@ -508,16 +496,17 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 原声/伴奏切换
          * {
-         * 	api: 'cloudSwitch',
-         * 	content: {
-         * 		// 当前曲目id
-         * 		songID: 0,
-         * 		// 需要静音的渠道,为空全部不静音
-         * 		parts: [
-         * 			''
-         * 		]
-         *        }
+         * api: 'cloudSwitch',
+         * content: {
+         * // 当前曲目id
+         * songID: 0,
+         * // 需要静音的渠道,为空全部不静音
+         * parts: [
+         * ''
+         * ]
+         * }
          * }
+         *
          * @param message
          */
         void cloudSwitch(JSONObject message);
@@ -527,32 +516,60 @@ public class JsInterfaceAccomPanyUtils extends Object {
         /**
          * 获取播放状态
          * {
-         * 	api: 'cloudGetMediaStatus'
+         * api: 'cloudGetMediaStatus'
          * })
-         *
+         * <p>
          * // 返回
-         *
+         * <p>
          * {
-         * 	api: 'cloudGetMediaStatus',
-         * 	content: {
-         * 		status: 'init' | 'play' | 'suspend'
-         *        }
+         * api: 'cloudGetMediaStatus',
+         * content: {
+         * status: 'init' | 'play' | 'suspend'
+         * }
          * }
+         *
          * @param message
          */
         void cloudGetMediaStatus(JSONObject message);
 
         /**
          * 节拍器控制
+         *
          * @param message
          */
         void cloudMetronome(JSONObject message);
 
         /**
          * 销毁
+         *
          * @param message
          */
         void cloudDestroy(JSONObject message);
+
+        /**
+         * 进入直播间
+         *
+         * @param roomId
+         * @param teacherId
+         */
+        void joinLiveRoom(String roomId, String teacherId);
+
+        /**
+         * 进入聊天
+         *
+         * @param type // single 单人 multi 多人
+         * @param id
+         */
+        void joinChatGroup(String type, String id);
+
+        /**
+         * 支付
+         *
+         * @param orderNo
+         * @param payChannel
+         * @param payInfo
+         */
+        void paymentOrder(String orderNo, String payChannel, String payInfo);
     }
 
 }

+ 55 - 2
teacher/src/main/java/com/cooleshow/teacher/widgets/helper/JsInterfaceUtils.java

@@ -1,5 +1,7 @@
 package com.cooleshow.teacher.widgets.helper;
 
+import static com.cooleshow.base.common.WebConstants.WEB_URL;
+
 import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
@@ -134,7 +136,7 @@ public class JsInterfaceUtils extends Object {
                         path = RouterPath.WebCenter.ACTIVITY_HORIZONTAL_SCREEN_HTML;
                     }
                     ARouter.getInstance().build(path)
-                            .withString("url", content.getString("url"))
+                            .withString(WEB_URL, content.getString("url"))
                             .withBoolean("isHideTitle", isHideTitle)
                             .withBoolean("statusBarTextColor", statusBarTextColor)
                             .withBoolean("isOpenLight", isOpenLight)
@@ -155,7 +157,7 @@ public class JsInterfaceUtils extends Object {
                     } catch (Exception e) {
                     }
                     ARouter.getInstance().build(RouterPath.WebCenter.ACTIVITY_ACCOMPANY_HTML)
-                            .withString("url", content.getString("url"))
+                            .withString(WEB_URL, content.getString("url"))
                             .withBoolean("isHideTitle", isHideTitle)
                             .withBoolean("statusBarTextColor", statusBarTextColor)
                             .withBoolean("isOpenLight", isOpenLight)
@@ -209,6 +211,32 @@ public class JsInterfaceUtils extends Object {
                         onListener.authToBack(jsonObject);
                     }
                 }
+                //进入直播间
+                if ("joinLiveRoom".equals(api)) {
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinLiveRoom(content.getString("roomId"), content.getString("teacherId"));
+                    }
+                }
+                //进入聊天
+                if ("joinChatGroup".equals(api)){
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.joinChatGroup(content.getString("type"),content.getString("id"));
+                    }
+                }
+                //跳转地址页面
+                if ("setAddress".equals(api)){
+                    ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
+                            .navigation(activity,1011);
+                }
+                //支付
+                if ("paymentOrder".equals(api)){
+                    JSONObject content = jsonObject.getJSONObject("content");
+                    if (onListener != null) {
+                        onListener.paymentOrder(content.getString("orderNo"),content.getString("payChannel"),content.getString("payInfo"));
+                    }
+                }
             } catch (Exception e) {
             }
         });
@@ -240,12 +268,14 @@ public class JsInterfaceUtils extends Object {
         void onAccompanySelecResult(String id, String name);
 
         void downloadFile(String url);
+
         /**
          * 选择文件
          *
          * @param message
          */
         void chooseFile(JSONObject message);
+
         //分享
         void createRightNavToShareButton(String image, String url);
 
@@ -276,6 +306,29 @@ public class JsInterfaceUtils extends Object {
         void setBarStatus(JSONObject message);
 
         void authToBack(JSONObject message);
+
+        /**
+         * 进入直播间
+         *
+         * @param roomId
+         * @param teacherId
+         */
+        void joinLiveRoom(String roomId, String teacherId);
+
+        /**
+         * 进入聊天
+         * @param type // single 单人 multi 多人
+         * @param id
+         */
+        void joinChatGroup(String type,String id);
+
+        /**
+         * 支付
+         * @param orderNo
+         * @param payChannel
+         * @param payInfo
+         */
+        void paymentOrder(String orderNo,String payChannel,String payInfo);
     }
 
 }

+ 19 - 0
teacher/src/main/res/layout/activity_add_accompaniment.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/color_f6f8f9"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout" />
+
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/rv_list"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:overScrollMode="never" />
+</LinearLayout>

+ 35 - 0
teacher/src/main/res/layout/activity_select_address_list.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/color_f6f8f9"
+    android:orientation="vertical">
+
+    <include
+        android:id="@+id/toolbar_include"
+        layout="@layout/common_toolbar_layout" />
+
+
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/rv_address"
+        android:layout_below="@+id/toolbar_include"
+        android:layout_width="match_parent"
+        android:layout_marginTop="15dp"
+        android:layout_marginBottom="80dp"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:id="@+id/tv_add"
+        android:layout_width="match_parent"
+        android:layout_height="44dp"
+        android:layout_alignParentBottom="true"
+        android:layout_marginLeft="28dp"
+        android:layout_marginTop="27dp"
+        android:layout_marginRight="28dp"
+        android:layout_marginBottom="48dp"
+        android:background="@drawable/shape_course_status_ing"
+        android:gravity="center"
+        android:text="添加新地址"
+        android:textColor="@color/white"
+        android:textSize="@dimen/sp_14" />
+</RelativeLayout>

+ 128 - 0
teacher/src/main/res/layout/fragment_mall.xml

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/rl_activity_html"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/fl_video"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="gone" />
+
+    <FrameLayout
+        android:layout_below="@+id/ll_activity_html"
+        android:id="@+id/view_parent"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:scrollbars="none" />
+    <LinearLayout
+        android:id="@+id/ll_activity_html"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+        <View
+            android:id="@+id/view_statusbar"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/statusbar_view_height"
+            android:background="#BCF1EB"
+            android:visibility="gone" />
+
+        <ProgressBar
+            android:id="@+id/progressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="match_parent"
+            android:layout_height="2dip"
+            android:progressDrawable="@drawable/pg_stu" />
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:id="@+id/header_bar_view"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <View
+                android:id="@+id/view"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/statusbar_view_height"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent" />
+
+            <ImageView
+                android:id="@+id/btn_back"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_back"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/btn_close"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_44"
+                android:paddingStart="@dimen/dp_12"
+                android:paddingEnd="@dimen/dp_12"
+                android:scaleType="center"
+                android:src="@drawable/ic_html_close_stu"
+                app:layout_constraintStart_toEndOf="@id/btn_back"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_title"
+                android:layout_width="0dp"
+                android:layout_height="@dimen/dp_40"
+                android:layout_marginStart="@dimen/dp_90"
+                android:layout_marginEnd="@dimen/dp_90"
+                android:ellipsize="marquee"
+                android:focusable="true"
+                android:focusableInTouchMode="true"
+                android:gravity="center"
+                android:paddingStart="@dimen/dp_15"
+                android:paddingEnd="@dimen/dp_15"
+                android:singleLine="true"
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_18"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <TextView
+                android:id="@+id/tv_action"
+                android:layout_width="wrap_content"
+                android:layout_height="@dimen/dp_40"
+                android:gravity="center"
+                android:paddingEnd="@dimen/dp_15"
+                android:text=""
+                android:textColor="@color/black"
+                android:textSize="@dimen/dp_16"
+                android:visibility="invisible"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+
+            <ImageView
+                android:id="@+id/iv_action"
+                android:layout_width="@dimen/dp_44"
+                android:layout_height="@dimen/dp_44"
+                android:layout_marginEnd="@dimen/dp_10"
+                android:scaleType="center"
+                android:padding="@dimen/dp_5"
+                android:src="@drawable/ic_delete"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/view" />
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+    </LinearLayout>
+
+
+
+</RelativeLayout>

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff