侧边栏修改
This commit is contained in:
@@ -17,10 +17,10 @@ import java.util.List;
|
||||
|
||||
public class FunGamesAdapter extends RecyclerView.Adapter {
|
||||
private Context mContext;
|
||||
private boolean rigts ;
|
||||
private boolean rigts;
|
||||
private List<CustomSidebarChildModel> child = new ArrayList<>();
|
||||
|
||||
public FunGamesAdapter(Context mContext,boolean rigts) {
|
||||
public FunGamesAdapter(Context mContext, boolean rigts) {
|
||||
this.mContext = mContext;
|
||||
this.rigts = rigts;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class FunGamesAdapter extends RecyclerView.Adapter {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
FunGamesChildViewHolder childViewHolder = (FunGamesChildViewHolder) holder;
|
||||
childViewHolder.setData(child.get(position),rigts);
|
||||
childViewHolder.setData(child.get(position), rigts);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,6 +44,18 @@ public class FunGamesAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
public void updateData(List<CustomSidebarChildModel> mChild) {
|
||||
child.clear();
|
||||
if (mChild.size() > 8) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
child.add(mChild.get(i));
|
||||
}
|
||||
} else {
|
||||
child.addAll(mChild);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void selectAll(List<CustomSidebarChildModel> mChild){
|
||||
child.clear();
|
||||
child.addAll(mChild);
|
||||
notifyDataSetChanged();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -12,24 +12,32 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.adapter.FunGamesAdapter;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.event.CustomDrawerPopupEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FunGamesViewHolder extends RecyclerView.ViewHolder {
|
||||
private FunGamesAdapter funGamesAdapter;
|
||||
private TextView sendGoodGift, subtitle;
|
||||
private TextView sendGoodGift, subtitle, selectMore;
|
||||
private RecyclerView childList;
|
||||
private ImageView selectMoreIcon;
|
||||
boolean isShowMore = true;
|
||||
|
||||
public FunGamesViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
sendGoodGift = itemView.findViewById(R.id.send_good_gift);
|
||||
subtitle = itemView.findViewById(R.id.subtitle);
|
||||
childList = itemView.findViewById(R.id.child_list);
|
||||
selectMoreIcon = itemView.findViewById(R.id.select_more_icon);
|
||||
selectMore = itemView.findViewById(R.id.select_more);
|
||||
funGamesAdapter = new FunGamesAdapter(itemView.getContext(), true);
|
||||
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4));
|
||||
childList.setAdapter(funGamesAdapter);
|
||||
@@ -37,9 +45,14 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
|
||||
public void setData(CustomSidebarInfoModel model) {
|
||||
|
||||
List<CustomSidebarChildModel> sidebarChildModels = model.getChild();
|
||||
// sidebarChildModels.addAll(model.getChild());
|
||||
// sidebarChildModels.addAll(model.getChild());
|
||||
itemView.findViewById(R.id.select_more_layout).setVisibility(sidebarChildModels.size() >= 8 ? View.VISIBLE : View.GONE);
|
||||
sendGoodGift.setText(model.getTitle());
|
||||
subtitle.setText(model.getSubtitle());
|
||||
funGamesAdapter.updateData(model.getChild());
|
||||
funGamesAdapter.updateData(sidebarChildModels);
|
||||
ViewClicksAntiShake.clicksAntiShake(subtitle, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
@@ -64,5 +77,21 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.select_more_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (isShowMore) {
|
||||
funGamesAdapter.selectAll(sidebarChildModels);
|
||||
|
||||
selectMore.setText(R.string.video_comment_collapsed);
|
||||
ImgLoader.display(itemView.getContext(), R.mipmap.icon_more_up, selectMoreIcon);
|
||||
} else {
|
||||
funGamesAdapter.updateData(sidebarChildModels);
|
||||
selectMore.setText(R.string.moer);
|
||||
ImgLoader.display(itemView.getContext(), R.mipmap.icon_more_down, selectMoreIcon);
|
||||
}
|
||||
isShowMore = !isShowMore;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user