|
@@ -11,6 +11,7 @@ import android.view.WindowManager;
|
|
import android.webkit.JavascriptInterface;
|
|
import android.webkit.JavascriptInterface;
|
|
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
|
|
+import com.cooleshow.base.common.WebApi;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.base.router.RouterPath;
|
|
import com.cooleshow.usercenter.UserConstants;
|
|
import com.cooleshow.usercenter.UserConstants;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
@@ -25,7 +26,6 @@ import io.rong.imlib.model.UserInfo;
|
|
* Description:
|
|
* Description:
|
|
* Copyright : Copyright (c) 2016
|
|
* Copyright : Copyright (c) 2016
|
|
* Company : 大雅
|
|
* Company : 大雅
|
|
- * Author : 刘瑞
|
|
|
|
* Date : 2018/11/12 15:23
|
|
* Date : 2018/11/12 15:23
|
|
*/
|
|
*/
|
|
public class JsInterfaceUtils extends Object {
|
|
public class JsInterfaceUtils extends Object {
|
|
@@ -51,6 +51,7 @@ public class JsInterfaceUtils extends Object {
|
|
String api = jsonObject.getString("api");
|
|
String api = jsonObject.getString("api");
|
|
if ("back".equals(api)) {
|
|
if ("back".equals(api)) {
|
|
activity.finish();
|
|
activity.finish();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("login".equals(api)) {
|
|
if ("login".equals(api)) {
|
|
UserHelper.saveUserToken("");
|
|
UserHelper.saveUserToken("");
|
|
@@ -59,6 +60,7 @@ public class JsInterfaceUtils extends Object {
|
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
.navigation();
|
|
.navigation();
|
|
activity.finish();
|
|
activity.finish();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("openConversationActivity".equals(api)) {
|
|
if ("openConversationActivity".equals(api)) {
|
|
JSONObject contentBean = jsonObject.getJSONObject("content");
|
|
JSONObject contentBean = jsonObject.getJSONObject("content");
|
|
@@ -70,6 +72,7 @@ public class JsInterfaceUtils extends Object {
|
|
Uri.parse(contentBean.getString("img"))));
|
|
Uri.parse(contentBean.getString("img"))));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if (TextUtils.equals("chooseFile", api)) {
|
|
if (TextUtils.equals("chooseFile", api)) {
|
|
//选择文件
|
|
//选择文件
|
|
@@ -82,30 +85,38 @@ public class JsInterfaceUtils extends Object {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
int orientation = content.getInt("orientation");
|
|
int orientation = content.getInt("orientation");
|
|
activity.setRequestedOrientation(orientation);
|
|
activity.setRequestedOrientation(orientation);
|
|
- if (onListener != null)
|
|
|
|
|
|
+ if (onListener != null) {
|
|
onListener.onSendMessage(content.toString());
|
|
onListener.onSendMessage(content.toString());
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
if ("keepScreenLongLight".equals(api)) {
|
|
if ("keepScreenLongLight".equals(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
boolean isOpenLight = content.getBoolean("isOpenLight");
|
|
boolean isOpenLight = content.getBoolean("isOpenLight");
|
|
keepScreenLongLight(isOpenLight);
|
|
keepScreenLongLight(isOpenLight);
|
|
- if (onListener != null)
|
|
|
|
|
|
+ if (onListener != null) {
|
|
onListener.onSendMessage(content.toString());
|
|
onListener.onSendMessage(content.toString());
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
if ("setStatusBarTextColor".equals(api)) {
|
|
if ("setStatusBarTextColor".equals(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
boolean statusBarTextColor = content.getBoolean("statusBarTextColor");
|
|
boolean statusBarTextColor = content.getBoolean("statusBarTextColor");
|
|
- if (onListener != null)
|
|
|
|
|
|
+ if (onListener != null) {
|
|
onListener.setStatusBarTextColor(statusBarTextColor);
|
|
onListener.setStatusBarTextColor(statusBarTextColor);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("isSpecialShapedScreen".equals(api)) {
|
|
if ("isSpecialShapedScreen".equals(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
content.put("isSpecialShapedScreen", ImmersionBar.hasNotchScreen(activity));
|
|
content.put("isSpecialShapedScreen", ImmersionBar.hasNotchScreen(activity));
|
|
content.put("notchHeight", ImmersionBar.getNotchHeight(activity));
|
|
content.put("notchHeight", ImmersionBar.getNotchHeight(activity));
|
|
- if (onListener != null)
|
|
|
|
|
|
+ if (onListener != null) {
|
|
onListener.onSendMessage(jsonObject.toString());
|
|
onListener.onSendMessage(jsonObject.toString());
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("getToken".equals(api)) {
|
|
if ("getToken".equals(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
@@ -114,8 +125,10 @@ public class JsInterfaceUtils extends Object {
|
|
content.put("tokenType", s[0]);
|
|
content.put("tokenType", s[0]);
|
|
content.put("accessToken", s[1]);
|
|
content.put("accessToken", s[1]);
|
|
|
|
|
|
- if (onListener != null)
|
|
|
|
|
|
+ if (onListener != null) {
|
|
onListener.onSendMessage(jsonObject.toString());
|
|
onListener.onSendMessage(jsonObject.toString());
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
if ("openWebView".equals(api)) {
|
|
if ("openWebView".equals(api)) {
|
|
@@ -142,6 +155,7 @@ public class JsInterfaceUtils extends Object {
|
|
.withBoolean("isOpenLight", isOpenLight)
|
|
.withBoolean("isOpenLight", isOpenLight)
|
|
.withInt("orientation", orientation)
|
|
.withInt("orientation", orientation)
|
|
.navigation();
|
|
.navigation();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("openAccompanyWebView".equals(api)) {
|
|
if ("openAccompanyWebView".equals(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
@@ -163,6 +177,7 @@ public class JsInterfaceUtils extends Object {
|
|
.withBoolean("isOpenLight", isOpenLight)
|
|
.withBoolean("isOpenLight", isOpenLight)
|
|
.withInt("orientation", orientation)
|
|
.withInt("orientation", orientation)
|
|
.navigation();
|
|
.navigation();
|
|
|
|
+ return;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -171,6 +186,7 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.onAccompanySelecResult(String.valueOf(content.getInt("id")), content.getString("name"));
|
|
onListener.onAccompanySelecResult(String.valueOf(content.getInt("id")), content.getString("name"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
|
|
|
|
}
|
|
}
|
|
if ("downloadFile".equals(api)) {
|
|
if ("downloadFile".equals(api)) {
|
|
@@ -178,6 +194,7 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.downloadFile(content.getString("downloadUrl"));
|
|
onListener.downloadFile(content.getString("downloadUrl"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -186,17 +203,20 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.shareAchievements(jsonObject);
|
|
onListener.shareAchievements(jsonObject);
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
if ("backIconChange".equals(api)) {
|
|
if ("backIconChange".equals(api)) {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.backIconChange(jsonObject);
|
|
onListener.backIconChange(jsonObject);
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("getNavHeight".equals(api)) {
|
|
if ("getNavHeight".equals(api)) {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.getNavHeight(jsonObject);
|
|
onListener.getNavHeight(jsonObject);
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* { status: 0 隐藏 1 显示 }
|
|
* { status: 0 隐藏 1 显示 }
|
|
@@ -205,11 +225,13 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.setBarStatus(jsonObject);
|
|
onListener.setBarStatus(jsonObject);
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("authToBack".equalsIgnoreCase(api)) {
|
|
if ("authToBack".equalsIgnoreCase(api)) {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.authToBack(jsonObject);
|
|
onListener.authToBack(jsonObject);
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
//进入直播间
|
|
//进入直播间
|
|
if ("joinLiveRoom".equals(api)) {
|
|
if ("joinLiveRoom".equals(api)) {
|
|
@@ -217,6 +239,7 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.joinLiveRoom(content.getString("roomId"), content.getString("teacherId"));
|
|
onListener.joinLiveRoom(content.getString("roomId"), content.getString("teacherId"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
//进入聊天
|
|
//进入聊天
|
|
if ("joinChatGroup".equals(api)) {
|
|
if ("joinChatGroup".equals(api)) {
|
|
@@ -224,11 +247,13 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.joinChatGroup(content.getString("type"), content.getString("id"));
|
|
onListener.joinChatGroup(content.getString("type"), content.getString("id"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
//跳转地址页面
|
|
//跳转地址页面
|
|
if ("setAddress".equals(api)) {
|
|
if ("setAddress".equals(api)) {
|
|
ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
|
|
ARouter.getInstance().build(RouterPath.MineCenter.MINE_SELECT_ADDRESS_LIST)
|
|
.navigation(activity, 1011);
|
|
.navigation(activity, 1011);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
//支付
|
|
//支付
|
|
if ("paymentOrder".equals(api)) {
|
|
if ("paymentOrder".equals(api)) {
|
|
@@ -236,12 +261,25 @@ public class JsInterfaceUtils extends Object {
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
onListener.paymentOrder(content.getString("orderNo"), content.getString("payChannel"), content.getString("payInfo"));
|
|
onListener.paymentOrder(content.getString("orderNo"), content.getString("payChannel"), content.getString("payInfo"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if ("savePicture".equalsIgnoreCase(api)) {
|
|
if ("savePicture".equalsIgnoreCase(api)) {
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
if (onListener != null) {
|
|
if (onListener != null) {
|
|
- onListener.savePicture(content.getString("base64"),content.getString("uuid"));
|
|
|
|
|
|
+ onListener.savePicture(content.getString("base64"), content.getString("uuid"));
|
|
}
|
|
}
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (TextUtils.equals(WebApi.openCourseDetail, api)) {
|
|
|
|
+ JSONObject content = jsonObject.getJSONObject("content");
|
|
|
|
+ String courseId = content.optString("courseId");
|
|
|
|
+ if (!TextUtils.isEmpty(courseId)) {
|
|
|
|
+ ARouter.getInstance().build(RouterPath.CourseCenter.PIANO_ROOM_COURSE_DETAIL)
|
|
|
|
+ .withString("course_id", courseId)
|
|
|
|
+ .navigation();
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
}
|
|
}
|
|
@@ -340,9 +378,10 @@ public class JsInterfaceUtils extends Object {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 保存图片
|
|
* 保存图片
|
|
|
|
+ *
|
|
* @param base64
|
|
* @param base64
|
|
*/
|
|
*/
|
|
- void savePicture(String base64,String uuid);
|
|
|
|
|
|
+ void savePicture(String base64, String uuid);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|