1010import android .widget .TextView ;
1111
1212import androidx .annotation .NonNull ;
13+ import androidx .cardview .widget .CardView ;
1314import androidx .recyclerview .widget .GridLayoutManager ;
1415import androidx .recyclerview .widget .RecyclerView ;
1516
@@ -31,6 +32,7 @@ public class HomeMenuAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
3132 public int itemSize ;
3233 public int shapeDrawable ;
3334 public int textColor ;
35+ public int cardColor =-1 ;
3436 long DURATION = 0 ;
3537 private boolean on_attach = true ;
3638
@@ -51,13 +53,20 @@ public class HomeMenuAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
5153 public ViewHolder onCreateViewHolder (ViewGroup parent , int viewType ) {
5254 View view =null ;
5355
54- if (isGridMenu ) {
55- view = mInflater .inflate (R .layout .rv_item_grid_menu , parent , false );
56+ if (isGridMenu && cardColor ==- 1 ) {
57+ view = mInflater .inflate (R .layout .rv_item_circle_grid_menu , parent , false );
5658 GridLayoutManager .LayoutParams params = (GridLayoutManager .LayoutParams ) view .getLayoutParams ();
5759 params .height = itemSize ;
5860 view .setLayoutParams (params );
5961
6062 }
63+ else if (cardColor !=-1 &&isGridMenu )
64+ {
65+ view = mInflater .inflate (R .layout .rv_item_grid_menu , parent , false );
66+ GridLayoutManager .LayoutParams params = (GridLayoutManager .LayoutParams ) view .getLayoutParams ();
67+ params .height = itemSize ;
68+ view .setLayoutParams (params );
69+ }
6170 else {
6271 view = mInflater .inflate (R .layout .rv_material_home_menu , parent , false );
6372 }
@@ -80,6 +89,11 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
8089
8190 viewHolder .imgMenuIcon .setVisibility (isMenuIcon ?View .VISIBLE :View .GONE );
8291
92+ if (isGridMenu &&cardColor !=-1 )
93+ {
94+ viewHolder .cardMenu .setCardBackgroundColor (context .getResources ().getColor (cardColor ));
95+ }
96+
8397 switch (drawable_shape )
8498 {
8599 case CIRCLE :
@@ -130,7 +144,10 @@ public void setAnimationType(HomeMenu.MENU_ANIMATION animationType,long duration
130144 this .DURATION =duration ;
131145 notifyDataSetChanged ();
132146 }
133-
147+ public void setMenuCardColor (int mCardcolor ) {
148+ this .cardColor = mCardcolor ;
149+ notifyDataSetChanged ();
150+ }
134151 public void setMenuIcon (boolean menuIcon ) {
135152 isMenuIcon = menuIcon ;
136153 notifyDataSetChanged ();
@@ -171,6 +188,7 @@ static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
171188 LinearLayout rootlayout ;
172189 TextView txtMenuDesc ;
173190 ImageView imgMenuIcon ;
191+ CardView cardMenu ;
174192
175193
176194 ViewHolder (View view ) {
@@ -179,6 +197,7 @@ static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
179197 rootlayout =view .findViewById (R .id .rootlayout );
180198 txtMenuDesc =view .findViewById (R .id .txtMenuDesc );
181199 imgMenuIcon =view .findViewById (R .id .imgMenuIcon );
200+ cardMenu =view .findViewById (R .id .cardMenu );
182201
183202 view .setOnClickListener (this );
184203 }
0 commit comments