侧边栏:权益

This commit is contained in:
18401019693 2022-11-09 17:02:02 +08:00
parent 60453c756c
commit f74a01efc0
8 changed files with 108 additions and 17 deletions

View File

@ -70,6 +70,9 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
}else if (holder instanceof FunGamesViewHolder) { }else if (holder instanceof FunGamesViewHolder) {
FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder; FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder;
funGamesViewHolder.setData(infoModels.get(position)); funGamesViewHolder.setData(infoModels.get(position));
}else if (holder instanceof RigtsInterestsViewHolder) {
RigtsInterestsViewHolder rigtsInterestsViewHolder = (RigtsInterestsViewHolder) holder;
rigtsInterestsViewHolder.setData(infoModels.get(position));
} }
} }

View File

@ -17,10 +17,12 @@ import java.util.List;
public class FunGamesAdapter extends RecyclerView.Adapter { public class FunGamesAdapter extends RecyclerView.Adapter {
private Context mContext; private Context mContext;
private boolean rigts ;
private List<CustomSidebarChildModel> child = new ArrayList<>(); private List<CustomSidebarChildModel> child = new ArrayList<>();
public FunGamesAdapter(Context mContext) { public FunGamesAdapter(Context mContext,boolean rigts) {
this.mContext = mContext; this.mContext = mContext;
this.rigts = rigts;
} }
@NonNull @NonNull
@ -33,13 +35,14 @@ public class FunGamesAdapter extends RecyclerView.Adapter {
@Override @Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
FunGamesChildViewHolder childViewHolder = (FunGamesChildViewHolder) holder; FunGamesChildViewHolder childViewHolder = (FunGamesChildViewHolder) holder;
((FunGamesChildViewHolder) holder).setData(child.get(position)); childViewHolder.setData(child.get(position),rigts);
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return child.size(); return child.size();
} }
public void updateData(List<CustomSidebarChildModel> mChild) { public void updateData(List<CustomSidebarChildModel> mChild) {
child.clear(); child.clear();
child.addAll(mChild); child.addAll(mChild);

View File

@ -29,6 +29,17 @@ public class CustomSidebarChildModel extends BaseModel {
@SerializedName("now_num") @SerializedName("now_num")
private String nowNum; private String nowNum;
private int resIcon;
public int getResIcon() {
return resIcon;
}
public CustomSidebarChildModel setResIcon(int resIcon) {
this.resIcon = resIcon;
return this;
}
public String getId() { public String getId() {
return id; return id;
} }

View File

@ -21,8 +21,14 @@ public class FunGamesChildViewHolder extends RecyclerView.ViewHolder {
funGameName = itemView.findViewById(R.id.fun_game_name); funGameName = itemView.findViewById(R.id.fun_game_name);
} }
public void setData(CustomSidebarChildModel model) { public void setData(CustomSidebarChildModel model, boolean rigts) {
if (rigts) {
ImgLoader.display(itemView.getContext(), model.getIcon(), funGamePic); ImgLoader.display(itemView.getContext(), model.getIcon(), funGamePic);
} else {
ImgLoader.display(itemView.getContext(), model.getResIcon(), funGamePic);
}
funGameName.setText(model.getTitle()); funGameName.setText(model.getTitle());
} }
} }

View File

@ -21,7 +21,7 @@ public class FunGamesViewHolder extends RecyclerView.ViewHolder {
sendGoodGift = itemView.findViewById(R.id.send_good_gift); sendGoodGift = itemView.findViewById(R.id.send_good_gift);
subtitle = itemView.findViewById(R.id.subtitle); subtitle = itemView.findViewById(R.id.subtitle);
childList = itemView.findViewById(R.id.child_list); childList = itemView.findViewById(R.id.child_list);
funGamesAdapter = new FunGamesAdapter(itemView.getContext()); funGamesAdapter = new FunGamesAdapter(itemView.getContext(), true);
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4)); childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4));
childList.setAdapter(funGamesAdapter); childList.setAdapter(funGamesAdapter);
} }

View File

@ -1,13 +1,55 @@
package com.yunbao.common.views; package com.yunbao.common.views;
import android.view.View; import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.FunGamesAdapter;
import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import java.util.ArrayList;
import java.util.List;
public class RigtsInterestsViewHolder extends RecyclerView.ViewHolder { public class RigtsInterestsViewHolder extends RecyclerView.ViewHolder {
private FunGamesAdapter funGamesAdapter;
private TextView sendGoodGift;
private RecyclerView childList;
public RigtsInterestsViewHolder(@NonNull View itemView) { public RigtsInterestsViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
sendGoodGift = itemView.findViewById(R.id.send_good_gift);
childList = itemView.findViewById(R.id.child_list);
sendGoodGift = itemView.findViewById(R.id.send_good_gift);
childList = itemView.findViewById(R.id.child_list);
funGamesAdapter = new FunGamesAdapter(itemView.getContext(), false);
childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 3));
childList.setAdapter(funGamesAdapter);
}
public void setData(CustomSidebarInfoModel model) {
sendGoodGift.setText(model.getTitle());
funGamesAdapter.updateData(generateData());
}
private List<CustomSidebarChildModel> generateData() {
List<CustomSidebarChildModel> child = new ArrayList<>();
child.add(new CustomSidebarChildModel()
.setTitle(itemView.getContext().getString(R.string.noble))
.setResIcon(R.mipmap.live_more_icon_aristocrat));
child.add(new CustomSidebarChildModel()
.setTitle(itemView.getContext().getString(R.string.guard_guard))
.setResIcon(R.mipmap.live_more_icon_guard));
child.add(new CustomSidebarChildModel()
.setTitle(itemView.getContext().getString(R.string.fan_club))
.setResIcon(R.mipmap.live_more_icon_fans));
return child;
} }
} }

View File

@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginEnd="14dp" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/fun_game_pic" android:id="@+id/fun_game_pic"
android:layout_width="40dp" android:layout_width="38dp"
android:layout_height="40dp" android:layout_height="38dp"
android:src="@mipmap/live_more_icon_guard" /> android:src="@mipmap/live_more_icon_guard" />
<TextView <TextView
@ -20,6 +19,6 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:text="@string/guard_guard" android:text="@string/guard_guard"
android:textColor="#9A9A9A" android:textColor="#9A9A9A"
android:textSize="12sp" /> android:textSize="10sp" />
</LinearLayout> </LinearLayout>

View File

@ -1,6 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_drawer_popup"
android:orientation="vertical">
</androidx.constraintlayout.widget.ConstraintLayout> <FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp">
<TextView
android:id="@+id/send_good_gift"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任務中心"
android:textColor="#F6F7FB"
android:textSize="14sp" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/child_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp" />
</LinearLayout>