Commit 268dc798 by 刘鹏

feat :入口优化

parent b8c73b1a
......@@ -51,7 +51,6 @@ import com.yidianling.uikit.custom.http.response.RecommendExpertBean
import com.yidianling.uikit.custom.widget.TitleBarBottom
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import retrofit2.HttpException
import java.net.URLEncoder
......@@ -127,14 +126,11 @@ object IMChatUtil {
* */
private fun isJumpToIm(skip_time: Long): Boolean {
val time = System.currentTimeMillis()
val skipTime = SharedPreferencesEditor.getString("skip_time_")
if (skipTime == null || skipTime.isEmpty()) {
return false
}
val timeDifference = (time - skipTime.toLong()) / 1000
return timeDifference < skip_time
}
......@@ -146,7 +142,6 @@ object IMChatUtil {
*/
@SuppressLint("CheckResult")
fun startChat(context: AppCompatActivity?, chatItemBean: ChatItemBean) {
if (context == null || (!isLogin(context, true))) {
return
}
......@@ -160,25 +155,25 @@ object IMChatUtil {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ res: BaseResponse<UserTypeBean> ->
if (res.code == 200 && res.data != null) {
if (res.data!!.collectEvent && TextUtils.equals(
res.data!!.userType,
USER_TYPE_ASSISTANT.toString()
)
) {
if (res.code == 200 && res.data != null && TextUtils.equals(
res.data!!.userType,
USER_TYPE_ASSISTANT.toString()
)
) {
if (TextUtils.equals(res.data!!.userType, USER_TYPE_ASSISTANT.toString())) {
//和助理私聊需要打开信息采集弹窗
prepareAssistantChatData(
context,
chatItemBean.toUid.toString(),
object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) { //新前置信息收集入口
override fun onSuccess(expertInfo: IMExpertBuild) {
//新前置信息收集入口
ImRetrofitApi.Companion.getImRetrofitApi()
.getSystemConfigByKeyword("lx_collect_card_config")
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe ({
.subscribe({
val skipTime = it.value1.toLong()
if (isJumpToIm(skipTime)) {
SessionHelper.startP2PSession(
......@@ -188,13 +183,14 @@ object IMChatUtil {
null,
P2PCustomActionHandlerImpl(chatItemBean)
)
}else{
} else {
CmsExamQuestionPaperActivity.start(
context, chatItemBean.toUid.toString(), expertInfo,
0, it.value1
context,
chatItemBean.toUid.toString(),
expertInfo, 0
)
}
},{
}, {
SessionHelper.startP2PSession(
context,
chatItemBean.utype,
......@@ -240,8 +236,79 @@ object IMChatUtil {
P2PCustomActionHandlerImpl(chatItemBean)
)
})
}
/**
* 非私聊列表进入,前置数据请求
* */
@SuppressLint("CheckResult")
fun startCms(context: AppCompatActivity, toUid: String, isFromQingShu: Int) {
if (!isLogin(context, true)) {
return
}
if (loadingDialog == null) {
loadingDialog = newInstance(null)
}
if (context.supportFragmentManager != null && !context.isDestroyed) {
loadingDialog?.show(context.supportFragmentManager, null)
}
ImRetrofitApi.Companion.getImRetrofitApi()
.getSystemConfigByKeyword("lx_collect_card_config")
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
//请求接口获取 前置信息收集间隔时间
val skipTime = it.value1.toLong()
if (isJumpToIm(skipTime)) {
//时间内已收集过信息,直接跳转到聊天页
startChat(context, toUid, isFromQingShu)
} else {
//超过间隔时间 判断用户类型
getImJavaApi().getChatUid(toUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ res: BaseAPIResponse<DoctorAssistantRespDtoBean> ->
//获取实际聊天对象 role 1 专家 2 代运营
if (res.data != null && res.data.role == 1) {
//role=1专家
if (loadingDialog != null && loadingDialog!!.isVisible) {
loadingDialog?.dismissAllowingStateLoss()
}
val toUid = res.data.chatUid
prepareChatData(context, toUid, object :
ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) {
startChatSession(toUid, expertInfo, isFromQingShu, context)
}
})
} else if (res.data != null && res.data!!.role == 2) {
//role=2代运营
val toUid = res.data.chatUid
prepareAssistantChatData(context, toUid,
object : ChatDataRequestListener {
override fun onSuccess(expertInfo: IMExpertBuild) {
CmsExamQuestionPaperActivity.start(
context,
toUid,
expertInfo,
0
)
}
})
} else {
startChat(context, toUid, isFromQingShu)
}
}, { throwable: Throwable? ->
if (loadingDialog != null && loadingDialog!!.isVisible) {
loadingDialog?.dismissAllowingStateLoss()
}
startChat(context, toUid, isFromQingShu)
})
}
}
}
/**
......@@ -273,12 +340,6 @@ object IMChatUtil {
res.data!!.chatEvent
)
}
if (res.data!!.collectEvent) { //和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper.setStatusCache(
"collectEvent",
res.data!!.collectEvent
)
}
if (TextUtils.equals(res.data!!.userType, USER_TYPE_EXPERT.toString())) { //专家
//在uid用户类型确定为专家的情况下,根据uid调用接口判断是进入专家私聊还是助理私聊
getImJavaApi().getChatUid(toUid)
......@@ -391,12 +452,6 @@ object IMChatUtil {
if (res.data!!.chatEvent) { //和助理私聊需要打开常用语弹窗
ChatStatusCacheHelper.setStatusCache("chatEvent", res.data!!.chatEvent)
}
if (res.data!!.collectEvent) { //和助理私聊需要打开信息采集弹窗
ChatStatusCacheHelper.setStatusCache(
"collectEvent",
res.data!!.collectEvent
)
}
if (TextUtils.equals(res.data!!.userType, "2")) {
//接口返回值是专家,java接口
prepareExpertChatData(context, toUid, listener)
......
......@@ -63,7 +63,8 @@ class IMServiceImpl : IImService {
}
override fun startP2PSession(context: Activity, toUid: String) {
IMChatUtil.startChat(context as AppCompatActivity, toUid, 0)
IMChatUtil.startCms(context as AppCompatActivity, toUid, 0)
}
override fun startP2PSession(context: Activity, location: Int, ffrom2: String?) {
......
......@@ -82,21 +82,16 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
private lateinit var expertInfo: IMExpertBuild
private var toUid: String? = null
private var isFromQingShu: Int = 0
private var skip_time: Long = 0
private var location: Int = 0
private var ffrom2: String? = null
@JvmStatic
fun start(
context: Context, toUid: String, expertInfo: IMExpertBuild,
isFromQingShu: Int, skip_time: String
) {
fun start(context: Context, toUid: String, expertInfo: IMExpertBuild, isFromQingShu: Int) {
val starter = Intent(context, CmsExamQuestionPaperActivity::class.java)
this.expertInfo = expertInfo
this.toUid = toUid
this.isFromQingShu = isFromQingShu
this.skip_time = skip_time.toLong()
context.startActivity(starter)
}
......@@ -554,6 +549,8 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
//刷新已回答问题,将多选设置成不可再选
mData.forEachIndexed { index, _ ->
mData[index].type4CanClick = false
mData[index].type3CanClick = false
mData[index].type6CanClick = false
}
}
......@@ -691,6 +688,10 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
val dataBean = AnswerQuestionType71RequestBean.DataBean()
dataBean.answer = answer
if (mType70RequestList.size > 0 && mType70RequestList[0].data.answers.size > 0 && mType70RequestList[0].data.answers[0].optionId != null) {
dataBean.cateId = mType70RequestList[0].data.answers[0].optionId
}
answerQuestionType71RequestBean.data = dataBean
toUid.let {
answerQuestionType71RequestBean.toUid = toUid
......@@ -729,23 +730,26 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
if (toUid != null) {
//代表是聊天列表进来的
instance.batchSendCustomizeMessage(JSON.toJSONString(mType70RequestList))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
instance.batchSendCustomizeMessage(JSON.toJSONString(mType71RequestList))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
Handler().postDelayed({
instance.batchSendCustomizeMessage(JSON.toJSONString(mType71RequestList))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}, 100L)
IMChatUtil.startChatSessionByCms(
toUid!!,
expertInfo,
isFromQingShu,
this@CmsExamQuestionPaperActivity
)
Handler().postDelayed({
IMChatUtil.startChatSessionByCms(
toUid!!,
expertInfo,
isFromQingShu,
this@CmsExamQuestionPaperActivity
)
}, 200L)
Handler().postDelayed({
finish()
......@@ -758,8 +762,6 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ uidBean ->
if (uidBean.code == "200" && uidBean.data != 0.toLong()) {
mType70RequestList.forEachIndexed { index, answerQuestionType70RequestBean ->
mType70RequestList[index].toUid = uidBean.data.toString()
}
......@@ -773,16 +775,20 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
mType71RequestList[index].toUid = uidBean.data.toString()
}
instance.batchSendCustomizeMessage(JSON.toJSONString(mType71RequestList))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
Handler().postDelayed({
instance.batchSendCustomizeMessage(JSON.toJSONString(mType71RequestList))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe()
}, 100L)
IMChatUtil.startChat(
this@CmsExamQuestionPaperActivity,
uidBean.data.toString(),
0
)
Handler().postDelayed({
IMChatUtil.startChat(
this@CmsExamQuestionPaperActivity,
uidBean.data.toString(),
0
)
}, 200L)
Handler().postDelayed({
finish()
......
......@@ -90,9 +90,10 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
break;
}
}
/**
* 主诉消息
* */
*/
private void convertType6(BaseViewHolder helper, QuestionMultiItem item) {
RecyclerView OneRecycle = helper.getView(R.id.tv_one_list);
TextView oneTitle = helper.getView(R.id.multiple_choice_title);
......@@ -107,6 +108,9 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
oneMaxSize = option.name.length();
}
}
helper.setGone(R.id.tv_one_list,item.type6CanClick);
GridLayoutManager gridLayoutManager = new GridLayoutManager(AVChatKit.getContext(), oneMaxSize > mTextMaxSize ? 1 : 2);
OneRecycle.setLayoutManager(gridLayoutManager);
QuestionOneCheckAdapter oneCheckAdapter = new QuestionOneCheckAdapter(item.questionsBean.options);
......@@ -123,7 +127,7 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
}
oneCheckAdapter.getData().get(position).check = true;
oneCheckAdapter.notifyDataSetChanged();
mOneCheckListener.zsItemClick(getCheckOptionsBeans(oneCheckAdapter),item.questionsBean, item.type6Position);
mOneCheckListener.zsItemClick(getCheckOptionsBeans(oneCheckAdapter), item.questionsBean, item.type6Position);
}
});
}
......@@ -197,6 +201,9 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
tv_more_define.setText("确定");
}
helper.setGone(R.id.tv_more_list, item.type4CanClick);
helper.setGone(R.id.tv_more_define, item.type4CanClick);
moreCheckAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
......@@ -264,6 +271,8 @@ public class QuestionAdapter extends BaseMultiItemQuickAdapter<QuestionMultiItem
oneMaxSize = option.name.length();
}
}
helper.setGone(R.id.tv_one_list,item.type3CanClick);
GridLayoutManager gridLayoutManager = new GridLayoutManager(AVChatKit.getContext(), oneMaxSize > mTextMaxSize ? 1 : 2);
OneRecycle.setLayoutManager(gridLayoutManager);
QuestionOneCheckAdapter oneCheckAdapter = new QuestionOneCheckAdapter(item.questionsBean.options);
......
......@@ -16,7 +16,9 @@ public class QuestionMultiItem implements MultiItemEntity {
public String type2Text;
/***type 3 单选 type 4 多选 type 6 */
public QuestionsBean questionsBean;
public boolean type4CanClick;
public boolean type3CanClick = true;
public boolean type4CanClick = true;
public boolean type6CanClick = true;
/**
* type5
......
......@@ -22,6 +22,7 @@ public class AnswerQuestionType71RequestBean {
public DataBean data;
public static class DataBean {
public String answer;
public String cateId;
}
}
......@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/type5_parent"
android:paddingLeft="12dp"
android:layout_height="wrap_content">
<ImageView
......@@ -33,6 +34,7 @@
android:layout_height="wrap_content"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17"
android:lineSpacingMultiplier="1.2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="请问是发生了什么事情导致的呢?(多选)?" />
......@@ -42,6 +44,7 @@
android:layout_width="239dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:lineSpacingMultiplier="1.2"
android:text="@string/question_notes"
android:textColor="@color/color_grey_999999"
android:textSize="14sp" />
......
......@@ -28,17 +28,18 @@
<TextView
android:id="@+id/more_title"
android:layout_width="263dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17"
android:lineSpacingMultiplier="1.2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="请问是发生了什么事情导致的呢?(多选)?"></TextView>
tools:text="请问是发生了什么事情导致的呢?(多选)?"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/tv_more_list"
android:layout_width="match_parent"
android:layout_width="263dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
......
......@@ -3,7 +3,8 @@
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:layout_height="wrap_content"
android:paddingLeft="12dp">
<ImageView
android:id="@+id/iv_header"
......@@ -20,6 +21,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:background="@drawable/im_custom_message_round_white_6dp_bg"
android:maxWidth="263dp"
android:orientation="vertical"
android:padding="12dp"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -28,22 +30,25 @@
<TextView
android:id="@+id/multiple_choice_title"
android:layout_width="239dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="请问是发生了什么事情导致的呢?(多选)?" />
tools:text="请问是发生" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/tv_one_list"
android:layout_width="match_parent"
android:layout_width="263dp"
android:layout_height="wrap_content"
android:maxWidth="270dp"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17" />
android:textSize="@dimen/im_text_size_17"
tools:itemCount="6"
tools:listitem="@layout/left_one_check_layout_item"
tools:spanCount="2"
tools:visibility="visible" />
</LinearLayout>
......
......@@ -26,6 +26,7 @@
android:background="@drawable/im_custom_message_round_white_6dp_bg"
android:maxWidth="270dp"
android:padding="12dp"
android:lineSpacingMultiplier="1.2"
android:textColor="@color/im_color_242424"
android:textSize="@dimen/im_text_size_17"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -34,6 +34,7 @@
android:layout_marginRight="8dp"
android:background="@drawable/im_question_message_round_1da1f2_8dp_bg"
android:maxWidth="270dp"
android:lineSpacingMultiplier="1.2"
android:textColor="@color/white"
android:textSize="@dimen/im_text_size_17"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -7,7 +7,9 @@
android:layout_marginRight="@dimen/platform_dp_9"
android:background="@drawable/im_background_18dp_e8f5fe"
android:gravity="center"
android:paddingLeft="@dimen/platform_dp_8"
android:paddingTop="@dimen/platform_dp_8"
android:paddingRight="@dimen/platform_dp_8"
android:paddingBottom="@dimen/platform_dp_8"
android:text="婚姻家庭婚姻混"
android:textColor="@color/platform_color_1DA1F2">
......
......@@ -6,21 +6,22 @@
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="@color/white">
<ImageView
android:id="@+id/left_back_btn"
android:layout_width="36dp"
android:layout_height="44dp"
android:paddingStart="16dp"
android:paddingTop="10dp"
android:paddingEnd="12dp"
android:paddingBottom="10dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:scaleType="centerCrop"
android:src="@drawable/im_nim_actionbar_dark_back_icon" />
android:src="@drawable/im_titlebar_back" />
<ImageView
android:id="@+id/iv_close"
android:layout_width="26dp"
......@@ -73,11 +74,11 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_input"
android:layout_width="match_parent"
app:layout_constraintBottom_toTopOf="@id/tv_finish"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/tv_finish"
tools:visibility="gone">
<TextView
......@@ -102,6 +103,7 @@
android:background="@color/white"
android:gravity="top"
android:hint="请简单描述遇到的问题......"
android:lineSpacingMultiplier="1.2"
android:maxHeight="200dp"
android:padding="12dp"
android:textColor="@color/color_242424"
......
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