11package fr .free .nrw .commons .contributions ;
22
3+ import static android .content .ContentResolver .requestSync ;
4+
35import android .annotation .SuppressLint ;
46import android .app .AlertDialog ;
57import android .content .ContentResolver ;
68import android .content .Intent ;
79import android .os .Bundle ;
8- import android .os .PersistableBundle ;
910import android .view .LayoutInflater ;
1011import android .view .Menu ;
1112import android .view .MenuInflater ;
1213import android .view .MenuItem ;
1314import android .view .View ;
1415import android .widget .ImageView ;
1516import android .widget .TextView ;
16-
1717import androidx .annotation .Nullable ;
1818import androidx .core .view .GravityCompat ;
1919import androidx .drawerlayout .widget .DrawerLayout ;
2020import androidx .fragment .app .Fragment ;
2121import androidx .fragment .app .FragmentManager ;
2222import androidx .fragment .app .FragmentPagerAdapter ;
2323import 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-
3124import butterknife .BindView ;
3225import butterknife .ButterKnife ;
26+ import com .google .android .material .tabs .TabLayout ;
3327import fr .free .nrw .commons .BuildConfig ;
3428import fr .free .nrw .commons .R ;
3529import fr .free .nrw .commons .auth .SessionManager ;
4539import fr .free .nrw .commons .upload .UploadService ;
4640import io .reactivex .android .schedulers .AndroidSchedulers ;
4741import io .reactivex .schedulers .Schedulers ;
42+ import java .util .List ;
43+ import javax .inject .Inject ;
4844import timber .log .Timber ;
4945
50- import static android .content .ContentResolver .requestSync ;
51-
5246public class MainActivity extends NavigationBaseActivity implements FragmentManager .OnBackStackChangedListener {
5347
5448 @ BindView (R .id .tab_layout )
@@ -68,8 +62,6 @@ public class MainActivity extends NavigationBaseActivity implements FragmentMana
6862 QuizChecker quizChecker ;
6963
7064
71- public Intent uploadServiceIntent ;
72-
7365 public ContributionsActivityPagerAdapter contributionsActivityPagerAdapter ;
7466 public static final int CONTRIBUTIONS_TAB_POSITION = 0 ;
7567 public static final int NEARBY_TAB_POSITION = 1 ;
@@ -117,13 +109,13 @@ private void initMain() {
117109 //Do not remove this, this triggers the sync service
118110 ContentResolver .setSyncAutomatically (sessionManager .getCurrentAccount (),BuildConfig .CONTRIBUTION_AUTHORITY ,true );
119111 requestSync (sessionManager .getCurrentAccount (), BuildConfig .CONTRIBUTION_AUTHORITY , new Bundle ());
120- uploadServiceIntent = new Intent (this , UploadService .class );
112+ Intent uploadServiceIntent = new Intent (this , UploadService .class );
121113 uploadServiceIntent .setAction (UploadService .ACTION_START_SERVICE );
122114 startService (uploadServiceIntent );
123115
124116 addTabsAndFragments ();
125117 if (contributionsActivityPagerAdapter .getItem (0 ) != null ) {
126- ((ContributionsFragment )contributionsActivityPagerAdapter .getItem (0 )).onAuthCookieAcquired (uploadServiceIntent );
118+ ((ContributionsFragment )contributionsActivityPagerAdapter .getItem (0 )).onAuthCookieAcquired ();
127119 }
128120 }
129121
@@ -147,10 +139,8 @@ private void addTabsAndFragments() {
147139 .show ()
148140 );
149141
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 ();
154144 setTabAndViewPagerSynchronisation ();
155145 }
156146
0 commit comments