Commit 5c3ea40e by Dell

1、支持异常问题

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