Commit 383d669f by 徐健

修复私聊页面和咨询列表刷新功能

parent bda332dd
......@@ -21,7 +21,7 @@ public final class DemoGlobalConfig implements IConfigModule {
String APP_DOMAIN = "https://api.github.com/";
// public static String appEnv = YDLConstants.ENV_AUTO_TEST;
// public static String appEnv = YDLConstants.ENV_TEST;
public static String appEnv = YDLConstants.ENV_PROD;
public static String appEnv = YDLConstants.ENV_TEST;
@Override
public void injectAppLifecycle(@NotNull Context context, @NotNull List<IAppLifecycles> lifecycles) {
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......@@ -48,7 +48,7 @@ ext {
"m-fm" : "0.0.23.5",
"m-user" : "0.0.41.3",
"m-home" : "0.0.6.26",
"m-im" : "0.0.3.9",
"m-im" : "0.0.3.10",
"m-dynamic" : "0.0.1.7",
"m-muse" : "0.0.20.8",
......
......@@ -196,6 +196,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
srlContainer.setProgressViewOffset(false, 0, 200)
srlContainer.setOnRefreshListener(this)
appbar_layout.addOnOffsetChangedListener { appbarLayout, i ->
srlContainer.isEnabled = i >= 0
}
initNetLossView()
......
......@@ -11,6 +11,10 @@
layout="@layout/consultant_layout_search_toolbar"
android:layout_width="match_parent"
android:layout_height="48dp" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srlContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
......@@ -58,4 +62,7 @@
android:visibility="gone" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
package com.yidianling.im.ui.page
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.view.ViewPager
import android.util.Log
import android.view.View
import android.view.WindowManager
import com.alibaba.android.arouter.launcher.ARouter
......@@ -70,11 +72,7 @@ class NewMultiMessageFragment : BaseFragment() {
override fun onResume() {
super.onResume()
// 刷新私聊列表
// 由于登录操作设置用户信息的操作是异步的,这边有一定几率获取的uid还是0,所以这边做一个延迟500毫秒的操作
if (mFragmentsList.size > 0 && mFragmentsList[0] is ChatFragment) {
(mFragmentsList[0] as ChatFragment).getChatMessageData()
}
getMsgData()
NIMClient.getService(MsgService::class.java).setChattingAccount(MsgService.MSG_CHATTING_ACCOUNT_NONE, SessionTypeEnum.None)
}
......@@ -134,7 +132,7 @@ class NewMultiMessageFragment : BaseFragment() {
/**
* 刷新当前展示的消息列表的数据,刷新顶部三个消息未读数,刷新底部消息未读数
*/
fun getMsgData() {
fun getMsgData(isRefreshInteractList: Boolean = false) {
/**
* 登录状态
*/
......@@ -142,8 +140,11 @@ class NewMultiMessageFragment : BaseFragment() {
if (view_pager.currentItem == 0 && mFragmentsList.size > 0 && mFragmentsList[0] is ChatFragment) {
(mFragmentsList[0] as ChatFragment).getChatMessageData()
}
if (view_pager.currentItem == 1 && mFragmentsList.size > 1 && mFragmentsList[1] is InteractFragment) {
(mFragmentsList[1] as InteractFragment).getInteractMessageData(refresh = true)
//互动列表单独刷新被点击的item。不进行列表的刷新,列表的刷新操作只在互动列表从私聊或者通知或者其余fragment切换过来的时候刷新
if (isRefreshInteractList) {
if (view_pager.currentItem == 1 && mFragmentsList.size > 1 && mFragmentsList[1] is InteractFragment) {
(mFragmentsList[1] as InteractFragment).getInteractMessageData(refresh = true)
}
}
if (view_pager.currentItem == 2 && mFragmentsList.size > 2 && mFragmentsList[2] is NoticeFragment) {
(mFragmentsList[2] as NoticeFragment).getNoticeMessageData()
......@@ -269,7 +270,7 @@ class NewMultiMessageFragment : BaseFragment() {
if (it.data) {
//清除私聊群聊未读数
MsgReceiveHelper.markAllRead()
getMsgData()
getMsgData(true)
ToastUtil.toastShort("已全部标记为已读")
} else {
ToastUtil.toastShort("标记失败")
......@@ -323,14 +324,15 @@ class NewMultiMessageFragment : BaseFragment() {
override fun onPageScrolled(p0: Int, p1: Float, p2: Int) {
}
@SuppressLint("CheckResult")
override fun onPageSelected(index: Int) {
setSelectTab(index)
// 这边延迟300毫秒加载,是为了不让动画进行时有卡顿
Observable.timer(300, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe( {
getMsgData()
} )
.subscribe {
getMsgData(true)
}
}
})
}
......
......@@ -251,8 +251,10 @@ class ChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
//登录状态
if (showData.size != 0) {
//数据不为空
chat_recyclerview.visibility = View.VISIBLE
ll_chat_unusual_view.visibility = View.GONE
} else {
chat_recyclerview.visibility = View.GONE
ll_chat_unusual_view.visibility = View.VISIBLE
when (mChatModelType) {
ChatModelType.ALL -> {
......@@ -273,6 +275,7 @@ class ChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
}
} else {
//未登录状态
chat_recyclerview.visibility = View.GONE
ll_chat_unusual_view.visibility = View.VISIBLE
ll_chat_unusual_view.setUnusualType(ChatUnusualView.TYPE_UNLOGIN)
ll_chat_unusual_view.setListener(object : ChatUnusualView.ChatUnusualListener {
......
......@@ -154,7 +154,7 @@ class InteractFragment : BaseFragment(), XRecyclerView.LoadingListener {
if (isVisibleToUser && getIsViewCreated()) {
// 每次展示的时候都需要处理页面展示逻辑
resetPageShow()
getInteractMessageData(false, refresh = true)
}
}
......@@ -177,8 +177,10 @@ class InteractFragment : BaseFragment(), XRecyclerView.LoadingListener {
//登录状态
if (interactList.size != 0) {
//数据不为空
interact_recyclerview.visibility = View.VISIBLE
ll_interact_unusual_view.visibility = View.GONE
} else {
interact_recyclerview.visibility = View.GONE
ll_interact_unusual_view.visibility = View.VISIBLE
ll_interact_unusual_view.setUnusualType(ChatUnusualView.TYPE_INTERACT_NO_DATA)
ll_interact_unusual_view.setListener(object : ChatUnusualView.ChatUnusualListener {
......@@ -189,6 +191,7 @@ class InteractFragment : BaseFragment(), XRecyclerView.LoadingListener {
}
} else {
//未登录
interact_recyclerview.visibility = View.GONE
ll_interact_unusual_view.visibility = View.VISIBLE
ll_interact_unusual_view.setUnusualType(ChatUnusualView.TYPE_UNLOGIN)
ll_interact_unusual_view.setListener(object : ChatUnusualView.ChatUnusualListener {
......
......@@ -106,13 +106,16 @@ class NoticeFragment : BaseFragment(), XRecyclerView.LoadingListener {
//登录状态
if (noticeList.size != 0) {
//数据不为空
notice_recyclerview.visibility = View.VISIBLE
ll_notice_unusual_view.visibility = View.GONE
}else {
notice_recyclerview.visibility = View.GONE
ll_notice_unusual_view.visibility = View.VISIBLE
ll_notice_unusual_view.setUnusualType(ChatUnusualView.TYPE_NOTIFICATION_NO_DATA)
}
}else {
//未登录
notice_recyclerview.visibility = View.GONE
ll_notice_unusual_view.visibility = View.VISIBLE
ll_notice_unusual_view.setUnusualType(ChatUnusualView.TYPE_UNLOGIN)
ll_notice_unusual_view.setListener(object : ChatUnusualView.ChatUnusualListener {
......
package com.yidianling.im.ui.page.fragment.adapter
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.support.v7.widget.RecyclerView
......@@ -25,7 +26,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers
* 互动列表适配器
* Created by xj on 2019/10/14.
*/
class InteractAdapter(var context: Context, private var mList: ArrayList<InteractItemBean>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class InteractAdapter(var context: Context, private var mList: ArrayList<InteractItemBean>) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object {
......@@ -60,18 +62,22 @@ class InteractAdapter(var context: Context, private var mList: ArrayList<Interac
/**
* 点击的时候先调接口,将数据库数据更新为已读,接口调用成功之后,刷新本地数据并跳转
*/
@SuppressLint("CheckResult")
private fun initClick(bean: InteractItemBean, index: Int) {
ImHttpImpl.getInstance().getMsgDetail(MsgDetailParam(bean.id.toString()))
.compose(RxUtils.resultData<MsgDetail>())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ res ->
}, { t ->
})
.compose(RxUtils.resultData<MsgDetail>())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ res ->
}, { t ->
})
//这里直接进行跳转,不然等待接口调用成功再跳转,会有点慢
mList[index].isRead = 2
notifyItemChanged(index + 1)
// 解析url,看是否跳转
if (!jumpForUrl(bean.link)) {
......@@ -114,19 +120,48 @@ class InteractAdapter(var context: Context, private var mList: ArrayList<Interac
context.startActivity(ImIn.membersIntent(context as Activity, bean.relationId1))
}
1109 -> { //1109 动态回复被点赞 1113 动态的评论被回复
context.startActivity(ImIn.replayInfoIntent(context as Activity, bean.relationId1, bean.remark))
context.startActivity(
ImIn.replayInfoIntent(
context as Activity,
bean.relationId1,
bean.remark
)
)
}
1113 -> { //1109 动态回复被点赞 1113 动态的评论被回复
context.startActivity(ImIn.replayInfoIntent(context as Activity, bean.relationId1, bean.remark))
context.startActivity(
ImIn.replayInfoIntent(
context as Activity,
bean.relationId1,
bean.remark
)
)
}
1110 -> { // 温暖 -> 评论详情
context.startActivity(ImIn.trendsDetailIntent(context as Activity, Integer.valueOf(bean.relationId1)!!, true))
context.startActivity(
ImIn.trendsDetailIntent(
context as Activity,
Integer.valueOf(bean.relationId1)!!,
true
)
)
}
1112 -> { // 收到评论 -> 评论详情
context.startActivity(ImIn.trendsDetailIntent(context as Activity, Integer.valueOf(bean.relationId1)!!, false))
context.startActivity(
ImIn.trendsDetailIntent(
context as Activity,
Integer.valueOf(bean.relationId1)!!,
false
)
)
}
1114 -> { // 访客 -> 专家首页
context.startActivity(ImIn.membersIntent(context as Activity, bean.relationUid.toString()))
context.startActivity(
ImIn.membersIntent(
context as Activity,
bean.relationUid.toString()
)
)
}
1115 -> {
} //专家主页被访问
......@@ -135,8 +170,6 @@ class InteractAdapter(var context: Context, private var mList: ArrayList<Interac
}
}
EventBus.getDefault().post(ReQureyUnreadNum())
}
......@@ -186,12 +219,14 @@ class InteractAdapter(var context: Context, private var mList: ArrayList<Interac
/**
* 互动列表有时间的item的holder
*/
inner class InteractTimeItemHolder(val view: InteractTimeItemView) : RecyclerView.ViewHolder(view)
inner class InteractTimeItemHolder(val view: InteractTimeItemView) :
RecyclerView.ViewHolder(view)
/**
* 互动列表底部item的holder
*/
inner class InteractFooterItemHolder(val view: InteractFooterItemView) : RecyclerView.ViewHolder(view)
inner class InteractFooterItemHolder(val view: InteractFooterItemView) :
RecyclerView.ViewHolder(view)
}
......
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