Make assumption that app is non-null explicit
The adapter has a hard coded assumption that mApp is never null. This documents it as such by making the member variable @NonNull. This is not perfect, because the consumer of this class doesn't quite seem to check this constraing properly, however at least within the class it adds some explicit documentation that is understood by editors and lint that this is a non-nullable field.
This commit is contained in:
parent
1eb7d389f2
commit
190cf40ff9
@ -6,6 +6,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.widget.TextViewCompat;
|
import android.support.v4.widget.TextViewCompat;
|
||||||
import android.support.v7.text.AllCapsTransformationMethod;
|
import android.support.v7.text.AllCapsTransformationMethod;
|
||||||
@ -77,6 +78,7 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
private final int VIEWTYPE_VERSION = 7;
|
private final int VIEWTYPE_VERSION = 7;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
@NonNull
|
||||||
private App mApp;
|
private App mApp;
|
||||||
private final AppDetailsRecyclerViewAdapterCallbacks mCallbacks;
|
private final AppDetailsRecyclerViewAdapterCallbacks mCallbacks;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
@ -86,13 +88,14 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
|
|
||||||
private HeaderViewHolder mHeaderView;
|
private HeaderViewHolder mHeaderView;
|
||||||
|
|
||||||
public AppDetailsRecyclerViewAdapter(Context context, App app, AppDetailsRecyclerViewAdapterCallbacks callbacks) {
|
public AppDetailsRecyclerViewAdapter(Context context, @NonNull App app, AppDetailsRecyclerViewAdapterCallbacks callbacks) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCallbacks = callbacks;
|
mCallbacks = callbacks;
|
||||||
|
mApp = app;
|
||||||
updateItems(app);
|
updateItems(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItems(App app) {
|
public void updateItems(@NonNull App app) {
|
||||||
mApp = app;
|
mApp = app;
|
||||||
|
|
||||||
// Get versions
|
// Get versions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user