diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java index 4c5aaf9dd..1ff46d624 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java @@ -67,6 +67,9 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter { }else if (holder instanceof DrawerTaskViewHolder) { DrawerTaskViewHolder taskViewHolder = (DrawerTaskViewHolder) holder; taskViewHolder.setData(infoModels.get(position)); + }else if (holder instanceof FunGamesViewHolder) { + FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder; + funGamesViewHolder.setData(infoModels.get(position)); } } diff --git a/common/src/main/java/com/yunbao/common/adapter/FunGamesAdapter.java b/common/src/main/java/com/yunbao/common/adapter/FunGamesAdapter.java new file mode 100644 index 000000000..5c55d6aa0 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/FunGamesAdapter.java @@ -0,0 +1,48 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.views.FunGamesChildViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class FunGamesAdapter extends RecyclerView.Adapter { + private Context mContext; + private List child = new ArrayList<>(); + + public FunGamesAdapter(Context mContext) { + this.mContext = mContext; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View runGamesView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_fun_games_child_view, parent, false); + return new FunGamesChildViewHolder(runGamesView); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + FunGamesChildViewHolder childViewHolder = (FunGamesChildViewHolder) holder; + ((FunGamesChildViewHolder) holder).setData(child.get(position)); + } + + @Override + public int getItemCount() { + return child.size(); + } + public void updateData(List mChild) { + child.clear(); + child.addAll(mChild); + notifyDataSetChanged(); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java new file mode 100644 index 000000000..033733abb --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/FunGamesChildViewHolder.java @@ -0,0 +1,28 @@ +package com.yunbao.common.views; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.glide.ImgLoader; + +public class FunGamesChildViewHolder extends RecyclerView.ViewHolder { + private ImageView funGamePic; + private TextView funGameName; + + public FunGamesChildViewHolder(@NonNull View itemView) { + super(itemView); + funGamePic = itemView.findViewById(R.id.fun_game_pic); + funGameName = itemView.findViewById(R.id.fun_game_name); + } + + public void setData(CustomSidebarChildModel model) { + ImgLoader.display(itemView.getContext(), model.getIcon(), funGamePic); + funGameName.setText(model.getTitle()); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java index 1ae8f0ad9..a971eebe1 100644 --- a/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/FunGamesViewHolder.java @@ -1,12 +1,34 @@ package com.yunbao.common.views; import android.view.View; +import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.FunGamesAdapter; +import com.yunbao.common.bean.CustomSidebarInfoModel; + public class FunGamesViewHolder extends RecyclerView.ViewHolder { - public FunGamesViewHolder(@NonNull View itemView) { - super(itemView); - } + private FunGamesAdapter funGamesAdapter; + private TextView sendGoodGift, subtitle; + private RecyclerView childList; + + 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); + funGamesAdapter = new FunGamesAdapter(itemView.getContext()); + childList.setLayoutManager(new GridLayoutManager(itemView.getContext(), 4)); + childList.setAdapter(funGamesAdapter); + } + + public void setData(CustomSidebarInfoModel model) { + sendGoodGift.setText(model.getTitle()); + subtitle.setText(model.getSubtitle()); + funGamesAdapter.updateData(model.getChild()); + } } diff --git a/common/src/main/res/layout/custom_drawer_popup.xml b/common/src/main/res/layout/custom_drawer_popup.xml index 1fe7b92b8..a87f71f26 100644 --- a/common/src/main/res/layout/custom_drawer_popup.xml +++ b/common/src/main/res/layout/custom_drawer_popup.xml @@ -1,23 +1,15 @@ - - - - - + - \ No newline at end of file + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_fun_games_child_view.xml b/common/src/main/res/layout/view_fun_games_child_view.xml new file mode 100644 index 000000000..af4505e8a --- /dev/null +++ b/common/src/main/res/layout/view_fun_games_child_view.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_fun_games_view.xml b/common/src/main/res/layout/view_fun_games_view.xml index 77d9ef65f..10d52e99e 100644 --- a/common/src/main/res/layout/view_fun_games_view.xml +++ b/common/src/main/res/layout/view_fun_games_view.xml @@ -1,6 +1,46 @@ - + 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"> - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file