Commit 9de31709 by 万齐军

Merge branch 'feat/yk/arch3' into 'feat/qj/arch3'

Feat/yk/arch3

See merge request app_android_lib/YDL-Component!280
parents 4dfc6b87 ba02ea5f
......@@ -30,4 +30,6 @@ android {
dependencies {
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly(project(":ydl-webview"))
}
\ No newline at end of file
......@@ -4,9 +4,10 @@ import android.app.Activity
import android.content.Context
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.template.IProvider
import com.ydl.webview.H5JsBean
import com.yidianling.consultant.OnBottomWordListener
import com.yidianling.consultant.bean.GuideBean
import com.yidianling.consultant.bean.Keyworks
import com.yidianling.consultant.OnBottomWordListener
/**
* Created by xj on 2019/11/14.
......@@ -51,4 +52,7 @@ interface IConsultantService: IProvider {
//获取底纹词
fun getbottomWord(type: Int, listener: OnBottomWordListener)
// 预览资源
fun resourceToPreview(dataList: List<H5JsBean.MediaInfo>?, params: H5JsBean.H5JsCmd.Params, activity: Activity)
}
\ No newline at end of file
package com.ydl.component.service;
import android.app.Activity;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.tencent.smtt.sdk.WebView;
import com.ydl.component.service.web.WVClickAbstractListener;
import com.ydl.component.service.web.WebJavascriptHandler;
import com.ydl.webview.IJavascriptHandler;
import com.ydl.webview.IWebService;
import com.ydl.webview.TellData;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Created by haorui on 2019-10-10.
* Des:
*/
@Route(path = "/web/webservice")
public class WebServiceImpl implements IWebService {
@Override
public void init(Context context) {
}
@NotNull
@Override
public IJavascriptHandler getJavascripHandler(@NotNull Activity activity, @Nullable WebView webView, @NotNull TellData tellData) {
return new WebJavascriptHandler(webView, new WVClickAbstractListener(activity));
}
}
package com.ydl.component.service.web
import android.Manifest
import com.blankj.utilcode.util.PermissionUtils
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.tencent.smtt.sdk.WebView
import com.ydl.audioim.YDLavManager
import com.ydl.confide.api.IConfideService
import com.ydl.confide.event.ConfideDialogEvent
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.modular.findRouteService
import com.yidianling.common.tools.ToastUtil
import com.yidianling.common.tools.asFragmentActivity
import com.yidianling.user.UserHelper
import de.greenrobot.event.EventBus
class JsMethod(private val webView: WebView?) {
fun handle(param: String): Boolean {
try {
val obj = JsonParser().parse(param).asJsonObject
val cmd = obj.getAsJsonObject("cmd")
val actionName = cmd?.getAsJsonPrimitive("action_name")?.asString
if (actionName.isNullOrBlank()) return false
return innerHandle(actionName, cmd)
} catch (throwable: Throwable) {
throwable.printStackTrace()
return false
}
}
private fun innerHandle(actionName: String, obj: JsonObject): Boolean {
val param = obj.getAsJsonObject("params")
when (actionName) {
"handle_confide_btn" -> {
val show = param.getAsJsonPrimitive("show").asInt
EventBus.getDefault().post(ConfideDialogEvent(show))
return true
}
"show_loading" -> {
// val topActivity = BaseActivityMgr.INST.getTopActivity()
// Loading.show(topActivity)
return true
}
"close_loading" -> {
// Loading.close()
return true
}
"open_app_eval_list" -> {
val url = param.getAsJsonPrimitive("url").asString
val topActivity = BaseActivityMgr.INST.getTopActivity()
NewH5Activity.start(topActivity, H5Params(url, ""))
return true
}
"toast" -> {
val msg = param.getAsJsonPrimitive("msg").asString
if (!msg.isNullOrBlank()) {
ToastUtil.toastShort(msg)
}
return true
}
"has_audio_permission" -> {
val callback = param.getAsJsonPrimitive("callback").asString
if (callback.isNullOrBlank()) return true
if (PermissionUtils.isGranted(Manifest.permission.RECORD_AUDIO)) {
webView?.post {
webView.loadUrl("javascript:$callback(1)")
}
return true
}
(webView?.context?.asFragmentActivity())?.let {
findRouteService(IConfideService::class.java).requestConfidePermission(it) { granted ->
webView.post {
webView.loadUrl("javascript:$callback(${if (granted) 1 else 0})")
}
}
}
return true
}
"confide_dial" -> {
//倾诉链接 java接口,支持axb和声网
val id = param.getAsJsonPrimitive("id").asInt
val data = param.getAsJsonObject("data").toString()
val topActivity = BaseActivityMgr.INST.topActivity
if (!YDLavManager.isOnlineRtm) {
//异常退出或者账号被顶掉,重新登录并拨打
YDLavManager.instances.login(UserHelper.getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
findRouteService(IConfideService::class.java).confideDial(id, data, topActivity)
} else {
ToastUtil.toastShort("请重新拨打")
}
}
} else {
findRouteService(IConfideService::class.java).confideDial(id, data, topActivity)
}
return true
}
"check_app_support" -> {
val callback = param.getAsJsonPrimitive("callback").asString
val type = param.getAsJsonPrimitive("type").asInt
if (callback.isNullOrBlank()) return true
webView?.post {
when (type) {
1,2 -> {//检查音频权限能力
webView.loadUrl("javascript:$callback(1)")
}
else -> {
webView.loadUrl("javascript:$callback(0)")
}
}
}
return true
}
else -> {
return false
}
}
}
}
\ No newline at end of file
package com.ydl.component.service.web;
import com.ydl.webview.H5JsBean;
/**
* webview 点击事件监听
* Created by harvie on 2017/7/4 0004.
*/
public interface WebViewClientClickListener {
void openH5(H5JsBean.H5JsCmd.Params jsData);
void courseList();
void activeDetail(String id);
void contactYi();
void contactCourseCustomerService();
void openTopicDetail(String topic_id);
void openMember(String id);
void sendTrend();
void sendResultTrend(final String cover1, final String title1, final String purl1, String share_url1);
void sendInfo(H5JsBean.H5JsCmd.Params params);
void searchList(H5JsBean.H5JsCmd.Params params);
void openExpertsHome(H5JsBean.H5JsCmd.Params params);
void openTest(H5JsBean.H5JsCmd.Params params);
void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu);
void chatSendMessage(int id, int toUid, int canTalk, String accessToken, int isFromQingShu);
void chatTeam(int tid, int doctorId);
void jumpLogin(H5JsBean.H5JsCmd.Params jsData);
void openFmDetail(int id);
void openArticle();
void openFmList();
void sendSubscriptionTimeMessage(String to_uid);
void pay(H5JsBean.H5JsCmd.Params jsData);
void payReceipt(H5JsBean.H5JsCmd.Params jsData);
void payCourse(H5JsBean.H5JsCmd.Params jsData);
void payTest(H5JsBean.H5JsCmd.Params jsData);
void viewTestResult(H5JsBean.H5JsCmd.Params jsData);
void ydlNative(H5JsBean.H5JsCmd jsData);//用于神策统计
void openOrderDetail(H5JsBean.H5JsCmd.Params params);
void expertProduct(H5JsBean.H5JsCmd.Params params);
void order(H5JsBean.H5JsCmd.Params params);
void toOrderCt(H5JsBean.H5JsCmd.Params params);
void showDocList(H5JsBean.H5JsCmd.Params params);
void goodExpert();
void copyWechat(H5JsBean.H5JsCmd.Params params);
void goWechat();
void listenOrderDetail(H5JsBean.H5JsCmd.Params params);
void detailSub(H5JsBean.H5JsCmd.Params params);
void openAgreement(H5JsBean.H5JsCmd.Params params);
void modifyEval(H5JsBean.H5JsCmd.Params params);
void visitEval(H5JsBean.H5JsCmd.Params params);
void coursePlay(H5JsBean.H5JsCmd.Params params);
void closeFloatView();
void courseWriteComment(H5JsBean.H5JsCmd.Params params);
void courseComment(H5JsBean.H5JsCmd.Params params);
void listenTel(H5JsBean.H5JsCmd.Params jsData);
void voiceBroadcast(H5JsBean.H5JsCmd.Params params);
void tel(H5JsBean.H5JsCmd.Params params);
void onOrderByApp(H5JsBean.H5JsCmd.Params params);
void orderSetTime(H5JsBean.H5JsCmd.Params params);
void searchServiceDoc(int cateId);
void openTestDetail(H5JsBean.H5JsCmd.Params params);
void shareAction(H5JsBean.H5JsCmd.Params params);
void openTestList();
void feedBack();
void phoneCall();
void chatSchedule(H5JsBean.H5JsCmd.Params params);
void invite(H5JsBean.H5JsCmd.Params params);
void balance(H5JsBean.H5JsCmd.Params params);
//是否显示下拉刷新控件
void switchDownRefresh(H5JsBean.H5JsCmd.Params params);
//跳转充值界面
void recharge();
void bindPhone();
//界面刷新
void refresh();
//声网拨号逻辑
void listenAgora(H5JsBean.H5JsCmd.Params jsData);
void setTitle(H5JsBean.H5JsCmd.Params jsData);
void saveImage(H5JsBean.H5JsCmd.Params jsData);
void sendToExpert(H5JsBean.H5JsCmd.Params jsData);
void confideConnect(H5JsBean.H5JsCmd.Params jsData);
void confidePay(H5JsBean.H5JsCmd.Params jsData);
void back();
//调用公共支付的
void commonPay(H5JsBean.H5JsCmd.Params jsData);
//隐藏statusbar,全屏展示
void hideStatusBar();
void showStatusBar();
//打开与关闭右上角菜单
void openRightTopMenu();
//打开与关闭底部分享弹框
void openShareMenu(H5JsBean.H5JsCmd.Params params);
//关闭页面
void closeWebKit();
void goHome(H5JsBean.H5JsCmd.Params params);
//保存图片
// void storePic();
void sendUnReadNum(String callbackFuncName, String uid);
//是否展示标题栏
void shouldShowTitleBar(boolean isShowTitleBar);
//设置当前页面类型
void setSelfPageType(int selfType);
//关闭私聊窗口立即咨询webview
void chatCloseBottomWebView();
default void playMeditation(int mediaId,long meditationId,int meditationType,String mediaCoverUrl){}
default void switchSound(int mediaId,long meditationId,int meditationType,int businessType,
String buried,String mediaUrl,String mediaCoverUrl,String title,
String desc,int status){
}
//页面内跳转url
void reloadUrl(String url);
default void setWebViewBG(String rgb,String alpha){}
void getNextExpertStatus(String doctorID, String title, String uid, String linkUrl);
//h5页面是否需要打开推送
void switchPushStatus(H5JsBean.H5JsCmd.Params params);
//显示评论弹窗
void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params);
void resourceToPreview(H5JsBean.H5JsCmd.Params params);
void showDocBooking(H5JsBean.H5JsCmd.Params params);
// 打开时间选择器
void openTimePicker(String jsCallBackName,String day,String doctorId,String orderId);
}
......@@ -4,25 +4,30 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import android.graphics.Rect
import android.text.TextUtils
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ScreenUtils
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.ydl.webview.H5JsBean
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.yidianling.consultant.ExpertSearchActivity
import com.yidianling.consultant.ExpertSearchFragment
import com.yidianling.consultant.OnBottomWordListener
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.consultant.bean.GuideBean
import com.yidianling.consultant.bean.Keyworks
import com.yidianling.consultant.data.ConsultantDataManager
import com.yidianling.consultant.OnBottomWordListener
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils
import com.yidianling.consultant.preview.GPreviewBuilder
import com.yidianling.consultant.preview.UserViewInfo
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -149,6 +154,32 @@ class ConsultantServiceImp : IConsultantService {
})
}
override fun resourceToPreview(dataList: List<H5JsBean.MediaInfo>?, params: H5JsBean.H5JsCmd.Params, activity: Activity) {
val mThumbViewInfoList: MutableList<UserViewInfo> = ArrayList()
dataList?.let {
for (mediaInfo in it) {
val userViewInfo =
UserViewInfo(mediaInfo.cover, mediaInfo.url, mediaInfo.sourcesType)
val bounds = Rect()
bounds.left = ScreenUtils.getScreenWidth() / 2
bounds.top = ScreenUtils.getScreenHeight() / 2
bounds.right = ScreenUtils.getScreenWidth() / 2
bounds.bottom = ScreenUtils.getScreenHeight() / 2
userViewInfo.bounds = bounds
mThumbViewInfoList.add(userViewInfo)
}
GPreviewBuilder.form(activity)
.setData(mThumbViewInfoList)
.setCurrentIndex(params.preview_index)
.setFullscreen(true)
.setToUid(params.info?.toUid.toString() + "")
.setDoctorId(params.info?.doctorId)
.setType(GPreviewBuilder.IndicatorType.Dot)
.start()
}
}
override fun resetConsultAssistantDialogStatus() {
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
......
......@@ -113,7 +113,7 @@ class JsMethod(private val webView: WebView?) {
if (callback.isNullOrBlank()) return true
webView?.post {
when (type) {
1 -> {//检查音频权限能力
1,2 -> {//检查音频权限能力
webView.loadUrl("javascript:$callback(1)")
}
else -> {
......
......@@ -10,10 +10,10 @@ import com.ydl.js_module.manager.WebViewRouterManager
import com.ydl.webview.H5JsBean
import com.ydl.webview.IJavascriptHandler
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.AliYunLogConfig
import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
......@@ -35,8 +35,7 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
@JavascriptInterface
fun sendDataToOC(params: String) {
LogUtil.i("js", params)
LogUtil.d("sendDataToOC")
LogUtil.e("js", params)
AliYunRichLogsHelper.getInstance().sendRichLog(AliYunLogConfig.WEB, "params:$params")
//js交互路由 后期会去除掉这个路由 统一使用下面的路由
//该路由只有测试记录h5页面在使用 - 测试题支付/测试题详情/测试题结果
......@@ -122,7 +121,7 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
"view_test_result" ->
//查看测试结果
if (wvEnventPro != null) {
wvEnventPro?.viewTestResult(jsData.cmd?.params)
wvEnventPro!!.viewTestResult(jsData.cmd?.params)
}
"chat" ->
//私聊
......@@ -492,6 +491,20 @@ class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnven
wvEnventPro?.chatCloseBottomWebView()
}
}
"open_article_comment_dialog" -> {
wvEnventPro?.showCommentArticleDialog(jsData.cmd?.params)
}
"resources_to_preview" -> {
wvEnventPro?.resourceToPreview(jsData.cmd?.params)
}
"doctor_booking" -> {
wvEnventPro?.showDocBooking(jsData.cmd?.params)
}
}
}
}
......@@ -29,6 +29,7 @@ import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.ydl.ydlcommon.modular.ModularServiceManagerKt;
import com.ydl.ydlcommon.router.IYDLRouterConstant;
import com.ydl.ydlcommon.router.YdlCommonOut;
import com.ydl.ydlcommon.utils.ActivityManager;
......@@ -1146,6 +1147,18 @@ public class NewH5_WVClickAbstractListener implements NewH5_WebViewClientClickLi
@Override
public void chatCloseBottomWebView() {
EventBus.getDefault().post(new CloseBottomWebviewEvent(true));
ModularServiceManager.INSTANCE.provide(IImService.class).dismissConsultServiceDialog();
}
@Override
public void resourceToPreview(H5JsBean.H5JsCmd.Params params) {
List<H5JsBean.MediaInfo> dataList = params.getDataList();
ModularServiceManagerKt.findRouteService(IConsultantService.class).resourceToPreview(dataList,params,mActivity);
}
@Override
public void showDocBooking(H5JsBean.H5JsCmd.Params params) {
ModularServiceManager.INSTANCE.provide(IImService.class).showConsultServiceDialog(mActivity, params.getToUid() + "", params.getDoctorId() + "");
}
@Override
......@@ -1223,4 +1236,11 @@ public class NewH5_WVClickAbstractListener implements NewH5_WebViewClientClickLi
((NewH5Activity) mActivity).setBG(rgb, alpha);
}
}
@Override
public void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params) {
if (mActivity instanceof NewH5Activity){
((NewH5Activity)mActivity).showCommentArticleDialog(params.getTitle());
}
}
}
......@@ -37,7 +37,7 @@ public interface NewH5_WebViewClientClickListener {
void openTest(H5JsBean.H5JsCmd.Params params);
//注册引导页--跳转私聊界面
void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu, boolean closeReplaceChat);
void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu,boolean closeReplaceChat);
void chatSendMessage(int id, int toUid, int canTalk, String accessToken, int isFromQingShu);
......@@ -224,4 +224,10 @@ public interface NewH5_WebViewClientClickListener {
* 关闭私聊窗口立即咨询webview
*/
void chatCloseBottomWebView();
void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params);
void resourceToPreview(H5JsBean.H5JsCmd.Params params);
void showDocBooking(H5JsBean.H5JsCmd.Params params);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment