Commit 55382eda authored by Geoffrey Métais's avatar Geoffrey Métais

Use onStart/onStop instead of onResume/onPause

parent 41f0e080
......@@ -251,11 +251,37 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
@Override
protected void onStart() {
super.onStart();
mCurrentFragmentId = mSettings.getInt("fragment_id", R.id.nav_video);
if (mMediaLibrary.isInitiated()) {
/* Load media items from database and storage */
if (mScanNeeded && Permissions.canReadStorage())
startService(new Intent(MediaParsingService.ACTION_RELOAD, null,this, MediaParsingService.class));
else if (!currentIdIsExtension())
restoreCurrentList();
}
mNavigationView.setNavigationItemSelectedListener(this);
if (BuildConfig.DEBUG)
createExtensionServiceConnection();
}
@Override
protected void onStop() {
super.onStop();
mNavigationView.setNavigationItemSelectedListener(null);
if (getChangingConfigurations() == 0) {
/* Check for an ongoing scan that needs to be resumed during onResume */
mScanNeeded = mMediaLibrary.isWorking();
}
/* Save the tab status in pref */
mSettings.edit().putInt("fragment_id", mCurrentFragmentId).apply();
if (mExtensionServiceConnection != null) {
unbindService(mExtensionServiceConnection);
mExtensionServiceConnection = null;
}
if (currentIdIsExtension())
mSettings.edit()
.putString("current_extension_name", mExtensionsManager.getExtensions(getApplication(), false).get(mCurrentFragmentId).componentName().getPackageName())
.apply();
}
private void loadPlugins() {
......@@ -293,14 +319,12 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
private void createExtensionServiceConnection() {
mExtensionServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mExtensionManagerService = ((ExtensionManagerService.LocalBinder)service).getService();
mExtensionManagerService.setExtensionManagerActivity(MainActivity.this);
loadPlugins();
}
@Override
public void onServiceDisconnected(ComponentName name) {}
};
......@@ -310,23 +334,6 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
mExtensionServiceConnection = null;
}
@Override
protected void onResume() {
super.onResume();
if (BuildConfig.DEBUG)
createExtensionServiceConnection();
mCurrentFragmentId = mSettings.getInt("fragment_id", R.id.nav_video);
if (mMediaLibrary.isInitiated()) {
/* Load media items from database and storage */
if (mScanNeeded && Permissions.canReadStorage())
startService(new Intent(MediaParsingService.ACTION_RELOAD, null,this, MediaParsingService.class));
else
if (!currentIdIsExtension())
restoreCurrentList();
}
mNavigationView.setNavigationItemSelectedListener(this);
}
@Override
protected void onResumeFragments() {
super.onResumeFragments();
......@@ -335,30 +342,6 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
showFragment(mCurrentFragmentId);
}
/**
* Stop audio player and save opened tab
*/
@Override
protected void onPause() {
super.onPause();
mNavigationView.setNavigationItemSelectedListener(null);
if (getChangingConfigurations() == 0) {
/* Check for an ongoing scan that needs to be resumed during onResume */
mScanNeeded = mMediaLibrary.isWorking();
}
/* Save the tab status in pref */
mSettings.edit().putInt("fragment_id", mCurrentFragmentId).apply();
if (mExtensionServiceConnection != null) {
unbindService(mExtensionServiceConnection);
mExtensionServiceConnection = null;
}
if (currentIdIsExtension())
mSettings.edit()
.putString("current_extension_name", mExtensionsManager.getExtensions(getApplication(), false).get(mCurrentFragmentId).componentName().getPackageName())
.apply();
}
protected void onSaveInstanceState(Bundle outState) {
if (mCurrentFragment instanceof ExtensionBrowser)
mCurrentFragment = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment