Commit b4bed120 by konghaorui

Merge branch 'dev' into feature/组件化_ending

# Conflicts:
#	app/src/main/java/com/ydl/component/base/DemoAppLifecycles.java
#	config.gradle
#	m-audioim/src/main/java/com/ydl/audioim/YDLavManager.kt
#	m-consultant/src/main/java/com/yidianling/consultant/ExpertSearchFragment.kt
#	m-consultant/src/main/java/com/yidianling/consultant/adapter/ExpertSearchAdapter.kt
#	m-consultant/src/main/res/layout/consultant_expert_search_item_view.xml
#	m-im/src/main/java/com/yidianling/uikit/business/session/activity/YDLBaseMessageActivity.java
#	m-im/src/main/java/com/yidianling/uikit/business/session/fragment/YDLMessageFragment.java
#	m-im/src/main/res_uikit/layout/im_nim_chat_confide_order_info_view.xml
#	m-im/src/main/res_uikit/layout/im_nim_ui_title_bar_bottom.xml
#	ydl-flutter-base/src/main/java/com/channel/ydl_flutter_base/plugin/YDLCommonPlugin.kt
parents f17008fd 1ed4124c
......@@ -4,6 +4,7 @@ import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import android.support.v7.app.AppCompatActivity
import com.yidianling.consultant.ExpertSearchFragment
import com.yidianling.dynamic.trendsHome.TrendsHomeFragment
import com.yidianling.home.ui.fragment.YdlHomeFragment
import com.yidianling.user.mine.MineFragment
......@@ -26,6 +27,7 @@ class TestAppActivity : AppCompatActivity() {
setContentView(R.layout.activity_test_app)
fragments.add(YdlHomeFragment())
fragments.add(ExpertSearchFragment())
fragments.add(TrendsHomeFragment().setTab("trend_tap"))
fragments.add(MineFragment())
val adapter: FragmentPagerAdapter =
......
package com.ydl.component.base;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Process;
import android.support.annotation.RequiresApi;
import com.facebook.stetho.Stetho;
import com.meituan.android.walle.WalleChannelReader;
import com.netease.nimlib.sdk.util.NIMUtil;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.smtt.sdk.QbSdk;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import com.ydl.audioim.YDLavManager;
import com.ydl.component.BuildConfig;
import com.ydl.component.MainActivity;
import com.ydl.media.audio.PlayService;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.ydl.ydlcommon.base.config.YDLConstants;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
import com.ydl.ydlcommon.utils.LogUtil;
import com.ydl.ydlcommon.utils.YdlBuryPointUtil;
import com.yidianling.course.lifeCallback.CoursePlayLifecycle;
import com.yidianling.im.config.NimApplication;
import org.jetbrains.annotations.NotNull;
import io.flutter.view.FlutterMain;
/**
* Created by haorui on 2019-09-02.
* Des:
*/
public class DemoAppLifecycles implements IAppLifecycles {
@Override
public void attachBaseContext(@NotNull Context base) {
}
@RequiresApi(api = Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void onCreate(@NotNull Application application) {
//模块初始化
moduleInit(application);
if (NIMUtil.isMainProcess(application)) {
YDLavManager.Companion.getInstances().init(application, "13b1536698f64905a1e7e5bb978ba821");
//第三方SDK初始化
initThirdServiceSDK(application);
//Flutter 初始化需要在主线程中执行
FlutterMain.startInitialization(application);
// FlutterMain.ensureInitializationComplete(application, null);
//
// FlutterEngine flutterEngine = new FlutterEngine(application);
// flutterEngine.getDartExecutor().executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault());
// YDLCommonPlugin plugin = new YDLCommonPlugin();
// flutterEngine.getLocalizationChannel().channel.setMethodCallHandler(plugin);
Intent intent = new Intent(application, PlayService.class);
application.startService(intent);
application.registerActivityLifecycleCallbacks(new CoursePlayLifecycle());
Stetho.initializeWithDefaults(application);
}
}
@Override
public void onTerminate(@NotNull Application application) {
}
private void moduleInit(Application application) {
NimApplication.getInstance().initIm(application, MainActivity.class);
}
private void initThirdServiceSDK(Application application) {
new Thread() {
@Override
public void run() {
super.run();
//设置线程优先级,不与主线程抢资源
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
//子线程中初始化X5内核,防止ANR问题
initX5(application);
if (DemoGlobalConfig.appEnv.equals(YDLConstants.ENV_PROD)) {
// YDLavManager.Companion.getInstances().init(application, "3387e9b251f3491e9221a9877e8f7830");
} else {
// YDLavManager.Companion.getInstances().init(application, "13b1536698f64905a1e7e5bb978ba821");
}
//bugly
String packageName = application.getPackageName();
String channel = WalleChannelReader.getChannel(application);
if (channel == null || channel.equals("null")) {
channel = "test";
}
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(application);
strategy.setAppChannel(channel);
String appkey = BuildConfig.DEBUG ? "630a3a5cea" : "3939e71afa";
CrashReport.initCrashReport(application, appkey, BuildConfig.DEBUG, strategy);
//umeng
String umAppkey = null;
if (BuildConfig.FLAVOR.endsWith("ydl")) {
umAppkey = "56970affe0f55a9cda001e24";
channel = "android_" + channel;
initUM(umAppkey, channel, application);
PlatformConfig.setWeixin("wx57a9d930270498c7", "17c031f02500ded3457a80e69d8e5e45");
PlatformConfig.setQQZone("1105070461", "6BvkUnk6wXJekcgR");
} else if (BuildConfig.FLAVOR.endsWith("xlzx")) {
umAppkey = "5859e1656e27a42fa400021f";
channel = "ATK_7_android_" + channel;
initUM(umAppkey, channel, application);
PlatformConfig.setWeixin("wx1c6af5a11b5f531f", "1ddb93abbb2d81e604657d38e94a5720");
PlatformConfig.setQQZone("1107931541", "8dCvxUpi525uPGTJ");
}
// 选用AUTO页面采集模式
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
MobclickAgent.setCatchUncaughtExceptions(!BuildConfig.DEBUG);
//开启友盟集成测试
UMConfigure.setLogEnabled(BuildConfig.DEBUG);
HttpConfig.Companion.getInstance().initSocketConfig(() -> {
//数据埋点初始化 (一定要放在主进程中/因为用到了umeng统计,需要放在umeng初始化后)
YdlBuryPointUtil.init(application, true);
});
//安全检测
//YDLAppProtector.init();
}
}.start();
}
private void initUM(String umAppKey, String channel, Application application) {
/**
* 初始化common库
* 参数1:上下文,不能为空
* 参数2:友盟 app key
* 参数3:友盟 channel
* 参数4:设备类型,UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子,默认为手机
* 参数5:Push推送业务的secret
*/
UMConfigure.init(application, umAppKey, channel, UMConfigure.DEVICE_TYPE_PHONE, null);
UMShareAPI.init(application, umAppKey);
}
/**
* 初始化X5内核
*
* @param application
*/
private void initX5(Application application) {
// 在调用TBS初始化、创建WebView之前进行如下配置,以开启优化方案
// HashMap map = new HashMap();
// map.put(TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER, true);
// QbSdk.initTbsSettings(map);
// if (!QbSdk.isTbsCoreInited()) {//// preinit只需要调用一次,如果已经完成了初始化,那么就直接构造view
// QbSdk.preInit(application, null);// 设置X5初始化完成的回调接口
// }
QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
@Override
public void onViewInitFinished(boolean arg0) {
//初始化完成回调
LogUtil.i("QbSdk onViewInitFinished:" + arg0);
}
@Override
public void onCoreInitFinished() {
LogUtil.i("QbSdk onCoreInitFinished");
}
};
QbSdk.initX5Environment(application, cb);
}
}
\ No newline at end of file
......@@ -5,8 +5,8 @@ ext {
ydl_app = [
appName : "心理咨询壹点灵",
applicationId: "com.cxzapp.yidianling",
versionName : "4.0.81",
versionCode : 4081,
versionName : "4.0.99",
versionCode : 4099,
]
xlzx_app = [
......@@ -42,12 +42,12 @@ ext {
ydlPublishVersion = [
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.48.10",
"m-consultant" : "0.0.58.7",
"m-fm" : "0.0.29.8",
"m-user" : "0.0.60.2",
"m-home" : "0.0.20.8",
"m-im" : "0.0.17.6",
"m-confide" : "0.0.48.22",
"m-consultant" : "0.0.59.8",
"m-fm" : "0.0.29.3",
"m-user" : "0.0.60.3",
"m-home" : "0.0.22.2",
"m-im" : "0.0.18.1",
"m-dynamic" : "0.0.7.6",
"m-muse" : "0.0.28.11",
......@@ -69,14 +69,14 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.39.23",
"ydl-platform" : "0.0.39.16",
//第二步 若干
"ydl-webview" : "0.0.38.25",
"ydl-webview" : "0.0.38.29",
"ydl-media" : "0.0.21.4",
"ydl-pay" : "0.0.18.7",
"m-audioim" : "0.0.48.2.9",
"ydl-flutter-base": "0.0.14.10",
"m-audioim" : "0.0.49.0",
"ydl-flutter-base": "0.0.14.12",
//以下 几乎不会动
"router" : "0.0.1",
......@@ -115,13 +115,13 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.39.23",
"ydl-platform" : "0.0.39.24",
//第二步 若干
"ydl-webview" : "0.0.38.25",
"ydl-webview" : "0.0.38.29",
"ydl-media" : "0.0.21.4",
"ydl-pay" : "0.0.18.7",
"m-audioim" : "0.0.48.2.9",
"m-audioim" : "0.0.49.0",
"ydl-flutter-base": "0.0.14.7",
//以下 几乎不会动
......@@ -270,7 +270,7 @@ ext {
//flutter功能组件升级===>发布ydl-flutter组件===>引用flutter相关的业务模块
"ydl-flutter-base" : "com.ydl:ydl-flutter-base:${ydlCompileVersion["ydl-flutter-base"]}", //组件化项目中的flutter base模块
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.18.6@aar", //flutter aar
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.18.9@aar", //flutter aar
"ydl-flutter-sp" : "com.ydl:ydl-flutter-sp:0.0.2@aar", //flutter 缓存 aar
//基础组件 <<--- 先发这个,发完改这里的版本号
......
......@@ -75,7 +75,7 @@ dependencies {
kapt "com.alibaba:arouter-compiler:$arouter_compiler"
api "com.alibaba:arouter-api:$arouter_api"
api ('com.ydl:ydl-av:1.2.1@aar'){
api ('com.ydl:ydl-av:1.2.4@aar'){
transitive = true
}
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.audioim">
package="com.ydl.audioim">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application>
<activity
android:name=".AudioHomeActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:screenOrientation="portrait"/>
android:name=".AudioHomeActivity"
android:launchMode="singleTask"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:screenOrientation="portrait" />
<activity
android:name="com.ydl.consultantim.ConsultantAudioHomeActivity"
android:launchMode="singleTask"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:screenOrientation="portrait" />
</application>
</manifest>
......@@ -35,15 +35,12 @@ import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.callback.CallListener
import com.ydl.ydl_av.messge_service.response.CallLocalResponse
import com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import com.ydl.ydl_av.messge_service.callback.CancelCallStatusListener
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger
......@@ -54,12 +51,13 @@ import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import io.agora.rtc.Constants
import io.agora.rtc.IRtcEngineEventHandler
import io.agora.rtm.RtmStatusCode
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
......@@ -70,7 +68,7 @@ import java.util.concurrent.TimeUnit
/**
* @author jiucheng
* @描述: 声网通话页面
* @描述: 倾诉声网通话页面
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
......@@ -183,7 +181,7 @@ class AudioHomeActivity :
override fun onWarning(warn: Int) {
super.onWarning(warn)
uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}")
uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}", callback = null)
//103:没有可用的频道资源。可能是因为服务端没法分配频道资源
//104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器
//105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的
......@@ -193,6 +191,7 @@ class AudioHomeActivity :
runOnUiThread {
when (warn) {
103, 104, 105, 106, 107 -> {
writeAgoraLog("通话挂断:网络异常(${warn})")
showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
......@@ -204,7 +203,8 @@ class AudioHomeActivity :
override fun onError(err: Int) {
super.onError(err)
uploadException("mRtcEventHandler-onError:errorCode--%${err}")
uploadException("mRtcEventHandler-onError:errorCode--%${err}", callback = null)
uploadLog()
//3:SDK 初始化失败。Agora 建议尝试以下处理方法
//7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化
//10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误
......@@ -236,8 +236,8 @@ class AudioHomeActivity :
leaveChannel()
}
123 -> {
showToast("当前用户不允许接听电话,请联系客服")
leaveChannel()
// showToast("当前用户不允许接听电话,请联系客服")
// leaveChannel()
}
else -> {
//异常关闭
......@@ -261,16 +261,31 @@ class AudioHomeActivity :
//更新:现在专家先加入频道,所以不会有等待的过程,
runOnUiThread {
writeAgoraLog("主叫加入频道成功")
//自己加入频道成功
connectSuccess()
}
}
override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onRejoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 用户声网重新加入频道成功:channel=$channel")
runOnUiThread {
//自己加入频道成功
if (!isConnectSuccess) {
writeAgoraLog("主叫重新加入频道成功")
connectSuccess()
}
}
}
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
super.onRtcStats(stats)
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
if (isConnectSuccess && null != stats?.users && stats.users == 1) {
writeAgoraLog("通话结束:用户加入了频道,但频道内只有一个人")
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
......@@ -282,6 +297,7 @@ class AudioHomeActivity :
super.onConnectionStateChanged(state, reason)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) {
writeAgoraLog("通话结束:原因(${reason})")
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
......@@ -296,15 +312,6 @@ class AudioHomeActivity :
uploadLog()
}
override fun onLastmileQuality(quality: Int) {
super.onLastmileQuality(quality)
// LogUtil.e("[agora]网络质量报告回调${quality}")
}
override fun onConnectionInterrupted() {
super.onConnectionInterrupted()
LogUtil.e("[agora]连接中断回调")
}
override fun onUserJoined(uid: Int, elapsed: Int) {
super.onUserJoined(uid, elapsed)
......@@ -314,6 +321,7 @@ class AudioHomeActivity :
override fun onUserOffline(uid: Int, elapsed: Int) {
super.onUserOffline(uid, elapsed)
LogUtil.e("[agora]远端用户$uid 离开频道回调")
writeAgoraLog("接通后通话结束:对方已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
showToast("专家已挂断")
......@@ -344,16 +352,19 @@ class AudioHomeActivity :
initSensorManager()
//页面传递数据初始化
initIntentData()
if (YDLavManager.sdkStatus != Constants.CONNECTION_STATE_CONNECTED) {
//再次登录声网,确保声网登录状态
reLoginRTM()
}
//view初始化
initView()
//设置信令的回调
setCallBack()
//点击事件
setClickEvent()
//权限申请
requestPermission()
}
private fun setWindowStatusBarColor() {
StatusBarUtils.setWindowStatusBarColor(this, R.color.audioim_color_40353535)
}
......@@ -383,14 +394,6 @@ class AudioHomeActivity :
listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID)
commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL)
writeAgoraLog()
localRemainTime = remainTime?.toInt()
handler = Handler()
vibrator = getSystemService(Service.VIBRATOR_SERVICE) as Vibrator?
}
private fun writeAgoraLog() {
val logBean = AgoraLogInfoBean(
expertHeadUrl,
expertName,
......@@ -401,18 +404,25 @@ class AudioHomeActivity :
callId,
listenId
)
val content = Gson().toJson(logBean)
writeAgoraLog("主叫方发送的邀请通话消息内容:$content", isAppend = false)
Observable.create<Any> {
try {
val content = Gson().toJson(logBean)
AudioLogUtils.writeAgoraLog(content)
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
localRemainTime = remainTime?.toInt()
handler = Handler()
vibrator = getSystemService(Service.VIBRATOR_SERVICE) as Vibrator?
}
private fun reLoginRTM() {
writeAgoraLog("RMT状态:${YDLavManager.sdkStatus},重新登录RMT")
val uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
YDLavManager.instances.login(uid) { _isSuccess, _msg ->
writeAgoraLog("登录RTM的uid=${uid}")
val result = if (_isSuccess) "RMT登录成功" else "RMT登录失败:$_msg"
writeAgoraLog(result)
}
}
private fun initView() {
tv_change_route.isEnabled = false
//水波纹view初始化
......@@ -451,13 +461,20 @@ class AudioHomeActivity :
return@setOnClickListener
}
if (isConnectSuccess) {
writeAgoraLog("已接通:主叫主动挂断")
updateExpertStatus(false, 1)
// userCloseCalling()
leaveChannel()
uploadLog()
} else {
userCloseCalling()
}
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_refuse_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
}
//免提
iv_hands_free.setOnClickListener {
......@@ -482,105 +499,6 @@ class AudioHomeActivity :
}
}
private fun setCallBack() {
//RTC 回调
YDLRTMClient.instances.setCallListener(object : CallListener {
override fun onCallRecivedByPeer(response: CallLocalResponse?) {
playWaitingMusic()
//返回给主叫:被叫已收到呼叫邀请
LogUtil.i("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}")
}
override fun onCallAccepted(response: CallLocalResponse?, msg: String?) {
//返回给主叫
LogUtil.i("[agora]${response?.calleeId}已接受呼叫邀请")
//加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道
joinChannel()
}
override fun onCallRefused(response: CallLocalResponse?, msg: String?) {
//返回给主叫
LogUtil.i("[agora]${response?.calleeId}已拒绝呼叫邀请")
ToastUtil.showToast(applicationContext, "对方已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
override fun onCallCanceled(response: CallLocalResponse?) {
//返回给主叫
LogUtil.i("[agora]主叫已取消呼叫邀请")
}
override fun onCallFailure(response: CallLocalResponse?, errorCode: Int) {
//返回给主叫
LogUtil.i("[agora]呼叫${response?.calleeId}用户失败:${response?.response}")
//专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
when (errorCode) {
//被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_OFFLINE,
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_NO_RESPONSE -> {
YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg)
}
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> {//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
}
}
}
override fun onRemoteInvitationReceived(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.i("[agora]收到来自${response?.callerId}的呼叫邀请")
}
override fun onRemoteInvitationAccepted(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.i("[agora]接受来自${response?.callerId}的呼叫成功")
}
override fun onRemoteInvitationRefused(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.i("[agora]已拒绝来自${response?.callerId}的呼叫")
}
override fun onRemoteInvitationCanceled(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.i("[agora]主叫${response?.callerId}已取消呼叫邀请")
}
override fun onRemoteInvitationFailure(response: CallRemoteResponse?, errorCode: Int) {
//返回给被叫
LogUtil.i("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}")
}
override fun onOtherMsg(error: String?) {
LogUtil.i("[agora]其它消息:${error}")
}
})
// channelManager = YDLRTMClient.instances.createChannelManager(channelId, object : ChannelListener {
// override fun onMemberCountUpdated(memberCount: Int) {
// //频道人数更新
// LogUtil.i("[agora]当前频道人数:$memberCount")
// }
//
// override fun onMessageReceived(message: RTMMesssage?, member: ChannelMember?) {
// //接到频道消息
// LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:" + message?.text)
// }
//
// override fun onMemberJoined(member: ChannelMember?) {
// //新用户加入频道
// LogUtil.i("[agora]新用户加入${member?.channelId}频道:${member?.userId}")
// }
//
// override fun onMemberLeft(member: ChannelMember?) {
// LogUtil.i("[agora]有用户离开${member?.channelId}频道:${member?.userId}")
// }
// })
}
/**
* 请求权限
*/
......@@ -626,21 +544,9 @@ class AudioHomeActivity :
)
sendDoctocrMsg = Gson().toJson(msgBean)
YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg)
writeAgoraLog("主叫发送通话邀请")
rtcCall()
// Observable.interval(0, 100, TimeUnit.MILLISECONDS)
// .subscribeOn(Schedulers.computation())
// .take(303)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
// var result = it.toFloat() / 2.5f
// progress_view.setProgress(result)
// if (result >= 100f && !iv_hang_up.isEnabled) {
// //挂断按钮可点击
// iv_hang_up.isEnabled = true
// iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up)
// }
// }, {}, {})
//开始60s等待倒计时
waitDisposable = Observable.interval(0, 100, TimeUnit.MILLISECONDS)
......@@ -657,25 +563,41 @@ class AudioHomeActivity :
}
}, {
LogUtil.d(it.message)
}, {
}) {
waittingStatus()
if (!isConnectSuccess) {
//关闭音乐
stopPlaying()
writeAgoraLog("未接通挂断:60s等待倒计时结束挂断")
//提示切换传统线路
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
YDLRTMClient.instances.cancelCall(
listenerUid,
channelId,
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
//通话结束或挂断时,上传日志文件
uploadLog()
showChooseDialog(2)
}
})
}
//双重保险:加入频道成功,通过服务端发推送给专家
noticeServerPush(true)
}
fun rtcCall() {
YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg)
}
/**
* 声网初始化
*/
......@@ -687,15 +609,13 @@ class AudioHomeActivity :
*/
voiceManage = YDLVoiceManager(this, BuildConfig.AGORA_APPID, mRtcEventHandler)
voiceManage!!.init()
voiceManage!!.getVoiceApi().enableLastmileTest()
//默认听筒模式
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
}
/**
* 声网加入频道
*/
private fun joinChannel() {
fun joinChannel() {
writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId")
voiceManage!!.getVoiceApi().joinChannel(
token!!,
channelId!!,
......@@ -710,11 +630,25 @@ class AudioHomeActivity :
*
*/
private fun userCloseCalling() {
writeAgoraLog("未接听时:主叫主动挂断,取消呼叫")
LogUtil.e("未接听挂断")
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
YDLRTMClient.instances.cancelCall(
listenerUid,
channelId,
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$errorMsg($errorCode),再次挂断")
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
//通话结束或挂断时,上传日志文件
uploadLog()
handler!!.postDelayed({
LogUtil.e("离开频道")
leaveChannel()
}, 100)
}
......@@ -756,10 +690,6 @@ class AudioHomeActivity :
val dialog =
AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() {
//是手动切换且连接成功
if (type == 1 && isConnectSuccess) {
uploadException("", "zhu")
}
switchAXB()
}
......@@ -778,7 +708,16 @@ class AudioHomeActivity :
* 切换成axb路线请求
*/
private fun switchAXB() {
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
if (isConnectSuccess) {
uploadException("", "zhu", "108", object : YDLavManager.UploadExceptionCallback {
override fun onSuccess() {
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
}
})
} else {
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
}
}
/**
......@@ -796,7 +735,18 @@ class AudioHomeActivity :
} else {
//未连接成功,切换axb时:需发送消息通知专家端用户已挂断
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid, channelId)
//发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(
listenerUid,
channelId,
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() {
}
})
leaveChannel()
}
}
......@@ -880,7 +830,7 @@ class AudioHomeActivity :
/**
* 播放等待音频
*/
private fun playWaitingMusic() {
fun playWaitingMusic() {
if (mPlayer == null) {
mPlayer = AudioPlayer(this)
}
......@@ -901,6 +851,7 @@ class AudioHomeActivity :
mPlayer!!.setDataSource(R.raw.audioim_hand_down_music)
mPlayer!!.switchPlayType(iv_hands_free.isSelected)
mPlayer!!.setCompletionListener(MediaPlayer.OnCompletionListener {
LogUtil.e("播放结束")
//通话剩余时间不足60s时,默认
if (localRemainTime!! < 60 && !TextUtils.isEmpty(commentUrl)) {
val h5Params = H5Params(commentUrl!!, "评价")
......@@ -933,6 +884,10 @@ class AudioHomeActivity :
//通知服务端,此次通话已经接通,服务端开始订单
updateExpertStatus(false, 0)
//是否开启外放
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
iv_hands_free.isSelected = false
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free_unuse)
// if (waitDisposable != null) {
// waitDisposable!!.dispose()
// }
......@@ -1052,12 +1007,13 @@ class AudioHomeActivity :
/**
* 声网离开频道
*/
private fun leaveChannel() {
fun leaveChannel() {
if (!isLeavelChannel) {
isLeavelChannel = true
//刷新h5页面
EventBus.getDefault().post(RefreshWebEvent(false))
stopPlaying()
LogUtil.e("播放结束音频")
//播放结束音频
playFinishMusic()
}
......@@ -1070,6 +1026,13 @@ class AudioHomeActivity :
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_page_visit",
"",
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
}
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
......@@ -1129,7 +1092,7 @@ class AudioHomeActivity :
}
private fun uploadLog() {
fun uploadLog() {
if (!hasUpLoadLog) {
hasUpLoadLog = true
LogHelper.getInstance().uploadLog(false)
......@@ -1141,13 +1104,26 @@ class AudioHomeActivity :
* 上传错误日志
* zhu 洪平要的,判别是移动端主动调的还是声网返的
*/
private fun uploadException(message: String, zhu: String = "") {
private fun uploadException(
message: String,
zhu: String = "",
eventType: String = "99",
callback: YDLavManager.UploadExceptionCallback?
) {
var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String =
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message)
var connectException = ConnectExceptionCommand(time + zhu, "2", "99", payLoad)
getPresenter().connectException(connectException)
var connectException = ConnectExceptionCommand(time + zhu, "2", eventType, payLoad)
YDLavManager.instances.uploadException(connectException, callback)
}
fun writeAgoraLog(content: String, isAppend: Boolean = true) {
try {
AudioLogUtils.writeAgoraLog(content, "confide", isAppend)
} catch (e: Exception) {
}
}
......@@ -1157,6 +1133,9 @@ class AudioHomeActivity :
override fun onDestroy() {
super.onDestroy()
if (isConnectSuccess) {
uploadException("", "zhu", "108", callback = null)
}
if (handler != null) {
handler = null
}
......@@ -1191,6 +1170,7 @@ class AudioHomeActivity :
if (mPlayer != null) {
mPlayer!!.clear()
mPlayer = null
}
}
......
......@@ -9,13 +9,22 @@ import com.ydl.ydl_av.messge_service.bean.RTMMesssage
import com.ydl.ydl_av.messge_service.callback.InitListener
import com.ydl.ydl_av.messge_service.callback.LoginCallback
import com.ydl.ydl_av.messge_service.request.LoginParam
import com.ydl.ydl_av.messge_service.response.CallLocalResponse
import com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.user.api.event.UserLoginEvent
import com.yidianling.user.api.event.UserLogoutEvent
import de.greenrobot.event.EventBus
import com.yidianling.common.tools.ToastUtil
import com.yidianling.user.api.service.IUserService
import io.agora.rtm.RtmStatusCode
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* @author harvie
......@@ -25,8 +34,12 @@ import io.reactivex.schedulers.Schedulers
class YDLavManager {
companion object{
val instances : YDLavManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
companion object {
val FILE_NAME = "consult"
//当前sdk的登录状态
var sdkStatus = -1
val instances: YDLavManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
YDLavManager()
}
}
......@@ -45,10 +58,157 @@ class YDLavManager {
public fun onEvent(event: UserLogoutEvent) {
instances.logout()
}
fun init(context: Context, appId: String) {
YDLRTMClient.instances.init(context, appId, listener)
//设置回调
setCallback()
val uid = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
if (!TextUtils.isEmpty(uid) && !TextUtils.equals("0", uid)) {
//不延时,可能会导致请求api报 network not unablibale
Handler().postDelayed({
login(uid)
}, 300)
}
}
private fun setCallback() {
YDLRTMClient.instances.setCallListener(object : CallListener {
override fun onCallRecivedByPeer(response: CallLocalResponse?) {
//返回给主叫:被叫已收到呼叫邀请
LogUtil.e("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}")
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.playWaitingMusic()
}
}
}
override fun onCallAccepted(response: CallLocalResponse?, msg: String?) {
//返回给主叫
LogUtil.e("[agora]${response?.calleeId}已接收呼叫邀请")
//加入声网频道时机修改:用户收到专家接受邀请的回调后再加入声网频道
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.joinChannel()
}
}
}
override fun onCallRefused(response: CallLocalResponse?, msg: String?) {
//返回给主叫
LogUtil.e("[agora]${response?.calleeId}已拒绝呼叫邀请")
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
ToastUtil.toastShort("对方已挂断")
act.writeAgoraLog("被叫拒绝了通话邀请")
//通话结束或挂断时,上传日志文件
act.uploadLog()
act.leaveChannel()
}
}
}
override fun onCallCanceled(response: CallLocalResponse?) {
//返回给主叫
LogUtil.e("[agora]主叫已取消呼叫邀请")
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.writeAgoraLog("主叫呼叫取消:超时或主动取消")
}
}
}
override fun onCallFailure(response: CallLocalResponse?, errorCode: Int) {
//返回给主叫
LogUtil.e("[agora]呼叫${response?.calleeId}用户失败:${response?.response}")
val act = ActivityManager.getInstance().getTopTaskActivity()
//专家离线或者30 秒后仍未收到专家响应,重新再邀请一次
when (errorCode) {
//被叫不在线 呼叫邀请发出 30 秒后被叫仍未 ACK 响应呼叫邀请
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_OFFLINE,
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_PEER_NO_RESPONSE -> {
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.rtcCall()
}
}
}
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> {//呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
if (act is AudioHomeActivity) {
act.runOnUiThread {
act.writeAgoraLog("呼叫失败:${errorCode}")
// //通话结束或挂断时,上传日志文件
// act.uploadLog()
// act.leaveChannel()
}
}
}
}
}
override fun onRemoteInvitationReceived(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.e("[agora]收到来自${response?.callerId}的呼叫邀请")
receivedCall(response?.content, "来自RTM")
}
override fun onRemoteInvitationAccepted(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.e("[agora]接受来自${response?.callerId}的呼叫成功")
}
override fun onRemoteInvitationRefused(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.e("[agora]已拒绝来自${response?.callerId}的呼叫")
}
override fun onRemoteInvitationCanceled(response: CallRemoteResponse?) {
//返回给被叫
LogUtil.e("[agora]主叫${response?.callerId}已取消呼叫邀请")
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME)
closePage()
}
override fun onRemoteInvitationFailure(response: CallRemoteResponse?, errorCode: Int) {
//返回给被叫
LogUtil.e("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}")
if (errorCode == RtmStatusCode.RemoteInvitationError.REMOTE_INVITATION_ERR_INVITATION_EXPIRE) {//呼叫邀请过期
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME)
} else {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:错误原因(${errorCode})", FILE_NAME)
}
//关闭页面
closePage()
}
override fun onOtherMsg(error: String?) {
LogUtil.e("[agora]其它消息:${error}")
}
})
}
fun login(userId: String?) {
login(userId) { _, _ ->
}
}
@SuppressLint("CheckResult")
fun login(userId:String?){
if (TextUtils.isEmpty(userId) || userId?:"0" <= "0"){
fun login(userId: String?, event: (isSuccess: Boolean, msg: String?) -> Unit) {
if (TextUtils.isEmpty(userId) || userId ?: "0" <= "0") {
//如果uid为空或小于等于0 ,则不进行登录,因为uid为0也会登录成功,会导致后面uid正确时无法登录
LogUtil.e("[agora]login-uid:$userId")
return
......@@ -56,30 +216,92 @@ class YDLavManager {
//登录实时消息
//获取token
AudioApiRequestUtil.getAgoraToken()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if ("200".equals(it.code)){
YDLRTMClient.instances.login(LoginParam(userId,it.data.token),object : LoginCallback {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if ("200".equals(it.code)) {
LogUtil.e("[agora]登录av的login-uid:$userId")
YDLRTMClient.instances.login(LoginParam(userId, it.data.token),
object : LoginCallback {
override fun onSuccess() {
//登陆成功,发起呼叫
LogUtil.d("[agora]实时消息登录成功")
LogUtil.e("[agora]实时消息登录成功")
event(true, "")
}
override fun onFailure(msg: String?) {
LogUtil.d("[agora]实时消息登录失败:$msg")
LogUtil.e("[agora]实时消息登录失败:$msg")
event(false, msg)
}
})
}else{
LogUtil.e("声网token获取失败uid:"+userId+" error:"+it.msg)
LogHelper.getInstance().writeLogSync("声网token获取失败uid:"+userId+" error:"+it.msg)
} else {
LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg)
LogHelper.getInstance()
.writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg)
}
}, {
LogUtil.e("声网token获取异常uid:" + userId + " error:" + it.message)
})
}
/**
* 收到邀请
*/
@SuppressLint("CheckResult")
fun receivedCall(content: String?, from: String = "") {
if (!TextUtils.isEmpty(content)) {
//如果已经接听了用户电话 再有电话进来 是不能接听的
if (!activityIsExists(ConsultantAudioHomeActivity::class.java) && !activityIsExists(
AudioHomeActivity::class.java
)
) {
//延时启动通话界面,防止刚打开就被main遮挡
Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
LogUtil.e("[agora]启动通话界面")
//邀请加入频道消息,跳转通话界面
ARouter.getInstance().build("/av/ConsultantAudioHomeActivity")
.withString("param", content)
.navigation()
AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
}
},{
LogUtil.e("声网token获取异常uid:"+userId+" error:"+it.message)
})
} else {
LogUtil.d("[agora]收到声网邀请,但界面实例已存在")
}
} else {
LogUtil.d("[agora]收到声网邀请,但response==null")
}
}
private fun activityIsExists(cls: Class<*>): Boolean {
for (activity in ActivityManager.getInstance().getActivitys()) {
if (activity.javaClass == cls) {
return true
}
}
return false
}
/**
* 关闭通话界面
*/
fun closePage() {
var act = ActivityManager.getInstance().getTopTaskActivity()
if (act is ConsultantAudioHomeActivity) {
//未接通时,收到呼叫进程失败关闭页面,已接通无需关闭
if (act.status == ConsultantAudioHomeActivity.STATUS_NOT_ANSWERED) {
act.close(ConsultantAudioHomeActivity.RESULT_USER_CANCEL, "")
}
}
}
/**
* 退出登录
*/
......@@ -99,6 +321,30 @@ class YDLavManager {
}
/**
* RTM登录异常,上传错误日志 msg
* 声网出现异常,上传错误日志 connectException
*/
@SuppressLint("CheckResult")
fun uploadException(connectException: ConnectExceptionCommand, callback: UploadExceptionCallback?) {
AudioApiRequestUtil.connectException(connectException)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
callback?.onSuccess()
}, {
LogUtil.e("agora", "声网上传异常与错误日志接口调用失败:" + it.message)
})
}
/**
* 上传异常错误回调
*/
interface UploadExceptionCallback {
fun onSuccess()
}
/**
* 实时消息全局监听
*/
private val listener = object :InitListener{
......
......@@ -71,11 +71,6 @@ interface IAudioHomeActivityContract {
*/
// fun connectFinish(param: ConnectFinishCommand)
/**
* 通话异常
*/
fun connectException(param: ConnectExceptionCommand)
/**
* 通知服务端发送推送
......
......@@ -4,9 +4,12 @@ import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraTokenResponse
import com.ydl.audioim.bean.ConnectBean
import com.ydl.audioim.http.command.*
import com.ydl.consultantim.bean.ListenTokenBean
import com.ydl.consultantim.command.ListenTokenCmd
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlnet.YDLHttpUtils
import io.reactivex.Observable
import okhttp3.MediaType
......@@ -85,5 +88,12 @@ class AudioApiRequestUtil {
fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>>{
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).getAgoraToken()
}
/**
* 获取声网登录token
*/
fun listenToken(cmd: ListenTokenCmd): Observable<BaseResponse<ListenTokenBean>>{
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).listenToken(NetworkParamsUtils.getMaps(cmd))
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.ydl.audioim.http
import com.ydl.audioim.bean.AgoraTokenResponse
import com.ydl.audioim.bean.ConnectBean
import com.ydl.consultantim.bean.ListenTokenBean
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
......@@ -61,4 +62,11 @@ interface AudioNetAPi {
@GET("im/getAgoraToken")
fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>>
//获取token
@FormUrlEncoded
@POST("listen/token")
fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>>
}
\ No newline at end of file
......@@ -10,7 +10,8 @@ data class ConnectExceptionCommand(
var noticeId: String, // 秒级
var productId: String, // 2
var eventType: String, // 99
var payload: PayLoad
var payload: PayLoad,
var callStatus: Int=-1//用于判断咨询声网时是哪方取消的:1 主叫取消 2被叫拒绝 (超时未接听算主叫取消)
) : BaseCommand()
data class PayLoad(
......
......@@ -66,20 +66,6 @@ class AudioHomePresenterImpl : BasePresenter<IAudioHomeActivityContract.View, IA
// })
// }
@SuppressLint("CheckResult")
override fun connectException(param: ConnectExceptionCommand) {
mModel.connectException(param)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe {
}
.doAfterTerminate {
}
.subscribe({
}, { e ->
LogUtil.e(e.message)
})
}
/**
* 登录声网
......
......@@ -29,10 +29,10 @@ class AudioLogUtils {
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeAgoraLog(content: String) {
fun writeAgoraLog(content: String, fileName: String, isAppend: Boolean = true) {
Observable.create<Any> {
try {
writeLog(content)
writeLog(content, fileName, isAppend)
if (BuildConfig.DEBUG) {
LogUtil.d("writeLog_complete")
}
......@@ -42,28 +42,30 @@ class AudioLogUtils {
.subscribe()
}
private fun writeLog(content: String) {
private fun writeLog(content: String, fileName: String, isAppend: Boolean) {
try {
val folder = getLogFolder()
val file = File(folder, "AgoraInfoLog")
val file = File(folder, fileName)
if (!file.exists() || !file.isFile) {
file.createNewFile()
}
val fileWriter = FileWriter(file, true)
val writer = BufferedWriter(fileWriter)
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("UserUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
writer.write("AgoraLog:$content")
writer.newLine()
writer.write("--------")
if (!isAppend) {
writer.write("----------------")
writer.newLine()
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("ExpertUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
}
writer.write(content)
writer.newLine()
writer.flush()
writer.close()
......
package com.ydl.consultantim
import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Paint
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.net.Uri
import android.os.PowerManager
import android.provider.Settings
import android.text.TextUtils
import android.view.View
import android.view.animation.AccelerateInterpolator
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson
import com.tbruyelle.rxpermissions2.RxPermissions
import com.ydl.audioim.BuildConfig
import com.ydl.audioim.R
import com.ydl.audioim.YDLavManager
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.DateUtils
import com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
import com.ydl.consultantim.event.AudioHomeEvent
import com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl
import com.ydl.consultantim.utils.ConsultantAudioUtils
import com.ydl.consultantim.utils.VibratorUtil
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.ActivityManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.Utils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import io.agora.rtc.Constants
import io.agora.rtc.IRtcEngineEventHandler
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.audioim_cativity_consultant_audio_home.*
import java.util.concurrent.TimeUnit
/**
* @author jiucheng
* @描述: 咨询声网通话页面
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
*/
@Route(path = "/av/ConsultantAudioHomeActivity")
class ConsultantAudioHomeActivity :
BaseMvpActivity<IConsultantAudioHomeActivityContract.View, IConsultantAudioHomeActivityContract.Presenter>(),
IConsultantAudioHomeActivityContract.View,
SensorEventListener {
//语音管理类
private var voiceManage: YDLVoiceManager? = null
//音视频数据
private var mAudioMessageBean: AudioMessageBean? = null
//音频播放
private var mPlayer: AudioPlayer? = null
//当前状态 0.未接听 1.已接听
public var status = STATUS_NOT_ANSWERED
//电源管理对象
private var localPowerManager: PowerManager? = null
//电源锁
private var localWakeLock: PowerManager.WakeLock? = null
private var sensorManager: SensorManager? = null
/**
* 通话开始时间(接通)
*/
private var callStartTime: Long? = null
/**
* 本次倾述倒计时
*/
private var totalDisposable: Disposable? = null
private var connectingStatusDisposable: Disposable? = null
//频道管理器
// private var channelManager: ChannelManager? = null
//频道token
private var channelToken: String? = null
private var hasUpLoadLog = false
private var callStatus: Int = -1
/**
* 是否连接成功
*/
private var isConnectSuccess: Boolean = false
/**
* 事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
private val mRtcEventHandler = object : IYDLVoiceEventHandler() {
/**
* 远端用户静音回调
* @param uid 用户 ID
* @param muted 该用户是否静音:true: 该用户已静音音频 false: 该用户已取消音频静音
*/
override fun onUserMuteAudio(uid: Int, muted: Boolean) {
runOnUiThread {
showToast("对方静音了,提醒他打开!")
}
}
override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onJoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 加入频道回调")
writeAgoraLog("被叫加入声网($channel)频道成功")
runOnUiThread {
// 加入频道后再通知用户已接受
YDLRTMClient.instances.acceptCall(mAudioMessageBean?.channelId)
tv_toast.visibility = View.VISIBLE
tv_toast.text = "连接中..."
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
//5s倒计时,5s后还是连接中,则直接关闭页面
connectingStatusWaitingTimeCount()
tv_tips.visibility = View.INVISIBLE
}
}
/**
* 重新加入频道回调
*/
override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onRejoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 重新加入频道回调")
writeAgoraLog("被叫重新加入声网频道($channel)成功")
runOnUiThread {
if (!isConnectSuccess) {
tv_toast.visibility = View.VISIBLE
tv_toast.text = "连接中..."
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
//5s倒计时,5s后还是连接中,则直接关闭页面
connectingStatusWaitingTimeCount()
}
}
}
override fun onUserJoined(uid: Int, elapsed: Int) {
super.onUserJoined(uid, elapsed)
LogUtil.e("[agora]远端用户加入频道回调")
writeAgoraLog("主叫加入声网频道成功")
//另一方加入频道成功
runOnUiThread {
isConnectSuccess = true
//通话开始,刷新ui开始倒计时
updateStartUi()
status = STATUS_ANSWERED
//接通开始回调
callStartTime = System.currentTimeMillis()
}
}
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
}
override fun onConnectionStateChanged(state: Int, reason: Int) {
super.onConnectionStateChanged(state, reason)
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) {
showToast("对方已挂断")
writeAgoraLog("通话挂断:网络连接被服务器中止")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
}
}
/**
* 离开频道回调(自己)
*
*/
override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) {
super.onLeaveChannel(stats)
LogUtil.e("[agora]自己离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
runOnUiThread {
//通知php 通话已结束
close(RESULT_ANSWERED_CODE, "")
}
}
/**
* 主播离开频道回调
* 提示有主播离开了频道(或掉线)。
* SDK 判断用户离开频道(或掉线)的依据是超时:在一定时间内(20 秒)没有收到对方的任何数据包,判定为对方掉线。
* 在网络较差的情况下,可能会有误报。建议可靠的掉线检测应该由信令来做
* @param uid 主播 ID
* @param reason 离线原因:
* USER_OFFLINE_QUIT(0):用户主动离开
* USER_OFFLINE_DROPPED(1):因过长时间收不到对方数据包,超时掉线。注意:由于 SDK 使用的是不可靠通道,也有可能对方主动离开本方没收到对方离开消息而误判为超时掉线
* USER_OFFLINE_BECOME_AUDIENCE(2):用户身份从主播切换为观众(直播模式下)
*/
override fun onUserOffline(uid: Int, elapsed: Int) {
super.onUserOffline(uid, elapsed)
LogUtil.e("[agora]$uid 主播离开频道回调")
runOnUiThread {
showToast("对方已挂断")
writeAgoraLog("通话接通后挂断:主叫离开频道")
//通话结束或挂断时,上传日志文件
uploadLog()
if (null != totalDisposable) {
totalDisposable!!.dispose()
}
//通知php 通话已结束
close(RESULT_ANSWERED_CODE, "")
}
}
/**
* 网络质量报告回调
* 报告本地用户的网络质量。当你调用 enableLastmileTest 之后,该回调函数每 2 秒触发一次
*/
override fun onLastmileQuality(quality: Int) {
super.onLastmileQuality(quality)
}
override fun onWarning(warn: Int) {
super.onWarning(warn)
// 过滤1031 录制声音模糊
if (warn != 1031) {
uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}")
}
LogUtil.e("[agora]发生警告回调=$warn")
//103:没有可用的频道资源。可能是因为服务端没法分配频道资源
//104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器
//105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的
//106:打开频道超时。查找到指定频道后,SDK 接着打开该频道,超时一般是因为网络太差,连接不到服务器
//107:打开频道请求被服务器拒绝。服务器可能没有办法处理该请求或该请求是非法的
runOnUiThread {
when (warn) {
103, 104, 105, 106, 107 -> {
writeAgoraLog("通话挂断:网络异常($warn)")
showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "[agora]专家网络较差")
}
}
}
}
override fun onError(err: Int) {
super.onError(err)
uploadException("mRtcEventHandler-onError:errorCode--%${err}")
LogUtil.e("[agora] 发生错误回调 =$err")
//3:SDK 初始化失败。Agora 建议尝试以下处理方法
//7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化
//10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误
//17:加入频道被拒绝。一般有以下原因:
//用户已进入频道,再次调用加入频道的 API,例如 joinChannel,会返回此错误。停止调用该方法即可。
//用户在做 Echo 测试时尝试加入频道。等待 Echo test 结束后再加入频道即可。
//101:不是有效的 APP ID。请更换有效的 APP ID 重新加入频道
//102:不是有效的 频道名。请更换有效的频道名重新加入频道
//109:当前使用的 Token 过期,不再有效
//110:生成的 Token 无效
//123:此用户被服务器禁止
runOnUiThread {
when (err) {
3, 7, 109, 110 -> {
showToast("请退出应用,重新打开")
close(RESULT_NOT_ANSWERED_CODE, "咨询师已挂断")
}
10, 17 -> {
showToast("当前网络较差,请更换网络")
close(RESULT_NOT_ANSWERED_CODE, "专家网络较差")
}
101 -> {
showToast("安装包有问题,请联系技术")
close(RESULT_NOT_ANSWERED_CODE, "安装包有问题,请联系技术")
}
102 -> {
showToast("频道错误,请联系技术")
close(RESULT_NOT_ANSWERED_CODE, "频道错误,请联系技术")
}
123 -> {
// showToast("对方不允许接听电话,请联系客服")
// close(RESULT_NOT_ANSWERED_CODE, "该专家不允许接听电话,请联系客服")
}
else -> {
}
}
}
}
}
override fun createPresenter(): IConsultantAudioHomeActivityContract.Presenter {
return ConsultantAudioHomePresenterImpl()
}
override fun layoutResId(): Int {
return R.layout.audioim_cativity_consultant_audio_home
}
companion object {
const val PARAM: String = "param"
//0.未接听 1.已接听
const val STATUS_NOT_ANSWERED = 0
const val STATUS_ANSWERED = 1
//666.未接听,直接挂断 667.已接听,正常挂断 668:未接听,用户端取消了
const val RESULT_NOT_ANSWERED_CODE = 666
const val RESULT_ANSWERED_CODE = 667
const val RESULT_USER_CANCEL = 668
}
override fun initDataAndEvent() {
EventBus.getDefault().register(this)
//状态栏颜色
setWindowStatusBarColor()
//点亮屏幕 并解锁
ConsultantAudioUtils.wakeUpAndUnlock(this)
//页面传递数据初始化
getParam()
//初始化传感器
initSensorManager()
initUser()
initData()
//获取声网频道号
getChannelToken()
}
private fun setWindowStatusBarColor() {
StatusBarUtils.setWindowStatusBarColor(this, R.color.audioim_color_40353535)
}
private fun getParam() {
if (null == intent) {
close(RESULT_NOT_ANSWERED_CODE, "通话异常")
return
}
if (null != intent.getStringExtra(PARAM)) {
val json = intent.getStringExtra(PARAM)
if (!TextUtils.isEmpty(json)) {
writeAgoraLog("收到邀请通话消息内容:$json")
mAudioMessageBean = Gson().fromJson(json, AudioMessageBean::class.java)
if (YDLavManager.sdkStatus != Constants.CONNECTION_STATE_CONNECTED) {
writeAgoraLog("RMT状态:${YDLavManager.sdkStatus},重新登录RMT")
val uid =
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
YDLavManager.instances.login(uid) { _isSuccess, _msg ->
writeAgoraLog("登录RTM的uid=${uid}")
val result = if (_isSuccess) "RMT登录成功" else "RMT登录失败:$_msg"
writeAgoraLog(result)
}
} else {
writeAgoraLog("当前RMT状态:${YDLavManager.sdkStatus}")
}
}
} else {
close(RESULT_NOT_ANSWERED_CODE, "通话异常")
return
}
}
@SuppressLint("InvalidWakeLockTag")
private fun initSensorManager() {
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager?
localPowerManager = getSystemService(POWER_SERVICE) as PowerManager?
localWakeLock = localPowerManager!!.newWakeLock(
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"yidianling"
)
}
/**
* 初始化界面用户信息
*/
private fun initUser() {
var userName = "咨询用户"
if (null != mAudioMessageBean) {
if (!TextUtils.isEmpty(mAudioMessageBean!!.userName)) {
userName = mAudioMessageBean!!.userName!!
}
if (!TextUtils.isEmpty(mAudioMessageBean!!.userIcon)) {
var option = SimpleImageOpConfiger()
option.errorPic = R.drawable.audioim_head_place_hold_pic
option.loadingPic = R.drawable.audioim_head_place_hold_pic
option.transform = 0
YDLImageCacheManager.showImage(this, mAudioMessageBean!!.userIcon, iv_head, option)
} else {
iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic)
}
} else {
iv_head.setBackgroundResource(R.drawable.audioim_head_place_hold_pic)
}
tv_name.text = userName
}
private fun initData() {
wave_view.setDuration(6000)
wave_view.setStyle(Paint.Style.STROKE)
wave_view.setSpeed(1000)
wave_view.setColor(Color.WHITE)
wave_view.setInitialRadius(140f)
wave_view.setInterpolator(AccelerateInterpolator(1.2f))
//启动背景动画
wave_view.start()
mPlayer = AudioPlayer(this)
mPlayer!!.setDataSource(R.raw.audioim_call_music)
mPlayer!!.start(isLooping = true, isSetOnCompletionListener = false)
//间接性震动手机
VibratorUtil.vibrate(AudioHomeActivity@ this, longArrayOf(1000, 1000, 1000, 1000), true)
}
/**
* //获取声网频道号
*/
private fun getChannelToken() {
writeAgoraLog("获取声网token")
//获取频道token
mPresenter.getChannelToken(mAudioMessageBean, false)
}
override fun channelTokenResponse(token: String?, needJoinChannel: Boolean) {
if (TextUtils.isEmpty(token)) {
LogUtil.e("[agora]token not null")
showToast("通话频道不存在")
finish()
return
}
this.channelToken = token
writeAgoraLog("返回的声网token=$channelToken")
if (needJoinChannel) {
//权限申请
requestPermission()
}
}
/**
* 更新ui
*/
private fun updateUI() {
tv_toast.visibility = View.VISIBLE
tv_toast.text = "正在建立连接..."
rl_call.visibility = View.GONE
rl_hands_free.visibility = View.VISIBLE
}
//申请音频权限
@SuppressLint("CheckResult")
private fun requestPermission() {
val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO)
.subscribe { permission ->
when {
//权限已申请 进行初始化操作
permission.granted -> init()
//权限为申请 重新申请
permission.shouldShowRequestPermissionRationale -> requestPermission()
//跳转设置界面
else -> {
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
finish()
}
}
}
}
private fun init() {
//初始化语音
initializeAgoraEngine()
joinChannel()
}
/**
* 语音通话 初始化
*/
private fun initializeAgoraEngine() {
/**
* 创建一个实例
* param appId 应用id
* param mRtcEventHandler 事件回调(SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/
voiceManage = YDLVoiceManager(this, BuildConfig.AGORA_APPID, mRtcEventHandler)
voiceManage!!.init()
}
/**
* 加入频道
*/
private fun joinChannel() {
val account = YdlCommonRouterManager.getYdlCommonRoute().getUid()
if (!TextUtils.isEmpty(mAudioMessageBean?.channelId)) {
LogUtil.e("[agora] joinChannel:$account")
voiceManage?.getVoiceApi()?.joinChannel(
channelToken
?: "", mAudioMessageBean!!.channelId!!, "Extra Optional Data", account
)
}
}
override fun executeFinish() {
//通话结束或挂断时,上传日志文件
uploadLog()
showToast("对方已挂断")
close(RESULT_ANSWERED_CODE, "")
}
/**
* 通话开始后更新ui
*/
private fun updateStartUi() {
tv_toast.text = "已接通"
tv_toast.postDelayed({ tv_toast.visibility = View.GONE }, 500)
rl_remain_time.visibility = View.VISIBLE
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
tv_remain_time.text = DateUtils.formatTime(it.toString())
}, {
//通话结束或挂断时,上传日志文件
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "对方异常")
})
}
/**
* 通话结束
*/
private fun callFinish() {
status = STATUS_NOT_ANSWERED
}
private fun showStopService() {
if (status == STATUS_NOT_ANSWERED) {
writeAgoraLog("通话未接通挂断:主动挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
//当未接听 直接挂断 要发送给老师一条消息
close(RESULT_NOT_ANSWERED_CODE, "用户已挂断")
} else if (status == STATUS_ANSWERED) {
writeAgoraLog("通话接通后挂断:专家主动挂断")
//正常接听 挂断电话 需要重置信令管理类状态
close(RESULT_ANSWERED_CODE, "")
}
}
override fun listenStatusPushResponse() {
}
/**
* 挂断
*/
fun hangUpClick(view: View) {
if (Utils.isFastClick()) {
//防止连击
return
}
showStopService()
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_refuse_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
}
/**
* 接听
*/
fun onCall(view: View) {
if (Utils.isFastClick()) {
//防止连击
return
}
//调用接口判断邀请专家的用户当前是否在频道内,如果在,则专家加入频道,如果不在,则提示用户已挂断
//更改逻辑:现在是专家先进频道,这个接口暂时只作为参考
// presenter.userIsInChannel(mAudioMessageBean?.channelId ?: "", mAudioMessageBean?.userId
// ?: "")
executeCall(true)
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_answer_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
}
/**
* 执行接听操作
*/
override fun executeCall(canExcute: Boolean) {
stopPlaying()
//停止震动
VibratorUtil.StopVibrate(this)
if (!canExcute) {
showToast("对方已挂断")
finish()
} else {
if (null != mAudioMessageBean) {
updateUI()
//专家先加入频道,然后再接受用户邀请,保证专家比用户先加入频道
if (!TextUtils.isEmpty(channelToken)) {
//权限申请完成后加入频道
requestPermission()
} else {
//获取频道token
mPresenter.getChannelToken(mAudioMessageBean)
}
}
}
}
/**
* 打开扬声器 true:开启 false:关闭(听筒)
*/
fun onSwitchSpeakerphoneClicked(view: View) {
view.isSelected = !view.isSelected
if (view.isSelected) {
//扬声器模式
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free)
} else {
//听筒模式
iv_hands_free.setImageResource(R.drawable.audioim_img_hands_free_unuse)
}
LogUtil.e("http---------------isSelected=" + !view.isSelected)
if (null == voiceManage || null == voiceManage!!.getVoiceApi()) {
return
}
voiceManage!!.getVoiceApi().setEnableSpeakerphone(view.isSelected)
}
override fun onResume() {
super.onResume()
sensorManager!!.registerListener(
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_page_visit",
"",
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
}
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
}
override fun onSensorChanged(event: SensorEvent?) {
val values = event!!.values
when (event.sensor.type) {
Sensor.TYPE_PROXIMITY -> {
if (values[0] == 0.0f) {
//贴近手机
if (!localWakeLock!!.isHeld) {
localWakeLock!!.acquire()
}
} else {
//离开手机
//唤醒设备
if (localWakeLock!!.isHeld) {
localWakeLock!!.release()
}
}
}
}
}
/**
* 显示自定义弹窗
*/
private fun showToast(msg: String?) {
runOnUiThread {
ToastHelper.show(msg ?: "")
}
}
//关闭本页面
fun close(code: Int, msg: String) {
runOnUiThread {
LogUtil.e("[agora]close(code:$code,msg:$msg)")
stopMusic()
//播放结束音频
playFinishMusic()
if (code == RESULT_ANSWERED_CODE) {
//已接听,正常挂断
//离开频道
leaveChannel()
} else if (code == RESULT_NOT_ANSWERED_CODE) {
callStatus = 2
uploadException("被叫拒绝", zhu = "")
//未接听,直接挂断 发送消息
YDLRTMClient.instances.refuseCall(mAudioMessageBean?.channelId)
} else if (code == RESULT_USER_CANCEL) {
callStatus = 1
uploadException("主叫取消", zhu = "")
showToast("对方已挂断")
}
finish()
}
}
private fun stopMusic() {
//停止播放音乐
stopPlaying()
//停止震动
VibratorUtil.StopVibrate(AudioHomeActivity@ this)
}
/**
* 停止播放
*/
private fun stopPlaying() {
if (mPlayer != null) {
mPlayer!!.pause()
}
}
/**
* 播放结束音频
*/
private fun playFinishMusic() {
if (mPlayer == null) {
mPlayer = AudioPlayer(this)
}
mPlayer!!.setDataSource(R.raw.audioim_hand_down_music)
// mPlayer!!.switchPlayType(true)
mPlayer!!.start(isLooping = false, isSetOnCompletionListener = false)
}
fun onEventMainThread(event: AudioHomeEvent) {
stopMusic()
}
/**
*连接中状态倒计时:5s后如果还是处于连接中,则直接退出当前页面
*/
private fun connectingStatusWaitingTimeCount() {
if (connectingStatusDisposable == null) {
connectingStatusDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.take(6)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {}, {
if (!isConnectSuccess) {
writeAgoraLog("通话未接通挂断:连接中的状态超过5s自动挂断")
showToast( "用户已挂断")
close(RESULT_NOT_ANSWERED_CODE, "")
}
})
}
}
/**
* 离开频道
*/
private fun leaveChannel() {
uploadException("", "zhu", "108")
if (totalDisposable != null) {
totalDisposable!!.dispose()
}
if (connectingStatusDisposable != null) {
connectingStatusDisposable!!.dispose()
}
if (null != voiceManage && null != voiceManage!!.getVoiceApi()) {
voiceManage!!.getVoiceApi().leaveChannel()
voiceManage!!.getVoiceApi().destroy()
voiceManage = null
}
if (mPlayer != null) {
mPlayer!!.clear()
}
if (null != sensorManager) {
sensorManager!!.unregisterListener(this)
}
//唤醒设备
if (null != localWakeLock && localWakeLock!!.isHeld) {
localWakeLock!!.release()
}
sensorManager = null
localWakeLock = null
localPowerManager = null
}
private fun voiceDestory() {
if (null != voiceManage && null != voiceManage!!.getVoiceApi()) {
voiceManage!!.getVoiceApi().destroy()
}
voiceManage = null
}
/**
* 重写返回键逻辑:屏蔽返回键
*/
override fun onBackPressed() {
}
private fun writeAgoraLog(content: String) {
Observable.create<Any> {
try {
AudioLogUtils.writeAgoraLog(content, "consult")
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
}
/**
* 上传错误日志
*/
private fun uploadException(
message: String,
zhu: String = "",
eventType: String = "99"
) {
var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String =
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(mAudioMessageBean?.channelId ?: "0", time, uid, "1", "999", message)
var connectException =
ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus)
YDLavManager.instances.uploadException(connectException, null)
}
private fun uploadLog() {
if (!hasUpLoadLog) {
hasUpLoadLog = true
LogHelper.getInstance().uploadLog(false)
}
}
override fun onDestroy() {
LogUtil.e("http-------------onDestory")
leaveChannel()
voiceDestory()
isConnectSuccess = false
status = STATUS_NOT_ANSWERED
hasUpLoadLog = false
EventBus.getDefault().unregister(this)
if (ActivityManager.getActivitySize() == 1) {
try {
// startActivity(MainActivity.newIntent(this, false))
ARouter.getInstance().build("/main/main")
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.navigation()
} catch (e: Exception) {
}
}
super.onDestroy()
}
}
package com.ydl.consultantim.bean
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/9
*/
data class ListenTokenBean(val token : String?,
val expired : String?,
val type : String?)
\ No newline at end of file
package com.ydl.consultantim.command;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/3/30
*/
public class ListenTokenCmd extends BaseCommand {
/**
* 类别 TOKEN|SIGNAL_TOKEN
*/
public String type;
/**
* 账号(就是uid)
* 如果是SIGNAL_TOKEN 则需要传递该参数
*/
public String account;
/**
* 频道ID
*/
public String channelId;
/**
* 过期时间
*/
public String expired;
}
package com.ydl.consultantim.contract
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
/**
* @author jiucheng
* @描述:声网倾诉首页约束类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
*/
interface IConsultantAudioHomeActivityContract {
interface View : IView {
fun listenStatusPushResponse()
fun channelTokenResponse(token: String?,needJoinChannel: Boolean)
// 执行接听操作
// canExcute是否执行
fun executeCall(canExcute: Boolean)
// 关闭当前页面,并提示用户已挂断
fun executeFinish()
}
interface Presenter : IPresenter<View> {
/**
* 通话开始(更新专家状态)
* @param param 请求参数
* @param isSwitchAxb 是否切换axb
*/
// fun connectStart(param: ConnectStartCommand)
/**
* 通话结束(更新专家状态)
* @param param 请求参数
* @param isSwitchAxb 是否切换axb
*/
// fun connectFinish(param: ConnectFinishCommand)
/**
* 获取频道token
*
*/
fun getChannelToken(mAudioMessageBean: AudioMessageBean?, needJoinChannel: Boolean = true)
/**
* 判断用户是否在频道中
*/
fun userIsInChannel(channelName: String, agoraUid: String)
}
interface Model : IModel {
/**
* 通话开始回调(更新专家状态)
*/
// fun connectStart(param: ConnectStartCommand)
/**
* 通话结束(更新专家状态)
*/
// fun connectFinish(param: ConnectFinishCommand)
}
}
package com.ydl.consultantim.event;
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/19
*/
public class AudioHomeEvent {
//1.发送停止播放电话铃声和震动
public int type;
public AudioHomeEvent(int type){
this.type = type;
}
}
package com.ydl.consultantim.model
import com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
/**
* @author jiucheng
* @描述:声网通话页面数据实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
*/
class ConsultantAudioHomeModelImpl : IConsultantAudioHomeActivityContract.Model {
}
package com.ydl.consultantim.presenter
import android.annotation.SuppressLint
import com.ydl.audioim.http.AudioApiRequestUtil
import com.ydl.consultantim.command.ListenTokenCmd
import com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
import com.ydl.consultantim.model.ConsultantAudioHomeModelImpl
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* @author jiucheng
* @描述:声网通话页面逻辑实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
*/
class ConsultantAudioHomePresenterImpl :
BasePresenter<IConsultantAudioHomeActivityContract.View, IConsultantAudioHomeActivityContract.Model>(),
IConsultantAudioHomeActivityContract.Presenter {
override fun userIsInChannel(channelName: String, agoraUid: String) {
// RetrofitUtils.userIsInChannel(channelName, agoraUid)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
// view.executeCall(it.data)
// }, {
// LogUtil.e("agora", "专家进入前判断用户是否在频道内接口异常:" + it.message)
// })
}
@SuppressLint("CheckResult")
override fun getChannelToken(msgBean: AudioMessageBean?, needJoinChannel: Boolean) {
if (ModularServiceManager.provide(IUserService::class.java).isLogin()) {
if (null != ModularServiceManager.provide(IUserService::class.java).getUserInfo()) {
val acount =
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
val tokenParam = ListenTokenCmd()
tokenParam.type = "TOKEN"
tokenParam.account = acount.toString()
tokenParam.uid = acount.toString()
tokenParam.channelId = msgBean?.channelId
AudioApiRequestUtil.listenToken(tokenParam)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
mView.channelTokenResponse(it.data.token, needJoinChannel)
}, {
})
}
}
}
override fun createModel(): IConsultantAudioHomeActivityContract.Model {
return ConsultantAudioHomeModelImpl()
}
}
package com.ydl.consultantim.utils
import android.annotation.SuppressLint
import android.app.KeyguardManager
import android.content.Context
import android.os.PowerManager
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/3/19
*/
class ConsultantAudioUtils {
companion object{
/**
* 唤醒手机屏幕并解锁
*/
@SuppressLint("InvalidWakeLockTag")
fun wakeUpAndUnlock(context: Context) { // 获取电源管理器对象
val pm = context.applicationContext
.getSystemService(Context.POWER_SERVICE) as PowerManager
val screenOn = pm.isScreenOn
if (!screenOn) { // 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
val wl = pm.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP or
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright"
)
wl.acquire(10000) // 点亮屏幕
wl.release() // 释放
}
// 屏幕解锁
val keyguardManager =context.applicationContext
.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
val keyguardLock = keyguardManager.newKeyguardLock("unLock")
// 屏幕锁定
keyguardLock.reenableKeyguard()
keyguardLock.disableKeyguard() // 解锁
}
}
}
\ No newline at end of file
package com.ydl.consultantim.utils;
import android.app.Activity;
import android.app.Service;
import android.os.Vibrator;
/**
* @author yuanWai
* @描述:震动工具类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/16
*/
public class VibratorUtil {
/**
* final Activity activity :调用该方法的Activity实例 long milliseconds :震动的时长,单位是毫秒
* long[] pattern :自定义震动模式 。数组中数字的含义依次是[静止时长,震动时长,静止时长,震动时长。。。]时长的单位是毫秒
* boolean isRepeat : 是否反复震动,如果是true,反复震动,如果是false,只震动一次
*/
// 一直震动多少秒
public static void vibrate(final Activity activity, long milliseconds) {
Vibrator vib = (Vibrator) activity
.getSystemService(Service.VIBRATOR_SERVICE);
assert vib != null;
vib.vibrate(milliseconds);
}
// 按照我们传进去的数组进行间歇性的震动
public static void vibrate(final Activity activity, long[] pattern,
boolean isRepeat) {
Vibrator vib = (Vibrator) activity
.getSystemService(Service.VIBRATOR_SERVICE);
assert vib != null;
vib.vibrate(pattern, isRepeat ? 1 : -1);
}
// 停止震动
public static void StopVibrate(final Activity activity) {
Vibrator vib = (Vibrator) activity
.getSystemService(Service.VIBRATOR_SERVICE);
assert vib != null;
vib.cancel();
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/platform_color_80353535">
<RelativeLayout
android:id="@+id/rl_head"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="74dp">
<com.ydl.ydlcommon.view.WaveView
android:id="@+id/wave_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true" />
<ImageView
android:layout_width="126dp"
android:layout_height="126dp"
android:layout_centerInParent="true"
android:background="@drawable/audioim_head_background" />
<ImageView
android:id="@+id/iv_head"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@drawable/audioim_head_place_hold_pic" />
</RelativeLayout>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_head"
android:layout_centerHorizontal="true"
android:layout_marginTop="-20dp"
android:textColor="@color/white"
android:textSize="26sp"
tools:text="用户" />
<TextView
android:id="@+id/tv_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_name"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="6dp"
android:layout_marginRight="25dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/white"
android:textSize="15sp"
android:text="向您发起语音通话请求" />
<!--自定义弹窗-->
<TextView
android:id="@+id/tv_toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_tips"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:background="@drawable/audioim_toast_view_background"
android:elevation="6dp"
android:paddingLeft="11dp"
android:paddingTop="4dp"
android:paddingRight="11dp"
android:paddingBottom="4dp"
android:textColor="@color/white"
android:visibility="gone"
tools:text="连接中..."
tools:visibility="visible" />
<!-- 倾诉剩余时间-->
<RelativeLayout
android:id="@+id/rl_remain_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/rl_hang_up"
android:layout_marginBottom="20dp"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/tv_notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="通话时长"
android:textColor="@color/platform_color_30FFFFFF"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_remain_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_notes"
android:layout_centerHorizontal="true"
android:text="00:00"
android:textColor="@color/white"
android:textSize="20sp" />
</RelativeLayout>
<!--挂断按钮-->
<RelativeLayout
android:id="@+id/rl_hang_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="72dp"
android:layout_marginBottom="18dp"
android:onClick="hangUpClick">
<ImageView
android:id="@+id/iv_hang_up"
android:layout_width="66dp"
android:layout_height="66dp"
android:layout_centerHorizontal="true"
android:src="@drawable/audioim_img_hang_up"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_hang_up"
android:layout_centerHorizontal="true"
android:layout_marginTop="9dp"
android:text="挂断"
android:textColor="@color/white"
android:textSize="12sp" />
</RelativeLayout>
<!-- 接听按钮-->
<RelativeLayout
android:id="@+id/rl_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="72dp"
android:layout_marginBottom="18dp"
android:onClick="onCall">
<ImageView
android:id="@+id/iv_hands_call"
android:layout_width="66dp"
android:layout_height="66dp"
android:src="@drawable/audioim_audio_home_img_answer" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_hands_call"
android:layout_centerHorizontal="true"
android:layout_marginTop="9dp"
android:text="接听"
android:textColor="@color/white"
android:textSize="12sp" />
</RelativeLayout>
<!-- 免提按钮-->
<RelativeLayout
android:id="@+id/rl_hands_free"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="72dp"
android:layout_marginBottom="18dp"
android:onClick="onSwitchSpeakerphoneClicked"
android:visibility="gone">
<ImageView
android:id="@+id/iv_hands_free"
android:layout_width="66dp"
android:layout_height="66dp"
android:src="@drawable/audioim_img_hands_free_unuse" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_hands_free"
android:layout_centerHorizontal="true"
android:layout_marginTop="9dp"
android:text="免提"
android:textColor="@color/white"
android:textSize="12sp" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -86,7 +86,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
initViews()
initData(intent)
}
override fun getStatusViewOptions(): StatusBarOptions {
......@@ -172,8 +171,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private var headData: HeadData? = null //筛选数据
private var isFromSplash = false
private val props1 = JSONObject() //筛选标题埋点参数
private var fromPageType: Int = 0 //从哪个页面跳转过来的
private val fromPages = arrayOf("首页搜索", "找专家", "在线专家")
private var fromPageType: Int = 1 //从哪个页面跳转过来的
private val fromPages = arrayOf("首页", "搜索页面", "在线专家")
private var isRecommend = false //埋点数据
private var keyWord: String? = null //埋点数据
private var isDoSearch: Boolean = false //埋点判断是否通过搜索进入埋点的
......@@ -380,7 +379,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
if (fromPageType != -1) {
doctorAdapter.setEntrance(fromPages[fromPageType])
doctorAdapter.setEntrance(fromPages[fromPageType],1)
}
}
......@@ -1454,7 +1453,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onResume() {
super.onResume()
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_PAGE_VISIT)
ActionCountUtils.count(ConsultBIConstants.ConsultSearchListEvent.APP_CONSULT_SEARCH_LIST_PAGE_VISIT)
}
......
......@@ -27,6 +27,7 @@ import com.ydl.ydl_image.listener.YDLImageRecyclerOnScrollListener
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.base.BaseMvpFragment
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.ui.LogoLoadingView
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.DisplayUtils
......@@ -58,8 +59,9 @@ import kotlinx.android.synthetic.main.consultant_layout_search_toolbar.*
import org.json.JSONObject
import java.util.concurrent.Executors
@Route(path = "/consultant/consultant")
class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPresenter>(), View.OnClickListener, IExpertSearchView,
OnCategoriesSelectedListener, OnSortItemSelectedListener, OnFilterConfirmListener,
class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPresenter>(),
View.OnClickListener, IExpertSearchView,
OnCategoriesSelectedListener, OnSortItemSelectedListener, OnFilterConfirmListener,
SwipeRefreshLayout.OnRefreshListener {
......@@ -69,11 +71,18 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
override fun initDataAndEvent() {
var statusBarHeight = StatusBarUtils.getStatusBarHeight(context);
rootView.setPadding(0,statusBarHeight,0,0)
rootView.setPadding(0, statusBarHeight, 0, 0)
btn_back.visibility = View.GONE
title_layout.setPadding(DisplayUtils.dp2px(context,15),0,0,0)
title_layout.setPadding(DisplayUtils.dp2px(context, 15), 0, 0, 0)
initViews()
initData()
val ffrom = PlatformDataManager.getRam().getChannelName()
if (!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")) {
rl_hot_fix_for_huawei.visibility = View.GONE
} else {
rl_hot_fix_for_huawei.visibility = View.VISIBLE
}
}
override fun initDataAndEventLazy() {
......@@ -92,7 +101,13 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
override fun showImage(url: String?, imgView: ImageView, width: Int, heigh: Int, ops: SimpleImageOpConfiger) {
override fun showImage(
url: String?,
imgView: ImageView,
width: Int,
heigh: Int,
ops: SimpleImageOpConfiger
) {
if (isAdded) {
YDLImageCacheManager.showImage(activity, url, imgView, width, heigh, ops)
}
......@@ -133,7 +148,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
private var headData: HeadData? = null //筛选数据
private val props1 = JSONObject() //筛选标题埋点参数
private var fromPageType: Int = 0 //从哪个页面跳转过来的
private val fromPages = arrayOf("首页搜索", "找专家", "在线专家")
private val fromPages = arrayOf("首页", "搜索页面", "在线专家")
private var isRecommend = false //埋点数据
private var keyWord: String? = null //埋点数据
private var isDoSearch: Boolean = false //埋点判断是否通过搜索进入埋点的
......@@ -158,7 +173,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
srlContainer.setOnRefreshListener(this)
initNetLossView()
recommendListView.addViewPagerScrollStateListener(object : RecommendListView.ViewPagerScrollStateCallback {
recommendListView.addViewPagerScrollStateListener(object :
RecommendListView.ViewPagerScrollStateCallback {
override fun viewPagerScroll(isScrolling: Boolean) {
//如果viewpager正在滚动,则禁止下拉刷新
srlContainer.isEnabled = !isScrolling
......@@ -211,7 +227,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200)
var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.GONE
......@@ -228,7 +246,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200)
var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.VISIBLE
......@@ -245,7 +265,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY).setDuration(200)
var animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
image_scroll_top.visibility = View.GONE
......@@ -281,15 +303,14 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (isVisibleToUser && isResumed) {
if (isVisibleToUser && isResumed) {
showConsultAssistantDialog()
}else {
} else {
hideConsultAssistantDialog()
}
if (isVisibleToUser && isResumed) {
onResume()
}
}
private fun showConsultAssistantDialog() {
......@@ -301,12 +322,12 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
private fun initNetLossView() {
v_loading.setListener(object : LogoLoadingView.LogoLoadingListener {
v_loading.setListener(object : LogoLoadingView.LogoLoadingListener {
override fun onDataResetClick() {
rvExperts.visibility = View.GONE
v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
rvExperts.visibility = View.GONE
v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
refresh(false)
}
......@@ -333,11 +354,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
getPresenter().localData(initShowType)
//refresh(false)
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
if (fromPageType != -1) {
doctorAdapter.setEntrance(fromPages[fromPageType])
doctorAdapter.setEntrance(fromPages[fromPageType], 0)
}
}
......@@ -349,9 +370,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
StatusBarUtils.setTransparentForImageView(activity, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(context)
val lp1 =title_layout.layoutParams as LinearLayout.LayoutParams
val lp1 = title_layout.layoutParams as LinearLayout.LayoutParams
lp1.height = (RxImageTool.dp2px(48f) + statusBarHeight)
title_layout.setPadding(0, statusBarHeight, 0, 0)
title_layout.setPadding(0, statusBarHeight, 0, 0)
}
}
......@@ -367,10 +388,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
allFilter.categories.add(cate)
if (allFilter.categories.size == 1 && !"全部".equals(allFilter.categories[0].cateName)) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
tvSubject.text = "主题"
}
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
break
......@@ -463,10 +484,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
if (allFilter.categories.size == 1 && "全部" != allFilter.categories[0].cateName) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
tvSubject.text = "主题"
}
}
}
......@@ -478,7 +499,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (hasSelectedArea) {
for ((index, bean) in headData!!.highlighter.withIndex()) {
if (bean.type == "2" || bean.type == "8") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
......@@ -494,16 +515,16 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
allFilter.region = bean
if (allFilter.region.value?.length ?: 0 > 4) {
tvArea.text = allFilter.region.value?.substring(0, 3) + "..."
tvArea.text = allFilter.region.value?.substring(0, 3) + "..."
} else {
tvArea.text = allFilter.region.value
tvArea.text = allFilter.region.value
}
updateFilterTextViewStatus(tvArea, FILTER_STATUS_FILTERED)
hasSelectedArea = true
} else {
allFilter.region = RegionItem()
tvArea.text = "地区"
tvArea.text = "地区"
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
hasSelectedArea = false
......@@ -520,7 +541,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (hasSelectedSort) {
for ((index, bean) in headData!!.highlighter.withIndex()) {
if (bean.type == "3") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
......@@ -539,9 +560,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
when {
allFilter.reorder.value.equals("综合排序") ->tvSort.text = "排序"
allFilter.reorder.value?.length ?: 0 > 4 ->tvSort.text = allFilter.reorder.value?.substring(0, 3) + "..."
else ->tvSort.text = allFilter.reorder.value
allFilter.reorder.value.equals("综合排序") -> tvSort.text = "排序"
allFilter.reorder.value?.length ?: 0 > 4 -> tvSort.text =
allFilter.reorder.value?.substring(0, 3) + "..."
else -> tvSort.text = allFilter.reorder.value
}
}
}
......@@ -634,7 +656,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (hasSelectedArea) {
for ((index, bean) in headData!!.highlighter.withIndex()) {
if (bean.type == "2" || bean.type == "8") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
......@@ -644,16 +666,20 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
bean.key = hotData.id
bean.value = hotData.value
for (headBean in headData!!.region) {
if (TextUtils.equals(headBean.key!!.substring(0, 2), bean.key!!.substring(0, 2))) {
if (TextUtils.equals(
headBean.key!!.substring(0, 2),
bean.key!!.substring(0, 2)
)
) {
allFilter.region = headBean
break
}
}
allFilter.sub = bean
if (allFilter.sub.value?.length ?: 0 > 4) {
tvArea.text = allFilter.sub.value?.substring(0, 3) + "..."
tvArea.text = allFilter.sub.value?.substring(0, 3) + "..."
} else {
tvArea.text = allFilter.sub.value
tvArea.text = allFilter.sub.value
}
updateFilterTextViewStatus(tvArea, FILTER_STATUS_FILTERED)
......@@ -662,7 +688,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
allFilter.region = RegionItem()
allFilter.sub = SubItem("不限", null)
tvArea.text = "地区"
tvArea.text = "地区"
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
hasSelectedArea = false
......@@ -678,14 +704,14 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (lin_filter2.childCount > 0) {
//清空选中
for (i in 0.until(lin_filter2.childCount)) {
val textView =lin_filter2.getChildAt(i) as TextView
val textView = lin_filter2.getChildAt(i) as TextView
textView.isSelected = false
textView.paint.isFakeBoldText = false
}
//重置选中状态
for ((index, other) in otherdata.withIndex()) {
for (i in 0 until lin_filter2.childCount) {
val textView =lin_filter2.getChildAt(i) as TextView
val textView = lin_filter2.getChildAt(i) as TextView
if (textView.text == other.value) {
textView.isSelected = true
textView.paint.isFakeBoldText = true
......@@ -696,7 +722,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
//服务列表数据获取到后的回调
override fun onServiceListFetched(data: MutableList<DoctorServiceItem>, page: Int, totalPage: Int) {
override fun onServiceListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onServiceListFetched")
// if (rvExperts.adapter != serviceAdapter) {
// rvExperts.adapter = serviceAdapter
......@@ -725,18 +755,22 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
isRecommend = false
isDoSearch = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
srlContainer.isRefreshing = false
rvExperts.visibility = View.VISIBLE
srlContainer.isRefreshing = false
}
//专家列表数据获取到后的回调
override fun onDoctorListFetched(data: MutableList<DoctorServiceItem>, page: Int, totalPage: Int) {
override fun onDoctorListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onDoctorListFetched")
if (rvExperts.adapter != doctorAdapter) {
rvExperts.adapter = doctorAdapter
rvExperts.adapter = doctorAdapter
}
LogUtil.d("data size " + data.size)
......@@ -763,10 +797,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
isDoSearch = false
isRecommend = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
rvExperts.visibility = View.VISIBLE
srlContainer.isRefreshing = false
}
......@@ -775,27 +809,30 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
isRecommend = false
if (curPage == 1) {
v_loading.setViewType(LogoLoadingView.TYPE_NET_LOSS, getString(R.string.consultant_reload_hint))
v_loading.visibility = View.VISIBLE
v_loading.setViewType(
LogoLoadingView.TYPE_NET_LOSS,
getString(R.string.consultant_reload_hint)
)
v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE
ll_network_error.visibility = View.GONE
} else {
ToastHelper.show("网络不给力")
}
srlContainer.isRefreshing = false
srlContainer.isRefreshing = false
}
override fun fetchListEmpty(msg: String?) {
isDoSearch = false
isRecommend = false
tv_reload.visibility = View.GONE
tv_reload_hint.text = msg
ll_network_error.visibility = View.VISIBLE
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty)
tv_reload.visibility = View.GONE
tv_reload_hint.text = msg
ll_network_error.visibility = View.VISIBLE
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty)
rvExperts.visibility = View.GONE
srlContainer.isRefreshing = false
rvExperts.visibility = View.GONE
srlContainer.isRefreshing = false
}
override fun fetchFailed(msg: String?) {
......@@ -804,17 +841,20 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (msg != null) {
ToastUtil.toastShort(msg)
}
v_loading.setViewType(LogoLoadingView.TYPE_NET_LOSS, getString(R.string.consultant_reload_hint))
v_loading.visibility = View.VISIBLE
v_loading.setViewType(
LogoLoadingView.TYPE_NET_LOSS,
getString(R.string.consultant_reload_hint)
)
v_loading.visibility = View.VISIBLE
ll_network_error.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.GONE
appbar_layout.setExpanded(false)
rvExperts.visibility = View.GONE
appbar_layout.setExpanded(false)
}
override fun showRefreshLayout() {
srlContainer.isRefreshing = true
srlContainer.isRefreshing = true
}
......@@ -826,8 +866,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
R.id.tvSubject -> {
props1.put("filtrate_first", "主题")
hideSoftInput()
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSubjectPopupWindow()
}, 300);
......@@ -835,8 +875,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
R.id.tvArea -> {
props1.put("filtrate_first", "地区")
hideSoftInput()
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showAreaPopupWindow()
}, 300);
......@@ -844,8 +884,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
R.id.tvSort -> {
props1.put("filtrate_first", "排序")
hideSoftInput()
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSortPopupWindow()
}, 300);
......@@ -853,8 +893,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
R.id.tvFilter -> {
props1.put("filtrate_first", "筛选")
hideSoftInput()
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showFilterPopupWindow()
}, 300);
......@@ -862,7 +902,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
R.id.tv_guide -> {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CONSULT_GUIDE_CLICK)
val h5param = H5Params(HttpConfig.H5_URL+ "help/consultation/", "咨询指南")
val h5param = H5Params(HttpConfig.H5_URL + "help/consultation/", "咨询指南")
h5param.isShowMenu = true
NewH5Activity.start(context, h5param)
}
......@@ -873,19 +913,19 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
R.id.rl_search -> {
ARouter.getInstance()
.build("/consult/hot_search")
.withString(HOT_SEARCH_DOCTOR_NAME,tv_search_content.text.toString())
.navigation()
.build("/consult/hot_search")
.withString(HOT_SEARCH_DOCTOR_NAME, tv_search_content.text.toString())
.navigation()
}
}
}
private fun scrollToTop() {
if ((rvExperts.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() > 10) {
rvExperts.scrollToPosition(10)
rvExperts.smoothScrollToPosition(0)
rvExperts.scrollToPosition(10)
rvExperts.smoothScrollToPosition(0)
} else {
rvExperts.smoothScrollToPosition(0)
rvExperts.smoothScrollToPosition(0)
}
}
......@@ -912,8 +952,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
val filterPopupWindow = FilterPopupWindow(context, headData?.filters!!, tempFilter)
filterPopupWindow.setOnDismissListener {
// viewDim.visibility = View.INVISIBLE
viewDim_filter.visibility = View.GONE
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size > 0 || !TextUtils.isEmpty(allFilter.priceRanges?.minPrice) || !TextUtils.isEmpty(allFilter.priceRanges?.maxPrice)) {
viewDim_filter.visibility = View.GONE
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size > 0 || !TextUtils.isEmpty(
allFilter.priceRanges?.minPrice
) || !TextUtils.isEmpty(allFilter.priceRanges?.maxPrice)
) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
......@@ -926,7 +969,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
filterPopupWindow.onFilterConfirmListener = this
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
// viewDim.visibility = View.VISIBLE
viewDim_filter.visibility = View.VISIBLE
viewDim_filter.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
......@@ -936,8 +979,19 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//筛选确认回调
override fun onFilterConfirmed() {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
LogUtil.d("filter: " + tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(","))
props1.put("filtrate_second", tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(","))
LogUtil.d(
"filter: " + tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(
","
) + "," + tempFilter.ages.map { it.value }.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(
","
)
)
props1.put(
"filtrate_second",
tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }.joinToString(",") + "," + tempFilter.ages.map { it.value }.joinToString(
","
) + "," + tempFilter.others.map { it.value }.joinToString(",")
)
BuryPointUtils.buryPoint("Filtrate", props1)
......@@ -958,13 +1012,17 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "4") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
activity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in allFilter.enquiries) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) {
if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
activity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -974,13 +1032,17 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
if (headData!!.highlighter[index].type == "5") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
activity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in allFilter.ages) {
if (TextUtils.equals(bean.value.toString(), headData!!.highlighter[index].id)) {
if (TextUtils.equals(
bean.value.toString(),
headData!!.highlighter[index].id
)
) {
activity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -990,13 +1052,17 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
if (headData!!.highlighter[index].type == "6") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
activity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in allFilter.others) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) {
if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
activity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -1007,13 +1073,17 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
if (headData!!.highlighter[index].type == "7") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
activity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in allFilter.title) {
if (TextUtils.equals(bean.key.toString(), headData!!.highlighter[index].id)) {
if (TextUtils.equals(
bean.key.toString(),
headData!!.highlighter[index].id
)
) {
activity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -1048,12 +1118,12 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
text = "筛选"
}
if (text?.length ?: 0 > 4) {
tvFilter.text = text?.substring(0, 3) + "..."
tvFilter.text = text?.substring(0, 3) + "..."
} else {
tvFilter.text = text
tvFilter.text = text
}
} else {
tvFilter.text = "筛选"
tvFilter.text = "筛选"
}
}
......@@ -1065,7 +1135,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (headData?.reorder != null) {
sortPopup = SortPopupWindow(activity, headData?.reorder!!, allFilter.reorder, this)
sortPopup!!.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
viewDim.visibility = View.INVISIBLE
if (allFilter.reorder != headData!!.reorder[0]) {
updateFilterTextViewStatus(tvSort, FILTER_STATUS_FILTERED)
} else {
......@@ -1078,7 +1148,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
sortPopup!!.showAsDropDown(viewSep2)
updateFilterTextViewStatus(tvSort, FILTER_STATUS_OPEN)
viewDim.visibility = View.VISIBLE
viewDim.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
......@@ -1087,22 +1157,24 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//排序选择回调
override fun onSortItemSelected(sortItem: ReorderItem) {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_SORT_CLICK, sortItem.value
?: "")
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_SORT_CLICK, sortItem.value
?: ""
)
if (sortItem.value.equals("综合排序")) {
tvSort.text = "排序"
tvSort.text = "排序"
} else if (sortItem.value?.length ?: 0 > 4) {
tvSort.text = sortItem.value?.substring(0, 3) + "..."
tvSort.text = sortItem.value?.substring(0, 3) + "..."
} else {
tvSort.text = sortItem.value
tvSort.text = sortItem.value
}
//判断排序选中,判断热门筛选中是否也有该排序
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "3") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
if (TextUtils.equals(sortItem.value, headData!!.highlighter[index].value)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -1128,82 +1200,88 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//显示地区弹窗
private fun showAreaPopupWindow() {
if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow(activity, headData?.region
?: ArrayList(), allFilter.region, allFilter.sub)
val regionPopupWindow = AreaPopupWindow(
activity, headData?.region
?: ArrayList(), allFilter.region, allFilter.sub
)
regionPopupWindow.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE
viewDim.visibility = View.VISIBLE
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
regionPopupWindow.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
viewDim.visibility = View.INVISIBLE
if (tvArea.text != "地区") {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
}
}
regionPopupWindow.onRegionSelectedListener = object : AreaPopupWindow.OnRegionSelectedListener {
override fun onRegionSelected(region: RegionItem, sub: SubItem) {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
allFilter.region = region
allFilter.sub = sub
if (region.key == null && sub.key == null) {
regionPopupWindow.onRegionSelectedListener =
object : AreaPopupWindow.OnRegionSelectedListener {
override fun onRegionSelected(region: RegionItem, sub: SubItem) {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
allFilter.region = region
allFilter.sub = sub
if (region.key == null && sub.key == null) {
// LogUtil.d("onRegionSelected: " + region.value)
// props1.put("filtrate_second", region.value)
// BuryPointUtils.buryPoint("Filtrate", props1)
tvArea.text = "地区"
} else if (region.key != null && sub.key == null) {
tvArea.text = "地区"
} else if (region.key != null && sub.key == null) {
// LogUtil.d("onRegionSelected: " + region.value)
// props1.put("filtrate_second", region.value)
// BuryPointUtils.buryPoint("Filtrate", props1)
if (region.value?.length ?: 0 > 4) {
tvArea.text = region.value?.substring(0, 3) + "..."
if (region.value?.length ?: 0 > 4) {
tvArea.text = region.value?.substring(0, 3) + "..."
} else {
tvArea.text = region.value
}
} else {
tvArea.text = region.value
}
} else {
// LogUtil.d("onRegionSelected: " + sub.value)
// props1.put("filtrate_second", sub.value)
// BuryPointUtils.buryPoint("Filtrate", props1)
if (sub.value?.length ?: 0 > 4) {
tvArea.text = sub.value?.substring(0, 3) + "..."
} else {
tvArea.text = sub.value
if (sub.value?.length ?: 0 > 4) {
tvArea.text = sub.value?.substring(0, 3) + "..."
} else {
tvArea.text = sub.value
}
}
}
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_AREA_CLICK, region.value + "|" + sub.value)
//更新热门搜索显示状态
if (headData!!.highlighter.size > 0) {
for ((index, hot) in headData!!.highlighter!!.withIndex()) {
if (hot.type == "2" || hot.type == "8") {
var textview =lin_filter2.getChildAt(index) as TextView
//有选择城市
if (!TextUtils.isEmpty(sub.key)) {
if (TextUtils.equals(sub.key, hot.id)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
} else {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
} else {
if (TextUtils.equals(region.key, hot.id)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_AREA_CLICK,
region.value + "|" + sub.value
)
//更新热门搜索显示状态
if (headData!!.highlighter.size > 0) {
for ((index, hot) in headData!!.highlighter!!.withIndex()) {
if (hot.type == "2" || hot.type == "8") {
var textview = lin_filter2.getChildAt(index) as TextView
//有选择城市
if (!TextUtils.isEmpty(sub.key)) {
if (TextUtils.equals(sub.key, hot.id)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
} else {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
} else {
textview.isSelected = false
textview.paint.isFakeBoldText = false
if (TextUtils.equals(region.key, hot.id)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
hasSelectedArea = true
} else {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
}
}
}
}
regionPopupWindow.dismiss()
refresh()
}
regionPopupWindow.dismiss()
refresh()
}
}
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
......@@ -1220,7 +1298,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (categories != null) {
categoryPopup = CategoryPopupWindow(activity, categories, tempFilter.categories)
categoryPopup!!.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
viewDim.visibility = View.INVISIBLE
if (allFilter.categories.size > 1 || (allFilter.categories.size == 1 && allFilter.categories[0] != headData!!.cates[0])) {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
......@@ -1230,7 +1308,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
categoryPopup!!.onSubjectsSelectedListener = this
categoryPopup!!.showAsDropDown(viewSep2)
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_OPEN)
viewDim.visibility = View.VISIBLE
viewDim.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
......@@ -1243,26 +1321,33 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
* 新增逻辑:当主题选择后,需要判断热门筛选中是否也有该主题,如果有,也需要同步更新选中状态
*/
override fun onCategoriesSelected(categories: ArrayList<CateItem>) {
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK, categories.map { it.cateName }.joinToString("|"))
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK,
categories.map { it.cateName }.joinToString("|")
)
if (categories.size == 1 && "全部" != categories[0].cateName) {
//显示选中标题
tvSubject.text = categories[0].cateName
tvSubject.text = categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
tvSubject.text = "主题"
}
//判断主题选中,判断热门筛选中是否也有该主题
Executors.newCachedThreadPool().execute {
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "1") {
var textview =lin_filter2.getChildAt(index) as TextView
var textview = lin_filter2.getChildAt(index) as TextView
activity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in categories) {
if (TextUtils.equals(bean.cateName, headData!!.highlighter[index].value)) {
if (TextUtils.equals(
bean.cateName,
headData!!.highlighter[index].value
)
) {
activity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -1297,8 +1382,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//刷新列表
private fun refresh(isShowRefresh: Boolean? = true) {
srlContainer.isRefreshing = isShowRefresh!!
val key =tv_search_content.text.toString()
srlContainer.isRefreshing = isShowRefresh!!
val key = tv_search_content.text.toString()
if (!TextUtils.isEmpty(key.trim())) {
allFilter.searchWord = key.trim()
} else {
......@@ -1312,7 +1397,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//执行搜索
private fun doSearch() {
image_scroll_top.visibility = View.GONE
image_scroll_top.visibility = View.GONE
hideSoftInput();
// keyWord = etSearch.text.toString()
// if (TextUtils.isEmpty(keyWord?.trim())) {
......@@ -1320,7 +1405,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
// return
// }
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK, keyWord ?: "")
ActionCountUtils.count(
ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,
keyWord ?: ""
)
isDoSearch = true
resetFilter()
refresh()
......@@ -1356,17 +1444,32 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
FILTER_STATUS_NORMAL -> {
tv.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
tv.setTextColor(ContextCompat.getColor(context, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_un, 0)
tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.platform_ic_arrow_drop_down_grey_500_18dp,
0
)
}
FILTER_STATUS_FILTERED -> {
tv.typeface = Typeface.DEFAULT_BOLD
tv.setTextColor(ContextCompat.getColor(context, R.color.platform_main_theme))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_un, 0)
tv.setTextColor(ContextCompat.getColor(context, R.color.consultant_main_theme))
tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.platform_ic_arrow_drop_down_grey_500_18dp,
0
)
}
FILTER_STATUS_OPEN -> {
tv.typeface = Typeface.DEFAULT_BOLD
tv.setTextColor(ContextCompat.getColor(context, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_arrow_drop_down_en, 0)
tv.setCompoundDrawablesWithIntrinsicBounds(
0,
0,
R.drawable.consultant_ic_arrow_drop_down,
0
)
}
}
}
......@@ -1384,11 +1487,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
*/
fun bury(keyworks: String, isResult: Boolean, isRecommend: Boolean, location: String) {
BuryPointUtils.getInstance().createMap()
.put("keyWord", keyworks)
.put("hasResult", isResult)
.put("isRecommend", isRecommend)
.put("location", location)
.burryPoint("search")
.put("keyWord", keyworks)
.put("hasResult", isResult)
.put("isRecommend", isRecommend)
.put("location", location)
.burryPoint("search")
}
override fun onResume() {
......
......@@ -15,12 +15,14 @@ import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.ExpertSearchActivity
import com.yidianling.consultant.IExpertSearchView
import com.yidianling.consultant.R
......@@ -38,8 +40,11 @@ import kotlinx.android.synthetic.main.consultant_item_tag.view.*
/**
* 专家服务列表适配器
*/
class ExpertSearchAdapter(private val context: Context, private val expertSearchView : IExpertSearchView, private val listData: ArrayList<DoctorServiceItem>)
: RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class ExpertSearchAdapter(
private val context: Context,
private val expertSearchView: IExpertSearchView,
private val listData: ArrayList<DoctorServiceItem>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object {
const val NORMAL_VIEW = 0
......@@ -47,66 +52,73 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
const val EMPTY_VIEW = 2
}
private val ffrom = PlatformDataManager.getRam().getChannelName()
//记录当前选择主题的id
var cateId : String? = null
var cateId: String? = null
var hasMore = true
var entranceName: String? = null
var pageIndex: Int = 0
fun setEntrance(entranceName: String) {
fun setEntrance(entranceName: String, pageIndex: Int) {
this.entranceName = entranceName
this.pageIndex = pageIndex
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
if (holder is NormalViewHolder) {
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
val itemBean = listData[position]
//头像
val headConfig = SimpleImageOpConfiger()
headConfig.loadingPic = R.drawable.consultant_avatar_def_circle
headConfig.errorPic = R.drawable.consultant_avatar_def_circle
expertSearchView.showImage(itemBean.head,holder.imgHead,holder.imgHead.width,holder.imgHead.height,headConfig)
expertSearchView.showImage(
itemBean.head,
holder.imgHead,
holder.imgHead.width,
holder.imgHead.height,
headConfig
)
//姓名
holder.tvName.text = itemBean.name
// if (TextUtils.isEmpty(itemBean.famousRemark)){
// holder.group_desc.visibility = View.GONE
// }else{
// holder.group_desc.visibility = View.VISIBLE
// //描述
// holder.tvDesc.text = itemBean.famousRemark
// }
//服务中
if (itemBean.inConsult || itemBean.isListening) {
holder.imgHead_online_server.visibility = View.VISIBLE
holder.chat_people_in_question.visibility = View.GONE
holder.imgHead_online.visibility = View.GONE
}else {
} else {
//不是服务中且问询人数大于0
if (itemBean.chatNum > 5) {
holder.chat_people_in_question.visibility = View.VISIBLE
holder.chat_people_in_question.text = "多人在问询"
}else if (itemBean.chatNum > 0){
} else if (itemBean.chatNum > 0) {
holder.chat_people_in_question.visibility = View.VISIBLE
holder.chat_people_in_question.text = "${itemBean.chatNum}人在问询"
}else {
} else {
holder.chat_people_in_question.visibility = View.GONE
}
//可预约
holder.imgHead_online_server.visibility = View.GONE
if (itemBean.isTodayFree == true){
if (itemBean.isTodayFree == true) {
holder.imgHead_online.visibility = View.VISIBLE
}else{
} else {
holder.imgHead_online.visibility = View.GONE
}
}
//省市
if (!TextUtils.isEmpty(itemBean.province)){
holder.tvCity.text = itemBean.province+"·"+itemBean.city
}else{
if (!TextUtils.isEmpty(itemBean.province)) {
holder.tvCity.text = itemBean.province + "·" + itemBean.city
} else {
holder.tvCity.text = ""
}
......@@ -151,20 +163,13 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
holder.imgAbilityLevel.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_xinshou)
holder.imgAbilityLevel.visibility = View.VISIBLE
}
// else if (3 == itemBean.abilityLevel){
// //精英
// holder.imgAbilityLevel.background = context.resources.getDrawable(R.drawable.consultant_expert_search_jingying)
// holder.imgAbilityLevel.visibility = View.VISIBLE
// }
else {
} else {
holder.imgAbilityLevel.visibility = View.GONE
}
//活动图标
if (!TextUtils.isEmpty(itemBean.activityImg)) {
holder.imgActivity.visibility = View.VISIBLE
GlideApp.with(context).load(itemBean.activityImg).into(holder.imgActivity)
// GlideApp.with(context).load("https://video.ydlcdn.com/2019/11/04/abdd3782c98939d0406080a6a80b8ea5.jpg").into(holder.imgActivity)
} else {
holder.imgActivity.visibility = View.GONE
}
......@@ -187,29 +192,38 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
}
}
holder.ll_feedbackRate.removeAllViews()
for (num in 1..5){
val view = LayoutInflater.from(context).inflate(R.layout.consultant_expert_search_feedbackrate, holder.ll_feedbackRate, false)
if (itemBean.feedbackRate >= num){
(view.imgRate as ImageView).background = context.resources.getDrawable(R.drawable.consultant_expert_search_full_star)
}else if (itemBean.feedbackRate < num && itemBean.feedbackRate > num - 1){
(view.imgRate as ImageView).background = context.resources.getDrawable(R.drawable.consultant_expert_search_half_star)
}else{
(view.imgRate as ImageView).background = context.resources.getDrawable(R.drawable.consultant_expert_search_nothing_star)
for (num in 1..5) {
val view = LayoutInflater.from(context).inflate(
R.layout.consultant_expert_search_feedbackrate,
holder.ll_feedbackRate,
false
)
if (itemBean.feedbackRate >= num) {
(view.imgRate as ImageView).background =
context.resources.getDrawable(R.drawable.consultant_expert_search_full_star)
} else if (itemBean.feedbackRate < num && itemBean.feedbackRate > num - 1) {
(view.imgRate as ImageView).background =
context.resources.getDrawable(R.drawable.consultant_expert_search_half_star)
} else {
(view.imgRate as ImageView).background =
context.resources.getDrawable(R.drawable.consultant_expert_search_nothing_star)
}
holder.ll_feedbackRate.addView(view)
}
//XXX人点评
val numSb = StringBuffer()
holder.tv_zixunOrderNum.text = numSb.append(itemBean.zixunOrderNum).append("").toString()
holder.tv_zixunOrderNum.text =
numSb.append(itemBean.zixunOrderNum).append("").toString()
//咨询师简介
holder.tvTeamCertifications.text = itemBean.teamCertifications
//咨询师标签
holder.ll_tags.removeAllViews()
if (!TextUtils.isEmpty(itemBean.tags)){
if (!TextUtils.isEmpty(itemBean.tags)) {
val tagList = itemBean.tags!!.split("|")
for (tag in tagList) {
if (!TextUtils.isEmpty(tag)){
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
if (!TextUtils.isEmpty(tag)) {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
view.tvTag.text = tag
holder.ll_tags.addView(view)
}
......@@ -218,53 +232,86 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
//帮助人数
val orderUser = StringBuffer()
holder.tvOrderNum.text = orderUser.append(itemBean.zixunOrderUser).append("").toString()
// if ( 50 <= itemBean.zixunOrderNum){
// holder.tvOrderNumContent.text = "帮助"
// holder.tvSaleDurationForMonth.visibility = View.VISIBLE
// holder.tvSaleDurationForMonthContent.visibility = View.VISIBLE
// }else{
// holder.tvOrderNumContent.text = "公益解答"
// holder.tvSaleDurationForMonth.visibility = View.GONE
// holder.tvSaleDurationForMonthContent.visibility = View.GONE
// }
//私聊文案
if (TextUtils.isEmpty(itemBean.chatBtnText)){
if (TextUtils.isEmpty(itemBean.chatBtnText)) {
holder.tvChat.text = "私聊"
holder.tvChat.setTextColor(ContextCompat.getColor(context,R.color.platform_but_text_color))
holder.tvChat.background = ContextCompat.getDrawable(context,R.drawable.consultant_expert_search_chat)
}else{
holder.tvChat.setTextColor(
ContextCompat.getColor(
context,
R.color.consultant_confirm_text_color
)
)
holder.tvChat.background =
ContextCompat.getDrawable(context, R.drawable.consultant_expert_search_chat)
} else {
holder.tvChat.text = itemBean.chatBtnText
holder.tvChat.setTextColor(ContextCompat.getColor(context,R.color.platform_color_999999))
holder.tvChat.background = ContextCompat.getDrawable(context,R.drawable.consultant_expert_search_chat_rest)
holder.tvChat.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_color_999999
)
)
holder.tvChat.background = ContextCompat.getDrawable(
context,
R.drawable.consultant_expert_search_chat_rest
)
}
//服务时长
val durationStringBuffer = StringBuffer()
holder.tvSaleDurationForMonth.text = durationStringBuffer.append(itemBean.allSaleDuration.toInt()).append("").toString()
holder.tvSaleDurationForMonth.text =
durationStringBuffer.append(itemBean.allSaleDuration.toInt()).append("").toString()
//价格
val sb = StringBuffer()
holder.tvPrice.text = sb.append("").append(itemBean.minBookingPrice).toString()
//套餐
holder.ll_products.removeAllViews()
if (null != itemBean.products && !itemBean.products.isEmpty()){
if (null != itemBean.products && !itemBean.products.isEmpty()) {
for (item in itemBean.products) {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_expert_search_products_item, holder.ll_tags, false)
if (1 == item.isPackage){
val view = LayoutInflater.from(context).inflate(
R.layout.consultant_expert_search_products_item,
holder.ll_tags,
false
)
if (1 == item.isPackage) {
view.tvTitle.text = "单次"
view.tvTitle.setTextColor(context.resources.getColor(R.color.platform_color_1DA1F2))
view.tvTitle.background = context.resources.getDrawable(R.drawable.consultant_expert_search_single)
view.tvTitle.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_single)
view.tvContent.text = item.name
holder.ll_products.addView(view)
} else if (2 == item.isPackage){
} else if (2 == item.isPackage) {
view.tvTitle.text = "套餐"
view.tvTitle.setTextColor(context.resources.getColor(R.color.consultant_color_FF9500))
view.tvTitle.background = context.resources.getDrawable(R.drawable.consultant_expert_search_menu)
view.tvTitle.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_menu)
view.tvContent.text = item.name
holder.ll_products.addView(view)
}else{
} else {
}
}
}
if (isFromXinliZiXunHuawei) {
holder.ll_honor_layout.visibility = View.GONE
holder.ll_tags.visibility = View.GONE
holder.imgHead_online.visibility = View.GONE
holder.imgHead_online_server.visibility = View.GONE
holder.tvPrice.visibility = View.GONE
holder.tvPriceContent.visibility = View.GONE
holder.tv_money_symbol.visibility = View.GONE
holder.chat_people_in_question.visibility = View.GONE
holder.tvCity.visibility = View.GONE
holder.tvChat.visibility = View.GONE
holder.tvChat.text = "咨询"
val params = holder.cv_head_view.layoutParams
params.width = RxImageTool.dp2px(92f)
params.height = RxImageTool.dp2px(92f)
holder.cv_head_view.layoutParams = params
}
} else if (holder is FooterViewHolder) {
if (hasMore) {
holder.itemView.visibility = View.VISIBLE
......@@ -277,27 +324,31 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
}
}
override fun getItemCount(): Int = if (listData.size < ExpertSearchActivity.PAGE_SIZE && hasMore) {
listData.size
} else {
listData.size + 1
}
override fun getItemCount(): Int =
if (listData.size < ExpertSearchActivity.PAGE_SIZE && hasMore) {
listData.size
} else {
listData.size + 1
}
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder =
when (viewType) {
NORMAL_VIEW -> {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_expert_search_item_view, parent, false)
NormalViewHolder(view)
}
FOOT_VIEW -> {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_footer, parent, false)
FooterViewHolder(view)
}
else -> {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_empty, parent, false)
EmptyViewHolder(view)
}
when (viewType) {
NORMAL_VIEW -> {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_expert_search_item_view, parent, false)
NormalViewHolder(view)
}
FOOT_VIEW -> {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_footer, parent, false)
FooterViewHolder(view)
}
else -> {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_empty, parent, false)
EmptyViewHolder(view)
}
}
override fun getItemViewType(position: Int): Int = when {
position < listData.size -> NORMAL_VIEW
......@@ -308,6 +359,7 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
inner class NormalViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
//头像
val imgHead = itemView.imgHead!!
val cv_head_view = itemView.cv_head_view!!
//专家姓名
val tvName = itemView.tvName!!
//活动图标
......@@ -318,6 +370,8 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
val imgServiceFree = itemView.imgServiceFree!!
//新驻图标
val imgNewEnter = itemView.imgNewEnter!!
//荣誉标签
val ll_honor_layout = itemView.ll_honor_layout!!
//好评率
val ll_feedbackRate = itemView.ll_feedbackRate!!
//xxx人点评
......@@ -336,6 +390,8 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
val tvSaleDurationForMonthContent = itemView.tvSaleDurationForMonthContent
//价格
val tvPrice = itemView.tvPrice!!
val tvPriceContent = itemView.tvPriceContent!!
val tv_money_symbol = itemView.tv_money_symbol!!
//服务套餐
val ll_products = itemView.ll_products!!
//私聊按钮
......@@ -362,27 +418,46 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
val itemBean = listData[adapterPosition]
var linkUrl = itemBean.linkUrl
if (!TextUtils.isEmpty(cateId)){
linkUrl = URLUtils.appendParmas(linkUrl,"cateId",cateId)
if (!TextUtils.isEmpty(cateId)) {
linkUrl = URLUtils.appendParmas(linkUrl, "cateId", cateId)
}
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_DOCTOR_CLICK,itemBean.doctorId?:"")
TempH5RouteUtils.tempH5Route(linkUrl)
// var params = URLDecoder.decode( Uri.parse(linkUrl)!!.getQueryParameter("params"),"UTF-8")
// ARouter.getInstance().build("/h5/h5").withSerializable("routerParam",params).navigation()
if (pageIndex == 0) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_DOCTOR_CLICK,
itemBean.doctorId ?: ""
)
} else {
ActionCountUtils.count(
ConsultBIConstants.ConsultSearchListEvent.APP_CONSULT_SEARCH_LIST_CONSULT_ITEM_CLICK,
itemBean.doctorId ?: ""
)
}
TempH5RouteUtils.tempH5Route(linkUrl)
}
}
itemView.tvChat.setOnClickListener {
if (adapterPosition != RecyclerView.NO_POSITION) {
val doctor = listData[adapterPosition]
if (pageIndex == 0) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CHAT_CLICK,
doctor.doctorId ?: ""
)
} else {
ActionCountUtils.count(
ConsultBIConstants.ConsultSearchListEvent.APP_CONSULT_SEARCH_LIST_CHAT_CLICK,
doctor.doctorId ?: ""
)
}
//判断是否已登录
if(!ConsultantIn.getUserImpl().isLogin()){
if (!ConsultantIn.getUserImpl().isLogin()) {
TempH5RouteUtils.tempH5Route(IYDLRouterConstant.ROUTER_MINE_LOGIN)
return@setOnClickListener
}
val doctor = listData[adapterPosition]
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CHAT_CLICK,doctor.doctorId?:"")
if (!TextUtils.isEmpty(doctor.uid)) {
//跳转私聊
......@@ -393,10 +468,10 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
if (!TextUtils.isEmpty(entranceName)) {
LogUtil.d("entrance name: $entranceName")
BuryPointUtils.getInstance().createMap()
.put("expert_entrance", entranceName?:"")
.put("expert_ID", doctor.doctorId?:0)
.put("expert_name", doctor.name?:"")
.burryPoint("Chat_click")
.put("expert_entrance", entranceName ?: "")
.put("expert_ID", doctor.doctorId ?: 0)
.put("expert_name", doctor.name ?: "")
.burryPoint("Chat_click")
}
}
}
......
......@@ -32,6 +32,19 @@ class ConsultBIConstants {
const val APP_CONSULT_LIST_CHAT_CLICK: String = APP_CONSULT_LIST_PAGE + "app_consult_list_chat_click"//每个咨询师私聊
}
}
class ConsultSearchListEvent {
companion object {
private const val CONSULT_SEARCH_LIST_PAGE: String = "consul_search_list_page|"//APP咨询搜索列表页 partId
const val APP_CONSULT_SEARCH_LIST_PAGE_VISIT: String = CONSULT_SEARCH_LIST_PAGE + "consul_search_list_page_visit"//列表页浏览事件
const val APP_CONSULT_SEARCH_LIST_CONSULT_ITEM_CLICK: String = CONSULT_SEARCH_LIST_PAGE + "consult_search_list_doctor_click "//每个咨询师页面点击
const val APP_CONSULT_SEARCH_LIST_CHAT_CLICK: String = CONSULT_SEARCH_LIST_PAGE + "consult__search_list_chat_click"//每个咨询师私聊
}
}
class UserMainEvent {
companion object {
......
......@@ -8,6 +8,7 @@ import android.text.TextUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.ConsultAssistantCenterActivity
......@@ -104,6 +105,7 @@ class ConsultAssistantDialogUtils private constructor() {
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
//获取用户uid
ActionCountUtils.count("main_page|main_daoyi_entry_click")
YdlBuryPointUtil.sendClick("home_page_assistant_click")
getConsultAssistantUid(activity)
}
......@@ -157,6 +159,7 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
ActionCountUtils.count("app_consult_list_page|app_consult_list_daoyi_entry_click")
YdlBuryPointUtil.sendClick("assistant_list_click")
// 咨询师列表页面且未登录情况下,跳转登录页面
if (!ConsultantIn.isLogin()) {
......@@ -178,6 +181,7 @@ class ConsultAssistantDialogUtils private constructor() {
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
ActionCountUtils.count("app_consult_list_page|app_consult_list_daoyi_entry_click")
YdlBuryPointUtil.sendClick("assistant_list_click")
// 咨询师列表页面且未登录情况下,跳转登录页面
if (!ConsultantIn.isLogin()) {
......@@ -200,14 +204,14 @@ class ConsultAssistantDialogUtils private constructor() {
* 咨询师列表页Fragment隐藏
*/
fun hide() {
consultAssistantFragmentDialog?.hide()
consultAssistantFragmentDialog?.dismiss()
}
/**
* 咨询师列表页Fragment隐藏
*/
fun hideAssistantActivity() {
consultAssistantActivityDialog?.hide()
consultAssistantActivityDialog?.dismiss()
}
/**
......
......@@ -11,57 +11,67 @@
layout="@layout/consultant_layout_search_toolbar"
android:layout_width="match_parent"
android:layout_height="48dp" />
<com.yidianling.consultant.ui.view.ExpertSearchSwipeRefreshLayout
android:id="@+id/srlContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/consultant_colorBg"
tools:ignore="InefficientWeight">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_layout"
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="@color/consultant_colorBg"
android:clipChildren="false"
android:clipToPadding="false"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
tools:ignore="InefficientWeight">
<android.support.design.widget.CollapsingToolbarLayout
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:background="@color/consultant_colorBg"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<com.yidianling.consultant.ui.view.topView.RecommendListView
android:id="@+id/recommendListView"
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.yidianling.consultant.ui.view.topView.RecommendListView>
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/consultant_layout_search_content" />
<!-- 心理咨询app华为渠道紧急处理,咨询师列表页先简单粗暴的隐藏顶部推荐模块-->
<RelativeLayout
android:id="@+id/rl_hot_fix_for_huawei"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<!--<include layout="@layout/layout_search_head_input"/>-->
<com.yidianling.consultant.ui.view.topView.RecommendListView
android:id="@+id/recommendListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<!--筛选弹窗半透明背景-->
<View
android:id="@+id/viewDim_filter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#40000000"
android:visibility="gone" />
</android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/consultant_layout_search_content" />
<!--<include layout="@layout/layout_search_head_input"/>-->
<!--筛选弹窗半透明背景-->
<View
android:id="@+id/viewDim_filter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#40000000"
android:visibility="gone" />
</android.support.design.widget.CoordinatorLayout>
</com.yidianling.consultant.ui.view.ExpertSearchSwipeRefreshLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/platform_dp_13"
android:paddingRight="@dimen/platform_dp_15"
android:paddingBottom="@dimen/platform_dp_8"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:paddingBottom="@dimen/platform_dp_8">
<!--头像-->
<LinearLayout
android:id="@+id/cvHead"
......@@ -15,18 +15,20 @@
android:layout_marginTop="@dimen/platform_dp_15"
android:background="@drawable/consultant_bg_radius_line_gray_05"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cv_head_view"
android:layout_width="92dp"
android:layout_height="114dp"
app:cardElevation="0px"
app:cardCornerRadius="4dp">
app:cardCornerRadius="4dp"
app:cardElevation="0px">
<ImageView
android:id="@+id/imgHead"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/consultant_avatar_def_circle"
/>
android:src="@drawable/consultant_avatar_def_circle" />
</android.support.v7.widget.CardView>
</LinearLayout>
......@@ -34,67 +36,70 @@
android:id="@+id/imgHead_online"
android:layout_width="62dp"
android:layout_height="14dp"
android:layout_alignBottom="@+id/cvHead"
android:layout_gravity="bottom"
android:scaleType="centerCrop"
android:layout_alignBottom="@+id/cvHead"
android:visibility="gone"
app:srcCompat="@drawable/consultant_online_yue"
tools:visibility="visible"
android:visibility="gone"/>
tools:visibility="visible" />
<ImageView
android:id="@+id/imgHead_online_server"
android:layout_width="41dp"
android:layout_height="14dp"
android:layout_alignBottom="@+id/cvHead"
android:layout_gravity="bottom"
android:scaleType="centerCrop"
android:layout_alignBottom="@+id/cvHead"
android:visibility="gone"
app:srcCompat="@drawable/consultant_online_server"
tools:visibility="visible"
android:visibility="gone"/>
tools:visibility="visible" />
<!--咨询师姓名-->
<TextView
android:id="@+id/tvName"
android:layout_toRightOf="@+id/cvHead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_12"
android:layout_marginLeft="@dimen/platform_dp_12"
android:textSize="@dimen/platform_dp_18"
android:textColor="@color/platform_color_242424"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_12"
android:layout_toEndOf="@+id/cvHead"
android:layout_toRightOf="@+id/cvHead"
android:gravity="center_vertical"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_18"
android:textStyle="bold"
tools:ignore="SpUsage"
tools:text="罗静"
android:layout_toEndOf="@+id/cvHead" />
tools:text="罗静" />
<LinearLayout
android:layout_toRightOf="@+id/tvName"
android:id="@+id/ll_honor_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:gravity="center_vertical"
android:layout_alignTop="@+id/tvName"
android:layout_alignBottom="@+id/tvName"
android:layout_marginStart="@dimen/platform_dp_2"
android:layout_toEndOf="@+id/tvName"
android:layout_marginStart="@dimen/platform_dp_2">
android:layout_toRightOf="@+id/tvName"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="8dp">
<ImageView
android:id="@+id/img_fightEpidemicIcon"
android:layout_width="53dp"
android:layout_height="@dimen/platform_dp_17"
android:layout_marginRight="4dp"
android:scaleType="centerCrop"
android:visibility="gone"/>
android:visibility="gone" />
<!--活动图标-->
<ImageView
android:id="@+id/img_activity"
android:layout_width="42dp"
android:layout_height="12dp"
android:layout_marginRight="4dp"
android:visibility="gone"/>
android:id="@+id/img_activity"
android:layout_width="42dp"
android:layout_height="12dp"
android:layout_marginRight="4dp"
android:visibility="gone" />
<!--公益图标-->
<ImageView
android:id="@+id/imgServiceFree"
......@@ -118,8 +123,8 @@
android:layout_height="@dimen/platform_dp_12"
android:layout_marginRight="4dp"
android:scaleType="fitCenter"
tools:background="@drawable/consultant_expert_search_shixi"
android:visibility="gone"/>
android:visibility="gone"
tools:background="@drawable/consultant_expert_search_shixi" />
</LinearLayout>
......@@ -130,37 +135,38 @@
android:layout_height="wrap_content"
android:layout_below="@+id/tvName"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_toRightOf="@+id/cvHead"
android:layout_toEndOf="@+id/cvHead"
android:layout_marginTop="@dimen/platform_dp_4"
android:textSize="@dimen/platform_dp_12"
android:textColor="@color/platform_color_242424"
android:lines="1"
android:layout_toEndOf="@+id/cvHead"
android:layout_toRightOf="@+id/cvHead"
android:ellipsize="end"
tools:text="一级婚姻家庭咨询师,二级心理咨询师"/>
android:lines="1"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_12"
tools:text="一级婚姻家庭咨询师,二级心理咨询师" />
<!--咨询师标签-->
<LinearLayout
android:id="@+id/ll_tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvName"
android:layout_alignTop="@+id/tvChat"
android:layout_alignBottom="@+id/tvChat"
android:layout_alignLeft="@+id/tvName"
android:layout_toLeftOf="@+id/tvChat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:id="@+id/ll_zixunOrderNum"
android:layout_width="match_parent"
android:layout_height="@dimen/platform_dp_16"
android:layout_toRightOf="@+id/cvHead"
android:layout_toEndOf="@+id/cvHead"
android:layout_below="@+id/tvTeamCertifications"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_5"
android:layout_toEndOf="@+id/cvHead"
android:layout_toRightOf="@+id/cvHead"
android:orientation="horizontal">
<!--好评率-->
<LinearLayout
......@@ -174,173 +180,179 @@
<!--61234人点评-->
<TextView
android:id="@+id/tv_zixunOrderNum"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="@dimen/platform_dp_12"
android:layout_marginLeft="@dimen/platform_dp_12"
android:textColor="@color/platform_color_242424"
tools:text="61234"
android:textStyle="bold"/>
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"
tools:text="61234" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="@dimen/platform_dp_12"
android:text="条评价"
android:textColor="@color/platform_color_999999"
android:text="条评价" />
android:textSize="@dimen/platform_dp_12" />
</LinearLayout>
<!--帮助人数-->
<TextView
android:id="@+id/tvOrderNumContent"
android:layout_toRightOf="@+id/cvHead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll_zixunOrderNum"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginLeft="@dimen/platform_dp_12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/cvHead"
android:text="帮助"
android:textColor="@color/platform_color_999999"
tools:ignore="SpUsage"
android:text="帮助" />
android:textSize="@dimen/platform_dp_12"
tools:ignore="SpUsage" />
<TextView
android:id="@+id/tvOrderNum"
android:layout_toRightOf="@+id/tvOrderNumContent"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_toRightOf="@+id/tvOrderNumContent"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"
tools:text="2648"
tools:ignore="SpUsage" />
tools:ignore="SpUsage"
tools:text="2648" />
<TextView
android:layout_toRightOf="@+id/tvOrderNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvOrderNumContent"
android:textSize="@dimen/platform_dp_12"
android:layout_toRightOf="@+id/tvOrderNum"
android:text="人"
android:textColor="@color/platform_color_999999"
tools:ignore="SpUsage"
android:text="人" />
android:textSize="@dimen/platform_dp_12"
tools:ignore="SpUsage" />
<!--服务时长-->
<TextView
android:id="@+id/tvSaleDurationForMonthContent"
android:layout_toRightOf="@+id/tvOrderNum"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_marginLeft="@dimen/platform_dp_20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_marginLeft="@dimen/platform_dp_20"
android:layout_toRightOf="@+id/tvOrderNum"
android:text="服务"
android:textColor="@color/platform_color_999999"
tools:ignore="SpUsage"
android:text="服务" />
android:textSize="@dimen/platform_dp_12"
tools:ignore="SpUsage" />
<TextView
android:id="@+id/tvSaleDurationForMonth"
android:layout_toRightOf="@+id/tvSaleDurationForMonthContent"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_toRightOf="@+id/tvSaleDurationForMonthContent"
android:gravity="center"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"
android:gravity="center"
tools:text="134"
tools:ignore="SpUsage" />
tools:ignore="SpUsage"
tools:text="134" />
<TextView
android:layout_toRightOf="@+id/tvSaleDurationForMonth"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_toRightOf="@+id/tvSaleDurationForMonth"
android:text="小时"
android:textColor="@color/platform_color_999999"
tools:ignore="SpUsage"
android:text="小时" />
android:textSize="@dimen/platform_dp_12"
tools:ignore="SpUsage" />
<TextView
android:id="@+id/people_in_question"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/platform_dp_12"
android:layout_alignTop="@+id/tvOrderNumContent"
android:layout_alignParentRight="true"
android:textColor="@color/platform_color_FF5040"
android:textSize="@dimen/platform_dp_12"
android:visibility="gone"
tools:ignore="SpUsage"
tools:text="多人在问询"
android:visibility="gone"
tools:visibility="visible"/>
tools:visibility="visible" />
<TextView
android:id="@+id/tv_money_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvPrice"
android:layout_marginTop="3dp"
android:layout_marginRight="1dp"
android:layout_toLeftOf="@+id/tvPrice"
android:text="¥"
android:textColor="#FF5040"
android:textSize="@dimen/platform_dp_11"
tools:ignore="SpUsage"
android:layout_marginTop="3dp"
android:textStyle="bold"
android:layout_marginRight="1dp"
android:text="¥" />
tools:ignore="SpUsage" />
<TextView
android:id="@+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvName"
android:layout_toLeftOf="@+id/tvPriceContent"
android:fontFamily="@font/platform_din_bold"
android:textColor="#FF5040"
android:textSize="@dimen/platform_dp_20"
android:fontFamily="@font/platform_din_bold"
tools:text="250" />
<TextView
android:id="@+id/tvPriceContent"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF5040"
android:textSize="@dimen/platform_dp_11"
android:layout_alignBottom="@+id/tvPrice"
android:layout_alignParentRight="true"
android:layout_marginLeft="1dp"
android:layout_marginBottom="2.5dp"
android:text="起"
android:layout_marginLeft="1dp" />
android:textColor="#FF5040"
android:textSize="@dimen/platform_dp_11" />
<TextView
android:id="@+id/tvCity"
android:layout_below="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_4"
android:layout_below="@+id/tvName"
android:layout_alignParentRight="true"
tools:text="浙江.杭州"
android:layout_marginTop="@dimen/platform_dp_4"
android:gravity="right"
android:textColor="@color/platform_color_999999"
android:textSize="@dimen/platform_dp_12"/>
android:textSize="@dimen/platform_dp_12"
tools:text="浙江.杭州" />
<!--<View-->
<!--android:id="@+id/vLine"-->
<!--android:layout_below="@+id/tvPrice"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="2dp"-->
<!--android:layout_marginLeft="104dp"-->
<!--android:layout_marginStart="104dp"-->
<!--android:layout_marginTop="7dp"-->
<!--android:layerType="software"-->
<!--android:background="@drawable/expert_search_dash_line" />-->
<!--android:id="@+id/vLine"-->
<!--android:layout_below="@+id/tvPrice"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="2dp"-->
<!--android:layout_marginLeft="104dp"-->
<!--android:layout_marginStart="104dp"-->
<!--android:layout_marginTop="7dp"-->
<!--android:layerType="software"-->
<!--android:background="@drawable/expert_search_dash_line" />-->
<!--服务套餐-->
<LinearLayout
android:id="@+id/ll_products"
android:layout_below="@+id/vLine"
android:layout_marginLeft="104dp"
android:layout_marginStart="104dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="104dp"
android:layout_marginLeft="104dp"
android:layout_marginTop="@dimen/platform_dp_5"
android:orientation="vertical"
android:visibility="gone">
......@@ -353,7 +365,10 @@
android:layout_height="@dimen/platform_dp_24"
android:layout_alignBottom="@+id/cvHead"
android:layout_alignParentRight="true"
android:background="@drawable/consultant_expert_search_chat"
android:gravity="center"
android:text="私聊"
android:textColor="@color/consultant_confirm_text_color"
android:textSize="@dimen/platform_dp_13"
android:textStyle="bold"
android:background="@drawable/consultant_expert_search_chat"
......@@ -365,31 +380,33 @@
android:id="@+id/group_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_10"
android:layout_below="@+id/tvChat"
android:layout_toRightOf="@+id/cvHead"
android:layout_marginLeft="@dimen/platform_dp_15"
android:visibility="gone"
android:background="@drawable/consultant_bg_radius_gray_2">
android:layout_marginTop="@dimen/platform_dp_10"
android:layout_toRightOf="@+id/cvHead"
android:background="@drawable/consultant_bg_radius_gray_2"
android:visibility="gone">
<ImageView
android:layout_width="12dp"
android:layout_height="11dp"
android:layout_marginTop="@dimen/platform_dp_6"
android:layout_marginLeft="@dimen/platform_dp_8"
android:src="@drawable/consultant_bg_item_desc"/>
android:layout_marginTop="@dimen/platform_dp_6"
android:src="@drawable/consultant_bg_item_desc" />
<TextView
android:id="@+id/tvDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="8dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="8dp"
android:ellipsize="end"
android:maxLines="2"
tools:text="的客人能够黄偶尔烦人呢日工俄日给你额鞥你让个汇入你哦个人会儿个黄胡蓉呢你个人给哦 而归黑人更换二给"
android:textColor="@color/platform_color_999999"
android:textSize="@dimen/platform_dp_11"/>
android:textSize="@dimen/platform_dp_11"
tools:text="的客人能够黄偶尔烦人呢日工俄日给你额鞥你让个汇入你哦个人会儿个黄胡蓉呢你个人给哦 而归黑人更换二给" />
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="8dp"
android:bottomLeftRadius="8dp"/>
<gradient
android:angle="0"
android:startColor="#CC1DA1F2"
android:endColor="#CC1DA1F2"/>
</shape>
\ No newline at end of file
......@@ -2,13 +2,14 @@ package com.yidianling.home.adapter
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.home.R
import com.yidianling.home.constract.YdlHomeViewHolderConstract
import com.yidianling.home.event.HomeImpl
import com.yidianling.home.event.IHomeEvent
import com.yidianling.home.model.bean.HomeAskBean
import com.yidianling.home.model.bean.HomeConfideBean
import com.yidianling.home.model.bean.HomeConsultBean
......@@ -22,10 +23,13 @@ import com.yidianling.home.ui.view.*
* @Company 壹点灵
* @date 2019/02/13
*/
class YdlHomeAdapter(private val mContext: Context,
private var homeEvent: HomeImpl,
private var list: ArrayList<HomePagerDataBean>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class YdlHomeAdapter(
private val mContext: Context,
private var homeEvent: HomeImpl,
private var list: ArrayList<HomePagerDataBean>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val ffrom = PlatformDataManager.getRam().getChannelName()
private val mInflater: LayoutInflater = LayoutInflater.from(mContext)
/**
* 倾述item的position
......@@ -141,21 +145,45 @@ class YdlHomeAdapter(private val mContext: Context,
when (holder) {
//顶部预约专家,即时倾诉,心理课堂,心理测试按钮模块
is HomeButtonBannerViewHolder -> {
holder.buttonBannerView.initData(list[position].headerBean?.homeSaleData,list[position].headerBean?.askCategoryData)
holder.buttonBannerView.initData(
list[position].headerBean?.homeSaleData,
list[position].headerBean?.askCategoryData
)
}
//倾诉*排解模块
is HomeConfideViewHolder -> {
holder.confideViewView.setTitle(list[position].headerBean?.listenCategoryDate, confideSelectPosition)
holder.confideViewView.setConfideExpertInfoView(list[position].confideBean?.body)
confidePosition = position
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
val parm = holder.itemView.layoutParams
parm.height = 0
holder.itemView.layoutParams = parm
} else {
holder.confideViewView.setTitle(
list[position].headerBean?.listenCategoryDate,
confideSelectPosition
)
holder.confideViewView.setConfideExpertInfoView(list[position].confideBean?.body)
confidePosition = position
}
}
//课程*成长模块
is HomeCourseViewHolder -> {
holder.courseViewView.initData(list[position].courseBean?.list)
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
val parm = holder.itemView.layoutParams
parm.height = 0
holder.itemView.layoutParams = parm
} else {
holder.courseViewView.initData(list[position].courseBean?.list)
}
}
//解忧*问答模块
is HomeAssuageGriefViewHolder -> {
holder.assuageGriefViewView.initData(position, list[position].askBean?.data)
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
val parm = holder.itemView.layoutParams
parm.height = 0
holder.itemView.layoutParams = parm
} else {
holder.assuageGriefViewView.initData(position, list[position].askBean?.data)
}
}
//文章*阅读模块
is HomeArticleViewHolder -> {
......@@ -163,9 +191,22 @@ class YdlHomeAdapter(private val mContext: Context,
}
//咨询模块
is HomeConsultViewHolder -> {
holder.consultView.setTitle(list[position].headerBean?.consultCategoryData, consultSelectPosition)
holder.consultView.setConsultInfoView(list[position].consultBean?.list,list[position].headerBean?.consultCategoryData?.get(consultSelectPosition))
consultPosition = position
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
val parm = holder.itemView.layoutParams
parm.height = 0
holder.itemView.layoutParams = parm
} else {
holder.consultView.setTitle(
list[position].headerBean?.consultCategoryData,
consultSelectPosition
)
holder.consultView.setConsultInfoView(
list[position].consultBean?.list,
list[position].headerBean?.consultCategoryData?.get(consultSelectPosition)
)
consultPosition = position
}
}
//测试模块
is HomeTestViewHolder -> {
......@@ -177,25 +218,30 @@ class YdlHomeAdapter(private val mContext: Context,
override fun getItemCount(): Int {
return list.size
}
/**
* 顶部预约专家,即时倾诉,心理测试按钮模块 ViewHolder
*/
inner class HomeButtonBannerViewHolder(val buttonBannerView: HomeButtonBannerView) : RecyclerView.ViewHolder(buttonBannerView)
inner class HomeButtonBannerViewHolder(val buttonBannerView: HomeButtonBannerView) :
RecyclerView.ViewHolder(buttonBannerView)
/**
* 咨询模块 ViewHolder
*/
inner class HomeConsultViewHolder(val consultView: HomeConsultView) : RecyclerView.ViewHolder(consultView)
inner class HomeConsultViewHolder(val consultView: HomeConsultView) :
RecyclerView.ViewHolder(consultView)
/**
* 倾诉*排解模块 ViewHolder
*/
inner class HomeConfideViewHolder(val confideViewView: HomeConfideView) : RecyclerView.ViewHolder(confideViewView)
inner class HomeConfideViewHolder(val confideViewView: HomeConfideView) :
RecyclerView.ViewHolder(confideViewView)
/**
* 课程*成长模块 ViewHolder
*/
inner class HomeCourseViewHolder(val courseViewView: HomeCourseView) : RecyclerView.ViewHolder(courseViewView)
inner class HomeCourseViewHolder(val courseViewView: HomeCourseView) :
RecyclerView.ViewHolder(courseViewView)
/**
* 测试模块 ViewHolder
......@@ -205,11 +251,14 @@ class YdlHomeAdapter(private val mContext: Context,
/**
* 解忧*问答模块 ViewHolder
*/
inner class HomeAssuageGriefViewHolder(val assuageGriefViewView: HomeAssuageGriefView) : RecyclerView.ViewHolder(assuageGriefViewView)
inner class HomeAssuageGriefViewHolder(val assuageGriefViewView: HomeAssuageGriefView) :
RecyclerView.ViewHolder(assuageGriefViewView)
/**
* 文章*阅读模块 ViewHolder
*/
inner class HomeArticleViewHolder(val articleViewView: HomeArticleView) : RecyclerView.ViewHolder(articleViewView)
inner class HomeArticleViewHolder(val articleViewView: HomeArticleView) :
RecyclerView.ViewHolder(articleViewView)
/**
* 底部提示语模块 ViewHolder
......
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.Color
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
......@@ -42,6 +43,7 @@ class HomeAssuageGriefView(private val mContext: Context, private var homeEvent:
fun initData(position: Int, list: List<HomeAskBean.DataBean>?) {
//添加View
if (list == null) {
visibility = View.GONE
return
}
if (cacheList.size != list?.size) {
......
package com.yidianling.home.ui.view
import android.content.Context
import android.graphics.Color
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.common.tools.RxImageTool
import com.yidianling.home.R
import com.yidianling.home.event.IHomeBaseEvent
......@@ -56,6 +60,36 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
// initButtonView()
val ffrom = PlatformDataManager.getRam().getChannelName()
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
homeModuleButtonBannerThird.visibility = View.GONE
homeModuleButtonBannerSecond.visibility = View.GONE
homeModuleButtonBannerFirst.background =
resources.getDrawable(R.drawable.home_dcotor_bt_bg_huawei)
homeModuleButtonBannerSecond.background =
resources.getDrawable(R.drawable.home_test_bt_bg_hauwei)
homeModuleButtonBannerThird.background =
resources.getDrawable(R.drawable.home_course_bt_bg_huawei)
homeModuleButtonBannerFourth.background =
resources.getDrawable(R.drawable.home_listen_bt_bg_huawei)
homeModuleButtonBannerFirstTitle.setTextColor(Color.WHITE)
tv_first_text.setTextColor(Color.WHITE)
homeModuleButtonBannerFourthTitle.setTextColor(Color.WHITE)
tv_second_text.setTextColor(Color.WHITE)
homeModuleButtonBannerThirdTitle.setTextColor(Color.WHITE)
tv_third_text.setTextColor(Color.WHITE)
homeModuleButtonBannerSecondTitle.setTextColor(Color.WHITE)
tv_fourth_text.setTextColor(Color.WHITE)
homeModuleButtonBannerFirstTitle.textSize = 18f
tv_first_text.textSize = 13f
homeModuleButtonBannerFourthTitle.textSize = 18f
tv_second_text.textSize = 13f
}
homeModuleButtonBannerFirst.setOnClickListener {
homeEvent?.reservationExpertsClick()
}
......@@ -76,8 +110,15 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
homeCategory: List<HomeHeaderBean.AskCategoryDataBean>?
) {
setRealTextView(homeSaleData)
homeEvent?.let { home_category_view.setEvent(it) };
home_category_view.initData(homeCategory)
val ffrom = PlatformDataManager.getRam().getChannelName()
if (!TextUtils.isEmpty(ffrom) && ffrom.endsWith("huawei")) {
home_category_view.visibility = View.GONE
} else {
homeEvent?.let { home_category_view.setEvent(it) }
home_category_view.initData(homeCategory)
}
}
/**
......
......@@ -2,8 +2,10 @@ package com.yidianling.home.ui.view
import android.content.Context
import android.support.constraint.ConstraintLayout
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.home.R
import kotlinx.android.synthetic.xlzx.home_common_title_view.view.*
......@@ -14,7 +16,9 @@ import kotlinx.android.synthetic.xlzx.home_common_title_view.view.*
* @Company 壹点灵
* @date 2019/02/14
*/
class HomeCommonTitleView(private val mContext: Context, private val attributeSet: AttributeSet) : ConstraintLayout(mContext, attributeSet) {
class HomeCommonTitleView(private val mContext: Context, private val attributeSet: AttributeSet) :
ConstraintLayout(mContext, attributeSet) {
private val ffrom = PlatformDataManager.getRam().getChannelName()
init {
initView()
......@@ -26,5 +30,13 @@ class HomeCommonTitleView(private val mContext: Context, private val attributeSe
fun setTitle(title: String) {
homeModuleCommonTitleViewTitle.text = title
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
if (isFromXinliZiXunHuawei) {
view_line.visibility = View.GONE
}
}
}
\ No newline at end of file
package com.yidianling.home.ui.view
import android.content.Context
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.common.tools.RxImageTool
import com.yidianling.home.R
import com.yidianling.home.event.IHomeBaseEvent
......@@ -20,7 +22,7 @@ import kotlinx.android.synthetic.xlzx.home_test_item_view.view.*
*/
class HomeTestItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
LinearLayout(mContext) {
private val ffrom = PlatformDataManager.getRam().getChannelName()
private var params: LinearLayout.LayoutParams? = null
init {
......@@ -35,6 +37,11 @@ class HomeTestItemView(private val mContext: Context, private var homeEvent: IHo
)
layoutParams = params
View.inflate(mContext, R.layout.home_test_item_view, this)
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
if (isFromXinliZiXunHuawei) {
tv_go.visibility = View.GONE
}
}
......
package com.yidianling.home.ui.view
import android.content.Context
import android.text.TextUtils
import android.view.View
import android.widget.LinearLayout
import com.ydl.ydl_image.config.ISimpleImageOpConfig
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.data.PlatformDataManager
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.home.R
......@@ -22,6 +24,7 @@ import kotlinx.android.synthetic.xlzx.home_test_top_item_view.view.*
*/
class HomeTestTopItemView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
LinearLayout(mContext) {
private val ffrom = PlatformDataManager.getRam().getChannelName()
init {
initView()
......@@ -37,6 +40,11 @@ class HomeTestTopItemView(private val mContext: Context, private var homeEvent:
layoutParams = params
View.inflate(mContext, R.layout.home_test_top_item_view, this)
val isFromXinliZiXunHuawei =
!TextUtils.isEmpty(ffrom) && ffrom.startsWith("ATK_7") && ffrom.endsWith("huawei")
if (isFromXinliZiXunHuawei) {
ll_day_test.visibility = View.GONE
}
}
/**
......
......@@ -14,19 +14,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="8dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingBottom="20dp">
android:paddingBottom="12dp">
<RelativeLayout
android:id="@+id/homeModuleButtonBannerFirst"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:background="@drawable/home_dcotor_bt_bg"
android:gravity="center">
......@@ -35,16 +32,17 @@
android:id="@+id/homeModuleButtonBannerFirstTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="预约咨询"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFirstTitle"
android:layout_marginTop="2dp"
android:text="1W+师资"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
......@@ -54,8 +52,7 @@
android:id="@+id/homeModuleButtonBannerFourth"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@drawable/home_listen_bt_bg"
android:gravity="center">
......@@ -64,16 +61,17 @@
android:id="@+id/homeModuleButtonBannerFourthTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="心理测试"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFourthTitle"
android:layout_marginTop="2dp"
android:text="专业权威"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
......@@ -83,27 +81,27 @@
android:id="@+id/homeModuleButtonBannerThird"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@drawable/home_course_bt_bg"
android:gravity="center"
android:orientation="vertical">
>
<TextView
android:id="@+id/homeModuleButtonBannerThirdTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="心理课堂"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerThirdTitle"
android:layout_marginTop="2dp"
android:text="学习与成长"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
......@@ -113,60 +111,35 @@
android:id="@+id/homeModuleButtonBannerSecond"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@drawable/home_test_bt_bg">
android:background="@drawable/home_test_bt_bg"
android:gravity="center">
<TextView
android:id="@+id/homeModuleButtonBannerSecondTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:text="即时倾诉"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<RelativeLayout
<TextView
android:id="@+id/tv_fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/home_button_first_free_bg"
android:paddingLeft="5dp"
android:paddingTop="1dp"
android:paddingRight="5dp"
android:paddingBottom="1dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/homeModuleButtonBannerSecondTitle"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/homeModuleButtonBannerSecondTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="即时倾诉"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerSecondTitle"
android:layout_centerVertical="true"
android:layout_marginTop="2dp"
android:text="专业解忧"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</LinearLayout>
</LinearLayout>
android:text="专业解忧"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_home_module_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="8dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:paddingBottom="12dp"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/homeModuleButtonBannerFirst"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:background="@drawable/home_dcotor_bt_bg"
android:gravity="center_horizontal">
<TextView
android:id="@+id/homeModuleButtonBannerFirstTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="预约咨询"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFirstTitle"
android:text="1W+师资"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/homeModuleButtonBannerFourth"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:background="@drawable/home_listen_bt_bg"
android:gravity="center_horizontal">
<TextView
android:id="@+id/homeModuleButtonBannerFourthTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="心理测试"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerFourthTitle"
android:text="专业权威"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/homeModuleButtonBannerThird"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:background="@drawable/home_course_bt_bg"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/homeModuleButtonBannerThirdTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="心理课堂"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerThirdTitle"
android:text="学习与成长"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/homeModuleButtonBannerSecond"
android:layout_width="0dp"
android:layout_height="78dp"
android:layout_weight="1"
android:background="@drawable/home_test_bt_bg"
android:gravity="center_horizontal">
<TextView
android:id="@+id/homeModuleButtonBannerSecondTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:text="即时倾诉"
android:textColor="@color/platform_black"
android:textSize="@dimen/platform_dp_16"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/homeModuleButtonBannerSecondTitle"
android:layout_centerVertical="true"
android:text="专业解忧"
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_11" />
</RelativeLayout>
</LinearLayout>
<com.yidianling.home.ui.widget.HomeModuleCategoryView
android:id="@+id/home_category_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="@dimen/platform_dp_24"
android:paddingBottom="@dimen/platform_dp_14">
<View
android:layout_width="0dp"
android:layout_height="5dp"
android:background="@drawable/home_common_title_gradient_back"
app:layout_constraintLeft_toLeftOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintRight_toRightOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintBottom_toBottomOf="@+id/homeModuleCommonTitleViewTitle"
android:layout_marginBottom="2dp"/>
<TextView
android:id="@+id/homeModuleCommonTitleViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="@dimen/platform_dp_1"
tools:text="通用.标题"
android:textSize="24dp"
android:textStyle="bold"
android:textColor="@color/platform_color_333333"
android:layout_marginLeft="@dimen/platform_dp_15"
app:layout_constraintLeft_toLeftOf="parent"/>
<LinearLayout
android:layout_width="66dp"
android:layout_height="@dimen/platform_dp_24"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginBottom="@dimen/platform_dp_3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/platform_dp_15"
android:background="@drawable/home_show_more_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="更多"
android:layout_marginLeft="@dimen/platform_dp_2"
android:textColor="@color/platform_color_444444"
android:textSize="13sp"/>
<ImageView
android:layout_height="8dp"
android:layout_width="4dp"
android:src="@drawable/home_sale_arrow"
android:layout_marginLeft="3dp"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:paddingTop="@dimen/platform_dp_24"
android:paddingBottom="@dimen/platform_dp_14">
<View
android:id="@+id/view_line"
android:layout_width="0dp"
android:layout_height="5dp"
android:background="@drawable/home_common_title_gradient_back"
app:layout_constraintLeft_toLeftOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintRight_toRightOf="@+id/homeModuleCommonTitleViewTitle"
app:layout_constraintBottom_toBottomOf="@+id/homeModuleCommonTitleViewTitle"
android:layout_marginBottom="2dp"/>
<TextView
android:id="@+id/homeModuleCommonTitleViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="@dimen/platform_dp_1"
tools:text="通用.标题"
android:textSize="24dp"
android:textStyle="bold"
android:textColor="@color/platform_color_333333"
android:layout_marginLeft="@dimen/platform_dp_15"
app:layout_constraintLeft_toLeftOf="parent"/>
<LinearLayout
android:layout_width="66dp"
android:layout_height="@dimen/platform_dp_24"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginBottom="@dimen/platform_dp_3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="@dimen/platform_dp_15"
android:background="@drawable/home_show_more_line">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="更多"
android:layout_marginLeft="@dimen/platform_dp_2"
android:textColor="@color/platform_color_444444"
android:textSize="13sp"/>
<ImageView
android:layout_height="8dp"
android:layout_width="4dp"
android:src="@drawable/home_sale_arrow"
android:layout_marginLeft="3dp"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
......@@ -81,6 +81,7 @@
</LinearLayout>
<TextView
android:id="@+id/tv_go"
android:layout_width="@dimen/platform_dp_32"
android:layout_height="@dimen/platform_dp_32"
android:background="@drawable/home_test_item_go_bg"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
......@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/home_image_default_back"
android:scaleType="centerCrop"/>
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
......@@ -32,13 +32,13 @@
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="45"/>
android:layout_weight="45" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="55"
android:background="@drawable/home_intelligent_gradient_back"/>
android:background="@drawable/home_intelligent_gradient_back" />
</LinearLayout>
</RelativeLayout>
......@@ -59,8 +59,7 @@
android:textColor="@color/platform_color_FFFFFF"
android:textSize="@dimen/platform_dp_24"
android:textStyle="bold"
tools:text="先结婚还是先买先结婚还是先买房"
/>
tools:text="先结婚还是先买先结婚还是先买房" />
<LinearLayout
android:id="@+id/homeModuleIntelligentTopViewDescLayout"
......@@ -82,19 +81,18 @@
android:textColor="@color/platform_color_444444"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"
tools:text="2486"
/>
tools:text="2486" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="已测"
android:textColor="@color/platform_color_666666"
android:textSize="@dimen/platform_dp_12"
/>
android:textSize="@dimen/platform_dp_12" />
</LinearLayout>
<RelativeLayout
android:id="@+id/ll_day_test"
android:layout_width="@dimen/platform_dp_64"
android:layout_height="@dimen/platform_dp_20"
android:layout_alignParentRight="true"
......@@ -107,7 +105,7 @@
android:text="每日一测"
android:textColor="@color/platform_color_242424"
android:textSize="@dimen/platform_dp_12"
android:textStyle="bold"/>
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
......@@ -43,7 +43,7 @@ interface ImRetrofitApi {
fun getUserType(@Query("targetUid") uid: String): Observable<BaseResponse<UserTypeBean>>
//根据专家uid获取私聊的目标uid(有可能是专家uid,有可能是助理uid)
@GET("doctor/chat-user")
@GET("consult/assistant/chat-user")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun getChatUid(@Query("doctorUid") uid: String): Observable<BaseAPIResponse<DoctorAssistantRespDtoBean>>
......
......@@ -36,6 +36,7 @@ import com.yidianling.im.session.action.SendCardAction;
import com.yidianling.im.session.action.TeamAVChatAction;
import com.yidianling.im.session.extension.CustomAttachChatTipMsg;
import com.yidianling.im.session.extension.CustomAttachConsult;
import com.yidianling.im.session.extension.CustomAttachConsultCallStatus;
import com.yidianling.im.session.extension.CustomAttachConsultPerfectData;
import com.yidianling.im.session.extension.CustomAttachConsultSubScript;
import com.yidianling.im.session.extension.CustomAttachModifyTime;
......@@ -64,6 +65,7 @@ import com.yidianling.im.session.extension.StickerAttachment;
import com.yidianling.im.session.viewholder.MsgViewHolderAVChat;
import com.yidianling.im.session.viewholder.MsgViewHolderChatTip;
import com.yidianling.im.session.viewholder.MsgViewHolderConsult;
import com.yidianling.im.session.viewholder.MsgViewHolderConsultCallStatus;
import com.yidianling.im.session.viewholder.MsgViewHolderConsultSubScribe;
import com.yidianling.im.session.viewholder.MsgViewHolderCustomTip;
import com.yidianling.im.session.viewholder.MsgViewHolderCustomerServiceCard;
......@@ -412,6 +414,7 @@ public class SessionHelper {
NimUIKit.registerMsgItemViewHolder(CustomAttachPleaseSubscribeConsultDate.class, MsgViewHolderPleaseSubscribeConsultDate.class);//请预约咨询时间
NimUIKit.registerMsgItemViewHolder(CustomCustomerServiceCardAttachment.class, MsgViewHolderCustomerServiceCard.class);//客服小壹名片
NimUIKit.registerMsgItemViewHolder(CustomAttachmentShareMsg.class, MsgViewHolderShareMsg.class);//分享推送
NimUIKit.registerMsgItemViewHolder(CustomAttachConsultCallStatus.class, MsgViewHolderConsultCallStatus.class);//咨询声网的拨打状态
}
private static void setSessionListener() {
......
package com.yidianling.im.session.extension;
import com.alibaba.fastjson.JSONObject;
/**
* Created by Wi1ls on 2016/11/28;
*/
public class CustomAttachConsultCallStatus extends CustomAttachment{
private final String KEY_STATUS="status";
private final String KEY_CALLER="caller";
private final String KEY_CALLEE="callee";
private final String KEY_DURATION="duration";
private String status;
private String caller;
private String callee;
private String duration;
public CustomAttachConsultCallStatus() {
super(CustomAttachmentType.TYPE_CUSTOMER_CONSULT_CALL_STATUS);
}
@Override
protected void parseData(JSONObject data) {
this.status=data.getString(KEY_STATUS);
this.caller=data.getString(KEY_CALLER);
this.callee=data.getString(KEY_CALLEE);
this.duration=data.getString(KEY_DURATION);
}
@Override
protected JSONObject packData() {
JSONObject data = new JSONObject();
data.put(KEY_STATUS,status);
data.put(KEY_CALLER, caller);
data.put(KEY_CALLEE, callee);
data.put(KEY_DURATION, duration);
return data;
}
public String getStatus() {
return status;
}
public String getCaller() {
return caller;
}
public String getCallee() {
return callee;
}
public String getDuration() {
return duration;
}
}
......@@ -111,6 +111,10 @@ public class CustomAttachParser implements MsgAttachmentParser {
//分享消息,倾诉推荐,课程,测评,文章
attachment = new CustomAttachmentShareMsg();
break;
case CustomAttachmentType.TYPE_CUSTOMER_CONSULT_CALL_STATUS:
//咨询的声网拨打状态的自定义消息
attachment = new CustomAttachConsultCallStatus();
break;
default:
attachment = new DefaultCustomAttachment();
break;
......
......@@ -33,4 +33,5 @@ public interface CustomAttachmentType {
int TYPE_PLEASE_SUBSCRIBE_CONSULT_DATE = 29;//请预约咨询时间
int TYPE_PUSH_SHARE = 30;// 分享,倾诉推荐,课程,测评,文章
int TYPE_CUSTOMER_SERVICE = 31; //客服名片
int TYPE_CUSTOMER_CONSULT_CALL_STATUS = 32; //咨询的声网拨打状态的自定义消息
}
package com.yidianling.im.session.viewholder;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.yidianling.im.R;
import com.yidianling.im.session.extension.CustomAttachConsultCallStatus;
import com.yidianling.nimbase.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yidianling.uikit.business.session.viewholder.MsgViewHolderBase;
/**
* Created by zhoujianghua on 2015/8/6.
*/
public class MsgViewHolderConsultCallStatus extends MsgViewHolderBase {
private ImageView typeImage;
private TextView statusLabel;
public MsgViewHolderConsultCallStatus(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
@Override
protected int getContentResId() {
return R.layout.im_ui_message_custom_consult_call_status;
}
@Override
protected void inflateContentView() {
typeImage = findViewById(R.id.type_img);
statusLabel = findViewById(R.id.tv_state);
}
@Override
protected void bindContentView() {
CustomAttachConsultCallStatus customAttachTipMsg = (CustomAttachConsultCallStatus) message.getAttachment();
layoutByDirection(customAttachTipMsg);
}
private void layoutByDirection(CustomAttachConsultCallStatus customAttachTipMsg) {
if (isReceivedMessage()) {
typeImage.setImageResource(R.drawable.im_avchat_left_type_audio);
statusLabel.setTextColor(context.getResources().getColor(R.color.platform_color_grey_999999));
} else {
typeImage.setImageResource(R.drawable.im_avchat_right_type_audio);
statusLabel.setTextColor(Color.WHITE);
}
if (TextUtils.equals("1", customAttachTipMsg.getStatus())) {
typeImage.setVisibility(View.VISIBLE);
statusLabel.setText(customAttachTipMsg.getDuration());
} else {
typeImage.setVisibility(View.GONE);
if (isReceivedMessage()) {
statusLabel.setText(customAttachTipMsg.getCallee());
} else {
statusLabel.setText(customAttachTipMsg.getCaller());
}
}
}
}
......@@ -11,6 +11,9 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.ydl.ydlcommon.data.http.RxUtils;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.common.tools.ToastUtil;
import com.yidianling.im.R;
import com.yidianling.nimbase.api.model.session.SessionCustomization;
import com.yidianling.nimbase.business.preference.UserPreferences;
......@@ -20,10 +23,16 @@ import com.yidianling.nimbase.common.util.sys.ScreenUtil;
import com.yidianling.uikit.business.session.fragment.YDLMessageFragment;
import com.yidianling.uikit.custom.bridge.ActionHandlerStorage;
import com.yidianling.uikit.custom.bridge.IP2PCustomActionHandler;
import com.yidianling.uikit.custom.http.ServiceImpl;
import com.yidianling.uikit.custom.widget.TitleBarBottom;
import java.net.URLEncoder;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by zhoujianghua on 2015/9/10.
*/
......
......@@ -82,11 +82,11 @@ import com.yidianling.uikit.custom.bridge.ActionHandlerStorage;
import com.yidianling.uikit.custom.bridge.IP2PCustomActionHandler;
import com.yidianling.uikit.custom.http.ServiceImpl;
import com.yidianling.uikit.custom.http.response.CommonQuestionBean;
import com.yidianling.uikit.custom.http.response.NewUserMesBean;
import com.yidianling.uikit.custom.http.response.SubmitUserInfoBean;
import com.yidianling.uikit.custom.http.response.UserQuestInfoBean;
import com.yidianling.uikit.custom.widget.ConfideOrderInfoView;
import com.yidianling.uikit.custom.widget.ExpertInfoDialog;
import com.yidianling.uikit.custom.widget.TitleBarBottom;
import com.yidianling.uikit.custom.widget.expertConsultService.view.ExpertConsultServiceListDialog;
import com.yidianling.user.api.service.IUserService;
......@@ -197,6 +197,14 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private String server_num;// 服务时长
private String good_num;// 好评率
private int userInfoDialogAge = 0;
private String userInfoDialogSex = "";
private String userInfoDialogConsultType = "";
private String userInfoDialogQuestionDes = "";
private String userInfoDialogSourceFrom = "";
private UserInfoDialog userInfoDialog = null;
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
......@@ -409,6 +417,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}, throwable -> {
});
if (ActionHandlerStorage.getL(sessionId) != null && ActionHandlerStorage.getL(sessionId).getUserType() == 1 && ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 3) {
//获取来源的专家
ServiceImpl.Companion.getInstance().getSourceDoctor(ActionHandlerStorage.getL(sessionId).getInfo().toUid, ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUid())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -416,6 +425,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
if (TextUtils.equals(res.code, "200") && res.data != null && !TextUtils.isEmpty(res.data.name)) {
addSourceLayoutScrollListener();
rl_doctor_name.setVisibility(View.VISIBLE);
tv_doctor_name.setText(res.data.name);
} else {
rl_doctor_name.setVisibility(View.GONE);
......@@ -425,13 +435,24 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
});
}
if (ActionHandlerStorage.getL(sessionId) != null && ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 1) {
if (TextUtils.isEmpty(SharedPreferencesEditor.getString("chat_age_ensure_" + ImIn.INSTANCE.getUserInfo().getUid()))) {
ServiceImpl.Companion.getInstance().getNewUserMes()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
if (hasCollectedInResp.data != null && hasCollectedInResp.data.size() > 0) {
String targetUid = "";
if (ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 1) {
//自己是用戶,搜索的是自己的信息
targetUid = ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUid();
} else if (ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 3) {
// 自己是助理,搜索的是对方(用户)的信息
if (ActionHandlerStorage.getL(sessionId) != null) {
targetUid = ActionHandlerStorage.getL(sessionId).getInfo().toUid;
}
}
ServiceImpl.Companion.getInstance().getNewUserMes(new NewUserMesBean(targetUid))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
if (hasCollectedInResp.data != null && hasCollectedInResp.data.size() > 0) {
if (ActionHandlerStorage.getL(sessionId) != null && ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 1) {
if (TextUtils.isEmpty(SharedPreferencesEditor.getString("chat_age_ensure_" + ImIn.INSTANCE.getUserInfo().getUid()))) {
for (UserQuestInfoBean bean : hasCollectedInResp.data) {
if (TextUtils.equals(bean.getUserInfoType(), "age")) {
try {
......@@ -447,10 +468,62 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
}
}
}
}, throwable -> {
});
}
}
// 如果对方是用户,自己是助理,则展示标题文本右侧icon,并设置点击事件,展示用户信息弹窗
if (ActionHandlerStorage.getL(sessionId).getUserType() == 1 && ModularServiceManager.INSTANCE.provide(IUserService.class).getUserInfo().getUser_type() == 3) {
if (null == userInfoDialog) {
for (UserQuestInfoBean bean : hasCollectedInResp.data) {
if (TextUtils.equals(bean.getUserInfoType(), "age")) {
try {
String year = bean.getContent();
userInfoDialogAge = Calendar.getInstance().get(Calendar.YEAR) - Integer.valueOf(year);
} catch (Exception e) { }
} else if (TextUtils.equals(bean.getUserInfoType(), "gener")) {
try {
userInfoDialogSex = bean.getContent();
} catch (Exception e) { }
}else if (TextUtils.equals(bean.getUserInfoType(), "questionType")) {
try {
userInfoDialogConsultType = bean.getContent();
} catch (Exception e) { }
}else if (TextUtils.equals(bean.getUserInfoType(), "questionContent")) {
try {
userInfoDialogQuestionDes = bean.getContent();
} catch (Exception e) { }
}
}
getSourceFrom();
}
}
}
}, throwable -> {
Log.i("user/getNewUserMes", throwable.toString());
});
}
@SuppressLint("CheckResult")
private void getSourceFrom() {
//获取私聊对象的uid,调用接口获取来源
String targetUid = ActionHandlerStorage.getL(sessionId).getInfo().toUid;
ServiceImpl.Companion.getInstance().getUserSourceFrom(targetUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(res -> {
if (!TextUtils.isEmpty(res.data)) {
userInfoDialogSourceFrom = res.data;
}
});
}
public void showUserInfoDialog() {
if (userInfoDialog != null) {
userInfoDialog.dismiss();
}
userInfoDialog = new UserInfoDialog(getActivity(), userInfoDialogSourceFrom, String.valueOf(userInfoDialogAge), userInfoDialogSex, userInfoDialogConsultType, userInfoDialogQuestionDes);
userInfoDialog.show();
}
private void addScrollListener() {
......@@ -1294,7 +1367,7 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resp -> {
if (resp.data != null && resp.data.size() > 0) {
ServiceImpl.Companion.getInstance().getNewUserMes()
ServiceImpl.Companion.getInstance().getNewUserMes(new NewUserMesBean(""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(hasCollectedInResp -> {
......@@ -1328,13 +1401,14 @@ public class YDLMessageFragment extends TFragment implements ModuleProxy {
private void showCheckAgeDialog() {
CommonDialog.create(getActivity())
.setLeftOnclick("返回", v -> {
.setLeftOnclick("返回", v -> {
getActivity().finish();
ActionCountUtils.Companion.count("under_age_alert_page|under_age_alert_return_click");
})
.setRightClick("继续", v -> {
SharedPreferencesEditor.putString("chat_age_ensure_" + ImIn.INSTANCE.getUserInfo().getUid(), "ensure");
ActionCountUtils.Companion.count("under_age_alert_page|under_age_alert_continue_clcik");})
ActionCountUtils.Companion.count("under_age_alert_page|under_age_alert_continue_clcik");
})
.setMessage("由于您未满16周岁,如需咨询需要在家长陪同下进行")
.setCancelAble(false)
.show();
......
package com.yidianling.uikit.business.session.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;
import com.yidianling.im.R;
public class MaxHeightScrollView extends ScrollView {
private int mMaxHeight;
public MaxHeightScrollView(Context context) {
super(context);
}
public MaxHeightScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public MaxHeightScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaxHeightScrollView);
mMaxHeight = typedArray.getLayoutDimension(R.styleable.MaxHeightScrollView_maxHeight, mMaxHeight);
typedArray.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mMaxHeight > 0) {
heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(mMaxHeight, View.MeasureSpec.AT_MOST);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
......@@ -52,7 +52,12 @@ interface ServiceApi {
//获取新用户收集的信息
@POST("user/getNewUserMes")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getNewUserMes(): Observable<BaseAPIResponse<List<UserQuestInfoBean>>>
fun getNewUserMes(@Body body: RequestBody): Observable<BaseAPIResponse<List<UserQuestInfoBean>>>
//获取用户来源的信息
@GET("user/getExChannel")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getUserSource(@Query("uid") uid: String): Observable<BaseAPIResponse<String>>
//信息采集的问题
@POST("user/collect/submit")
......
package com.yidianling.uikit.custom.http
import com.alibaba.fastjson.JSON
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.uikit.custom.http.response.*
......@@ -66,8 +67,20 @@ class ServiceImpl private constructor() {
/**
* 获取新用户收集的信息
*/
fun getNewUserMes(): Observable<BaseAPIResponse<List<UserQuestInfoBean>>> {
return YDLHttpUtils.obtainApi(ServiceApi::class.java).getNewUserMes()
fun getNewUserMes(bean: NewUserMesBean): Observable<BaseAPIResponse<List<UserQuestInfoBean>>> {
val beanStr = JSON.toJSONString(bean)
val body = RequestBody.create(
MediaType.parse("application/json; charset=utf-8"),
beanStr
) as RequestBody
return YDLHttpUtils.obtainApi(ServiceApi::class.java).getNewUserMes(body)
}
/**
* 获取用户来源
*/
fun getUserSourceFrom(uid: String): Observable<BaseAPIResponse<String>> {
return YDLHttpUtils.obtainApi(ServiceApi::class.java).getUserSource(uid)
}
/**
......
package com.yidianling.uikit.custom.http.response
class NewUserMesBean(val targetUid: String)
\ No newline at end of file
......@@ -36,7 +36,6 @@ public class ConfideOrderInfoView extends RelativeLayout {
private String mSessionId;
private IP2PCustomActionHandler.DocInfo info = null;
private TextView tv_status = null;
private TextView tv_tips = null;
private TextView tv_action = null;
private TextView tv_order_info = null;
private ImageView iv_call = null;
......@@ -61,7 +60,6 @@ public class ConfideOrderInfoView extends RelativeLayout {
View.inflate(mContext, R.layout.im_nim_chat_confide_order_info_view, this);
setBackground(getResources().getDrawable(R.drawable.im_bg_im_confide_action));
tv_status = findViewById(R.id.tv_status);
tv_tips = findViewById(R.id.tv_tips);
tv_action = findViewById(R.id.tv_action);
iv_call = findViewById(R.id.iv_call);
tv_order_info = findViewById(R.id.tv_order_info);
......@@ -78,7 +76,6 @@ public class ConfideOrderInfoView extends RelativeLayout {
//有未完成订单
if (info.hasAvailableListenOrder == 2) {
tv_status.setText("剩余时间:" + coverTime(Integer.valueOf(info.listenOrderRemainTime)));
tv_tips.setVisibility(View.GONE);
if (info.is_online == 3) { //通话中
......@@ -98,7 +95,6 @@ public class ConfideOrderInfoView extends RelativeLayout {
tv_action.setBackground(getResources().getDrawable(R.drawable.im_background_chat_confide_order_action));
tv_action.setTextColor(getResources().getColor(R.color.platform_but_text_color));
tv_action.setText("去评价");
tv_tips.setVisibility(View.VISIBLE);
}
tv_order_info.setText(info.listenOrderDesc);
}
......
......@@ -21,7 +21,7 @@ import com.yidianling.im.R;
public class TitleBarBottom extends RelativeLayout {
TextView tv_left_text, tv_center_title, tv_bottom_title, tv_right_text;
ImageView iv_title_divide, image, rightImage;
ImageView iv_title_divide, image, rightImage, title_tv_right_btn;
private View root;
......@@ -59,10 +59,20 @@ public class TitleBarBottom extends RelativeLayout {
iv_title_divide = (ImageView) root.findViewById(R.id.iv_title_divide);
image = (ImageView) root.findViewById(R.id.image);
rightImage = (ImageView) root.findViewById(R.id.iv_right);
title_tv_right_btn = (ImageView) root.findViewById(R.id.title_tv_right_btn);
setupView();
}
/**
* 设置标题文本右侧icon
*/
public void setTitleTextRightIcon(int resId, OnClickListener onClickListener) {
title_tv_right_btn.setImageResource(resId);
title_tv_right_btn.setVisibility(View.VISIBLE);
title_tv_right_btn.setOnClickListener(onClickListener);
}
/**
* 左侧文字点击事件
*/
public void setOnLeftTextClick(OnTitleBarTextClick leftTextClick) {
......
package com.yidianling.uikit.custom.widget
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import com.yidianling.im.R
import kotlinx.android.synthetic.main.im_user_info_dialog_layout.*
/**
* 用户信息弹窗
* Created by xj on 2020/3/25.
*/
class UserInfoDialog(
private val mContext: Context,
private val sourceFrom: String, //来源
private val age: String, //年龄
private val sex: String, //性别
private val consultType: String, //咨询类型
private val questionDes: String //问题描述
) : Dialog(mContext, R.style.dialog_default_style) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.im_user_info_dialog_layout)
val params = window.attributes
params.width = WindowManager.LayoutParams.MATCH_PARENT
params.height = WindowManager.LayoutParams.WRAP_CONTENT
window.setGravity(Gravity.CENTER)
window.attributes = params
if (!TextUtils.isEmpty(sourceFrom)) {
user_info_dialog_sourceFrom.visibility = View.VISIBLE
user_info_dialog_sourceFrom_tv.text = sourceFrom
}
user_info_dialog_age_tv.text = age
user_info_dialog_sex_tv.text = sex
user_info_dialog_consultType_tv.text = consultType
user_info_dialog_questionDes_tv.text = questionDes
user_info_dialog_close.setOnClickListener {
if (null != mContext) {
dismiss()
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="6dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/type_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3dp"
android:layout_marginRight="8dp"
android:contentDescription="@string/im_empty"
android:src="@drawable/im_avchat_left_type_audio"/>
<TextView
android:id="@+id/tv_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
android:text="无人接听"
android:textColor="@color/im_color_grey_999999"
android:textSize="14sp"/>
</LinearLayout>
......@@ -134,5 +134,9 @@
<!-- 指定消失的动画xml -->
</style>
<declare-styleable name="MaxHeightScrollView">
<attr name="maxHeight" format="dimension" />
</declare-styleable>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@color/platform_white"/>
</shape>
\ No newline at end of file
......@@ -70,20 +70,4 @@
tools:background="@drawable/im_background_chat_confide_order_action"
tools:text="去评价" />
<TextView
android:id="@+id/tv_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/im_background_chat_confide_order_tpis"
android:paddingLeft="5dp"
android:paddingTop="1dp"
android:paddingRight="5dp"
android:paddingBottom="1dp"
android:text="最高返30元红包"
android:textColor="@color/im_white"
android:textSize="9sp"
android:visibility="gone" />
</merge>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@null"
android:gravity="center_vertical" />
<TextView
android:id="@+id/tv_left_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toEndOf="@id/image"
android:layout_toRightOf="@id/image"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@android:color/white"
android:textSize="@dimen/platform_default_text_size_big"
tools:text="关闭"
tools:textColor="@color/platform_black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:layout_marginBottom="3dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_center_title"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:ellipsize="end"
android:gravity="center"
android:maxEms="12"
android:maxLength="12"
android:textColor="@color/im_color_242424"
android:textSize="17dp"
tools:text="现现现现现现在在现在在在在现在在" />
<TextView
android:id="@+id/tv_bottom_title"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:drawablePadding="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxEms="12"
android:maxLength="8"
android:textColor="@color/platform_color_666666"
android:textSize="10dp"
tools:drawableLeft="@drawable/im_background_chat_top_status_online"
tools:text="现在" />
</LinearLayout>
<ImageView
android:id="@+id/iv_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@null"
android:gravity="center_vertical"
tools:src="@drawable/platform_more_green"/>
<TextView
android:id="@+id/tv_right_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/iv_right"
android:layout_toStartOf="@id/iv_right"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="@color/platform_main_theme"
android:textSize="@dimen/platform_default_text_size_big"
android:drawablePadding="5dp"
tools:drawableLeft="@drawable/platform_share"
tools:ignore="RelativeOverlap" />
<ImageView
android:id="@+id/iv_title_divide"
android:layout_width="match_parent"
android:layout_height="@dimen/im_divide_line_stroke_width"
android:layout_alignParentBottom="true"
android:background="@color/im_divide_color" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@null"
android:gravity="center_vertical" />
<TextView
android:id="@+id/tv_left_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toEndOf="@id/image"
android:layout_toRightOf="@id/image"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@android:color/white"
android:textSize="@dimen/platform_default_text_size_big"
tools:text="关闭"
tools:textColor="@color/platform_black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:layout_marginBottom="3dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_center_title"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:ellipsize="end"
android:gravity="center"
android:maxEms="12"
android:maxLength="12"
android:textColor="@color/im_color_242424"
android:textSize="17dp"
tools:text="现现现现现现在在现在在在在现在在" />
<TextView
android:id="@+id/tv_bottom_title"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:drawablePadding="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxEms="12"
android:maxLength="8"
android:textColor="@color/platform_color_666666"
android:textSize="10dp"
tools:drawableLeft="@drawable/im_background_chat_top_status_online"
tools:text="现在" />
</LinearLayout>
<ImageView
android:id="@+id/title_tv_right_btn"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="3dp"
android:src="@drawable/im_star_red"
android:layout_marginLeft="4dp"
android:layout_gravity="center"
android:visibility="gone"/>
</LinearLayout>
<ImageView
android:id="@+id/iv_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@null"
android:gravity="center_vertical"
tools:src="@drawable/platform_more_green" />
<TextView
android:id="@+id/tv_right_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toStartOf="@id/iv_right"
android:layout_toLeftOf="@id/iv_right"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:textColor="@color/platform_main_theme"
android:textSize="@dimen/platform_default_text_size_big"
tools:drawableLeft="@drawable/platform_share"
tools:ignore="RelativeOverlap" />
<ImageView
android:id="@+id/iv_title_divide"
android:layout_width="match_parent"
android:layout_height="@dimen/im_divide_line_stroke_width"
android:layout_alignParentBottom="true"
android:background="@color/im_divide_color" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp">
<LinearLayout
android:id="@+id/dialog_user_detail_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/im_user_info_dialog_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="30dp"
android:paddingRight="20dp"
android:paddingBottom="21dp">
<RelativeLayout
android:id="@+id/user_info_dialog_sourceFrom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="31dp"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="推广来源"
android:textSize="15dp"
android:textColor="@color/platform_color_666666"/>
<TextView
android:id="@+id/user_info_dialog_sourceFrom_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="SEM"
android:layout_alignParentRight="true"
android:textSize="15dp"
android:textColor="@color/platform_color_242424"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="31dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="年龄"
android:textSize="15dp"
android:textColor="@color/platform_color_666666"/>
<TextView
android:id="@+id/user_info_dialog_age_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="18"
android:layout_alignParentRight="true"
android:textSize="15dp"
android:textColor="@color/platform_color_242424"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="31dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别"
android:textSize="15dp"
android:textColor="@color/platform_color_666666"/>
<TextView
android:id="@+id/user_info_dialog_sex_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="男"
android:layout_alignParentRight="true"
android:textSize="15dp"
android:textColor="@color/platform_color_242424"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="31dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="咨询类型"
android:textSize="15dp"
android:textColor="@color/platform_color_666666"/>
<TextView
android:id="@+id/user_info_dialog_consultType_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="恋爱情感"
android:layout_alignParentRight="true"
android:textSize="15dp"
android:textColor="@color/platform_color_242424"/>
</RelativeLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp">
<TextView
android:id="@+id/user_info_dialog_questionDes_left_tv"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:text="问题描述"
android:maxLines="1"
android:textSize="15dp"
android:textColor="@color/platform_color_666666"/>
<com.yidianling.uikit.business.session.view.MaxHeightScrollView
android:layout_marginLeft="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
app:maxHeight="150dp">
<TextView
android:gravity="left"
android:id="@+id/user_info_dialog_questionDes_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="我是描述"
android:textSize="15dp"
android:textColor="@color/platform_color_242424"/>
</com.yidianling.uikit.business.session.view.MaxHeightScrollView>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/im_main_theme"
android:text="*涉及用户隐私,请谨慎使用上述信息*"
android:textSize="12dp"/>
</LinearLayout>
<ImageView
android:id="@+id/user_info_dialog_close"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_below="@+id/dialog_user_detail_bg"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="@drawable/im_expert_info_dialog_close_icon" />
</RelativeLayout>
......@@ -198,7 +198,8 @@ interface UserApi {
fun getFocusData(@Query("parentId") parentId: String = "0"): Observable<BaseAPIResponse<List<CollectFocusItemBean>>>
//获取新用户引导页面url
@FormUrlEncoded
@POST("user/getNewUserJumpUrl")
@Headers( YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun getNewUserJumpUrl(): Observable<BaseAPIResponse<String>>
fun getNewUserJumpUrl(@FieldMap params: Map<String, String>): Observable<BaseAPIResponse<String>>
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.google.gson.internal.LinkedTreeMap
import com.umeng.socialize.bean.SHARE_MEDIA
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseCommand
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.router.YdlCommonOut
......@@ -215,7 +216,8 @@ class UserHttpImpl private constructor() : UserHttp {
}
override fun getNewUserJumpUrl(): Observable<BaseAPIResponse<String>> {
return getUserApi().getNewUserJumpUrl()
return RxUtils.mapObservable(BaseCommand())
.flatMap { getUserApi().getNewUserJumpUrl(it) }
}
private object Holder {
......
......@@ -11,7 +11,6 @@ import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.GsonProvider
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.YdlBuryPointUtil
......@@ -45,6 +44,7 @@ class YDLCommonPlugin : MethodChannel.MethodCallHandler {
var pluginDelegate:CommonPluginDelegate?=null
const val CHANNEL: String = "lib/common/channel"
const val GETPUBLICPARAMAS: String = "getPublicParamas"
const val GET_PACKAGE_AND_FFROM: String = "get_package_and_ffrom" // 获取包名和渠道名,中间用,分割
const val ACTION_PUSH_EVENT_TRACKING_TAP: String = "action_push_event_tracking_tap"// 点击事件埋点
const val ACTION_PUSH_EVENT_TRACKING_PV: String = "action_push_event_tracking_pv"//pv埋点
const val ACTION_ORIGIN_THEME: String = "platform_origin_theme"//马甲包获取应用各个主题色的action
......@@ -175,6 +175,11 @@ class YDLCommonPlugin : MethodChannel.MethodCallHandler {
)
)
}
GET_PACKAGE_AND_FFROM -> {
val packageName = YdlCommonOut.getApp().packageName
val ffrom = PlatformDataManager.getRam().getChannelName()
result.success("$packageName,$ffrom")
}
}
}
......
......@@ -102,6 +102,32 @@ abstract class BaseActivity : AppCompatActivity(), IActivityLifecycleable {
}
}
/**
* 设置底部抬高的布局的颜色
*/
open fun setBottomColor(color: String) {
try {
if (getStatusViewOptions()?.isAddStatusView) {
if (StatusBarUtils.hasBottomNavigatorLine(this)) {
findViewById<View>(R.id.ll_bottom_v).setBackgroundColor(
Color.parseColor(
color
)
)
}
} else {
if (StatusBarUtils.hasBottomNavigatorLine(this)) {
findViewById<View>(R.id.ll_bottom_fit_v).setBackgroundColor(
Color.parseColor(
color
)
)
}
}
} catch (e: Exception) {
}
}
open fun getDefaultBottomColor(): Int {
return Color.parseColor("#00000000")
}
......
......@@ -154,6 +154,8 @@ class LogHelper private constructor() {
val yunxinLog = getYunXinLog(BaseApp.getApp())
//声网日志
val agoraLog = getAgoraLog(BaseApp.getApp())
val agoraRtmLog = getAgoraRTMLog(BaseApp.getApp())
val agoraRtmBackLog = getAgoraRtmBackLog(BaseApp.getApp())
if (zipFile.exists()) zipFile.delete()
zipFile.createNewFile()
......@@ -167,6 +169,12 @@ class LogHelper private constructor() {
if (agoraLog.exists()) {
files.add(agoraLog)
}
if (agoraRtmLog.exists()) {
files.add(agoraRtmLog)
}
if (agoraRtmBackLog.exists()) {
files.add(agoraRtmBackLog)
}
// ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true)
ZipUtils.toZip(files, FileOutputStream(zipFile))
......@@ -226,10 +234,27 @@ class LogHelper private constructor() {
//获取声网日志
private fun getAgoraLog(context: Context): File {
val agora = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorasdk.log"
return File(agora)
// val agora = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorasdk.log"
val filePath = context.getExternalFilesDir(null).path + "/agorasdk.log"
return File(filePath)
}
//获取RTM日志
private fun getAgoraRTMLog(context: Context): File {
val agoraRTMLog = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorartm.log"
return File(agoraRTMLog)
}
//获取RTM备份日志
private fun getAgoraRtmBackLog(context: Context): File {
val agoraRTMLog = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorartm_1.log"
return File(agoraRTMLog)
}
private object Holder {
val INSTANCE = LogHelper()
}
......
......@@ -44,6 +44,8 @@ class H5JsBean {
var orderStatus: Int = 0
var orderStatusDesc: String? = null
var bottomfitViewColor: String? = null //底部适配布局的颜色
var orderContent: String? = null//默认发送的第一天聊天
var action_name: String? = null
......
......@@ -17,7 +17,6 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.ValueCallback;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
......@@ -28,6 +27,7 @@ import com.tencent.smtt.export.external.interfaces.JsResult;
import com.tencent.smtt.export.external.interfaces.SslError;
import com.tencent.smtt.export.external.interfaces.SslErrorHandler;
import com.tencent.smtt.sdk.CookieSyncManager;
import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
......@@ -557,6 +557,12 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
});
}
public void setBottomViewColor(String color) {
runOnUiThread(() -> {
setBottomColor(color);
});
}
public void showTitleBar() {
runOnUiThread(() -> {
tb_title.setVisibility(VISIBLE);
......@@ -1280,6 +1286,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
* 新用户侧滑按钮限制
*/
if (h5Params.getBackLimit() != null && h5Params.getBackLimit() == H5Params.BackLimit.NEW_USER_PAGE) {
ModularServiceManager.INSTANCE.provide(IAppService.class).mainIntent(this);
return true;
}
......
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