123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package com.cooleshow.base.utils;
- import android.text.TextUtils;
- import com.alibaba.android.arouter.launcher.ARouter;
- import com.cooleshow.base.bean.RouteBean;
- import com.cooleshow.base.common.BaseApplication;
- import com.cooleshow.base.common.WebConstants;
- import com.cooleshow.base.constanst.Constants;
- import com.cooleshow.base.constanst.RouteConstants;
- import com.cooleshow.base.router.RouterPath;
- import org.json.JSONObject;
- /**
- * Author by pq, Date on 2022/6/29.
- */
- public class JumpUtils {
- public static final String ACTION_H5 = "h5";
- public static final String ACTION_APP = "app";
- public static boolean jump(RouteBean routeBean) {
- if (routeBean == null) {
- return false;
- }
- try {
- String action = routeBean.action;
- if (TextUtils.equals(action, ACTION_APP)) {
- //跳转原生页面
- if (!TextUtils.isEmpty(routeBean.pageTag)) {
- if (TextUtils.equals(routeBean.pageTag, RouteConstants.PAGE_TAG_BUY_PRACTICE)) {
- //购买陪练课,跳转首页课表
- ARouter.getInstance().build(RouterPath.APPCenter.PATH_HOME)
- .withInt(Constants.MAIN_PAGE_SELECT_POTION_KEY, 1)
- .navigation();
- return true;
- }
- if (TextUtils.equals(routeBean.pageTag, RouteConstants.PAGE_TAG_EVALUATE)) {
- //跳转评价页面
- if (BaseApplication.Companion.isTeacherClient()) {
- ARouter.getInstance().build(RouterPath.CommentCenter.TEACHER_COURSE_COMMENT)
- .navigation();
- }
- }
- if (TextUtils.equals(routeBean.pageTag, RouteConstants.PAGE_TAG_HOMEWORK)) {
- //原生跳作业详情页面
- if (BaseApplication.Companion.isTeacherClient()) {
- //老师端 区分琴房课和陪练课
- String params = routeBean.params;
- if (!TextUtils.isEmpty(params)) {
- String courseId = getParams(params, "courseId");
- String studentId = getParams(params, "studentId");
- if (TextUtils.isEmpty(courseId) && TextUtils.isEmpty(studentId)) {
- ARouter.getInstance().build(RouterPath.WorkCenter.TEACHER_WORK_ASSIGN_HOMEWORK)
- .withString("course_id", courseId)
- .withString("student_id", studentId)
- .navigation();
- }
- }
- } else {
- //学生端直接跳作业详情页面
- String params = routeBean.params;
- if (!TextUtils.isEmpty(params)) {
- String courseId = getParams(params, "courseId");
- if (TextUtils.isEmpty(courseId)) {
- ARouter.getInstance().build(RouterPath.WorkCenter.STUDENT_HOMEWORK_DETAIL)
- .withString("course_id", courseId)
- .navigation();
- }
- }
- }
- }
- }
- } else {
- //跳转H5页面
- if (TextUtils.isEmpty(routeBean.url)) {
- return false;
- }
- ARouter.getInstance()
- .build(RouterPath.WebCenter.ACTIVITY_HTML)
- .withString(WebConstants.WEB_URL, routeBean.url)
- .navigation();
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
- private static String getParams(String paramsJson, String key) {
- try {
- JSONObject jsonObject = new JSONObject(paramsJson);
- return jsonObject.optString(key);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "";
- }
- }
|