1
1
package fr .free .nrw .commons .contributions ;
2
2
3
+ import static android .content .ContentResolver .requestSync ;
4
+
3
5
import android .annotation .SuppressLint ;
4
6
import android .app .AlertDialog ;
5
7
import android .content .ContentResolver ;
6
8
import android .content .Intent ;
7
9
import android .os .Bundle ;
8
- import android .os .PersistableBundle ;
9
10
import android .view .LayoutInflater ;
10
11
import android .view .Menu ;
11
12
import android .view .MenuInflater ;
12
13
import android .view .MenuItem ;
13
14
import android .view .View ;
14
15
import android .widget .ImageView ;
15
16
import android .widget .TextView ;
16
-
17
17
import androidx .annotation .Nullable ;
18
18
import androidx .core .view .GravityCompat ;
19
19
import androidx .drawerlayout .widget .DrawerLayout ;
20
20
import androidx .fragment .app .Fragment ;
21
21
import androidx .fragment .app .FragmentManager ;
22
22
import androidx .fragment .app .FragmentPagerAdapter ;
23
23
import androidx .viewpager .widget .ViewPager ;
24
-
25
- import com .google .android .material .tabs .TabLayout ;
26
-
27
- import java .util .List ;
28
-
29
- import javax .inject .Inject ;
30
-
31
24
import butterknife .BindView ;
32
25
import butterknife .ButterKnife ;
26
+ import com .google .android .material .tabs .TabLayout ;
33
27
import fr .free .nrw .commons .BuildConfig ;
34
28
import fr .free .nrw .commons .R ;
35
29
import fr .free .nrw .commons .auth .SessionManager ;
45
39
import fr .free .nrw .commons .upload .UploadService ;
46
40
import io .reactivex .android .schedulers .AndroidSchedulers ;
47
41
import io .reactivex .schedulers .Schedulers ;
42
+ import java .util .List ;
43
+ import javax .inject .Inject ;
48
44
import timber .log .Timber ;
49
45
50
- import static android .content .ContentResolver .requestSync ;
51
-
52
46
public class MainActivity extends NavigationBaseActivity implements FragmentManager .OnBackStackChangedListener {
53
47
54
48
@ BindView (R .id .tab_layout )
@@ -68,8 +62,6 @@ public class MainActivity extends NavigationBaseActivity implements FragmentMana
68
62
QuizChecker quizChecker ;
69
63
70
64
71
- public Intent uploadServiceIntent ;
72
-
73
65
public ContributionsActivityPagerAdapter contributionsActivityPagerAdapter ;
74
66
public static final int CONTRIBUTIONS_TAB_POSITION = 0 ;
75
67
public static final int NEARBY_TAB_POSITION = 1 ;
@@ -117,13 +109,13 @@ private void initMain() {
117
109
//Do not remove this, this triggers the sync service
118
110
ContentResolver .setSyncAutomatically (sessionManager .getCurrentAccount (),BuildConfig .CONTRIBUTION_AUTHORITY ,true );
119
111
requestSync (sessionManager .getCurrentAccount (), BuildConfig .CONTRIBUTION_AUTHORITY , new Bundle ());
120
- uploadServiceIntent = new Intent (this , UploadService .class );
112
+ Intent uploadServiceIntent = new Intent (this , UploadService .class );
121
113
uploadServiceIntent .setAction (UploadService .ACTION_START_SERVICE );
122
114
startService (uploadServiceIntent );
123
115
124
116
addTabsAndFragments ();
125
117
if (contributionsActivityPagerAdapter .getItem (0 ) != null ) {
126
- ((ContributionsFragment )contributionsActivityPagerAdapter .getItem (0 )).onAuthCookieAcquired (uploadServiceIntent );
118
+ ((ContributionsFragment )contributionsActivityPagerAdapter .getItem (0 )).onAuthCookieAcquired ();
127
119
}
128
120
}
129
121
@@ -147,10 +139,8 @@ private void addTabsAndFragments() {
147
139
.show ()
148
140
);
149
141
150
- if (uploadServiceIntent != null ) {
151
- // If auth cookie already acquired notify contrib fragment so that it san operate auth required actions
152
- ((ContributionsFragment )contributionsActivityPagerAdapter .getItem (CONTRIBUTIONS_TAB_POSITION )).onAuthCookieAcquired (uploadServiceIntent );
153
- }
142
+ ((ContributionsFragment ) contributionsActivityPagerAdapter
143
+ .getItem (CONTRIBUTIONS_TAB_POSITION )).onAuthCookieAcquired ();
154
144
setTabAndViewPagerSynchronisation ();
155
145
}
156
146
0 commit comments