猜你喜欢
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yunbao.common.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -10,7 +11,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.bean.AnchorRecommendModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.http.main.MainNetManager;
|
||||
import com.yunbao.common.views.DrawerRecommendViewHolder;
|
||||
import com.yunbao.common.views.DrawerTaskViewHolder;
|
||||
import com.yunbao.common.views.FunGamesViewHolder;
|
||||
@@ -85,6 +88,34 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
RecommendViewHolder recommendViewHolder = (RecommendViewHolder) holder;
|
||||
recommendViewHolder.setData(infoModels.get(position));
|
||||
recommendViewHolder.updateData(list);
|
||||
recommendViewHolder.setListener(new RecommendViewHolder.RecommendViewListener() {
|
||||
@Override
|
||||
public void changeOneBatch() {
|
||||
//推荐位
|
||||
MainNetManager.get((Activity) mContext)
|
||||
.anchorRecommend("9", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
|
||||
@Override
|
||||
public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
|
||||
|
||||
List<AnchorRecommendItemModel> models = anchorRecommendModel.getList();
|
||||
|
||||
recommendViewHolder.updateData(models);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goToLive(AnchorRecommendItemModel model) {
|
||||
if (listener != null) {
|
||||
listener.goToLive(model);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,4 +148,15 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
|
||||
infoModels.addAll(mInfoModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private CustomDrawerListener listener;
|
||||
|
||||
public CustomDrawerPopupAdapter setListener(CustomDrawerListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface CustomDrawerListener {
|
||||
void goToLive(AnchorRecommendItemModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,14 @@ public class RecommendAdapter extends RecyclerView.Adapter {
|
||||
|
||||
RecommendChildViewHolder itemViewHolder = (RecommendChildViewHolder) holder;
|
||||
itemViewHolder.setData(list.get(position));
|
||||
itemViewHolder.setListener(new RecommendChildViewHolder.RecommendChildListener() {
|
||||
@Override
|
||||
public void goToLive(AnchorRecommendItemModel model) {
|
||||
if (callback != null) {
|
||||
callback.goToLive(model);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,4 +53,15 @@ public class RecommendAdapter extends RecyclerView.Adapter {
|
||||
list.addAll(mList);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private RecommendCallback callback;
|
||||
|
||||
public RecommendAdapter setCallback(RecommendCallback callback) {
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface RecommendCallback {
|
||||
void goToLive(AnchorRecommendItemModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,21 @@ public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initView() {
|
||||
drawerList = findViewById(R.id.drawerList);
|
||||
adapter = new CustomDrawerPopupAdapter(mContext);
|
||||
adapter.setList(list);
|
||||
drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
drawerList.setAdapter(adapter);
|
||||
adapter.setListener(new CustomDrawerPopupAdapter.CustomDrawerListener() {
|
||||
@Override
|
||||
public void goToLive(AnchorRecommendItemModel model) {
|
||||
if (callBack != null) {
|
||||
callBack.goToLive(model);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
@@ -70,4 +79,15 @@ public class CustomDrawerPopupView extends DrawerPopupView {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CustomDrawerPopupCallBack callBack;
|
||||
|
||||
public CustomDrawerPopupView setCallBack(CustomDrawerPopupCallBack callBack) {
|
||||
this.callBack = callBack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface CustomDrawerPopupCallBack {
|
||||
void goToLive(AnchorRecommendItemModel model);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
public class RecommendChildViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView cover;
|
||||
@@ -38,5 +39,24 @@ public class RecommendChildViewHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
ImgLoader.display(itemView.getContext(), bean.getThumb(), cover);
|
||||
name.setText(bean.getUserNicename());
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (listener != null) {
|
||||
listener.goToLive(bean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private RecommendChildListener listener;
|
||||
|
||||
public RecommendChildViewHolder setListener(RecommendChildListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface RecommendChildListener {
|
||||
void goToLive(AnchorRecommendItemModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.RecommendAdapter;
|
||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,6 +29,24 @@ public class RecommendViewHolder extends RecyclerView.ViewHolder {
|
||||
recommendAdapter = new RecommendAdapter(itemView.getContext());
|
||||
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 3));
|
||||
childList.setAdapter(recommendAdapter);
|
||||
ViewClicksAntiShake.clicksAntiShake(subtitle, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (listener != null) {
|
||||
listener.changeOneBatch();
|
||||
}
|
||||
}
|
||||
});
|
||||
recommendAdapter.setCallback(new RecommendAdapter.RecommendCallback() {
|
||||
@Override
|
||||
public void goToLive(AnchorRecommendItemModel model) {
|
||||
if (listener != null) {
|
||||
listener.goToLive(model);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarInfoModel model) {
|
||||
@@ -38,4 +57,17 @@ public class RecommendViewHolder extends RecyclerView.ViewHolder {
|
||||
public void updateData(List<AnchorRecommendItemModel> list) {
|
||||
recommendAdapter.updateData(list);
|
||||
}
|
||||
|
||||
private RecommendViewListener listener;
|
||||
|
||||
public RecommendViewHolder setListener(RecommendViewListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface RecommendViewListener {
|
||||
void changeOneBatch();
|
||||
|
||||
void goToLive(AnchorRecommendItemModel model);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user