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 d8d593a23..f3e0b2437 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -31,7 +31,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.android.billingclient.api.Purchase; import com.android.billingclient.api.SkuDetails; -import com.blankj.utilcode.util.GsonUtils; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.tencent.imsdk.v2.V2TIMCallback; @@ -47,7 +46,6 @@ import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.ChatRemarksBean; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.IMLoginModel; -import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveSvgGiftBean; import com.yunbao.common.bean.UpdataListBean; import com.yunbao.common.custom.TabButtonGroup; @@ -59,7 +57,6 @@ import com.yunbao.common.event.RongIMConnectionStatusEvent; import com.yunbao.common.event.UpdateTablePointMe; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; @@ -375,35 +372,32 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene if (!isClickfloatBanner) { isClickfloatBanner = true; String Uid = floatBanner.getUid(); - LiveNetManager.get(mContext) - .getLiveInfo(String.valueOf(Uid), new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveInfoModel data) { + LiveHttpUtil.getLiveInfo(Uid + "", new 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, (liveBean, liveType, liveTypeVal, liveSdk) -> { - //讲数据转成json - String json = GsonUtils.toJson(data); - LiveBean liveBean2 = GsonUtils.fromJson(json, LiveBean.class); - if (liveBean2 == null) { + + 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, liveBean2, liveType, liveTypeVal, "", 0, liveSdk); + LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); - }); - //讲数据转成json - String json = GsonUtils.toJson(data); - LiveBean liveBean = GsonUtils.fromJson(json, LiveBean.class); - mCheckLivePresenter.checkLive(liveBean); - isClickfloatBanner = false; - } + } + }); - @Override - public void onError(String error) { + mCheckLivePresenter.checkLive(liveBean); + } else { - RouteUtil.forwardUserHome(mContext, String.valueOf(Uid), 0); - isClickfloatBanner = false; - } - }); + RouteUtil.forwardUserHome(mContext,Uid, 0); + + } + } + }); } diff --git a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java index d9b1f047e..2a48406ce 100644 --- a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java @@ -16,16 +16,15 @@ import android.widget.TextView; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.blankj.utilcode.util.GsonUtils; +import com.alibaba.fastjson.JSON; import com.yunbao.common.activity.AbsActivity; -import com.yunbao.common.bean.LiveInfoModel; -import com.yunbao.common.http.base.HttpCallback; -import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.SearchHistoryRecordManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.RouteUtil; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.bean.LiveBean; +import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.main.R; import com.yunbao.main.event.JumpUserHomeEvent; @@ -169,34 +168,35 @@ public class SearchActivity extends AbsActivity { */ @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) -> { - //讲数据转成json - String json = GsonUtils.toJson(data); - LiveBean liveBean2 = GsonUtils.fromJson(json, LiveBean.class); - if (liveBean2 == null) { + LiveHttpUtil.getLiveInfo(event.getModel().getId()+ "", new 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, liveBean2, liveType, liveTypeVal, "", 0, liveSdk); - }); - //讲数据转成json - String json = GsonUtils.toJson(data); - LiveBean liveBean = GsonUtils.fromJson(json, LiveBean.class); - mCheckLivePresenter.checkLive(liveBean); - } + LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); - @Override - public void onError(String error) { - //跳转到个人资料 - if (imm != null && mEditText != null) { - imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); - RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); } + }); + + mCheckLivePresenter.checkLive(liveBean); + } else { + //跳转到个人资料 + if (imm != null && mEditText != null) { + imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); + RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0); } - }); + } + } + }); + } 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 3bdb153dd..644f3936e 100644 --- a/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/SearchResultsItemFragment.java @@ -13,11 +13,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.SearchModel; -import com.yunbao.common.event.SearchRecommendEvent; import com.yunbao.common.fragment.BaseFragment; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.main.MainNetManager; -import com.yunbao.common.utils.Bus; import com.yunbao.common.views.weight.OnRecyclerViewScrollListener; import com.yunbao.main.R; import com.yunbao.main.adapter.SearchRecommendBodyAdapter; @@ -48,7 +46,22 @@ public class SearchResultsItemFragment extends BaseFragment { @Override protected void initVariables(Bundle bundle) { - setSearchKey(bundle.getString("searchKey"), bundle.getInt("type")); + this.searchKey = bundle.getString("searchKey"); + this.type = bundle.getInt("type"); + } + + @Override + public void onResume() { + super.onResume(); + setSearchKey(searchKey, type); + } + + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser && type > 1) { + setSearchKey(searchKey, type); + } } @Override @@ -117,8 +130,7 @@ public class SearchResultsItemFragment extends BaseFragment { * @param type 類型 */ public void setSearchKey(String searchKey, int type) { - this.searchKey = searchKey; - this.type = type; + if (type == 1) { MainNetManager.get(getActivity()) .search(WordsTypeUtil.changeSimplified(searchKey),