@@ -16,7 +16,7 @@ public class AdapterLayoutDelegate {
1616 private ViewGroup mViewGroup ;
1717
1818 /**
19- * Checks for if the data changes and changes the views accordingly
19+ * Checks for if the data changes and changes the views accordingly
2020 */
2121 private RecyclerView .AdapterDataObserver mObserver = new RecyclerView .AdapterDataObserver () {
2222 @ Override
@@ -60,6 +60,7 @@ public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
6060
6161 /**
6262 * Create a new delegate, acting as the bridge between the adapter and the ViewGroup
63+ *
6364 * @param viewGroup the ViewGroup which will have views added and removed from
6465 */
6566 public AdapterLayoutDelegate (ViewGroup viewGroup ) {
@@ -68,13 +69,15 @@ public AdapterLayoutDelegate(ViewGroup viewGroup) {
6869
6970 /**
7071 * Set the adapter which will add and remove views from this layout
72+ *
7173 * @param adapter the adapter
7274 */
73- public void setAdapter (RecyclerView .Adapter adapter ) {
75+ public void setAdapter (@ Nullable RecyclerView .Adapter adapter ) {
7476 if (mAdapter != null ) {
7577 try {
7678 mAdapter .unregisterAdapterDataObserver (mObserver );
77- } catch (Exception ignored ) {}
79+ } catch (Exception ignored ) {
80+ }
7881 }
7982
8083 mAdapter = adapter ;
@@ -86,18 +89,22 @@ public void setAdapter(RecyclerView.Adapter adapter) {
8689
8790 /**
8891 * Returns the adapter which was passed via {@link #setAdapter(RecyclerView.Adapter)}
92+ *
8993 * @return the adapter
9094 */
91- public @ Nullable RecyclerView .Adapter getAdapter () {
95+ @ Nullable
96+ public RecyclerView .Adapter getAdapter () {
9297 return mAdapter ;
9398 }
9499
95100 /**
96101 * Return the {@link android.support.v7.widget.RecyclerView.ViewHolder} at the specified position.
102+ *
97103 * @param index the position at which to get the ViewHolder
98104 * @return the ViewHolder at the index, or null if none exists
99105 */
100- public @ Nullable RecyclerView .ViewHolder getViewHolderAt (int index ) {
106+ @ Nullable
107+ public RecyclerView .ViewHolder getViewHolderAt (int index ) {
101108 View view = mViewGroup .getChildAt (index );
102109 if (view == null ) {
103110 return null ;
@@ -107,7 +114,7 @@ public void setAdapter(RecyclerView.Adapter adapter) {
107114
108115 private void addViews (int positionStart , int itemCount ) {
109116 final int end = positionStart + itemCount ;
110- for (int i = positionStart ; i < end ; i ++) {
117+ for (int i = positionStart ; i < end ; i ++) {
111118 addViewAt (i );
112119 }
113120 }
@@ -124,16 +131,11 @@ private void addViewAt(int viewType, int index) {
124131 mAdapter .onBindViewHolder (viewHolder , index );
125132 }
126133
127- private void updateViews (int positionStart , int itemCount , Object payload ) {
128- //TODO do something with the payload?
134+ private void updateViews (int positionStart , int itemCount , @ Nullable Object payload ) {
129135 final int end = positionStart + itemCount ;
130- for (int i = positionStart ; i < end ; i ++) {
136+ for (int i = positionStart ; i < end ; i ++) {
131137 RecyclerView .ViewHolder viewHolder = getViewHolderAt (i );
132- if (payload != null ) {
133- mAdapter .onBindViewHolder (viewHolder , i );
134- } else {
135- mAdapter .onBindViewHolder (viewHolder , i );
136- }
138+ mAdapter .onBindViewHolder (viewHolder , i );
137139 }
138140 }
139141
0 commit comments