Commit 5c3ea40e by Dell

1、支持异常问题

2、支持IM保护
parent 98749f01
...@@ -521,6 +521,7 @@ interface HostUrl { ...@@ -521,6 +521,7 @@ interface HostUrl {
const val POST_GET_LIVE_CONFIG = "common/getIosLiveConfig" const val POST_GET_LIVE_CONFIG = "common/getIosLiveConfig"
/** /**
* 获取赛事列表 * 获取赛事列表
*/ */
......
...@@ -469,6 +469,7 @@ object Constants { ...@@ -469,6 +469,7 @@ object Constants {
const val MESSAGE_USER_ID = "user_id" const val MESSAGE_USER_ID = "user_id"
const val MESSAGE_USER_RID = "user_rid" const val MESSAGE_USER_RID = "user_rid"
const val USER_HX_ID = "user_hx_id" const val USER_HX_ID = "user_hx_id"
const val ROOM_NUM = "roomNum"
const val GIFT_BEAN = "gift_bean" const val GIFT_BEAN = "gift_bean"
const val SPORT_TYPE= "sport_type" const val SPORT_TYPE= "sport_type"
......
...@@ -68,6 +68,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -68,6 +68,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
private var matchId = "" private var matchId = ""
private var liveUserHxId = "" private var liveUserHxId = ""
private var sportType = 0 private var sportType = 0
private var roomNum = ""
var historyList = arrayListOf<HistoryMessageEntity>() var historyList = arrayListOf<HistoryMessageEntity>()
override fun loadData() { override fun loadData() {
presenter?.getHistoryMessage(roomId) presenter?.getHistoryMessage(roomId)
...@@ -261,11 +262,12 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -261,11 +262,12 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
if (isShowChat) { if (isShowChat) {
mFragment.add( mFragment.add(
LiveConversationFragment.newInstance( LiveConversationFragment.newInstance(
roomId, conversationId = roomId,
notice, notice = notice,
notice2, notice2 = notice2,
liveUserHxId, roomNum = roomNum,
LiveRoomUserName userHxId = liveUserHxId,
userName = LiveRoomUserName
) )
) )
} }
...@@ -420,6 +422,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta ...@@ -420,6 +422,7 @@ class LiveActivity : RefreshActivity<LiveActivityPresenter>(), LiveActivityConta
} }
LiveRoomUserName = bean?.userName ?: "" LiveRoomUserName = bean?.userName ?: ""
liveUserHxId = bean?.huanXinUserId.orEmpty() liveUserHxId = bean?.huanXinUserId.orEmpty()
roomNum = bean?.roomNum.orEmpty()
if (VersionControl.isShowLive()) { if (VersionControl.isShowLive()) {
initIm(bean?.huanXinUserId ?: "") initIm(bean?.huanXinUserId ?: "")
} else { } else {
......
...@@ -54,12 +54,14 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -54,12 +54,14 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
private CustomChatRoomListener customChatRoomListener; private CustomChatRoomListener customChatRoomListener;
private EMConnectionListener connectionListener; private EMConnectionListener connectionListener;
private String userHxId = ""; private String userHxId = "";
private String roomNum = "";
@Override @Override
public void initView() { public void initView() {
super.initView(); super.initView();
initConnectListener(); initConnectListener();
liveUserName = getArguments().getString(Constants.LIVE_ROOM_USER_NAME); liveUserName = getArguments().getString(Constants.LIVE_ROOM_USER_NAME);
roomNum = getArguments().getString(Constants.ROOM_NUM, "");
userHxId = getArguments().getString(Constants.USER_HX_ID, ""); userHxId = getArguments().getString(Constants.USER_HX_ID, "");
chatLayout.getChatMessageListLayout().setItemShowType(EaseChatMessageListLayout.ShowType.LEFT); chatLayout.getChatMessageListLayout().setItemShowType(EaseChatMessageListLayout.ShowType.LEFT);
chatLayout.getChatMessageListLayout().setBackground(new ColorDrawable(Color.parseColor("#F4F4F4"))); chatLayout.getChatMessageListLayout().setBackground(new ColorDrawable(Color.parseColor("#F4F4F4")));
...@@ -112,6 +114,7 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess ...@@ -112,6 +114,7 @@ public class ChatFragment extends CustomEaseChatFragment implements OnRecallMess
message.setAttribute(Constants.MESSAGE_USER_RID, liveUserBean.getId()); message.setAttribute(Constants.MESSAGE_USER_RID, liveUserBean.getId());
message.setAttribute(Constants.MESSAGE_USER_ID, userHxId); message.setAttribute(Constants.MESSAGE_USER_ID, userHxId);
message.setAttribute(Constants.USER_LEVEL, liveUserBean.getLevel()); message.setAttribute(Constants.USER_LEVEL, liveUserBean.getLevel());
message.setAttribute(Constants.ROOM_NUM,roomNum);
} }
} }
return super.addMsgAttrsBeforeSend(message); return super.addMsgAttrsBeforeSend(message);
......
...@@ -43,11 +43,13 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres ...@@ -43,11 +43,13 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
conversationId: String, conversationId: String,
notice: String, notice: String,
notice2: String, notice2: String,
roomNum:String,
userHxId:String, userHxId:String,
userName: String userName: String
): LiveConversationFragment { ): LiveConversationFragment {
val args = Bundle() val args = Bundle()
args.putString(Constants.USER_HX_ID, userHxId) args.putString(Constants.USER_HX_ID, userHxId)
args.putString(Constants.ROOM_NUM, roomNum)
args.putString(EaseConstant.EXTRA_CONVERSATION_ID, conversationId) args.putString(EaseConstant.EXTRA_CONVERSATION_ID, conversationId)
args.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM) args.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
args.putBoolean(EaseConstant.EXTRA_IS_ROAM, true) args.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
...@@ -117,6 +119,7 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres ...@@ -117,6 +119,7 @@ class LiveConversationFragment : RefreshVP2Fragment<LiveConversationFragmentPres
private fun initChatFragment() { private fun initChatFragment() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(Constants.USER_HX_ID, arguments?.getString(Constants.USER_HX_ID)) bundle.putString(Constants.USER_HX_ID, arguments?.getString(Constants.USER_HX_ID))
bundle.putString(Constants.ROOM_NUM, arguments?.getString(Constants.ROOM_NUM))
bundle.putString(EaseConstant.EXTRA_CONVERSATION_ID, arguments?.getString(EaseConstant.EXTRA_CONVERSATION_ID)) bundle.putString(EaseConstant.EXTRA_CONVERSATION_ID, arguments?.getString(EaseConstant.EXTRA_CONVERSATION_ID))
bundle.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM) bundle.putInt(EaseConstant.EXTRA_CHAT_TYPE, EaseConstant.CHATTYPE_CHATROOM)
bundle.putBoolean(EaseConstant.EXTRA_IS_ROAM, true) bundle.putBoolean(EaseConstant.EXTRA_IS_ROAM, true)
......
...@@ -111,10 +111,6 @@ class MainFragment : RefreshFragment<MainFragmentPresenter>(), MainFragmentConta ...@@ -111,10 +111,6 @@ class MainFragment : RefreshFragment<MainFragmentPresenter>(), MainFragmentConta
// SPUtil.put(Constants.SHOW_LIVE_CONFIG, true) // SPUtil.put(Constants.SHOW_LIVE_CONFIG, true)
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) {
super.showError(throwable,isConfigStatus)
mStatusLayoutManager.showErrorLayout()
}
override fun initEventAndData() { override fun initEventAndData() {
initListener() initListener()
......
...@@ -73,10 +73,7 @@ class MainNewsContentNormalFragment : RefreshVP2Fragment<MainNewsContentNormalPr ...@@ -73,10 +73,7 @@ class MainNewsContentNormalFragment : RefreshVP2Fragment<MainNewsContentNormalPr
} }
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) {
super.showError(throwable,isConfigStatus)
mStatusLayoutManager.showErrorLayout()
}
override fun onNewsData(data: NewsDataBean?) { override fun onNewsData(data: NewsDataBean?) {
setLoadMore(newsAdapter,data?.dataList) setLoadMore(newsAdapter,data?.dataList)
......
...@@ -67,10 +67,7 @@ class MainNewsFragment : RefreshFragment<MainNewsFragmentPresenter>(), MainNewsF ...@@ -67,10 +67,7 @@ class MainNewsFragment : RefreshFragment<MainNewsFragmentPresenter>(), MainNewsF
tabLayout_main.setViewPager2(vp_main) tabLayout_main.setViewPager2(vp_main)
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) {
super.showError(throwable,isConfigStatus)
mStatusLayoutManager.showErrorLayout()
}
override fun initEventAndData() { override fun initEventAndData() {
initStatusLayout(ll_root as View) initStatusLayout(ll_root as View)
......
...@@ -463,21 +463,7 @@ class MainPagerFragment : RefreshFragment<MainPagerFragmentPresenter>(), MainPag ...@@ -463,21 +463,7 @@ class MainPagerFragment : RefreshFragment<MainPagerFragmentPresenter>(), MainPag
} }
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) {
super.showError(throwable,isConfigStatus)
if (!isNeedLoadData) {
return
}
ll_empty.visibility = View.VISIBLE
tv_empty_reload.setOnClickListener {
ll_empty.visibility = View.GONE
tv_empty_reload.postDelayed({
// initView()
lazyLoad()
}, 500)
}
}
private fun isCanPlay(movieDetailBean: MovieDetailBean?): Boolean { private fun isCanPlay(movieDetailBean: MovieDetailBean?): Boolean {
if (movieDetailBean?.isCanPlay == Constants.VIDEO_CAN_PLAY) { if (movieDetailBean?.isCanPlay == Constants.VIDEO_CAN_PLAY) {
......
...@@ -186,10 +186,7 @@ class MatchContentFragment : RefreshVP2Fragment<MatchContentPresenter>(), ...@@ -186,10 +186,7 @@ class MatchContentFragment : RefreshVP2Fragment<MatchContentPresenter>(),
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) {
super.showError(throwable,isConfigStatus)
mStatusLayoutManager.showErrorLayout()
}
override fun onSubscribeMatch(id: String, status: Boolean) { override fun onSubscribeMatch(id: String, status: Boolean) {
......
...@@ -342,23 +342,43 @@ abstract class BaseActivity<P : IBasePresenter?> : RxAppCompatActivity(), IBaseD ...@@ -342,23 +342,43 @@ abstract class BaseActivity<P : IBasePresenter?> : RxAppCompatActivity(), IBaseD
override fun showError(t: Throwable, isConfigStatus: Boolean) { override fun showError(t: Throwable, isConfigStatus: Boolean) {
when (t) { when (t) {
is ConnectException -> { is ConnectException -> {
if (isConfigStatus) {
showCustomException(t)
}else{
ToastUtil.s(getString(R.string.base_connect_failed)) ToastUtil.s(getString(R.string.base_connect_failed))
}
} }
is UnknownHostException -> { is UnknownHostException -> {
if (isConfigStatus) {
showCustomException(t)
}else{
ToastUtil.s(getString(R.string.base_request_serve_failed)) ToastUtil.s(getString(R.string.base_request_serve_failed))
}
} }
is SocketTimeoutException -> { is SocketTimeoutException -> {
if (isConfigStatus) {
showCustomException(t)
}else{
ToastUtil.s(getString(R.string.base_socket_timeout)) ToastUtil.s(getString(R.string.base_socket_timeout))
}
} }
is JsonParseException -> { is JsonParseException -> {
if (isConfigStatus) {
showCustomException(t)
}else{
ToastUtil.s(getString(R.string.base_parse_failed)) ToastUtil.s(getString(R.string.base_parse_failed))
}
t.printStackTrace() t.printStackTrace()
} }
is ApiException -> { is ApiException -> {
//通用的Api异常处理 //通用的Api异常处理
//通用的Api异常处理
if (isConfigStatus){ if (isConfigStatus){
onApiException(t) onApiException(t)
}else{ }else{
......
...@@ -140,13 +140,13 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay { ...@@ -140,13 +140,13 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay {
if (activity is BaseActivity<*>) (activity as BaseActivity<*>?)!!.hideProgressDialog() if (activity is BaseActivity<*>) (activity as BaseActivity<*>?)!!.hideProgressDialog()
} }
override fun showError(throwable: Throwable,isConfigStatus:Boolean) { override fun showError(throwable: Throwable, isConfigStatus: Boolean) {
showFragmentError(throwable) showFragmentError(throwable, isConfigStatus)
} }
override fun onApiException(e: ApiException) { override fun onApiException(e: ApiException) {
showCustomException(e) showCustomException(e)
showErrorLayout()
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
...@@ -158,35 +158,61 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay { ...@@ -158,35 +158,61 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay {
} }
} }
fun showFragmentError(t: Throwable) { private fun showFragmentError(t: Throwable, isConfigStatus: Boolean) {
when (t) { when (t) {
is ConnectException -> { is ConnectException -> {
if (isConfigStatus) {
showCustomException(t)
} else {
ToastUtil.s(getString(R.string.base_connect_failed)) ToastUtil.s(getString(R.string.base_connect_failed))
}
} }
is UnknownHostException -> { is UnknownHostException -> {
if (isConfigStatus) {
showCustomException(t)
} else {
ToastUtil.s(getString(R.string.base_request_serve_failed)) ToastUtil.s(getString(R.string.base_request_serve_failed))
}
} }
is SocketTimeoutException -> { is SocketTimeoutException -> {
if (isConfigStatus) {
showCustomException(t)
} else {
ToastUtil.s(getString(R.string.base_socket_timeout)) ToastUtil.s(getString(R.string.base_socket_timeout))
}
} }
is JsonParseException -> { is JsonParseException -> {
if (isConfigStatus) {
showCustomException(t)
} else {
ToastUtil.s(getString(R.string.base_parse_failed)) ToastUtil.s(getString(R.string.base_parse_failed))
}
t.printStackTrace() t.printStackTrace()
} }
is ApiException -> { is ApiException -> {
//通用的Api异常处理 //通用的Api异常处理
onApiException(t) //通用的Api异常处理
if (isConfigStatus) {
showCustomException(t)
} else {
ToastUtil.s(t.message)
}
} }
else -> { else -> {
if (isConfigStatus) {
showCustomException(t) showCustomException(t)
// baseDelegate.showError(t) } else {
ToastUtil.s(t.message)
}
} }
} }
showErrorLayout()
} }
open fun showErrorLayout() { open fun showErrorLayout() {
...@@ -196,6 +222,7 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay { ...@@ -196,6 +222,7 @@ abstract class BaseFragment<P : IBasePresenter?> : RxFragment(), IBaseDisplay {
open fun showCustomException(t: Throwable) { open fun showCustomException(t: Throwable) {
ToastUtil.s(t.message) ToastUtil.s(t.message)
if (BuildConfig.DEBUG) t.printStackTrace() if (BuildConfig.DEBUG) t.printStackTrace()
showErrorLayout()
} }
......
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