Moved the new version check to the application class.

This commit is contained in:
Kartikey Kushwaha 2018-08-12 16:35:53 +05:30
parent 7c875a8541
commit 06f20c66f8
3 changed files with 6 additions and 4 deletions

View file

@ -99,6 +99,11 @@ public class App extends Application {
ImageLoader.getInstance().init(getImageLoaderConfigurations(10, 50)); ImageLoader.getInstance().init(getImageLoaderConfigurations(10, 50));
configureRxJavaErrorHandler(); configureRxJavaErrorHandler();
// Check for new version
if (BuildConfig.FLAVOR.equals("github")) {
new FetchAppVersionTask().execute();
}
} }
protected Downloader getDownloader() { protected Downloader getDownloader() {

View file

@ -124,6 +124,7 @@ public class FetchAppVersionTask extends AsyncTask<Void, Void, String> {
Application app = App.getContext(); Application app = App.getContext();
// A pending intent to open the apk location url in the browser.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkLocationUrl)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(apkLocationUrl));
PendingIntent pendingIntent PendingIntent pendingIntent
= PendingIntent.getActivity(app, 0, intent, 0); = PendingIntent.getActivity(app, 0, intent, 0);

View file

@ -80,10 +80,6 @@ public class MainActivity extends AppCompatActivity {
ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this)); ThemeHelper.setTheme(this, ServiceHelper.getSelectedServiceId(this));
if (BuildConfig.FLAVOR.equals("github")) {
new FetchAppVersionTask().execute();
}
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);