Commit 9fd68e5a by YKai

Merge remote-tracking branch 'origin/d/v4.4.07' into feature/yk_release

parents 2fb167a1 25924372
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../publish.gradle"
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.audioim.api">
</manifest>
\ No newline at end of file
package com.ydl.audioim.api
import android.app.Activity
import android.content.Context
import com.alibaba.android.arouter.facade.template.IProvider
/**
* Created by Ykai on 2022/7/26.
*/
interface IAudioImService : IProvider{
/**
* YDLavManager初始化方法
*/
fun yDLAvManagerInit(context: Context, appId: String)
/**
* 获取rtm是否在线
*/
fun getIsOnlineRtm(): Boolean
/**
* rtm登录返回并登录状态
*/
fun loginRtm(userId:String?,event: (isSuccess: Boolean, msg: String?) -> Unit)
/**
* rtm登录
*/
fun loginRtm(userId:String?)
/**
* 拨打语音电话转axb弹窗
*/
fun openAxbDialog(activity: Activity?, type:Int, phoneNumber: String?)
/**
* 事件上报
*/
fun callEventSave(status: String, res: String, session: String?, line: String)
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ public class ExpertInfoBean {
public String listenerIsOpen;
public String listenOrderStatus;
public String channelId;
public ExpertInfoBean.ListenRemainingTime remainingTime;
public ListenRemainingTime remainingTime;
public String totalDuration;
public String commentUrl;
......
......@@ -38,7 +38,5 @@ interface IConfideService : IProvider {
uid: String
)
fun isOnlineRtm():Boolean
fun requestConfidePermission(activity: FragmentActivity, call: ((Boolean) -> Unit)?)
}
\ No newline at end of file
package com.ydl.confide.home.event
package com.ydl.confide.event
data class ChangeAnotherExpertEvent(
var doctorID: String,
var title: String,
var uid: String,
var linkUrl: String
)
class ConfideDialogEvent(val show: Int)
\ No newline at end of file
)
\ No newline at end of file
package com.ydl.confide.event
class ConfideDialogEvent(val show: Int)
\ No newline at end of file
......@@ -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.yidianling.im.event
package com.yidianling.im.api.event
data class CloseBottomWebviewEvent( var close:Boolean)
\ No newline at end of file
......@@ -188,4 +188,6 @@ interface IImService : IProvider {
fun showConsultServiceDialog(activity: Activity, toUid: String, doctorId: String)
fun dismissConsultServiceDialog();
/**群聊*/
fun startTeamSession(activity: Activity, tid: String, doctorId: String)
}
\ No newline at end of file
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../publish.gradle"
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "com.google.code.gson:gson:2.8.5"
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.js.api">
</manifest>
\ No newline at end of file
package com.ydl.js.api
import com.alibaba.android.arouter.facade.template.IProvider
interface IJsService : IProvider {
fun isH5Open(): Boolean
fun isMainOpen(): Boolean
fun setH5Open(open: Boolean)
fun setMainOpen(open: Boolean)
}
\ No newline at end of file
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "../../publish.gradle"
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "com.google.code.gson:gson:2.8.5"
implementation "com.alibaba:arouter-api:$arouter_api"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.muse.api">
</manifest>
\ No newline at end of file
package com.ydl.muse.api
import android.app.Activity
import com.alibaba.android.arouter.facade.template.IProvider
interface IMuseService : IProvider {
fun switchSound(activity: Activity,
mediaId: Int, meditationId: Long, meditationType: Int, businessType: Int,
buried: String?, mediaUrl: String?, mediaCoverUrl: String?,
title: String?, desc: String?, status: Int
)
}
\ No newline at end of file
......@@ -220,6 +220,8 @@ dependencies {
implementation project(':m-fm')
implementation project(":api:fm")
implementation project(':ydl-tuicore')
implementation project(':m-js')
implementation project(':api:js')
implementation rootProject.ext.dependencies["retrofit-url-manager"]
......
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.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Rect;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ScreenUtils;
import com.ydl.confide.api.IConfideService;
import com.ydl.confide.home.event.ChangeAnotherExpertEvent;
import com.ydl.webview.H5JsBean;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.consultant.preview.GPreviewBuilder;
import com.yidianling.consultant.preview.UserViewInfo;
import com.yidianling.im.api.service.IImService;
import com.yidianling.im.event.CloseBottomWebviewEvent;
import com.yidianling.muse.activity.ChooseMusicActivity;
import java.util.ArrayList;
import java.util.List;
import de.greenrobot.event.EventBus;
/**
* webview 点击事件监听 抽象类
* Created by harvie on 2017/7/4 0004.
*/
public class WVClickAbstractListener implements WebViewClientClickListener {
public Activity mContext;
public WVClickAbstractListener(Activity activity) {
this.mContext = activity;
}
@Override
public void openH5(H5JsBean.H5JsCmd.Params jsData) {
LogUtil.d("openH5 params: " + jsData.toString());
H5Params h5Params = new H5Params(jsData.getUrl(), null);
h5Params.setShareData(jsData.getShare());
h5Params.setShowMenu(jsData.getDot_flag());
NewH5Activity.start(mContext, h5Params);
}
@Override
public void courseList() {
}
@Override
public void activeDetail(String id) {
}
@Override
public void contactYi() {
try {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startP2PSession(mContext, -1, "14", "14", "客服小壹", "14");
} catch (Exception e) {
}
}
@Override
public void contactCourseCustomerService() {
}
@Override
public void openTopicDetail(String topic_id) {
}
@Override
public void openMember(String id) {
}
@Override
public void sendTrend() {
}
@Override
public void sendResultTrend(String cover1, String title1, String purl1, String share_url1) {
}
@Override
public void sendInfo(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void searchList(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void openExpertsHome(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void openTest(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu) {
if ((toUid + "").equals("14")) {
//找客服私聊不需要积分
contactYi();
} else {
try {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startChatCloseReplaceChat(mContext, String.valueOf(toUid));
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void chatSendMessage(int id, int toUid, int canTalk, String accessToken, int isFromQingShu) {
}
@Override
public void chatTeam(int tid, int doctorId) {
}
@Override
public void jumpLogin(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void openFmDetail(int id) {
}
@Override
public void openArticle() {
}
@Override
public void openFmList() {
}
@Override
public void sendSubscriptionTimeMessage(String to_uid) {
}
@Override
public void pay(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void payReceipt(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void payCourse(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void payTest(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void viewTestResult(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void ydlNative(H5JsBean.H5JsCmd jsData) {
}
@Override
public void openOrderDetail(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void expertProduct(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void order(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void toOrderCt(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void showDocList(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void goodExpert() {
}
@Override
public void copyWechat(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void goWechat() {
}
@Override
public void listenOrderDetail(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void detailSub(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void openAgreement(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void modifyEval(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void visitEval(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void coursePlay(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void closeFloatView() {
}
@Override
public void courseWriteComment(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void courseComment(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void listenTel(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void voiceBroadcast(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void tel(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void onOrderByApp(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void orderSetTime(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void searchServiceDoc(int cateId) {
}
@Override
public void openTestDetail(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void shareAction(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).showShareMenu(params);
}
}
@Override
public void openTestList() {
}
@Override
public void feedBack() {
}
@Override
public void phoneCall() {
}
@Override
public void chatSchedule(H5JsBean.H5JsCmd.Params params) {
ModularServiceManager.INSTANCE.provide(IImService.class)
.chatScheule(mContext, params.getUser_url(), params.getDoc_url(), params.getDsmId(), params.getTitle(), params.getToUid());
}
@Override
public void invite(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void balance(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void switchDownRefresh(H5JsBean.H5JsCmd.Params params) {
if (mContext != null && mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).hasShowDownRefresh(params.getSwitch());
}
}
@Override
public void recharge() {
}
@Override
public void bindPhone() {
}
@Override
public void refresh() {
}
@Override
public void listenAgora(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void setTitle(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void saveImage(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void sendToExpert(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void confideConnect(H5JsBean.H5JsCmd.Params jsData) {
((IConfideService) ARouter.getInstance().build("/confide/ConfideService").navigation()).connectionJava(jsData.getId(), 3, mContext, null, jsData.getCallType());
}
@Override
public void confidePay(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void back() {
mContext.finish();
}
@Override
public void commonPay(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void hideStatusBar() {
}
@Override
public void showStatusBar() {
}
@Override
public void openRightTopMenu() {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).openRightTopMenu();
}
}
@Override
public void openShareMenu(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).openShareMenu(params);
}
}
@Override
public void closeWebKit() {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).finish();
}
}
@Override
public void goHome(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void sendUnReadNum(String callbackFuncName, String uid) {
final StringBuffer sb = new StringBuffer();
sb.append(callbackFuncName);
sb.append("('");
sb.append("33,125");
sb.append("')");
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).callJSFunc(sb.toString());
}
}
@Override
public void shouldShowTitleBar(boolean isShowTitleBar) {
if (mContext instanceof NewH5Activity) {
if (isShowTitleBar) {
((NewH5Activity) mContext).showTitleBar();
} else {
((NewH5Activity) mContext).hideJavaTitleBar();
}
}
}
@Override
public void setSelfPageType(int selfType) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).setSelfPageType(selfType);
}
}
@Override
public void playMeditation(int mediaId, long meditationId, int meditationType, String mediaCoverUrl) {
if (mContext instanceof NewH5Activity) {
// YDLRouterManager.Companion.router(ROUTER_MUSE_PLAY,
// new YDLRouterParams().putExtra("MEDITATION_ID", String.valueOf(meditationId))
// .putExtra("MEDIA_ID", String.valueOf(mediaId))
// .putExtra("MEDITATION_TYPE", String.valueOf(meditationType))
// .putExtra("MEDIA_COVER_URL", mediaCoverUrl));
ARouter.getInstance().build("/muse/play")
.withLong("MEDITATION_ID", meditationId)
.withLong("MEDIA_ID", mediaId)
.withInt("MEDITATION_TYPE", meditationType)
.withString("MEDIA_COVER_URL", mediaCoverUrl)
.navigation();
}
}
@Override
public void getNextExpertStatus(String doctorID, String title, String uid, String linkUrl) {
EventBus.getDefault().post(new ChangeAnotherExpertEvent(doctorID, title, uid, linkUrl));
}
@Override
public void switchPushStatus(H5JsBean.H5JsCmd.Params params) {
if (params.getSwitchStatus() == 1) {
// MsgPushLifecycle.Companion.setH5Open(true);
} else {
// MsgPushLifecycle.Companion.setH5Open(false);
}
}
@Override
public void resourceToPreview(H5JsBean.H5JsCmd.Params params) {
List<H5JsBean.MediaInfo> dataList = params.getDataList();
H5JsBean.DoctorInfo info = params.getInfo();
List<UserViewInfo> mThumbViewInfoList = new ArrayList<>();
for (H5JsBean.MediaInfo mediaInfo : dataList) {
UserViewInfo userViewInfo = new UserViewInfo(mediaInfo.getCover(), mediaInfo.getUrl(), mediaInfo.getSourcesType());
Rect bounds = new Rect();
bounds.left = ScreenUtils.getScreenWidth() / 2;
bounds.top = ScreenUtils.getScreenHeight() / 2;
bounds.right = ScreenUtils.getScreenWidth() / 2;
bounds.bottom = ScreenUtils.getScreenHeight() / 2;
userViewInfo.setBounds(bounds);
mThumbViewInfoList.add(userViewInfo);
}
GPreviewBuilder.form(mContext)
.setData(mThumbViewInfoList)
.setCurrentIndex(params.getPreview_index())
.setFullscreen(true)
.setToUid(info.getToUid() + "")
.setDoctorId(info.getDoctorId())
.setType(GPreviewBuilder.IndicatorType.Dot)
.start();
}
@Override
public void showDocBooking(H5JsBean.H5JsCmd.Params params) {
ModularServiceManager.INSTANCE.provide(IImService.class).showConsultServiceDialog(mContext, params.getToUid() + "", params.getDoctorId() + "");
}
@Override
public void switchSound(int mediaId, long meditationId, int meditationType, int businessType,
String buried, String mediaUrl, String mediaCoverUrl,
String title, String desc, int status) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).switchSound(mediaId, meditationId, meditationType,
businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status);
} else if (mContext instanceof ChooseMusicActivity) {
((ChooseMusicActivity) mContext).switchSound(mediaId, meditationId, meditationType,
businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status);
}
}
@Override
public void chatCloseBottomWebView() {
EventBus.getDefault().post(new CloseBottomWebviewEvent(true));
ModularServiceManager.INSTANCE.provide(IImService.class).dismissConsultServiceDialog();
}
@Override
public void reloadUrl(String url) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).loadUrl(url);
}
}
@Override
public void setWebViewBG(String rgb, String alpha) {
if (mContext instanceof NewH5Activity) {
((NewH5Activity) mContext).setBG(rgb, alpha);
}
}
/**
* 打开时间选择器
*/
@SuppressLint("CheckResult")
@Override
public void openTimePicker(String jsCallBackName, String day, String doctorId, String orderId) {
}
@Override
public void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params) {
if (mContext instanceof NewH5Activity){
((NewH5Activity)mContext).showCommentArticleDialog(params.getTitle());
}
}
}
/build
\ No newline at end of file
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.cxzapp.yidianling"
minSdk 21
targetSdk 28
versionCode 1
versionName "1.0"
flavorDimensions "versionCode"
ndk {
abiFilters "arm64-v8a"
}
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "e4b0d0bb7ef01053c93e25ba", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
XIAOMI_APPKEY : "MI-5241743243980",//小米平台注册的appkey
XIAOMI_APPID : "MI-2882303761517432980",//小米平台注册的appid
HUAWEI_APPID : "10444675",//华为平台注册的appid
OPPO_APPKEY : "OP-afk71f35VogGw0w0wKsookksc", // OPPO平台注册的appkey
OPPO_APPID : "OP-3245516", // OPPO平台注册的appid
OPPO_APPSECRET: "OP-691184F044acA7a6851F578451f67616",//OPPO平台注册的appsecret
VIVO_APPKEY : '67d79734-c9c5-4916-a6f4-ba2ef4df09a4',
VIVO_APPID : '14298',
MEIZU_APPKEY : "MZ-00d268d7228748479036f202d45b4ef2",//魅族平台注册的appkey
MEIZU_APPID : "MZ-120344",//魅族平台注册的appid
qqappid : "1105070461",
APPLICATIONID : rootProject.ext.ydl_app["applicationId"]
]
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/proguard/coroutines.pro'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
signingConfigs {
release {
storeFile file("../app/keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
}
buildTypes {
debug{
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
signingConfigs {
release {
storeFile file("keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
}
productFlavors {
ydl{}
xlzx{}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
repositories {
flatDir {
dirs 'aar'
}
}
dependencies {
implementation fileTree(dir: 'aar', include: ['*.aar'])
implementation(project(":ydl-flutter-base"))
implementation(project(":ydl-media"))
implementation(project(":ydl-net"))
implementation(project(":ydl-pay"))
implementation(project(":ydl-platform"))
implementation(project(":ydl-tuicore"))
implementation(project(":ydl-utils"))
implementation(project(":ydl-webview"))
implementation(project(":m-article"))
implementation(project(":m-audioim"))
implementation(project(":m-confide"))
implementation(project(":m-consultant"))
implementation(project(":m-course"))
implementation(project(":m-dynamic"))
implementation(project(":m-fm"))
implementation(project(":m-home"))
implementation(project(":m-im"))
implementation(project(":m-js"))
implementation(project(":m-muse"))
implementation(project(":m-tests"))
implementation(project(":m-user"))
implementation('com.ydl.debugkit:debugkit:1.0.0')
implementation('com.ydl.aar:heytap:3.0.0')
implementation "com.ydl.lib:smart_spa:0.0.4"
implementation 'com.volcengine:apm_insight:1.4.6.cn'
implementation 'com.volcengine:apm_insight_crash:1.4.5'
implementation 'com.meituan.android.walle:library:1.1.5'
implementation 'com.readystatesoftware.systembartint:systembartint:1.0.3'
// 权限库
implementation 'com.hjq:xxpermissions:10.2'
// 时间选择器
implementation 'com.contrarywind:Android-PickerView:4.1.9'
// sophix hotfix
implementation 'com.aliyun.ams:alicloud-android-hotfix:3.3.5'
implementation 'com.github.feeeei:CircleSeekbar:v1.1.2'
//====================极光推送====================
implementation 'cn.jiguang.sdk:jpush:4.6.4'
implementation 'cn.jiguang.sdk:jcore:3.2.4'
implementation 'cn.jiguang.sdk.plugin:oppo:4.6.4'
implementation 'cn.jiguang.sdk.plugin:vivo:4.6.4'
implementation 'cn.jiguang.sdk.plugin:meizu:4.6.4'
implementation 'cn.jiguang.sdk.plugin:huawei:4.6.4'
implementation 'cn.jiguang.sdk.plugin:meizu:4.6.4'
implementation 'cn.jiguang.sdk.plugin:xiaomi:4.6.4'
implementation 'com.huawei.hms:push:5.3.0.304'
//====================云信基础库====================
implementation 'com.ydl:nim-base:1.1.0.7'
implementation 'com.netease.nimlib:basesdk:9.1.1'
implementation 'com.netease.nimlib:avchat:9.1.1'
implementation 'com.netease.nimlib:nrtc:9.1.1'
//OPPO推送需要单独引入
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'commons-codec:commons-codec:1.6'
implementation 'androidx.annotation:annotation:1.1.0'
//====================YDL 功能库====================
implementation "com.ydl.aar:resource:0.0.1-ydl"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.cxzapp.yidianling">
</manifest>
\ No newline at end of file
......@@ -167,7 +167,7 @@ ext {
"ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar",
"ydl-device" : "com.ydl:device-id:0.0.31",
//flutter功能组件升级===>发布ydl-flutter组件===>引用flutter相关的业务模块
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.51@aar", //flutter aar
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.56@aar", //flutter aar
// "ydl-flutter-sp" : "com.ydl:ydl-flutter-sp:0.0.2@aar", //flutter 缓存 aar
]
......
......@@ -75,4 +75,5 @@ dependencies {
api project(':ydl-webview')
implementation project(":api:user")
implementation project(":api:im")
implementation project(":api:audioim")
}
......@@ -32,6 +32,7 @@ import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.listener.IntentConstants
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.router.AudioImIn
......
......@@ -398,7 +398,7 @@ class YDLavManager {
@SuppressLint("CheckResult")
fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") {
if (TextUtils.isEmpty(userId) || (userId ?: "0") <= "0") {
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
LogUtil.e("[agora]login-uid:$userId")
AliYunRichLogsHelper.getInstance()
......
package com.ydl.audioim.modular
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.widget.AxbConfirmDialog
/**
* Created by Ykai on 2022/7/26.
*/
@Route(path = "/audioim/AudioImService")
class AudioImServiceImp : IAudioImService {
override fun yDLAvManagerInit(context: Context, appId: String) {
YDLavManager.instances.init(context, appId)
}
override fun getIsOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
}
override fun loginRtm(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
YDLavManager.instances.login(userId, event)
}
override fun loginRtm(userId: String?) {
YDLavManager.instances.login(userId)
}
override fun openAxbDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$phoneNumber"))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
}
override fun callEventSave(status: String, res: String, session: String?, line: String) {
YDLavManager.instances.callEventSave(status, res, session, line)
}
override fun init(context: Context?) {
}
}
\ No newline at end of file
# 声网module
\ No newline at end of file
......@@ -71,10 +71,10 @@ dependencies {
api rootProject.ext.dependencies["ydl-user-router"]
api project(':ydl-media')
api project(':ydl-platform')
api project(':m-audioim')
api project(":ydl-pay")
api project(':ydl-webview')
api project(':ydl-utils')
implementation project(":api:audioim")
implementation project(":api:im")
implementation project(":api:user")
implementation project(":api:consultant")
......
......@@ -27,8 +27,8 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.tencent.smtt.export.external.interfaces.JsResult
import com.tencent.smtt.sdk.*
import com.ydl.confide.R
import com.ydl.confide.home.event.ChangeAnotherExpertEvent
import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.confide.event.ConfideDialogEvent
import com.ydl.confide.event.ChangeAnotherExpertEvent
import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.router.PhoneCallIn
import com.ydl.utils.WebUrlParamsUtils
......
......@@ -24,7 +24,7 @@ import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.jcodecraeer.xrecyclerview.ProgressStyle
import com.jcodecraeer.xrecyclerview.XRecyclerView
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.home.adapter.ConfideHomeAdapter
......@@ -248,10 +248,8 @@ class ConfideHomeActivity :
}
if (!confidedId.isNullOrBlank() && !doctorId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { _: Boolean, _ ->
showPayOrDetail(confidedId, doctorId)
}
} else {
......
......@@ -4,14 +4,12 @@ import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.ConfideBottomSheetDialogFragment
import com.ydl.confide.home.ConfideHomeActivity
......@@ -20,6 +18,7 @@ import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.webview.TellData
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.YDLCacheUtils
/**
......@@ -73,7 +72,7 @@ class ConfdieServiceImpl : IConfideService {
override fun ydlAvManagerLogin(uid: String?) {
YDLavManager.instances.login(uid)
findRouteService(IAudioImService::class.java).loginRtm(uid)
}
override fun startCondifeHomePage(context: Context, isSplash: Boolean) {
......@@ -91,17 +90,17 @@ class ConfdieServiceImpl : IConfideService {
//debug包根据url判断使用正式或者测试key
val cacheAppEnv = YDLCacheUtils.getCacheApi()
if (!TextUtils.isEmpty(cacheAppEnv)) {
avManagerKey = if (!TextUtils.isEmpty(cacheAppEnv)) {
if (YDLConstants.ENV_TEST == cacheAppEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
} else {
if (YDLConstants.ENV_TEST == appEnv || YDLConstants.ENV_AUTO_TEST == appEnv) {
avManagerKey = "13b1536698f64905a1e7e5bb978ba821"
"13b1536698f64905a1e7e5bb978ba821"
} else {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
"3387e9b251f3491e9221a9877e8f7830"
}
}
} else {
......@@ -109,27 +108,11 @@ class ConfdieServiceImpl : IConfideService {
avManagerKey = "3387e9b251f3491e9221a9877e8f7830"
}
YDLavManager.instances.init(app, avManagerKey)
}
override fun isOnlineRtm(): Boolean {
return YDLavManager.isOnlineRtm
findRouteService(IAudioImService::class.java).yDLAvManagerInit(app, avManagerKey)
}
override fun showAxbConfirmDialog(activity: Activity?, type: Int, phoneNumber: String?) {
val dialog = AxbConfirmDialog(activity, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
phoneNumber?.let {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber!!))
activity?.startActivity(phoneIntent)
}
}
override fun onClose() {
}
})
dialog.show()
findRouteService(IAudioImService::class.java).openAxbDialog(activity, type, phoneNumber)
}
override fun closePlayer() {
......
......@@ -3,15 +3,12 @@ package com.ydl.confide.home.modular.service
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.audioim.bean.ExpertInfoBean
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.listener.IntentConstants
import com.ydl.confide.home.ConfidePermissionDialog
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConnectParamJava
......@@ -109,7 +106,7 @@ class ConfideWebServiceImpl {
data: ConfideConnectResponse?
) {
val expertInfo = data?.dialDetail?.agoraExpertInfo ?: return
if (!YDLavManager.isOnlineRtm) { // 判断如果账号在其它设备登录rtm是否在线
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) { // 判断如果账号在其它设备登录rtm是否在线
ToastUtil.toastShort("网络通话错误代码001")
return
}
......@@ -128,21 +125,9 @@ class ConfideWebServiceImpl {
* axb 通话
* */
fun axb(activity: Activity, phone: String?) {
if (phone.isNullOrEmpty()) return
val dialog = AxbConfirmDialog(
activity,
1,
object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
val phoneIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${phone}"))
activity.startActivity(phoneIntent)
}
override fun onClose() {
}
})
dialog.show()
if (phone.isNullOrEmpty())
return
findRouteService(IAudioImService::class.java).openAxbDialog(activity,1,phone)
}
//java版axb和声网接口
......@@ -154,8 +139,8 @@ class ConfideWebServiceImpl {
tellData: TellData?,
callType: String?
) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(PhoneCallIn.getUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
toDial(id, type, callType, activity, tellData)
} else {
......@@ -340,7 +325,7 @@ class ConfideWebServiceImpl {
expertInfo.remainingTime =
ExpertInfoBean.ListenRemainingTime(expertInfo.totalDuration);
}
YDLavManager.instances.callEventSave("10", "用户点击拨打", expertInfo.channelId, "7")
findRouteService(IAudioImService::class.java).callEventSave("10", "用户点击拨打", expertInfo.channelId, "7")
Loading.close()
ARouter.getInstance().build("/av/AudioHomeActivity")
.withString(IntentConstants.INTENT_EXPERT_HEAD_URL, expertInfo.expertHeadUrl)
......
......@@ -398,8 +398,10 @@ class ConfideHomeUtils {
}
}
} else {
for (bodyItem in item.body!!) {
bodyItem.confideIsPlay = false
if (item.body != null) {
for (bodyItem in item.body) {
bodyItem.confideIsPlay = false
}
}
}
}
......
......@@ -16,7 +16,7 @@ import com.alibaba.android.arouter.launcher.ARouter
import com.dou361.ijkplayer.widget.IjkVideoView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.interfaces.DraweeController
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.api.IAudioImService
import com.ydl.confide.R
import com.ydl.confide.api.ConfideRoute
import com.ydl.confide.databinding.ItemExpertIntroBinding
......@@ -36,7 +36,6 @@ import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.confide_home_activity.*
import tv.danmaku.ijk.media.player.IjkMediaPlayer
import java.io.UnsupportedEncodingException
import java.net.URLDecoder
......@@ -123,8 +122,8 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
else -> {
if (!item.confideId.isNullOrBlank()) {
if (!YDLavManager.isOnlineRtm) {
YDLavManager.instances.login(
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
findRouteService(IAudioImService::class.java).loginRtm(
PhoneCallIn.getUserService().getUserInfo()?.uid
) { _: Boolean, _ ->
showPayOrDetail(item, it)
......
......@@ -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()
}
......
......@@ -150,7 +150,6 @@ class TrendsListFragment : BaseLazyFragment(), ITrendsListView,
var id: String? = "0"
trendsDatas?.let { trendsDatas ->
if (trendsDatas.size > 0) {
LogUtil.i("TAG get last content: " + trendsDatas[trendsDatas.size].toString())
id = trendsDatas[trendsDatas.size - 1].id
return if (id == null || id == "") {
0
......
......@@ -431,4 +431,13 @@ class IMServiceImpl : IImService {
override fun dismissConsultServiceDialog() {
expertConsultServiceListDialog2?.changeItem()
}
override fun startTeamSession(activity: Activity, tid: String, doctorId: String) {
SessionHelper.startTeamSession(
activity,
tid + "",
null,
P2PCustomActionHandlerImpl(doctorId + "")
)
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ import com.ydl.ydlcommon.view.dialog.CommonDialog;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.im.config.constants.ImConstants;
import com.yidianling.im.event.CloseBottomWebviewEvent;
import com.yidianling.im.api.event.CloseBottomWebviewEvent;
import com.yidianling.im.event.MultipleAnswerBean;
import com.yidianling.im.event.MultipleSelectedEvent;
import com.yidianling.im.helper.IMChatUtil;
......
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply from: "../publish.gradle"
kapt {
arguments {
arg("AROUTER_MODULE_NAME", "js")
}
}
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
buildToolsVersion rootProject.ext.android["buildToolsVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
consumerProguardFiles "consumer-rules.pro"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: "js"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled true
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.alibaba:arouter-api:$arouter_api"
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
// 时间选择器
implementation 'com.contrarywind:Android-PickerView:4.1.9'
api rootProject.ext.dependencies["ydl-user-router"]
api project(':ydl-webview')
api project(':ydl-platform')
implementation project(':ydl-media')
implementation project(":ydl-pay")
implementation project(":api:im")
implementation project(":api:user")
implementation project(":api:consultant")
implementation project(":api:confide")
implementation project(":api:dynamic")
implementation project(":api:tests")
implementation project(":api:fm")
implementation project(":api:course")
implementation project(':api:muse')
implementation project(':api:js')
implementation project(':api:audioim')
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.js">
</manifest>
\ No newline at end of file
package com.ydl.component.service.web
package com.ydl.js
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.audioim.api.IAudioImService
import com.ydl.confide.api.IConfideService
import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.confide.event.ConfideDialogEvent
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.ui.Loading
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.Utils
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
......@@ -50,6 +51,7 @@ class JsMethod(private val webView: WebView?) {
}
"close_loading" -> {
// Loading.close()
return true
}
"open_app_eval_list" -> {
......@@ -83,18 +85,19 @@ class JsMethod(private val webView: WebView?) {
}
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) {
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
//异常退出或者账号被顶掉,重新登录并拨打
YDLavManager.instances.login(UserHelper.getUserInfo()?.uid) { isSuccess: Boolean, _ ->
findRouteService(IAudioImService::class.java).loginRtm(JsModularService.getIUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
findRouteService(IConfideService::class.java).confideDial(id, data, topActivity)
findRouteService(IConfideService::class.java).confideDial(id,
data,
topActivity)
} else {
ToastUtil.toastShort("请重新拨打")
}
......@@ -120,6 +123,32 @@ class JsMethod(private val webView: WebView?) {
}
return true
}
"startCms" ->{
if (Utils.isFastClick()) {
return true
}
val activity = BaseActivityMgr.INST.topActivity
if (JsModularService.getIUserService().loginByOneKeyLogin(activity, true)) {
val location = param.getAsJsonPrimitive("location").asInt
JsModularService.getImService().startP2PSession(activity, location, null)
}
return true
}
"to_search_list" ->{
if (Utils.isFastClick()) {
return true
}
val cateId = param.getAsJsonPrimitive("cateId").asString
val cateTitle = param.getAsJsonPrimitive("cateTitle").asString
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_CONSULT_LIST,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_CATEID, cateId)
.putExtra(IYDLRouterConstant.EXTRA_CATETITLE, cateTitle)
.putExtra(IYDLRouterConstant.EXTRA_SHOWTYPE, "0")
)
return true
}
else -> {
return false
}
......
package com.ydl.js
import com.ydl.confide.api.IConfideService
import com.ydl.course.api.ICourseService
import com.ydl.muse.api.IMuseService
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.dynamic.api.IDynamicService
import com.yidianling.fm.api.service.IFMService
import com.yidianling.im.api.service.IImService
import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.service.IAppService
import com.yidianling.user.api.service.IUserService
class JsModularService {
companion object{
fun getIConfideService(): IConfideService{
return ModularServiceManager.provide(IConfideService::class.java)
}
fun getIUserService(): IUserService{
return ModularServiceManager.provide(IUserService::class.java)
}
fun getIAppService(): IAppService{
return ModularServiceManager.provide(IAppService::class.java)
}
fun getIDynamicService(): IDynamicService{
return ModularServiceManager.provide(IDynamicService::class.java)
}
fun getImService(): IImService {
return ModularServiceManager.provide(IImService::class.java)
}
fun getITestsApiService(): ITestsApiService {
return ModularServiceManager.provide(ITestsApiService::class.java)
}
fun getIFMService(): IFMService {
return ModularServiceManager.provide(IFMService::class.java)
}
fun getICourseService(): ICourseService {
return ModularServiceManager.provide(ICourseService::class.java)
}
fun getIMuseService(): IMuseService {
return ModularServiceManager.provide(IMuseService::class.java)
}
}
}
\ No newline at end of file
package com.ydl.component.service.web
package com.ydl.js
import android.webkit.JavascriptInterface
import androidx.fragment.app.FragmentActivity
......@@ -12,18 +12,20 @@ import com.ydl.webview.IJavascriptHandler
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
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
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.LogUtil
import com.yidianling.user.UserHelper
import com.yidianling.user.api.service.IUserService
/**
* update by harvie on 2017/7/04
*/
class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPro: WebViewClientClickListener?) : IJavascriptHandler() {
class NewH5_JavascriptHandler(private val webView: WebView?, private val wvEnventPro: NewH5_WebViewClientClickListener?) : IJavascriptHandler() {
private val js = JsMethod(webView)
......@@ -33,9 +35,8 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
@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页面在使用 - 测试题支付/测试题详情/测试题结果
val webViewRouter = WebViewRouterManager()
......@@ -47,7 +48,6 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
if (YDLRouterManager.router(params)) {
return
}
if (js.handle(params)) return
val jsData = Gson().fromJson(params, H5JsBean::class.java)
//是否登录
......@@ -60,10 +60,13 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
if (jsData.cmd?.params?.toUid != 0) {
wvEnventPro?.chat(
UserHelper.getUserInfo()?.uid?.toInt()
?: 0, jsData.cmd?.params?.toUid
?: 0, 0, UserHelper.getUserInfo()?.accessToken, jsData.cmd?.params?.isFromQingShu
?: 0)
findRouteService(IUserService::class.java).getUserInfo()?.uid?.toInt() ?: 0,
jsData.cmd?.params?.toUid ?: 0,
0,
findRouteService(IUserService::class.java).getUserInfo()?.accessToken,
jsData.cmd?.params?.isFromQingShu ?: 0,
jsData.cmd?.params?.closeReplaceChat ?: false
)
} else {
wvEnventPro?.openH5(jsData.cmd?.params)
}
......@@ -123,12 +126,22 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
"chat" ->
//私聊
if (wvEnventPro != null) {
wvEnventPro!!.chat(ModularServiceManager.getPlatformUserService()?.getUser()?.userId?.toInt()?:0, jsData.cmd!!.params!!.toUid, 0, ModularServiceManager.getPlatformUserService()?.getUser()?.token, jsData.cmd!!.params!!.isFromQingShu)
wvEnventPro?.chat(findRouteService(IUserService::class.java).getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid, 0,
JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu,
jsData.cmd!!.params!!.closeReplaceChat
)
// 埋点
ActionCountUtils.count("ydl_user_main_page|private_chat_click")
}
"chat_send_message" ->
//跳转私聊:并发送消息
if (wvEnventPro != null) {
wvEnventPro!!.chatSendMessage(ModularServiceManager.getPlatformUserService()?.getUser()?.userId?.toInt()?:0, jsData.cmd!!.params!!.toUid, 0, ModularServiceManager.getPlatformUserService()?.getUser()?.token, jsData.cmd!!.params!!.isFromQingShu)
wvEnventPro!!.chatSendMessage(findRouteService(IUserService::class.java).getUserResponse()?.uid?.toInt() ?: 0,
jsData.cmd!!.params!!.toUid,
0, JsModularService.getIUserService().getUserInfo()?.accessToken,
jsData.cmd!!.params!!.isFromQingShu)
}
"chat_team" ->
//群聊
......@@ -379,6 +392,9 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
"chatUnread" -> {
wvEnventPro?.sendUnReadNum(jsData.cmd!!.params?.callBack, jsData.cmd!!.params?.uid.toString())
}
"switch_push_status" -> {
wvEnventPro?.switchPushStatus(jsData.cmd?.params)
}
"showTitleBar" -> {
jsData.cmd!!.params?.let {
wvEnventPro?.shouldShowTitleBar(it.isShowTitleBar!!)
......@@ -389,10 +405,23 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
wvEnventPro?.setSelfPageType(it.selfPageType)
}
}
"chat_close_bottom_webview" -> {
jsData.cmd!!.params?.let {
wvEnventPro?.chatCloseBottomWebView()
"setBootomFitViewColor" -> {
wvEnventPro?.setBootomFitViewColor(jsData.cmd?.params?.bottomfitViewColor ?: "")
}
// 打开时间选择器
"requestSelectTime"->{
if (Utils.isFastClick()){
return
}
wvEnventPro?.openTimePicker(jsData.cmd?.params?.callBack,jsData.cmd?.params?.day,jsData.cmd?.params?.doctorId.toString(),jsData.cmd?.params?.orderId)
}
// 返回上一页并刷新
"goBackAndReload"->{
wvEnventPro?.goBackAndReload(jsData.cmd?.params?.url)
}
// 跳转到第三方app
"toThirdApp" ->{
wvEnventPro?.toThirdApp(jsData.cmd?.params?.url)
}
......@@ -438,7 +467,7 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
jsData.cmd?.params?.let{
val rgb = it.color
val alpha = it.alpha
wvEnventPro?.setWebViewBG(rgb,alpha)
wvEnventPro?.setBG(rgb,alpha)
}
}
......@@ -457,15 +486,10 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
findRouteService(IConfideService::class.java).showExpertDetailDialog(topActivity, url, doctorId, uid ?: "")
}
}
"switch_push_status" -> {
wvEnventPro?.switchPushStatus(jsData.cmd?.params)
}
// 打开时间选择器
"requestSelectTime"->{
if (Utils.isFastClick()){
return
"chat_close_bottom_webview" -> {
jsData.cmd!!.params?.let {
wvEnventPro?.chatCloseBottomWebView()
}
wvEnventPro?.openTimePicker(jsData.cmd?.params?.callBack,jsData.cmd?.params?.day,jsData.cmd?.params?.doctorId.toString(),jsData.cmd?.params?.orderId)
}
"open_article_comment_dialog" -> {
......@@ -481,7 +505,6 @@ class WebJavascriptHandler(private val webView: WebView?, private val wvEnventPr
wvEnventPro?.showDocBooking(jsData.cmd?.params)
}
}
}
}
package com.ydl.js;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.ydl.confide.api.IConfideService;
import com.ydl.confide.event.ChangeAnotherExpertEvent;
import com.ydl.js.bean.TimeDataBean;
import com.ydl.js.http.JsHttpImpl;
import com.ydl.js.moduler.service.JsImpl;
import com.ydl.media.audio.AudioPlayer;
import com.ydl.media.view.PlayerFloatHelper;
import com.ydl.webview.H5JsBean;
import com.ydl.webview.H5Params;
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;
import com.ydl.ydlcommon.utils.ImageUtil;
import com.ydl.ydlcommon.utils.remind.ToastHelper;
import com.ydl.ydlcommon.view.dialog.YDLShareDialog;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.consultant.api.IConsultantService;
import com.yidianling.im.api.event.CloseBottomWebviewEvent;
import com.yidianling.im.api.service.IImService;
import com.yidianling.user.api.bean.UserResponseBean;
import com.yidianling.user.api.service.IAppService;
import com.yidianling.user.api.service.IUserService;
import com.yidianling.ydl_pay.common.CommonPayDialog;
import com.yidianling.ydl_pay.pay.PayActivity;
import com.yidianling.ydl_pay.pay.PayParams;
import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import de.greenrobot.event.EventBus;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* webview 点击事件监听 抽象类
* Created by harvie on 2017/7/4 0004.
*/
public class NewH5_WVClickAbstractListener implements NewH5_WebViewClientClickListener {
//上次点击时间
private long lastClickTime = 0L;
private static final int FAST_CLICK_DELAY_TIME = 500; // 快速点击间隔
public Activity mActivity;
private OptionsPickerView<String> pvOptions;
public NewH5_WVClickAbstractListener(Activity activity) {
this.mActivity = activity;
}
/**
* 打开h5页面
*
* @param params
*/
@Override
public void openH5(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("openH5 params: " + params.toString());
H5Params h5Params = new H5Params(params.getUrl(), null);
h5Params.setShareData(params.getShare());
h5Params.setShowMenu(params.getDot_flag());
NewH5Activity.start(mActivity, h5Params);
}
@Override
public void courseList() {
LogUtil.d("course_list");
YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_BASE);
}
@Override
public void activeDetail(String id) {
LogUtil.d("active_detail");
try {
JsModularService.Companion.getIDynamicService().startTrendsDetail(mActivity, Integer.parseInt(id), false, false, false, false, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 小壹
*/
@Override
public void contactYi() {
LogUtil.d("contactYi");
try {
JsModularService.Companion.getImService().startP2PSession(mActivity, -1, "14", "14", "客服小壹", "14");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 课程专属客服
*/
@Override
public void contactCourseCustomerService() {
try {
JsModularService.Companion.getImService().startP2PSession(mActivity, -1, "4108805", "4108805", "课程小助手-壹壹", "4108805");
} catch (Exception e) {
}
}
/**
* 跳转话题详情
*
* @param topic_id
*/
@Override
public void openTopicDetail(String topic_id) {
LogUtil.d("OpenTopicDetail");
try {
Intent intents = JsModularService.Companion.getIDynamicService().topicDetailIntent(mActivity, false, topic_id);
mActivity.startActivity(intents);
} catch (Exception e) {
}
}
/**
* 会员主页
*
* @param id
*/
@Override
public void openMember(String id) {
LogUtil.d("OpenMember");
try {
Intent intentm = JsModularService.Companion.getIDynamicService().membersIntent(mActivity, id);
mActivity.startActivity(intentm);
} catch (Exception e) {
}
}
/**
* 跳转发布动态
*/
@Override
public void sendTrend() {
LogUtil.d("SendTrend");
try {
Intent intenta = JsModularService.Companion.getIDynamicService().publishTrendIntent(mActivity);
mActivity.startActivity(intenta);
} catch (Exception e) {
}
}
/**
* 发送测试题到动态
*
* @param cover1
* @param title1
* @param purl1
* @param share_url1
*/
@Override
public void sendResultTrend(final String cover1, final String title1, final String purl1, final String share_url1) {
LogUtil.d("SendResultTrend");
mActivity.runOnUiThread(() -> {
YDLShareDialog dialog = YDLShareDialog.Companion.style1(mActivity, title1, share_url1, title1, cover1);
dialog.setCallBack(type -> {
if (1 == type) {
if (JsModularService.Companion.getIUserService().loginByOneKeyLogin(mActivity, true)) {
//跳转到发布页面
try {
Intent intentp = JsModularService.Companion.getIDynamicService().publishTrendIntent(mActivity, purl1, cover1, title1);
mActivity.startActivity(intentp);
} catch (Exception e) {
}
}
}
});
dialog.show(mActivity.getFragmentManager(), "lose");
});
}
/**
* 跳转选择用户界面发送消息
*/
@Override
public void sendInfo(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("SendInfo");
try {
Intent intent = JsModularService.Companion.getITestsApiService()
.getSelectConversationActivityIntent(mActivity, 1, params.getShare().getTitle(),
params.getShare().getCover(), params.getId(), params.getUrl(),
params.getShare().getShare_url());
mActivity.startActivity(intent);
} catch (Exception e) {
}
}
/**
* 打开专家搜索列表
*
* @param params
*/
@Override
public void searchList(H5JsBean.H5JsCmd.Params params) {
try {
ModularServiceManager.INSTANCE.provide(IConsultantService.class).startExpertSearchActivity(mActivity, "0", "", 0);
} catch (Exception e) {
}
}
/**
* 专家主页
*
* @param params
*/
@Override
public void openExpertsHome(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("OpenExpertsHome");
openH5(params);
}
/**
* 开始测试
*/
@Override
public void openTest(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("OpenTest");
openH5(params);
}
/**
* 私聊
*
* @param id
* @param toUid
* @param canTalk
* @param accessToken
*/
@Override
public void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu, boolean closeReplaceChat) {
LogUtil.d("chat");
if ((toUid + "").equals("14")) {
//找客服私聊不需要积分
contactYi();
} else {
try {
if (closeReplaceChat) {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startChatCloseReplaceChat(mActivity, String.valueOf(toUid));
} else {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startChat(mActivity, String.valueOf(toUid), 0x001, canTalk, isFromQingShu, false);
}
} catch (Exception e) {
}
}
}
/**
* 跳转私聊并发送消息
*
* @param id
* @param toUid
* @param canTalk
* @param accessToken
* @param isFromQingShu
*/
@Override
public void chatSendMessage(int id, int toUid, int canTalk, String accessToken, int isFromQingShu) {
if (toUid == 0) {
ToastUtil.toastShort("参数错误,请刷新页面后重试");
return;
}
try {
ModularServiceManager.INSTANCE.provide(IImService.class).createTextMessage(String.valueOf(toUid), "你好,我想找你倾诉,请尽快上线私聊我,我在等你。", new com.yidianling.im.api.bean.IMRequestCallback<Void>() {
@Override
public void onSuccess(@Nullable Void aVoid) {
}
@Override
public void onFailed(int i) {
String message = "发送失败";
if (i == 7101) {
message = "您已被对方拉黑!";
}
ToastUtil.toastShort(message);
}
@Override
public void onException(@Nullable Throwable throwable) {
ToastUtil.toastShort("发送异常");
}
});
} catch (Exception e) {
e.printStackTrace();
}
try {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startChat(mActivity, String.valueOf(toUid), 0x001, canTalk, 0, false);
} catch (Exception e) {
}
}
//群聊
@Override
public void chatTeam(int tid, int doctorId) {
LogUtil.d("chatTeam");
//群聊直播
Log.e("js", "群聊直播---------");
if (tid == 0) {
ToastUtil.toastShort("群信息有误,请联系客服");
return;
}
JsModularService.Companion.getImService().startTeamSession(mActivity, tid + "",doctorId + "");
}
/**
* 跳转登录
*/
@Override
public void jumpLogin(H5JsBean.H5JsCmd.Params jsData) {
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).successPage = jsData.getSourceUrl();
}
JsModularService.Companion.getIUserService().loginByOneKeyLogin(mActivity, true);
}
}
/**
* Fm详情
*
* @param id
*/
@Override
public void openFmDetail(int id) {
LogUtil.d("OpenFmDetail");
//电台播放
try {
Intent intent = JsModularService.Companion.getIFMService().fmDetailIntent(mActivity, id);
mActivity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void openArticle() {
LogUtil.d("OpenArticle");
YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_ARTICLE_LIST);
}
@Override
public void openFmList() {
LogUtil.d("OpenFmList");
//电台播放
try {
Intent intent = JsModularService.Companion.getIFMService().fmListIntent(mActivity);
mActivity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void sendSubscriptionTimeMessage(String to_uid) {
LogUtil.d("sendSubSriptTimeMessage");
try {
ModularServiceManager.INSTANCE.provide(IImService.class).sendSubscriptionTimeMessage(to_uid, "请尽快添加可预约时间", new com.yidianling.im.api.bean.IMRequestCallback<Void>() {
@Override
public void onSuccess(@Nullable Void aVoid) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).dismissProgressDialog();
}
}
@Override
public void onFailed(int i) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).dismissProgressDialog();
}
String message = "发送失败";
if (i == 7101) {
message = "您已被对方拉黑!";
}
ToastHelper.Companion.show(message);
}
@Override
public void onException(@Nullable Throwable throwable) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).dismissProgressDialog();
}
ToastHelper.Companion.show("发送异常");
}
});
} catch (Exception e) {
}
try {
ModularServiceManager.INSTANCE.provide(IImService.class)
.startChat(mActivity, to_uid, 0x001, 0, 0, false);
} catch (Exception e) {
}
}
@Override
public void pay(H5JsBean.H5JsCmd.Params jsData) {
LogUtil.d("pay");
PayParams payParams = new PayParams();
payParams.setPayId(jsData.getPayId());
payParams.setNeedPay(Float.valueOf(jsData.getMoney()));
payParams.setTitle("预约咨询");
payParams.setVisibleIndemnity(true);
payParams.setMerchantType(jsData.getMerchantType());
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).successPage = jsData.getSucc();
}
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 33);
}
}
//专家收款
@Override
public void payReceipt(H5JsBean.H5JsCmd.Params jsData) {
LogUtil.d("pay_receipt");
PayParams payParams = new PayParams();
payParams.setPayId(jsData.getPayId());
payParams.setNeedPay(Float.valueOf(jsData.getMoney()));
payParams.setTitle("预约咨询");
payParams.setVisibleIndemnity(true);
payParams.setMerchantType(jsData.getMerchantType());
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).successPage = jsData.getSucc();
}
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 33);
}
}
@Override
public void payCourse(H5JsBean.H5JsCmd.Params jsData) {
LogUtil.d("pay_course");
PayParams payParams = new PayParams();
payParams.setPayId(jsData.getPayId());
payParams.setNeedPay(Float.valueOf(jsData.getMoney()));
payParams.setTitle("课程");
payParams.setMerchantType(jsData.getMerchantType());
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).successPage = jsData.getSucc();
}
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 33);
}
}
@Override
public void payTest(H5JsBean.H5JsCmd.Params jsData) {
LogUtil.d("pay_course");
if (!TextUtils.isEmpty(jsData.getPayId()) || jsData.getTest_items_id() != 0) {
//设置支付结果页
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).successPage = jsData.getSucc();
}
}
PayParams payParams = new PayParams();
if (TextUtils.isEmpty(jsData.getPayId()) && jsData.getTest_items_id() != 0) {
//创建支付订单
payParams.setNeedPay(jsData.getPrice());
payParams.setPayId(String.valueOf(jsData.getTest_items_id()));
payParams.setTitle("心理测试");
payParams.setBtnPayText("(¥" + jsData.getPrice() + ") 确认付款");
payParams.setInlet(PayParams.INLET_TEST);
payParams.setMerchantType(jsData.getMerchantType());
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 44);
} else if (!TextUtils.isEmpty(jsData.getPayId()) && !TextUtils.isEmpty(jsData.getOrderId())) {
//待支付订单跳转
payParams.setInlet(PayParams.INLET_NORMAL);
payParams.setPayId(jsData.getPayId());
payParams.setNeedPay(jsData.getPrice());
payParams.setTitle("心理测试");
payParams.setType(2);
float couponMoney = TextUtils.isEmpty(jsData.getCouponMoney()) ? 0f : Float.valueOf(jsData.getCouponMoney());
payParams.setBtnPayText("(¥" + new DecimalFormat("0.00").format(jsData.getPrice() - couponMoney) + ")确认付款");
payParams.setCoupon_money(couponMoney);
payParams.setMerchantType(jsData.getMerchantType());
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 44);
} else {
//直接支付
payParams.setPayId(jsData.getPayId());
payParams.setNeedPay(Float.valueOf(jsData.getMoney()));
payParams.setTitle("测评");
payParams.setMerchantType(jsData.getMerchantType());
mActivity.startActivityForResult(PayActivity.Companion.newIntent(mActivity, payParams), 44);
}
}
}
/**
* 查看测试结果
*
* @param jsData
*/
@Override
public void viewTestResult(H5JsBean.H5JsCmd.Params jsData) {
if (jsData.getTestResultId() != 0) {
try {
JsModularService.Companion.getITestsApiService().testH5Result(jsData.getTestResultId().toString());
} catch (Exception e) {
}
}
}
@Override
public void ydlNative(H5JsBean.H5JsCmd jsData) {
LogUtil.d("ydlNative");
//用于子类统计数据的 不做业务处理
}
@Override
public void openOrderDetail(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void expertProduct(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void order(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void toOrderCt(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void showDocList(H5JsBean.H5JsCmd.Params params) {
}
@Override
public void goodExpert() {
}
@Override
public void copyWechat(H5JsBean.H5JsCmd.Params params) {
String weixin_id = params.getWeixin();
//获取剪贴板管理器:
@SuppressLint("WrongConstant") ClipboardManager cm = (ClipboardManager) mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
// 创建普通字符型ClipData
ClipData mClipData = ClipData.newPlainText("Label", weixin_id);
// 将ClipData内容放到系统剪贴板里。
cm.setPrimaryClip(mClipData);
}
@Override
public void goWechat() {
LogUtil.d("GoweChat");
try {
Intent intent = mActivity.getPackageManager().getLaunchIntentForPackage("com.tencent.mm");
mActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
ToastUtil.toastLong(mActivity, "您的手机尚未安装微信或者微信版本太低!");
}
}
@Override
public void listenOrderDetail(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void detailSub(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void openAgreement(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void modifyEval(H5JsBean.H5JsCmd.Params params) {
openH5(params);
}
@Override
public void visitEval(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("VistEval");
openH5(params);
}
@Override
public void coursePlay(H5JsBean.H5JsCmd.Params params) {
if (TextUtils.isEmpty(params.getCourse_id())) {
ToastUtil.toastShort("参数错误,请重试");
return;
}
try {
JsModularService.Companion.getICourseService().startCoursePlayActivity(mActivity,
Integer.valueOf(params.getCourse_id()), params.getCoursePlayUrl(), 1, params.getMediaType());
} catch (Exception e) {
}
}
@Override
public void closeFloatView() {
mActivity.runOnUiThread(() -> {
try {
if (PlayerFloatHelper.Companion.isShow(mActivity)) {
PlayerFloatHelper.Companion.removeView(mActivity);
AudioPlayer.Companion.get().stopPlayer();
}
} catch (Exception e) {
e.printStackTrace();
}
});
}
@Override
public void courseWriteComment(H5JsBean.H5JsCmd.Params params) {
try {
JsModularService.Companion.getICourseService().startCourseCommentActivity(mActivity, Objects.requireNonNull(params.getCourse_id()));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void courseComment(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("courseComment");
//课程评论列表
try {
JsModularService.Companion.getICourseService().startCourseReplyActivity(mActivity, params.getCourse_id());
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void listenTel(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void voiceBroadcast(H5JsBean.H5JsCmd.Params params) {
}
/**
* axb拨号逻辑
*
* @param params
*/
@Override
public void tel(H5JsBean.H5JsCmd.Params params) {
try {
ModularServiceManager.INSTANCE.provide(IConfideService.class).showAxbConfirmDialog(mActivity, 1, params.getPhoneNumber());
} catch (Exception e) {
}
}
/**
* 声网拨号逻辑
*
* @param jsData
*/
@Override
public void listenAgora(H5JsBean.H5JsCmd.Params jsData) {
}
@Override
public void setTitle(H5JsBean.H5JsCmd.Params jsData) {
}
//倾诉链接java接口,支持axb和声网,双呼由h5发起
@Override
public void confideConnect(H5JsBean.H5JsCmd.Params jsData) {
//h5activity中实现
}
@Override
public void confidePay(H5JsBean.H5JsCmd.Params jsData) {
//h5中实现
}
@Override
public void back() {
//h5中实现
mActivity.finish();
}
@Override
public void saveImage(H5JsBean.H5JsCmd.Params jsData) {
ImageUtil.savePicture(mActivity, jsData.getImageBase64());
}
@Override
public void sendToExpert(H5JsBean.H5JsCmd.Params jsData) {
//专家解读
ARouter.getInstance().build("/test/select_conversation")
.withInt("flag", 1)
.withString("title", jsData.getShare().getTitle())
.withString("head", jsData.getShare().getCover())
.withInt("id", jsData.getTest_items_id())
.withString("share_url", jsData.getShare().getShare_url())
.withString("url", HttpConfig.Companion.getH5_URL() + "ceshi/result/" + jsData.getTestResultId())
.navigation();
}
/**
* 调用公共支付的
*
* @param jsData
*/
@Override
public void commonPay(H5JsBean.H5JsCmd.Params jsData) {
if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
return;
}
lastClickTime = System.currentTimeMillis();
UserResponseBean.UserInfo userInfo = JsModularService.Companion.getIUserService().getUserInfo();
if (userInfo != null) {
mActivity.runOnUiThread(() -> {
CommonPayDialog.Build build = new CommonPayDialog.Build(mActivity)
.setCourseId(Objects.requireNonNull(jsData.getGoodsId()))
.setToken(Objects.requireNonNull(userInfo.getAccessToken()))
.setUid(userInfo.getUid())
.setIsTestEnvironment(false)
.setFfrom(YdlCommonOut.Companion.getChannelName())
.setListener(new CommonPayDialog.OnPayResultListener() {
@Override
public void onSuccesed() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).refresh();
}
}
@Override
public void onFailed() {
}
});
build.build().show();
});
}
}
@Override
public void onOrderByApp(H5JsBean.H5JsCmd.Params params) {
LogUtil.d("onorder_by_app");
//预约下单
// DownOrderActivity.Companion.start(mContext, params.getProduct_id());
//新版走h5下单流程,此处不需要了
}
@Override
public void orderSetTime(H5JsBean.H5JsCmd.Params params) {
//预约下单选择时间
LogUtil.d("order_set_time");
Intent in = mActivity.getIntent();
in.putExtra("schedule_id", params.getSchedule_id());
in.putExtra("schedule_time", params.getSchedule_time());
mActivity.setResult(Activity.RESULT_OK, in);
mActivity.finish();
mActivity.overridePendingTransition(0, R.anim.app_activity_open_down);
}
@Override
public void searchServiceDoc(int cateId) {
try {
ModularServiceManager.INSTANCE.provide(IConsultantService.class).startExpertSearchActivity(mActivity, String.valueOf(cateId));
} catch (Exception e) {
}
}
@Override
public void openTestDetail(H5JsBean.H5JsCmd.Params params) {
try {
JsModularService.Companion.getITestsApiService().testDetailH5(String.valueOf(params.getTest_items_id()));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void shareAction(H5JsBean.H5JsCmd.Params params) {
if (mActivity != null) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).showShareMenu(params);
}
}
}
@Override
public void openTestList() {
YDLRouterManager.Companion.router(IYDLRouterConstant.ROUTER_TEST_HOME);
}
@Override
public void feedBack() {
try {
ModularServiceManager.INSTANCE.provide(IAppService.class).feedBackIntent(mActivity);
} catch (Exception e) {
}
}
@Override
public void phoneCall() {
try {
ModularServiceManager.INSTANCE.provide(IConfideService.class).startCondifeHomePage(mActivity, false);
} catch (Exception e) {
}
}
@Override
public void chatSchedule(H5JsBean.H5JsCmd.Params params) {
try {
ModularServiceManager.INSTANCE.provide(IImService.class)
.chatScheule(mActivity, params.getUser_url(), params.getDoc_url(), params.getDsmId(), params.getTitle(), params.getToUid());
} catch (Exception e) {
}
}
@Override
public void invite(H5JsBean.H5JsCmd.Params params) {
if (mActivity != null && null != params && null != params.getShare()) {
YDLShareDialog dialog = YDLShareDialog.Companion.style4(mActivity, params.getShare().getTitle(), params.getShare().getShare_url(), params.getShare().getDesc(), params.getShare().getCover());
dialog.show(mActivity.getFragmentManager(), "lose");
}
}
@Override
public void balance(H5JsBean.H5JsCmd.Params params) {
if (!JsModularService.Companion.getIUserService().loginByOneKeyLogin(mActivity, true)) {
return;
}
try {
ModularServiceManager.INSTANCE.provide(IAppService.class).accountHistoryIntent(mActivity);
} catch (Exception e) {
}
}
@Override
public void switchDownRefresh(H5JsBean.H5JsCmd.Params params) {
if (mActivity != null && mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).hasShowDownRefresh(params.getSwitch());
}
}
@Override
public void refresh() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).refresh();
}
}
@Override
public void recharge() {
if (!JsModularService.Companion.getIUserService().loginByOneKeyLogin(mActivity, true)) {
return;
}
try {
ModularServiceManager.INSTANCE.provide(IAppService.class).rechargeActivityIntent(mActivity);
} catch (Exception e) {
}
}
@Override
public void bindPhone() {
try {
ModularServiceManager.INSTANCE.provide(IUserService.class).wxBindToInputhonePage(mActivity);
} catch (Exception e) {
}
}
@Override
public void openRightTopMenu() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).openRightTopMenu();
}
}
@Override
public void openShareMenu(H5JsBean.H5JsCmd.Params params) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).openShareMenu(params);
}
}
@Override
public void hideStatusBar() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).hideJavaTitleBar();
}
}
@Override
public void showStatusBar() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).showTitleBar();
}
}
@Override
public void closeWebKit() {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).closeWebKit();
}
}
@Override
public void goHome(H5JsBean.H5JsCmd.Params params) {
//关闭所有页面返回首页
JsModularService.Companion.getIAppService().mainIntent(mActivity,params.getSelectTab(), false);
//关闭当前H5页面
mActivity.finish();
}
@SuppressLint("CheckResult")
@Override
public void sendUnReadNum(String callbackFuncName, String uid) {
try {
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
ModularServiceManager.INSTANCE.provide(IImService.class)
.getChatUid(mActivity, uid, responseUid -> {
final StringBuffer sb = new StringBuffer();
sb.append(callbackFuncName);
sb.append("('");
int unReadNum = ModularServiceManager.INSTANCE.provide(IImService.class).getUnReadByUid(responseUid);
sb.append(unReadNum);
sb.append(",");
int unReadAllNum = ModularServiceManager.INSTANCE.provide(IImService.class).getAllUnReadNum();
sb.append(unReadAllNum);
sb.append("')");
if (mActivity != null && mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).callJSFunc(sb.toString());
}
});
} catch (Exception e) {
}
}
@Override
public void switchPushStatus(H5JsBean.H5JsCmd.Params params) {
if (params.getSwitchStatus() == 1) {
JsImpl.Companion.setH5Open(true);
} else {
JsImpl.Companion.setH5Open(false);
}
}
@Override
public void shouldShowTitleBar(boolean isShowTitleBar) {
if (isShowTitleBar && mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).notCoverTitleBar();
} else {
((NewH5Activity) mActivity).coverJavaTitleBar();
}
}
@Override
public void setSelfPageType(int selfType) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).setSelfPageType(selfType);
}
}
@Override
public void setBootomFitViewColor(String color) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).setBottomViewColor(color);
}
}
/**
* 打开时间选择器
*/
@SuppressLint("CheckResult")
@Override
public void openTimePicker(String jsCallBackName, String day, String doctorId, String orderId) {
ArrayList<String> options1Items = new ArrayList<>();
ArrayList<List<String>> options2Items = new ArrayList<>();
ArrayList<List<List<String>>> options3Items = new ArrayList<>();
// 所构造的时间数据
ArrayList<List<String>> TIMELIST = new ArrayList<>();
JsHttpImpl.Companion.getInstance().getTimePickerData(day, doctorId, orderId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(response -> {
if (response.code == 200) {
for (int i = 0; i < response.data.size(); i++) { // 遍历服务时间
TimeDataBean timeDataBean = response.data.get(i);
options1Items.add(String.valueOf(timeDataBean.getServiceTime()));
// 构造时间数据
for (int j = 0; j < response.data.size(); j++) {
List<String> list = new ArrayList<>();
for (int k = 0; k < timeDataBean.getTimes().size(); k++) {
String[] times = timeDataBean.getTimes().get(k).split("-");
list.add(times[0]);
int timeInterval = (int) ((getTimeToDate(times[1]) - getTimeToDate(times[0])) / 1000 / 60 / 10);
for (int l = 0; l < timeInterval; l++) {
String time = getHourMin(getTimeToDate(list.get(list.size() - 1)) + 10 * 60 * 1000);
list.add(time);
}
}
TIMELIST.add(list);
}
ArrayList<String> amList = new ArrayList<>(); // 上午、下午集合(第二级)
ArrayList<List<String>> timeList = new ArrayList<>(); // 上午或者下午对应的时间 (第三级)
for (int j = 0; j < 2; j++) {
List<String> tmList = new ArrayList<>(); // 上午或者下午对应的时间集合
if (j == 0) {
for (int k = 0; k < TIMELIST.get(i).size(); k++) {
if (getTimeToDate(TIMELIST.get(i).get(k)) <= getTimeToDate("12:00")) {
tmList.add(TIMELIST.get(i).get(k));
}
}
if (tmList.size() > 0) {
amList.add("上午");
}
} else {
for (int k = 0; k < TIMELIST.get(i).size(); k++) {
if (getTimeToDate(TIMELIST.get(i).get(k)) > getTimeToDate("12:00")) {
tmList.add(TIMELIST.get(i).get(k));
}
}
if (tmList.size() > 0) {
amList.add("下午");
}
}
if (tmList.size() > 0) {
timeList.add(tmList);
}
}
options2Items.add(amList);
options3Items.add(timeList);
}
pvOptions = new OptionsPickerBuilder(mActivity, (options1, options2, options3, v) -> {
// 选择完时间回调给前端
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).callJSFunc("saveChooseTimer(\"" + options3Items.get(options1).get(options2).get(options3) + "," + options1Items.get(options1) + "\")");
}
LogUtil.e("saveChooseTimer(\"" + options3Items.get(options1).get(options2).get(options3) + "," + options1Items.get(options1) + "\")");
})
.setTitleText("请选择开始时间")
.setDividerColor(Color.TRANSPARENT)
.setTextColorCenter(Color.BLACK) //设置选中项文字颜色
.setLabels("分钟", "", "")
.setCyclic(false, false, false)
.setContentTextSize(20)
.isRestoreItem(true)
.build();
pvOptions.setPicker(options1Items, options2Items, options3Items);
pvOptions.show();
}
}, e -> {
ToastUtil.toastShort(e.getMessage());
});
}
// 关闭当前h5页面并刷新上一个h5页面
@Override
public void goBackAndReload(String url) {
H5Params h5Params = new H5Params(url, null);
NewH5Activity.start(mActivity, h5Params);
if (ActivityManager.Companion.getInstance().getSecondTaskActivity() != null) {
ActivityManager.Companion.getInstance().getSecondTaskActivity().finish();
}
mActivity.finish();
}
@Override
public void toThirdApp(String url) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (!TextUtils.isEmpty(url)) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
mActivity.startActivity(intent);
}
}
});
}
@Override
public void getNextExpertStatus(String doctorID, String title, String uid, String linkUrl) {
EventBus.getDefault().post(new ChangeAnotherExpertEvent(doctorID, title, uid, linkUrl));
}
@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
public void reloadUrl(String url) {
if (mActivity instanceof NewH5Activity) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
((NewH5Activity) mActivity).loadUrl(url);
}
});
}
}
/**
* 时间字符串转时间戳
*
* @param time
* @return
*/
private long getTimeToDate(String time) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date date = new Date();
try {
date = sdf.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
return date.getTime();
}
/**
* 根据时间戳获取时分
*
* @return
*/
private String getHourMin(long time) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(new Date(time));
}
@Override
public void playMeditation(int mediaId, long meditationId, int meditationType, String mediaCoverUrl) {
if (mActivity instanceof NewH5Activity) {
ARouter.getInstance().build("/muse/play")
.withLong("MEDITATION_ID", meditationId)
.withLong("MEDIA_ID", mediaId)
.withInt("MEDITATION_TYPE", meditationType)
.withString("MEDIA_COVER_URL", mediaCoverUrl)
.navigation();}
}
@Override
public void switchSound(int mediaId, long meditationId, int meditationType, int businessType,
String buried, String mediaUrl, String mediaCoverUrl,
String title, String desc, int status) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).switchSound(mediaId, meditationId, meditationType,
businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status);
} else if ("ChooseMusicActivity".equals(mActivity.getClass().getSimpleName())) {
JsModularService.Companion.getIMuseService().switchSound(mActivity,mediaId, meditationId, meditationType,
businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status);
}
}
@Override
public void setBG(String rgb, String alpha) {
if (mActivity instanceof NewH5Activity) {
((NewH5Activity) mActivity).setBG(rgb, alpha);
}
}
@Override
public void showCommentArticleDialog(H5JsBean.H5JsCmd.Params params) {
if (mActivity instanceof NewH5Activity){
((NewH5Activity)mActivity).showCommentArticleDialog(params.getTitle());
}
}
}
package com.ydl.component.service.web;
package com.ydl.js;
import com.ydl.webview.H5JsBean;
......@@ -8,7 +8,7 @@ import com.ydl.webview.H5JsBean;
* Created by harvie on 2017/7/4 0004.
*/
public interface WebViewClientClickListener {
public interface NewH5_WebViewClientClickListener {
void openH5(H5JsBean.H5JsCmd.Params jsData);
......@@ -36,7 +36,8 @@ public interface WebViewClientClickListener {
void openTest(H5JsBean.H5JsCmd.Params params);
void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu);
//注册引导页--跳转私聊界面
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);
......@@ -170,49 +171,63 @@ public interface WebViewClientClickListener {
//关闭页面
void closeWebKit();
void goHome(H5JsBean.H5JsCmd.Params params);
//保存图片
// void storePic();
/**
* 向h5发送对那个uid的未读数
* @param callbackFuncName
* @param uid
*/
void sendUnReadNum(String callbackFuncName, String uid);
//h5页面是否需要打开推送
void switchPushStatus(H5JsBean.H5JsCmd.Params params);
//是否展示标题栏
void shouldShowTitleBar(boolean isShowTitleBar);
//设置当前页面类型
void setSelfPageType(int selfType);
//关闭私聊窗口立即咨询webview
void chatCloseBottomWebView();
void setBootomFitViewColor(String color);
/**打开时间选择器*/
void openTimePicker(String jsCallBackName, String day, String doctorId, String orderId);
default void playMeditation(int mediaId,long meditationId,int meditationType,String mediaCoverUrl){}
/**返回上一页并刷新*/
void goBackAndReload(String url);
default void switchSound(int mediaId,long meditationId,int meditationType,int businessType,
String buried,String mediaUrl,String mediaCoverUrl,String title,
String desc,int status){
/**跳转第三方APP*/
void toThirdApp(String url);
}
//页面内跳转url
/**页面内跳转url*/
void reloadUrl(String url);
default void setWebViewBG(String rgb,String alpha){}
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) {
}
default void setBG(String rgb, String alpha) {
}
void getNextExpertStatus(String doctorID, String title, String uid, String linkUrl);
//h5页面是否需要打开推送
void switchPushStatus(H5JsBean.H5JsCmd.Params params);
/**
* 关闭私聊窗口立即咨询webview
*/
void chatCloseBottomWebView();
//显示评论弹窗
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);
}
package com.ydl.js
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.text.TextUtils
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.tencent.smtt.sdk.WebView
import com.ydl.audioim.api.IAudioImService
import com.ydl.webview.*
import com.ydl.ydlcommon.modular.findRouteService
import com.ydl.ydlcommon.utils.Utils
import com.yidianling.common.tools.ToastUtil
import com.yidianling.ydl_pay.pay.payDialog.CallBack
import com.yidianling.ydl_pay.pay.payDialog.ConfidePayParams
import com.yidianling.ydl_pay.pay.payDialog.PayDialog
/**
* Created by haorui on 2019-10-10.
* Des:
*/
@Route(path = "/web/webservice")
class WebServiceImpl : IWebService {
override fun getJavascripHandler(activity: Activity, webView:WebView?, tellData: TellData): IJavascriptHandler {
return NewH5_JavascriptHandler(webView, object : NewH5_WVClickAbstractListener(activity) {
override fun setTitle(jsData: H5JsBean.H5JsCmd.Params?) {
//设置webview标题
if (activity is NewH5Activity) {
activity.setWebViewTitle(jsData?.title)
}
}
//倾诉链接java接口
override fun confideConnect(jsData: H5JsBean.H5JsCmd.Params?) {
if (Utils.isFastClick()) {
//防止连击
return
}
if (!findRouteService(IAudioImService::class.java).getIsOnlineRtm()) {
//异常退出或者账号被顶掉,重新登录并拨打
findRouteService(IAudioImService::class.java).loginRtm(JsModularService.getIUserService().getUserInfo()?.uid) { isSuccess: Boolean, _ ->
if (isSuccess) {
connectionJava(jsData?.id ?: 0, jsData?.confideType ?: 1, activity, tellData, jsData?.callType)
} else {
ToastUtil.toastShort("请重新拨打")
}
}
} else {
connectionJava(jsData?.id ?: 0, jsData?.confideType ?: 1, activity, tellData, jsData?.callType)
}
}
//php线路已废除
override fun listenTel(jsData: H5JsBean.H5JsCmd.Params?) {
}
override fun listenAgora(jsData: H5JsBean.H5JsCmd.Params?) {
if (Utils.isFastClick()) {
//防止连击
return
}
//声网路线
connectionJava(jsData?.id ?: 0, 3, activity, tellData, jsData?.callType)
}
override fun confidePay(jsData: H5JsBean.H5JsCmd.Params?) {
//倾诉支付
val confidePay = ConfidePayParams(
jsData?.payTitle ?: "倾诉服务", jsData?.orderPrice, jsData?.coupnPrice ?: 0.00,
jsData?.avliableMoney ?: 0.00, jsData?.payId ?: "", jsData?.confideUrl ?: "", jsData?.merchantType
)
confidePayDialog(jsData?.id, jsData?.confideType, activity, confidePay, jsData?.callType)
}
override fun back() {
if (activity is NewH5Activity) {
activity.goBack()
}
}
})
}
//倾诉支付弹窗
private fun confidePayDialog(id: Int?, type : Int?, activity: Activity, confidePay : ConfidePayParams, callType:String?){
PayDialog(activity)
.setCallback(object : CallBack {
override fun onSuccess() {
//支付成功,直接拨打
if (TextUtils.isEmpty(confidePay.confideUrl)) {
connectionJava(id ?: 0, type ?: 1, activity, null, callType)
} else {
//倾诉订单列表页面过来,会有confideUrl值,则直接跳转此url
NewH5Activity.start(activity, H5Params(confidePay.confideUrl!!, ""))
}
}
override fun onError() {
}
})
.show(confidePay)
}
//java版axb和声网接口
@SuppressLint("CheckResult")
private fun connectionJava(id: Int, type: Int, activity: Activity, tellData: TellData?, callType: String?) {
try {
JsModularService.getIConfideService().connectionJava(
id, type, activity, Gson().toJson(tellData), callType
)
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun init(context: Context) {
}
}
package com.ydl.js.bean
data class TimeDataBean(
var serviceTime:Int, // 咨询时长
var times:ArrayList<String> // 时间集合
)
\ No newline at end of file
package com.ydl.js.http
import com.ydl.js.bean.TimeDataBean
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseResponse
import io.reactivex.Observable
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query
interface JsApi {
/**
* 获取时间选择器数据
*/
@GET("consult/user/order/selectWorriesReducibleTime")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getTimePickerData(
@Query("day") day: String,
@Query("doctorId") doctorId: String,
@Query("orderId") orderId: String
): Observable<BaseResponse<ArrayList<TimeDataBean>>>
}
\ No newline at end of file
package com.ydl.js.http
import com.ydl.js.bean.TimeDataBean
import com.ydl.ydlcommon.data.http.BaseResponse
import io.reactivex.Observable
interface JsHttp {
// 获取时间选择器数据
fun getTimePickerData(day:String,doctorId:String,orderId:String): Observable<BaseResponse<ArrayList<TimeDataBean>>>
}
package com.ydl.js.http
import com.ydl.js.bean.TimeDataBean
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlnet.YDLHttpUtils
import io.reactivex.Observable
class JsHttpImpl private constructor() : JsHttp{
companion object {
fun getInstance(): JsHttpImpl {
return Holder.INSTANCE
}
fun clearAppApi() {
Holder.INSTANCE.appApi = null
}
}
private var appApi: JsApi? = null
private fun getAppApi(): JsApi {
if (appApi == null) {
appApi = YDLHttpUtils.obtainApi(JsApi::class.java)
}
return appApi!!
}
object Holder {
val INSTANCE = JsHttpImpl()
}
override fun getTimePickerData(
day: String,
doctorId: String,
orderId: String
): Observable<BaseResponse<ArrayList<TimeDataBean>>> {
return getAppApi().getTimePickerData(day,doctorId,orderId)
}
}
\ No newline at end of file
package com.ydl.js.moduler.service
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.js.api.IJsService
@Route(path = "/js/JsService")
class JsImpl : IJsService {
companion object {
var isH5Open = true
var isMainOpen = true
}
override fun init(context: Context?) {
}
override fun isH5Open(): Boolean {
return isH5Open
}
override fun isMainOpen(): Boolean {
return isMainOpen
}
override fun setH5Open(open: Boolean) {
isH5Open = open
}
override fun setMainOpen(open: Boolean) {
isMainOpen = open
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromYDelta="0"
android:toYDelta="100%p" />
</set>
\ No newline at end of file
......@@ -59,6 +59,7 @@ dependencies {
api project(":ydl-platform")
implementation project(':ydl-media')
implementation project(":api:user")
implementation project(":api:muse")
implementation project(':ydl-flutter-base')
implementation project(':ydl-webview')
......
package com.yidianling.muse.moduler.service
import android.app.Activity
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.muse.api.IMuseService
import com.yidianling.muse.activity.ChooseMusicActivity
@Route(path = "/muse/MuseService")
class MuseImpl : IMuseService {
override fun init(context: Context?) {
}
override fun switchSound(
activity: Activity,
mediaId: Int,
meditationId: Long,
meditationType: Int,
businessType: Int,
buried: String?,
mediaUrl: String?,
mediaCoverUrl: String?,
title: String?,
desc: String?,
status: Int
) {
(activity as ChooseMusicActivity).switchSound(
mediaId, meditationId, meditationType,
businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status
)
}
}
\ No newline at end of file
......@@ -9,7 +9,9 @@ import android.widget.ImageView;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.config.ChannelConfig;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.data.PlatformDataManager;
import com.yidianling.common.tools.RxNetTool;
import com.yidianling.user.R;
......@@ -58,11 +60,15 @@ public class H5Activity extends BaseActivity {
// 开启 DOM storage API 功能
web_view.getSettings().setDomStorageEnabled(true);
if (getIntent().getBooleanExtra(INTENT_PRIVACY, false)) {
String ffrom = PlatformDataManager.INSTANCE.getRam().getChannelName();
//隐私政策
if (!RxNetTool.isConnected(BaseApp.Companion.getApp())){
if (!RxNetTool.isConnected(BaseApp.Companion.getApp())) {
//无网络 读取本地文件
web_view.loadUrl("file:///android_asset/html/yinsi.html");
}else {
} else if (ffrom.startsWith(ChannelConfig.ATK_4.name())) {
//心理测试包更改隐私协议地址
web_view.loadUrl("https://m.ydl.com/Protol/yinsi/shdh/test");
} else {
web_view.loadUrl("https://m.ydl.com/Protol/yinsi/shdh");//加载url
}
} else {
......
......@@ -17,6 +17,8 @@ import com.mobile.auth.gatewayauth.model.TokenRet
import com.ydl.ydlcommon.app.Apm
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.ChannelConfig
import com.ydl.ydlcommon.data.PlatformDataManager.getRam
import com.ydl.ydlcommon.utils.JPushUtils
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.YDLCacheUtils
......@@ -307,7 +309,7 @@ object OneKeyLoginHelp {
val appName= mActivity.resources.getString(R.string.user_login_name_start)
var appPrivacyOneTip = "${appName}用户使用协议"
var appPrivacyOne = "https://h5.ydl.com/SDUserProtol"
var appPrivacyTwo = "https://m.ydl.com/Protol/yinsi/shdh"
var appPrivacyTwo = getPrivacyUrl()
if (mAppType == YDL_EXPERT_APP) {
loginLogo = "ic_expert_login_logo"
loginHeight = 60
......@@ -394,7 +396,7 @@ object OneKeyLoginHelp {
// 每次打开页面前先清空所有的自定义控件,再重新设置
phoneNumberAuthHelper.removeAuthRegisterXmlConfig()
phoneNumberAuthHelper.removeAuthRegisterViewConfig()
var appPrivacyTwo = getPrivacyUrl()
val dialogHeight = RxImageTool.px2dp((RxDeviceTool.getScreenHeight(mActivity) * 0.45f))
phoneNumberAuthHelper.setAuthUIConfig(
AuthUIConfig.Builder()
......@@ -422,7 +424,7 @@ object OneKeyLoginHelp {
.setSwitchAccTextColor(Color.parseColor("#999999"))
.setSwitchOffsetY_B(80)
.setAppPrivacyOne("壹点灵用户使用协议", "https://h5.ydl.com/SDUserProtol")
.setAppPrivacyTwo("隐私协议", "https://m.ydl.com/Protol/yinsi/shdh")
.setAppPrivacyTwo("隐私协议", appPrivacyTwo)
.setAppPrivacyColor(Color.parseColor("#bfbfbf"), Color.parseColor("#991da1f2"))
.setCheckboxHidden(checkBoxHidden) // 设置是否同意协议的checkbox隐藏
.setCheckBoxHeight(22)
......@@ -439,6 +441,16 @@ object OneKeyLoginHelp {
)
}
private fun getPrivacyUrl(): String {
val ffrom = getRam().getChannelName()
var appPrivacyTwo = "https://m.ydl.com/Protol/yinsi/shdh"
if (ffrom.startsWith(ChannelConfig.ATK_4.name)) {
//心理测试包更改隐私协议地址
appPrivacyTwo = "https://m.ydl.com/Protol/yinsi/shdh/test"
}
return appPrivacyTwo
}
// 一键登录token监听器
private var mTokenListener: TokenResultListener = object : TokenResultListener {
......
......@@ -5,4 +5,6 @@ include ':app',
':m-consultant', ':m-muse', ':m-fm', ':m-tests', ":m-course",
":m-im",":m-dynamic",":m-article",":m-audioim",":m-user", ":m-confide"
include ':ydl-tuicore', ':api:confide', ':api:dynamic', ':api:fm', ':api:consultant',
':api:course', ':api:user', ':api:tests', ':api:im',':api:home'
':api:course', ':api:user', ':api:tests', ':api:im',':api:home',':api:muse',':api:js',':api:audioim'
include ':m-js'
include ':app2'
......@@ -4,6 +4,11 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: "../publish.gradle"
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
android {
compileSdkVersion 28
......@@ -42,6 +47,9 @@ dependencies {
api(rootProject.ext.dependencies["ydl-ijkplayer-jjdxm"]) {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation "com.alibaba:arouter-api:$arouter_api"
// 注意此处的依赖方式:kotlin中使用和java中使用方式有不同
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
api project(':ydl-platform')
......
......@@ -28,7 +28,7 @@ import okio.BufferedSource;
* Des: 解析框架中的网络请求和响应结果并打印
*/
public class RequestLogInterceptor implements Interceptor {
private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
// private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
private boolean mIsDebug;
private RequestHandler mRequestHandler;
......@@ -40,18 +40,18 @@ public class RequestLogInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//打印请求信息
if (request.body() != null && isParseable(request.body().contentType())) {
mPrinter.printJsonRequest(request, parseParams(request));
} else {
mPrinter.printFileRequest(request);
}
if (mRequestHandler != null) {
request = mRequestHandler.onHttpRequestBefore(chain, request);
}
long t1 = System.nanoTime();
//
// //打印请求信息
// if (request.body() != null && isParseable(request.body().contentType())) {
// mPrinter.printJsonRequest(request, parseParams(request));
// } else {
// mPrinter.printFileRequest(request);
// }
//
// if (mRequestHandler != null) {
// request = mRequestHandler.onHttpRequestBefore(chain, request);
// }
// long t1 = System.nanoTime();
Response originalResponse;
try {
originalResponse = chain.proceed(request);
......@@ -59,35 +59,35 @@ public class RequestLogInterceptor implements Interceptor {
NetLogUtils.debugInfo("Http Error: " + e);
throw e;
}
long t2 = System.nanoTime();
// long t2 = System.nanoTime();
ResponseBody responseBody = originalResponse.body();
// ResponseBody responseBody = originalResponse.body();
//打印响应结果
String bodyString = null;
if (responseBody != null && isParseable(responseBody.contentType())) {
bodyString = printResult(request, originalResponse);
if (mRequestHandler != null) {
mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
}
}
if (mIsDebug) {
final List<String> segmentList = request.url().encodedPathSegments();
final String header = originalResponse.headers().toString();
final int code = originalResponse.code();
final boolean isSuccessful = originalResponse.isSuccessful();
final String message = originalResponse.message();
final String url = originalResponse.request().url().toString();
if (responseBody != null && isParseable(responseBody.contentType())) {
mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful,
code, header, responseBody.contentType(), bodyString, segmentList, message, url);
} else {
mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header, segmentList, message, url);
}
}
// String bodyString = null;
// if (responseBody != null && isParseable(responseBody.contentType())) {
// bodyString = printResult(request, originalResponse);
// if (mRequestHandler != null) {
// mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
// }
// }
//
// if (mIsDebug) {
// final List<String> segmentList = request.url().encodedPathSegments();
// final String header = originalResponse.headers().toString();
// final int code = originalResponse.code();
// final boolean isSuccessful = originalResponse.isSuccessful();
// final String message = originalResponse.message();
// final String url = originalResponse.request().url().toString();
//
// if (responseBody != null && isParseable(responseBody.contentType())) {
// mPrinter.printJsonResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), isSuccessful,
// code, header, responseBody.contentType(), bodyString, segmentList, message, url);
// } else {
// mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
// isSuccessful, code, header, segmentList, message, url);
// }
// }
return originalResponse;
}
......
......@@ -35,8 +35,6 @@ import okio.BufferedSink
import java.io.EOFException
import java.nio.charset.Charset
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
/**
......@@ -142,8 +140,8 @@ class HttpConfig {
commonParams(),
requestHead(appName),
addEncryptionHeaderParamsInterceptor(),
responseErrorInterceptor()
// respErrorInterceptor()
responseErrorInterceptor(),
respErrorInterceptor(),
)
.setRequestHandler(getRequestHandler())
.setReadTimeout(15)
......@@ -193,22 +191,29 @@ class HttpConfig {
val code = resp.code()
val message = resp.message()
val api = req.url().encodedPath()
if (api.contains("data/bigdata/maidian/writeMaiDianData")) {
return@Interceptor resp
}
if (!resp.isSuccessful) {
Apm.reportEventWithExt("network_api", "resp_fail", api, mapOf("code" to code.toString(), "msg" to message))
Apm.reportEventWithExt("network_api_android", "resp_fail", api, mapOf("code" to code.toString(), "msg" to message))
} else {
try {
val body = resp.body() ?: return@Interceptor resp
val buffer = body.source().buffer()
val source = body.source()
source.request(Long.MAX_VALUE)
val buffer = source.buffer()
if (!isPlaintext(buffer)) return@Interceptor resp
val readString = buffer.clone().readString(Charset.forName("UTF-8"))
val fromJson = Gson().fromJson<BaseAPIResponse<Any>>(readString, BaseAPIResponse::class.java)
if (fromJson == null) {
return@Interceptor resp
}
if (fromJson.code != "200" && fromJson.code != "0") {
Apm.reportEventWithExt("network_api", "business_fail", api, mapOf("code" to code.toString(), "msg" to message))
Apm.reportEventWithExt("network_api_android", "business_fail", api, mapOf("code" to code.toString(), "msg" to message))
}
} catch (throwable: Throwable) {
LogUtil.e(throwable.message)
Apm.reportEventWithExt("network_api_android", "throwable", api, mapOf("msg" to (throwable.message ?: "")))
}
}
return@Interceptor resp
}
......
......@@ -76,10 +76,16 @@ object ModularServiceManager {
private val routerMap: HashMap<String, IProvider> = HashMap()
@Deprecated("使用findRouteService代替",
ReplaceWith("findRouteService(IPlatformUserModuleService::class.java)", "import com.ydl.ydlcommon.modular.findRouteService")
)
fun getPlatformUserService(): IPlatformUserModuleService? {
return provide(IPlatformUserModuleService::class.java)
}
@Deprecated("使用findRouteService代替",
ReplaceWith("findRouteService(clz)", "import com.ydl.ydlcommon.modular.findRouteService")
)
fun <T : IProvider> provide(clz: Class<T>, path: String): T {
var provider: IProvider? = null
......@@ -106,6 +112,9 @@ object ModularServiceManager {
return provider as T
}
@Deprecated("使用findRouteService代替",
ReplaceWith("findRouteService(clz)", "import com.ydl.ydlcommon.modular.findRouteService")
)
fun <T : IProvider> provide(clz: Class<T>): T {
var provider: IProvider? = null
......
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