From 270bf2786e5df7222276536bc030b004938dfb69 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 10 Aug 2022 21:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98,shouye=20ytuijian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/views/LiveEndViewHolder.java | 73 ++++++++++--------- .../yunbao/main/activity/MainActivity.java | 1 + .../fragment/SearchRecommendFragment.java | 3 +- .../fragment/SearchResultsItemFragment.java | 5 +- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java index dc104115e..5f13526b3 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java @@ -11,14 +11,12 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.blankj.utilcode.util.GsonUtils; +import com.alibaba.fastjson.JSON; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.IMLoginModel; -import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; @@ -105,6 +103,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList .anchorRecommend("3", new HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { + if (((Activity) mContext).isFinishing()) return; if (data.getListShow() == 1) { listShow.setVisibility(View.VISIBLE); } else { @@ -115,11 +114,11 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList } else { changeBatchUser.setVisibility(View.GONE); } - if (data.getList().size()>2){ + if (data.getList().size() > 2) { listShow.setVisibility(View.VISIBLE); //组装搜索历史数据 adapter.showData(data.getList()); - }else { + } else { listShow.setVisibility(View.GONE); } @@ -305,45 +304,49 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList */ @Subscribe(threadMode = ThreadMode.MAIN) public void onJumpUserHome(JumpUserHomeEvent event) { - LiveNetManager.get(mContext) - .getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { - LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> { + LiveHttpUtil.getLiveInfo(event.getModel().getId() + "", new com.yunbao.common.http.HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() { + @Override + public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) { if (liveBean == null) { return; } LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); - }); - //讲数据转成json - String json = GsonUtils.toJson(data); - LiveBean liveBean = GsonUtils.fromJson(json, LiveBean.class); - mCheckLivePresenter.checkLive(liveBean); - if (mContext instanceof LiveAnchorActivity) { - ((LiveAnchorActivity) mContext).superBackPressed(); - } else if (mContext instanceof LiveAudienceActivity) { - ((LiveAudienceActivity) mContext).exitLiveRoom(); - } else if (mContext instanceof LiveRyAnchorActivity) { - ((LiveRyAnchorActivity) mContext).superBackPressed(); + RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); + if (mContext instanceof LiveAnchorActivity) { + ((LiveAnchorActivity) mContext).superBackPressed(); + } else if (mContext instanceof LiveAudienceActivity) { + ((LiveAudienceActivity) mContext).exitLiveRoom(); + } else if (mContext instanceof LiveRyAnchorActivity) { + ((LiveRyAnchorActivity) mContext).superBackPressed(); + } } + }); + + mCheckLivePresenter.checkLive(liveBean); + } else { + + RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); + + RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); + if (mContext instanceof LiveAnchorActivity) { + ((LiveAnchorActivity) mContext).superBackPressed(); + } else if (mContext instanceof LiveAudienceActivity) { + ((LiveAudienceActivity) mContext).exitLiveRoom(); + } else if (mContext instanceof LiveRyAnchorActivity) { + ((LiveRyAnchorActivity) mContext).superBackPressed(); + } + } + } + }); - @Override - public void onError(String error) { - - RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); - if (mContext instanceof LiveAnchorActivity) { - ((LiveAnchorActivity) mContext).superBackPressed(); - } else if (mContext instanceof LiveAudienceActivity) { - ((LiveAudienceActivity) mContext).exitLiveRoom(); - } else if (mContext instanceof LiveRyAnchorActivity) { - ((LiveRyAnchorActivity) mContext).superBackPressed(); - - } - } - }); } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index c0608c006..68049ec03 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -428,6 +428,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { + if (isFinishing()) return; if (data.getListShow() == 1 && data.getList().size() > 2) { floatBanner.setVisibility(View.VISIBLE); findViewById(R.id.banner_click).setVisibility(View.VISIBLE); diff --git a/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java b/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java index 6926e4f5b..4bb3602d7 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchRecommendFragment.java @@ -60,6 +60,7 @@ public class SearchRecommendFragment extends BaseFragment { .anchorRecommend("10", new HttpCallback() { @Override public void onSuccess(AnchorRecommendModel data) { + if (getActivity().isFinishing()) return; //组装搜索历史数据 List searchRecommendModels = new ArrayList<>(); Map historyRecordMap = SearchHistoryRecordManager.get(getActivity()).getHistoryRecordMap(); @@ -67,7 +68,7 @@ public class SearchRecommendFragment extends BaseFragment { SearchRecommendModel model = new SearchRecommendModel(); searchRecommendModels.add(model.setHistoryRecordMap(historyRecordMap)); } - searchRecommendModels.add( new SearchRecommendModel().setList(data.getList())); + searchRecommendModels.add(new SearchRecommendModel().setList(data.getList())); adapter.addData(searchRecommendModels); } diff --git a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java index 644f3936e..36018ba82 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java @@ -138,6 +138,7 @@ public class SearchResultsItemFragment extends BaseFragment { type, page, new HttpCallback>>() { @Override public void onSuccess(List> data) { + if (getActivity().isFinishing()) return; if (page > 1) { itemAdapter.onLoadMoreData(data, searchKey); } else { @@ -154,6 +155,7 @@ public class SearchResultsItemFragment extends BaseFragment { @Override public void onError(String error) { + if (getActivity().isFinishing()) return; emptyLayout.setVisibility(View.VISIBLE); searchList.setVisibility(View.GONE); } @@ -165,7 +167,7 @@ public class SearchResultsItemFragment extends BaseFragment { type, page, new HttpCallback>() { @Override public void onSuccess(List data) { - + if (getActivity().isFinishing()) return; List> listList = new ArrayList<>(); listList.add(data); if (page > 1) { @@ -187,6 +189,7 @@ public class SearchResultsItemFragment extends BaseFragment { @Override public void onError(String error) { + if (getActivity().isFinishing()) return; emptyLayout.setVisibility(View.VISIBLE); searchList.setVisibility(View.GONE); }