修改测试问题,shouye ytuijian

This commit is contained in:
18401019693 2022-08-10 13:40:58 +08:00
parent 2b5d3b51f4
commit e96d0e7bf4
8 changed files with 36 additions and 20 deletions

View File

@ -368,7 +368,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
mViewPager.setCurrentItem(0); mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0); mTabButtonGroup.setCurPosition(0);
isInstructor(); isInstructor();
initAnchorRecommendBanner();
findViewById(R.id.banner_click).setOnClickListener(new View.OnClickListener() { findViewById(R.id.banner_click).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -406,6 +405,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
if (index==0){ if (index==0){
floatBanner.setVisibility(View.VISIBLE); floatBanner.setVisibility(View.VISIBLE);
findViewById(R.id.banner_click).setVisibility(View.VISIBLE); findViewById(R.id.banner_click).setVisibility(View.VISIBLE);
initAnchorRecommendBanner();
}else { }else {
floatBanner.setVisibility(View.GONE); floatBanner.setVisibility(View.GONE);
findViewById(R.id.banner_click).setVisibility(View.GONE); findViewById(R.id.banner_click).setVisibility(View.GONE);
@ -675,7 +675,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
//获取指导员引导逻辑 //获取指导员引导逻辑
NoviceInstructorManager.get(mContext).getNoviceInstructor(); NoviceInstructorManager.get(mContext).getNoviceInstructor();
NoviceInstructorManager.get(mContext).checktHomeZdyPop(); NoviceInstructorManager.get(mContext).checktHomeZdyPop();
initAnchorRecommendBanner();
} }

View File

@ -25,6 +25,7 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
private List<SearchModel> searchModels = new ArrayList<>(); private List<SearchModel> searchModels = new ArrayList<>();
private int type = -1; private int type = -1;
private Context context; private Context context;
private String searchKey;
public SearchResultsAdapter(Context context) { public SearchResultsAdapter(Context context) {
this.context = context; this.context = context;
@ -42,7 +43,7 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
//展示网络请求弹窗 //展示网络请求弹窗
SearchResultsViewHolder resultsViewHolder = (SearchResultsViewHolder) holder; SearchResultsViewHolder resultsViewHolder = (SearchResultsViewHolder) holder;
resultsViewHolder.showData(searchModels.get(position), type); resultsViewHolder.showData(searchModels.get(position), type,searchKey);
resultsViewHolder.setCallback(new SearchResultsViewHolder.SearchResultsCallback() { resultsViewHolder.setCallback(new SearchResultsViewHolder.SearchResultsCallback() {
@Override @Override
public void focusOn(SearchModel model) { public void focusOn(SearchModel model) {
@ -82,7 +83,8 @@ public class SearchResultsAdapter extends RecyclerView.Adapter {
* *
* @param models * @param models
*/ */
public void putData(List<SearchModel> models, int type) { public void putData(List<SearchModel> models, int type, String searchKey) {
this.searchKey = searchKey;
this.type = type; this.type = type;
searchModels.clear(); searchModels.clear();
searchModels.addAll(models); searchModels.addAll(models);

View File

@ -24,6 +24,7 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
private int type = -1; private int type = -1;
//确定是不是全部展示列表 //确定是不是全部展示列表
private boolean isAll = true; private boolean isAll = true;
private String searchKey = "";
@NonNull @NonNull
@Override @Override
@ -42,13 +43,13 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof AnchorSearchResultsItemViewHolder) { if (holder instanceof AnchorSearchResultsItemViewHolder) {
AnchorSearchResultsItemViewHolder itemViewHolder = (AnchorSearchResultsItemViewHolder) holder; AnchorSearchResultsItemViewHolder itemViewHolder = (AnchorSearchResultsItemViewHolder) holder;
itemViewHolder.showAnchors(lists.get(position), ANCHOR); itemViewHolder.showAnchors(lists.get(position), ANCHOR,searchKey);
if (type != 1 && !isAll) { if (type != 1 && !isAll) {
itemViewHolder.hideTypeTitle(); itemViewHolder.hideTypeTitle();
} }
} else { } else {
UserSearchResultsItemViewHolder viewHolder = (UserSearchResultsItemViewHolder) holder; UserSearchResultsItemViewHolder viewHolder = (UserSearchResultsItemViewHolder) holder;
viewHolder.showAnchors(lists.get(position), USER); viewHolder.showAnchors(lists.get(position), USER,searchKey);
if (type != 1 && !isAll) { if (type != 1 && !isAll) {
viewHolder.hideTypeTitle(); viewHolder.hideTypeTitle();
} }
@ -78,7 +79,8 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
* @param mLists 數據源 * @param mLists 數據源
* @param type * @param type
*/ */
public void showData(List<List<SearchModel>> mLists, int type) { public void showData(List<List<SearchModel>> mLists, int type,String searchKey) {
this.searchKey = searchKey;
this.type = type; this.type = type;
//展示全部列表在只展示用户或者主播的一个判断服务器在查全部的时候会返回两个集合没数据也会展示一个空集合 //展示全部列表在只展示用户或者主播的一个判断服务器在查全部的时候会返回两个集合没数据也会展示一个空集合
if (mLists.size() > 1) { if (mLists.size() > 1) {
@ -104,7 +106,8 @@ public class SearchResultsItemAdapter extends RecyclerView.Adapter {
/** /**
* 加载更多资源 * 加载更多资源
*/ */
public void onLoadMoreData(List<List<SearchModel>> mLists) { public void onLoadMoreData(List<List<SearchModel>> mLists,String searchKey) {
this.searchKey = searchKey;
lists.addAll(mLists); lists.addAll(mLists);
notifyDataSetChanged(); notifyDataSetChanged();
} }

View File

@ -83,9 +83,9 @@ public class SearchResultsItemFragment extends BaseFragment {
public void onSuccess(List<List<SearchModel>> data) { public void onSuccess(List<List<SearchModel>> data) {
fragment.dismiss(); fragment.dismiss();
if (page > 1) { if (page > 1) {
itemAdapter.onLoadMoreData(data); itemAdapter.onLoadMoreData(data,searchKey);
} else { } else {
itemAdapter.showData(data, type); itemAdapter.showData(data, type,searchKey);
} }
} }
@ -109,9 +109,9 @@ public class SearchResultsItemFragment extends BaseFragment {
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); itemAdapter.onLoadMoreData(listList,searchKey);
} else { } else {
itemAdapter.showData(listList, type); itemAdapter.showData(listList, type,searchKey);
} }
} }

View File

@ -39,12 +39,12 @@ public class AnchorSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
}); });
} }
public void showAnchors(List<SearchModel> searchModels, int type) { public void showAnchors(List<SearchModel> searchModels, int type, String searchKey) {
this.searchModels = searchModels; this.searchModels = searchModels;
resultsAdapter = new SearchResultsAdapter(itemView.getContext()); resultsAdapter = new SearchResultsAdapter(itemView.getContext());
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false)); anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
anchorList.setAdapter(resultsAdapter); anchorList.setAdapter(resultsAdapter);
resultsAdapter.putData(searchModels, type); resultsAdapter.putData(searchModels, type,searchKey );
} }
public void hideTypeTitle() { public void hideTypeTitle() {

View File

@ -71,7 +71,7 @@ public class FloatBannerView extends FrameLayout {
*/ */
public void showBanner(List<AnchorRecommendItemModel> mList) { public void showBanner(List<AnchorRecommendItemModel> mList) {
list.clear(); list.clear();
list.addAll(mList); list.addAll(mList);release();
bannerHandler.post(mFlipRunnable); bannerHandler.post(mFlipRunnable);
} }

View File

@ -1,5 +1,7 @@
package com.yunbao.main.views; package com.yunbao.main.views;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
@ -25,6 +27,7 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
private RelativeLayout avatarLayout; private RelativeLayout avatarLayout;
private SearchModel model; private SearchModel model;
private SearchResultsCallback callback; private SearchResultsCallback callback;
private String searchKey = "";
public SearchResultsViewHolder setCallback(SearchResultsCallback callback) { public SearchResultsViewHolder setCallback(SearchResultsCallback callback) {
this.callback = callback; this.callback = callback;
@ -51,7 +54,7 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
}); });
} }
public void showData(SearchModel model, int type) { public void showData(SearchModel model, int type, String searchKey) {
this.model = model; this.model = model;
ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar); ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar);
//用戶直接隱藏 //用戶直接隱藏
@ -66,7 +69,7 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
if (anchorLevelBean != null) { if (anchorLevelBean != null) {
ImgLoader.display(isLive.getContext(), CommonAppConfig.getInstance().HOST + anchorLevelBean.getThumb(), contribute); ImgLoader.display(isLive.getContext(), CommonAppConfig.getInstance().HOST + anchorLevelBean.getThumb(), contribute);
} }
isLive.setVisibility(model.getIslive() == 0 ? View.VISIBLE : View.GONE); isLive.setVisibility(model.getIslive() == 0 ? View.GONE : View.VISIBLE);
} }
if (model.getSex() == 2) { if (model.getSex() == 2) {
@ -74,7 +77,7 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
} else { } else {
ImgLoader.displayAvatar(itemView.getContext(), R.mipmap.icon_sex_male_1, sex); ImgLoader.displayAvatar(itemView.getContext(), R.mipmap.icon_sex_male_1, sex);
} }
nickName.setText(model.getUserNicename()); nickName.setText(userNicenamehighlight(model.getUserNicename(),searchKey));
focusOn.setVisibility(TextUtils.equals(model.getIsattention(), "1") ? View.GONE : View.VISIBLE); focusOn.setVisibility(TextUtils.equals(model.getIsattention(), "1") ? View.GONE : View.VISIBLE);
} }
@ -91,4 +94,12 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
public interface SearchResultsCallback { public interface SearchResultsCallback {
void focusOn(SearchModel model); void focusOn(SearchModel model);
} }
private Spanned userNicenamehighlight(String context, String keyword) {
String keywordHtml = "</font><font color='#FF8D41'size='42px'>" + keyword + "</font><font color='#161616'size='42px'>";
String contextHtml = "<font color='#161616'size='42px'>" + context + "</font>";
contextHtml = contextHtml.replace(keyword, keywordHtml);
return Html.fromHtml(contextHtml);
}
} }

View File

@ -38,11 +38,11 @@ public class UserSearchResultsItemViewHolder extends RecyclerView.ViewHolder {
}); });
} }
public void showAnchors(List<SearchModel> searchModels, int type) { public void showAnchors(List<SearchModel> searchModels, int type, String searchKey) {
resultsAdapter = new SearchResultsAdapter(itemView.getContext()); resultsAdapter = new SearchResultsAdapter(itemView.getContext());
anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false)); anchorList.setLayoutManager(new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.VERTICAL, false));
anchorList.setAdapter(resultsAdapter); anchorList.setAdapter(resultsAdapter);
resultsAdapter.putData(searchModels, type); resultsAdapter.putData(searchModels, type,searchKey);
//滾動到頂部 //滾動到頂部
anchorList.smoothScrollToPosition(0); anchorList.smoothScrollToPosition(0);
} }