修改测试问题,shouye ytuijian
This commit is contained in:
parent
6b4bbcf93e
commit
3efd35f897
@ -1,41 +0,0 @@
|
|||||||
package com.yunbao.common.dialog;
|
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import com.yunbao.common.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 耗时操作通用Loading弹窗
|
|
||||||
*/
|
|
||||||
public class LoadingDialog extends AbsDialogFragment {
|
|
||||||
@Override
|
|
||||||
protected int getLayoutId() {
|
|
||||||
return R.layout.view_loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getDialogStyle() {
|
|
||||||
return R.style.dialog4;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canCancel() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setWindowAttributes(Window window) {
|
|
||||||
window.setWindowAnimations(R.style.bottomToTopAnim);
|
|
||||||
WindowManager.LayoutParams params = window.getAttributes();
|
|
||||||
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
||||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
||||||
params.gravity = Gravity.CENTER;
|
|
||||||
window.setAttributes(params);
|
|
||||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,7 +20,6 @@ import com.yunbao.common.bean.AnchorRecommendModel;
|
|||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.bean.LiveInfoModel;
|
import com.yunbao.common.bean.LiveInfoModel;
|
||||||
import com.yunbao.common.bean.SetAttentsModel;
|
import com.yunbao.common.bean.SetAttentsModel;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.http.live.LiveNetManager;
|
import com.yunbao.common.http.live.LiveNetManager;
|
||||||
@ -102,9 +101,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
* 加载用户猜你喜欢数据
|
* 加载用户猜你喜欢数据
|
||||||
*/
|
*/
|
||||||
private void initDataOfUser() {
|
private void initDataOfUser() {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
MainNetManager.get((Activity) mContext)
|
MainNetManager.get((Activity) mContext)
|
||||||
.anchorRecommend("3", new HttpCallback<AnchorRecommendModel>() {
|
.anchorRecommend("3", new HttpCallback<AnchorRecommendModel>() {
|
||||||
@Override
|
@Override
|
||||||
@ -119,7 +115,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
} else {
|
} else {
|
||||||
changeBatchUser.setVisibility(View.GONE);
|
changeBatchUser.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
fragment.dismiss();
|
|
||||||
//组装搜索历史数据
|
//组装搜索历史数据
|
||||||
adapter.showData(data.getList());
|
adapter.showData(data.getList());
|
||||||
|
|
||||||
@ -127,7 +122,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -228,20 +222,16 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
|
|
||||||
followUser.setVisibility(TextUtils.equals(liveBean.getIsattention(), "1") ? View.GONE : View.VISIBLE);
|
followUser.setVisibility(TextUtils.equals(liveBean.getIsattention(), "1") ? View.GONE : View.VISIBLE);
|
||||||
followUser.setOnClickListener(v -> {
|
followUser.setOnClickListener(v -> {
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
LiveNetManager.get(mContext)
|
LiveNetManager.get(mContext)
|
||||||
.setAttents(String.valueOf(liveBean.getUid()), new HttpCallback<SetAttentsModel>() {
|
.setAttents(String.valueOf(liveBean.getUid()), new HttpCallback<SetAttentsModel>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(SetAttentsModel data) {
|
public void onSuccess(SetAttentsModel data) {
|
||||||
followUser.setVisibility(View.GONE);
|
followUser.setVisibility(View.GONE);
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
ToastUtil.show(error);
|
ToastUtil.show(error);
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -308,14 +298,10 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
*/
|
*/
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onJumpUserHome(JumpUserHomeEvent event) {
|
public void onJumpUserHome(JumpUserHomeEvent event) {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
LiveNetManager.get(mContext)
|
LiveNetManager.get(mContext)
|
||||||
.getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback<LiveInfoModel>() {
|
.getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback<LiveInfoModel>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(LiveInfoModel data) {
|
public void onSuccess(LiveInfoModel data) {
|
||||||
fragment.dismiss();
|
|
||||||
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> {
|
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> {
|
||||||
if (liveBean == null) {
|
if (liveBean == null) {
|
||||||
return;
|
return;
|
||||||
@ -339,7 +325,6 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
fragment.dismiss();
|
|
||||||
|
|
||||||
RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0);
|
RouteUtil.forwardUserHome(mContext, String.valueOf(event.getModel().getId()), 0);
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ import com.yunbao.common.bean.LiveSvgGiftBean;
|
|||||||
import com.yunbao.common.bean.UpdataListBean;
|
import com.yunbao.common.bean.UpdataListBean;
|
||||||
import com.yunbao.common.custom.TabButtonGroup;
|
import com.yunbao.common.custom.TabButtonGroup;
|
||||||
import com.yunbao.common.dialog.InstructorOperationDialog;
|
import com.yunbao.common.dialog.InstructorOperationDialog;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
|
||||||
import com.yunbao.common.event.InstructorOperationEvent;
|
import com.yunbao.common.event.InstructorOperationEvent;
|
||||||
import com.yunbao.common.event.MessageIMEvent;
|
import com.yunbao.common.event.MessageIMEvent;
|
||||||
import com.yunbao.common.event.NoviceInstructorEvent;
|
import com.yunbao.common.event.NoviceInstructorEvent;
|
||||||
@ -418,9 +417,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
* 首页推荐位
|
* 首页推荐位
|
||||||
*/
|
*/
|
||||||
private void initAnchorRecommendBanner() {
|
private void initAnchorRecommendBanner() {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
MainNetManager.get(mContext)
|
MainNetManager.get(mContext)
|
||||||
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
|
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
|
||||||
@Override
|
@Override
|
||||||
@ -433,14 +429,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
floatBanner.setVisibility(View.GONE);
|
floatBanner.setVisibility(View.GONE);
|
||||||
findViewById(R.id.banner_click).setVisibility(View.GONE);
|
findViewById(R.id.banner_click).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
fragment.dismiss();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import androidx.fragment.app.FragmentTransaction;
|
|||||||
import com.blankj.utilcode.util.GsonUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.yunbao.common.activity.AbsActivity;
|
import com.yunbao.common.activity.AbsActivity;
|
||||||
import com.yunbao.common.bean.LiveInfoModel;
|
import com.yunbao.common.bean.LiveInfoModel;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.http.live.LiveNetManager;
|
import com.yunbao.common.http.live.LiveNetManager;
|
||||||
import com.yunbao.common.manager.SearchHistoryRecordManager;
|
import com.yunbao.common.manager.SearchHistoryRecordManager;
|
||||||
@ -170,14 +169,10 @@ public class SearchActivity extends AbsActivity {
|
|||||||
*/
|
*/
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onJumpUserHome(JumpUserHomeEvent event) {
|
public void onJumpUserHome(JumpUserHomeEvent event) {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
LiveNetManager.get(mContext)
|
LiveNetManager.get(mContext)
|
||||||
.getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback<LiveInfoModel>() {
|
.getLiveInfo(String.valueOf(event.getModel().getId()), new HttpCallback<LiveInfoModel>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(LiveInfoModel data) {
|
public void onSuccess(LiveInfoModel data) {
|
||||||
fragment.dismiss();
|
|
||||||
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> {
|
LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean, liveType, liveTypeVal, liveSdk) -> {
|
||||||
if (liveBean == null) {
|
if (liveBean == null) {
|
||||||
return;
|
return;
|
||||||
@ -193,7 +188,6 @@ public class SearchActivity extends AbsActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
fragment.dismiss();
|
|
||||||
//跳转到个人资料
|
//跳转到个人资料
|
||||||
if (imm != null && mEditText != null) {
|
if (imm != null && mEditText != null) {
|
||||||
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
||||||
|
@ -11,7 +11,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.yunbao.common.bean.SearchModel;
|
import com.yunbao.common.bean.SearchModel;
|
||||||
import com.yunbao.common.bean.SetAttentsModel;
|
import com.yunbao.common.bean.SetAttentsModel;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.http.live.LiveNetManager;
|
import com.yunbao.common.http.live.LiveNetManager;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
@ -47,8 +46,6 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
|
|||||||
resultsViewHolder.setCallback(new SearchResultsViewHolder.SearchResultsCallback() {
|
resultsViewHolder.setCallback(new SearchResultsViewHolder.SearchResultsCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void focusOn(SearchModel model) {
|
public void focusOn(SearchModel model) {
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(((FragmentActivity) context).getSupportFragmentManager(), "LoadingDialog");
|
|
||||||
LiveNetManager.get(context)
|
LiveNetManager.get(context)
|
||||||
.setAttents(String.valueOf(model.getId()), new HttpCallback<SetAttentsModel>() {
|
.setAttents(String.valueOf(model.getId()), new HttpCallback<SetAttentsModel>() {
|
||||||
@Override
|
@Override
|
||||||
@ -59,13 +56,11 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
ToastUtil.show(error);
|
ToastUtil.show(error);
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
|
|||||||
private final int ANCHOR = 2, USER = 3, EMPTY = 4;
|
private final int ANCHOR = 2, USER = 3, EMPTY = 4;
|
||||||
private int type = -1;
|
private int type = -1;
|
||||||
//确定是不是全部展示列表
|
//确定是不是全部展示列表
|
||||||
private boolean isAll = true, empty = false;
|
private boolean isAll = true;
|
||||||
private String searchKey = "";
|
private String searchKey = "";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -67,9 +67,7 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
if (empty) {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
if (type == 1 && lists.size() > 1) {
|
if (type == 1 && lists.size() > 1) {
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
return ANCHOR;
|
return ANCHOR;
|
||||||
@ -100,18 +98,8 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
|
|||||||
if (mLists.get(1).size() == 0) {
|
if (mLists.get(1).size() == 0) {
|
||||||
this.type = USER;
|
this.type = USER;
|
||||||
}
|
}
|
||||||
if (mLists.get(0).size() == 0 && mLists.get(1).size() == 0) {
|
|
||||||
empty = true;
|
|
||||||
} else {
|
|
||||||
empty = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
isAll = false;
|
isAll = false;
|
||||||
if (mLists.get(0).size() == 0) {
|
|
||||||
empty = true;
|
|
||||||
} else {
|
|
||||||
empty = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
lists.clear();
|
lists.clear();
|
||||||
for (List<SearchModel> searchModels : mLists) {
|
for (List<SearchModel> searchModels : mLists) {
|
||||||
|
@ -10,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.yunbao.common.bean.AnchorRecommendModel;
|
import com.yunbao.common.bean.AnchorRecommendModel;
|
||||||
import com.yunbao.common.bean.SearchRecommendModel;
|
import com.yunbao.common.bean.SearchRecommendModel;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
|
||||||
import com.yunbao.common.event.SearchRecommendEvent;
|
import com.yunbao.common.event.SearchRecommendEvent;
|
||||||
import com.yunbao.common.fragment.BaseFragment;
|
import com.yunbao.common.fragment.BaseFragment;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
@ -57,14 +56,10 @@ public class SearchRecommendFragment extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadData() {
|
protected void loadData() {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(getChildFragmentManager(), "LoadingDialog");
|
|
||||||
MainNetManager.get(getActivity())
|
MainNetManager.get(getActivity())
|
||||||
.anchorRecommend("10", new HttpCallback<AnchorRecommendModel>() {
|
.anchorRecommend("10", new HttpCallback<AnchorRecommendModel>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(AnchorRecommendModel data) {
|
public void onSuccess(AnchorRecommendModel data) {
|
||||||
fragment.dismiss();
|
|
||||||
//组装搜索历史数据
|
//组装搜索历史数据
|
||||||
List<SearchRecommendModel> searchRecommendModels = new ArrayList<>();
|
List<SearchRecommendModel> searchRecommendModels = new ArrayList<>();
|
||||||
Map<String, String> historyRecordMap = SearchHistoryRecordManager.get(getActivity()).getHistoryRecordMap();
|
Map<String, String> historyRecordMap = SearchHistoryRecordManager.get(getActivity()).getHistoryRecordMap();
|
||||||
@ -79,7 +74,6 @@ public class SearchRecommendFragment extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
fragment.dismiss();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,23 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.AnchorRecommendModel;
|
||||||
import com.yunbao.common.bean.SearchModel;
|
import com.yunbao.common.bean.SearchModel;
|
||||||
import com.yunbao.common.dialog.LoadingDialog;
|
import com.yunbao.common.event.SearchRecommendEvent;
|
||||||
import com.yunbao.common.fragment.BaseFragment;
|
import com.yunbao.common.fragment.BaseFragment;
|
||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.http.main.MainNetManager;
|
import com.yunbao.common.http.main.MainNetManager;
|
||||||
|
import com.yunbao.common.utils.Bus;
|
||||||
import com.yunbao.common.views.weight.OnRecyclerViewScrollListener;
|
import com.yunbao.common.views.weight.OnRecyclerViewScrollListener;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
|
import com.yunbao.main.adapter.SearchRecommendBodyAdapter;
|
||||||
import com.yunbao.main.adapter.SearchResultsItemAdapter;
|
import com.yunbao.main.adapter.SearchResultsItemAdapter;
|
||||||
import com.yunbao.main.utils.WordsTypeUtil;
|
import com.yunbao.main.utils.WordsTypeUtil;
|
||||||
|
|
||||||
@ -30,6 +36,10 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
private int type = 1;
|
private int type = 1;
|
||||||
private RecyclerView searchList;
|
private RecyclerView searchList;
|
||||||
private SearchResultsItemAdapter itemAdapter;
|
private SearchResultsItemAdapter itemAdapter;
|
||||||
|
private LinearLayout emptyLayout;
|
||||||
|
private RecyclerView liveList;
|
||||||
|
private SearchRecommendBodyAdapter adapter;
|
||||||
|
private ImageView changeBatch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
|
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
|
||||||
@ -44,7 +54,9 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void initViews(Bundle savedInstanceState, View contentView) {
|
protected void initViews(Bundle savedInstanceState, View contentView) {
|
||||||
searchList = contentView.findViewById(R.id.search_list);
|
searchList = contentView.findViewById(R.id.search_list);
|
||||||
|
emptyLayout = contentView.findViewById(R.id.empty_layout);
|
||||||
itemAdapter = new SearchResultsItemAdapter();
|
itemAdapter = new SearchResultsItemAdapter();
|
||||||
|
|
||||||
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
searchList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||||
searchList.setAdapter(itemAdapter);
|
searchList.setAdapter(itemAdapter);
|
||||||
searchList.addOnScrollListener(new OnRecyclerViewScrollListener() {
|
searchList.addOnScrollListener(new OnRecyclerViewScrollListener() {
|
||||||
@ -54,6 +66,32 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
setSearchKey(searchKey, type);
|
setSearchKey(searchKey, type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
emptyLayout.setVisibility(View.GONE);
|
||||||
|
liveList = contentView.findViewById(R.id.live_list);
|
||||||
|
changeBatch = contentView.findViewById(R.id.change_batch);
|
||||||
|
liveList.setLayoutManager(new GridLayoutManager(contentView.getContext(), 2, GridLayoutManager.VERTICAL, false));
|
||||||
|
adapter = new SearchRecommendBodyAdapter(getActivity());
|
||||||
|
liveList.setAdapter(adapter);
|
||||||
|
//启用嵌套滚动
|
||||||
|
liveList.setNestedScrollingEnabled(false);
|
||||||
|
changeBatch.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Bus.get().post(new SearchRecommendEvent());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MainNetManager.get(getActivity())
|
||||||
|
.anchorRecommend("10", new HttpCallback<AnchorRecommendModel>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(AnchorRecommendModel data) {
|
||||||
|
adapter.showData(data.getList());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,9 +106,6 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
* @param type 類型
|
* @param type 類型
|
||||||
*/
|
*/
|
||||||
public void setSearchKey(String searchKey, int type) {
|
public void setSearchKey(String searchKey, int type) {
|
||||||
//展示网络请求弹窗
|
|
||||||
LoadingDialog fragment = new LoadingDialog();
|
|
||||||
fragment.show(getChildFragmentManager(), "LoadingDialog");
|
|
||||||
this.searchKey = searchKey;
|
this.searchKey = searchKey;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
@ -80,18 +115,24 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
type, page, new HttpCallback<List<List<SearchModel>>>() {
|
type, page, new HttpCallback<List<List<SearchModel>>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<List<SearchModel>> data) {
|
public void onSuccess(List<List<SearchModel>> data) {
|
||||||
fragment.dismiss();
|
|
||||||
if (page > 1) {
|
if (page > 1) {
|
||||||
itemAdapter.onLoadMoreData(data, searchKey);
|
itemAdapter.onLoadMoreData(data, searchKey);
|
||||||
} else {
|
} else {
|
||||||
itemAdapter.showData(data, type, searchKey);
|
|
||||||
|
if (data.get(0).size() == 0 && data.get(1).size() == 0) {
|
||||||
|
emptyLayout.setVisibility(View.VISIBLE);
|
||||||
|
searchList.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
itemAdapter.showData(data, type, searchKey);
|
||||||
|
searchList.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
|
emptyLayout.setVisibility(View.VISIBLE);
|
||||||
fragment.dismiss();
|
searchList.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -101,14 +142,21 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
type, page, new HttpCallback<List<SearchModel>>() {
|
type, page, new HttpCallback<List<SearchModel>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<SearchModel> data) {
|
public void onSuccess(List<SearchModel> data) {
|
||||||
fragment.dismiss();
|
|
||||||
|
|
||||||
List<List<SearchModel>> listList = new ArrayList<>();
|
List<List<SearchModel>> listList = new ArrayList<>();
|
||||||
listList.add(data);
|
listList.add(data);
|
||||||
if (page > 1) {
|
if (page > 1) {
|
||||||
itemAdapter.onLoadMoreData(listList, searchKey);
|
itemAdapter.onLoadMoreData(listList, searchKey);
|
||||||
} else {
|
} else {
|
||||||
itemAdapter.showData(listList, type, searchKey);
|
if (data.size() == 0) {
|
||||||
|
emptyLayout.setVisibility(View.VISIBLE);
|
||||||
|
searchList.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
itemAdapter.showData(listList, type, searchKey);
|
||||||
|
searchList.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,8 +164,8 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
|
emptyLayout.setVisibility(View.VISIBLE);
|
||||||
fragment.dismiss();
|
searchList.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -164,4 +212,5 @@ public class SearchResultsItemFragment extends BaseFragment {
|
|||||||
searchRecommendFragment.setArguments(bundle);
|
searchRecommendFragment.setArguments(bundle);
|
||||||
return searchRecommendFragment;
|
return searchRecommendFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,78 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fadingEdge="none" />
|
android:fadingEdge="none" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/empty_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="141.67dp"
|
||||||
|
android:src="@mipmap/img_search_empty" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/type_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginTop="31dp"
|
||||||
|
android:layout_marginRight="15dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/change_batch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical|right"
|
||||||
|
android:background="@mipmap/icon_cange" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/anchor_more"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:text="@string/you_may_also_like"
|
||||||
|
android:textColor="#FF000000"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2px"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/live_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:fadingEdge="none" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user