@@ -226,49 +226,50 @@ public String getText() {
226
226
}
227
227
228
228
public static class ChatHolder extends RecyclerView .ViewHolder {
229
- View mView ;
229
+ private final TextView mNameField ;
230
+ private final TextView mTextField ;
231
+ private final FrameLayout mLeftArrow ;
232
+ private final FrameLayout mRightArrow ;
233
+ private final RelativeLayout mMessageContainer ;
234
+ private final LinearLayout mMessage ;
230
235
231
236
public ChatHolder (View itemView ) {
232
237
super (itemView );
233
- mView = itemView ;
238
+ mNameField = (TextView ) itemView .findViewById (R .id .name_text );
239
+ mTextField = (TextView ) itemView .findViewById (R .id .message_text );
240
+ mLeftArrow = (FrameLayout ) itemView .findViewById (R .id .left_arrow );
241
+ mRightArrow = (FrameLayout ) itemView .findViewById (R .id .right_arrow );
242
+ mMessageContainer = (RelativeLayout ) itemView .findViewById (R .id .message_container );
243
+ mMessage = (LinearLayout ) itemView .findViewById (R .id .message );
234
244
}
235
245
236
- public void setIsSender (Boolean isSender ) {
237
- FrameLayout left_arrow = (FrameLayout ) mView .findViewById (R .id .left_arrow );
238
- FrameLayout right_arrow = (FrameLayout ) mView .findViewById (R .id .right_arrow );
239
- RelativeLayout messageContainer = (RelativeLayout ) mView .findViewById (R .id .message_container );
240
- LinearLayout message = (LinearLayout ) mView .findViewById (R .id .message );
241
-
242
- int color ;
246
+ public void setIsSender (boolean isSender ) {
247
+ final int color ;
243
248
if (isSender ) {
244
- color = ContextCompat .getColor (mView .getContext (), R .color .material_green_300 );
245
-
246
- left_arrow .setVisibility (View .GONE );
247
- right_arrow .setVisibility (View .VISIBLE );
248
- messageContainer .setGravity (Gravity .END );
249
+ color = ContextCompat .getColor (itemView .getContext (), R .color .material_green_300 );
250
+ mLeftArrow .setVisibility (View .GONE );
251
+ mRightArrow .setVisibility (View .VISIBLE );
252
+ mMessageContainer .setGravity (Gravity .END );
249
253
} else {
250
- color = ContextCompat .getColor (mView .getContext (), R .color .material_gray_300 );
251
-
252
- left_arrow .setVisibility (View .VISIBLE );
253
- right_arrow .setVisibility (View .GONE );
254
- messageContainer .setGravity (Gravity .START );
254
+ color = ContextCompat .getColor (itemView .getContext (), R .color .material_gray_300 );
255
+ mLeftArrow .setVisibility (View .VISIBLE );
256
+ mRightArrow .setVisibility (View .GONE );
257
+ mMessageContainer .setGravity (Gravity .START );
255
258
}
256
259
257
- ((GradientDrawable ) message .getBackground ()).setColor (color );
258
- ((RotateDrawable ) left_arrow .getBackground ()).getDrawable ()
260
+ ((GradientDrawable ) mMessage .getBackground ()).setColor (color );
261
+ ((RotateDrawable ) mLeftArrow .getBackground ()).getDrawable ()
259
262
.setColorFilter (color , PorterDuff .Mode .SRC );
260
- ((RotateDrawable ) right_arrow .getBackground ()).getDrawable ()
263
+ ((RotateDrawable ) mRightArrow .getBackground ()).getDrawable ()
261
264
.setColorFilter (color , PorterDuff .Mode .SRC );
262
265
}
263
266
264
267
public void setName (String name ) {
265
- TextView field = (TextView ) mView .findViewById (R .id .name_text );
266
- field .setText (name );
268
+ mNameField .setText (name );
267
269
}
268
270
269
271
public void setText (String text ) {
270
- TextView field = (TextView ) mView .findViewById (R .id .message_text );
271
- field .setText (text );
272
+ mTextField .setText (text );
272
273
}
273
274
}
274
275
}
0 commit comments