2
2
3
3
import android .content .Context ;
4
4
import android .database .Cursor ;
5
+
6
+ import androidx .annotation .NonNull ;
5
7
import androidx .cursoradapter .widget .CursorAdapter ;
6
8
import android .view .LayoutInflater ;
7
9
import android .view .View ;
@@ -20,14 +22,12 @@ class ContributionsListAdapter extends CursorAdapter {
20
22
21
23
private final ContributionDao contributionDao ;
22
24
private UploadService uploadService ;
23
- private Context context ;
24
25
25
26
public ContributionsListAdapter (Context context ,
26
27
Cursor c ,
27
28
int flags ,
28
29
ContributionDao contributionDao ) {
29
30
super (context , c , flags );
30
- this .context = context ;
31
31
this .contributionDao = contributionDao ;
32
32
}
33
33
@@ -53,12 +53,12 @@ public void bindView(View view, Context context, Cursor cursor) {
53
53
new DisplayableContribution .ContributionActions () {
54
54
@ Override
55
55
public void retryUpload () {
56
- ContributionsListAdapter .this .retryUpload (contribution );
56
+ ContributionsListAdapter .this .retryUpload (view . getContext (), contribution );
57
57
}
58
58
59
59
@ Override
60
60
public void deleteUpload () {
61
- ContributionsListAdapter .this .deleteUpload (contribution );
61
+ ContributionsListAdapter .this .deleteUpload (view . getContext (), contribution );
62
62
}
63
63
});
64
64
views .bindModel (context , displayableContribution );
@@ -68,7 +68,7 @@ public void deleteUpload() {
68
68
* Retry upload when it is failed
69
69
* @param contribution contribution to be retried
70
70
*/
71
- private void retryUpload (Contribution contribution ) {
71
+ private void retryUpload (@ NonNull Context context , Contribution contribution ) {
72
72
if (NetworkUtils .isInternetConnectionEstablished (context )) {
73
73
if (contribution .getState () == STATE_FAILED
74
74
&& uploadService != null ) {
@@ -87,7 +87,7 @@ private void retryUpload(Contribution contribution) {
87
87
* Delete a failed upload attempt
88
88
* @param contribution contribution to be deleted
89
89
*/
90
- private void deleteUpload (Contribution contribution ) {
90
+ private void deleteUpload (@ NonNull Context context , Contribution contribution ) {
91
91
if (NetworkUtils .isInternetConnectionEstablished (context )) {
92
92
if (contribution .getState () == STATE_FAILED ) {
93
93
Timber .d ("Deleting failed contrib %s" , contribution .toString ());
0 commit comments