@@ -63,28 +63,8 @@ public LaundryRoomAdapter.CustomViewHolder onCreateViewHolder(ViewGroup parent,
63
63
64
64
@ Override
65
65
public void onBindViewHolder (LaundryRoomAdapter .CustomViewHolder holder , int position ) {
66
-
67
66
LaundryRoom room = mRooms .get (position );
68
67
69
- if (isHome ) {
70
- holder .name .setVisibility (View .GONE );
71
- holder .title .setVisibility (View .GONE );
72
- holder .lineChart .setVisibility (View .GONE );
73
- holder .layout .setBackgroundResource (0 );
74
- LinearLayout .LayoutParams layoutParams = (LinearLayout .LayoutParams ) holder .layout .getLayoutParams ();
75
- layoutParams .setMargins (0 , 0 , 0 , 0 );
76
- layoutParams .setMarginStart (0 );
77
- holder .layout .setLayoutParams (layoutParams );
78
- CardView container = (CardView ) holder .dryerRecyclerView .getParent ();
79
- ConstraintLayout .LayoutParams params = (ConstraintLayout .LayoutParams ) container .getLayoutParams ();
80
- params .setMargins (0 ,0 ,0 ,0 );
81
- container .setLayoutParams (params );
82
- container = (CardView ) holder .washerRecyclerView .getParent ();
83
- params = (ConstraintLayout .LayoutParams ) container .getLayoutParams ();
84
- params .setMargins (0 ,0 ,0 ,0 );
85
- container .setLayoutParams (params );
86
- }
87
-
88
68
// update name of laundry room and type of machine
89
69
int hall_no = room .getId ();
90
70
String location = sp .getString (hall_no + mContext .getString (R .string .location ), "" );
@@ -109,13 +89,11 @@ public void onBindViewHolder(LaundryRoomAdapter.CustomViewHolder holder, int pos
109
89
// add washer info
110
90
// recycler view for the time remaining
111
91
LaundryMachineAdapter washerAdapter = new LaundryMachineAdapter (mContext , washers , mContext .getString (R .string .washer ), roomName );
112
- holder .washerRecyclerView .setLayoutManager (new LinearLayoutManager (mContext , LinearLayoutManager .HORIZONTAL , false ));
113
92
holder .washerRecyclerView .setAdapter (washerAdapter );
114
93
115
94
// add dryer info
116
95
// recycler view for the time remaining
117
96
LaundryMachineAdapter adapter = new LaundryMachineAdapter (mContext , dryers , mContext .getString (R .string .dryer ), roomName );
118
- holder .dryerRecyclerView .setLayoutManager (new LinearLayoutManager (mContext , LinearLayoutManager .HORIZONTAL , false ));
119
97
holder .dryerRecyclerView .setAdapter (adapter );
120
98
121
99
// overview of how many machines are available
@@ -135,7 +113,7 @@ public void onBindViewHolder(LaundryRoomAdapter.CustomViewHolder holder, int pos
135
113
int totalDryers = openDryers + runningDryers + offlineDryers + outOfOrderDryers ;
136
114
holder .dryerAvailability .setText (openDryers + " of " + totalDryers + " Open" );
137
115
138
- if (mRoomsData != null ) {
116
+ if (! isHome && mRoomsData != null ) {
139
117
if (mRoomsData .size () > position ) createLaundryChart (holder , position );
140
118
}
141
119
@@ -210,7 +188,6 @@ public int getItemCount() {
210
188
public class CustomViewHolder extends RecyclerView .ViewHolder {
211
189
212
190
Context mContext ;
213
- ArrayList <LaundryRoom > mRooms ;
214
191
215
192
//@BindView(R.id.laundry_room_title)
216
193
TextView name ;
@@ -233,7 +210,6 @@ public CustomViewHolder(View view, Context context, ArrayList<LaundryRoom> rooms
233
210
super (view );
234
211
235
212
mContext = context ;
236
- mRooms = rooms ;
237
213
238
214
//@BindView(R.id.laundry_room_title)
239
215
name = view .findViewById (R .id .laundry_room_title );
@@ -251,6 +227,28 @@ public CustomViewHolder(View view, Context context, ArrayList<LaundryRoom> rooms
251
227
lineChart = view .findViewById (R .id .laundry_availability_chart );
252
228
//@BindView(R.id.laundry_card)
253
229
layout = view .findViewById (R .id .laundry_card );
230
+
231
+ washerRecyclerView .setLayoutManager (new LinearLayoutManager (mContext , LinearLayoutManager .HORIZONTAL , false ));
232
+ dryerRecyclerView .setLayoutManager (new LinearLayoutManager (mContext , LinearLayoutManager .HORIZONTAL , false ));
233
+
234
+ if (isHome ) {
235
+ name .setVisibility (View .GONE );
236
+ title .setVisibility (View .GONE );
237
+ lineChart .setVisibility (View .GONE );
238
+ layout .setBackgroundResource (0 );
239
+ LinearLayout .LayoutParams layoutParams = (LinearLayout .LayoutParams ) layout .getLayoutParams ();
240
+ layoutParams .setMargins (0 , 0 , 0 , 0 );
241
+ layoutParams .setMarginStart (0 );
242
+ layout .setLayoutParams (layoutParams );
243
+ CardView container = (CardView ) dryerRecyclerView .getParent ();
244
+ ConstraintLayout .LayoutParams params = (ConstraintLayout .LayoutParams ) container .getLayoutParams ();
245
+ params .setMargins (0 ,0 ,0 ,0 );
246
+ container .setLayoutParams (params );
247
+ container = (CardView ) washerRecyclerView .getParent ();
248
+ params = (ConstraintLayout .LayoutParams ) container .getLayoutParams ();
249
+ params .setMargins (0 ,0 ,0 ,0 );
250
+ container .setLayoutParams (params );
251
+ }
254
252
}
255
253
}
256
254
}
0 commit comments