Commit a3ae9dac authored by Ludovic Fauvet's avatar Ludovic Fauvet

Always call the supermethod before doing any work in the lifecycle methods

According to the documentation the implementation of these lifecycle
methods must always call the superclass implementation before doing any
work.

https://developer.android.com/guide/components/activities.html#ImplementingLifecycleCallbacks
parent 54278b77
......@@ -187,8 +187,8 @@ public class AudioService extends Service {
@Override
public void onDestroy() {
unregisterReceiver(serviceReceiver);
super.onDestroy();
unregisterReceiver(serviceReceiver);
}
@Override
......
......@@ -60,8 +60,8 @@ public class BrowserActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.browser);
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
mAdapter = new BrowserAdapter(this);
setListAdapter(mAdapter);
......@@ -80,9 +80,9 @@ public class BrowserActivity extends ListActivity {
@Override
protected void onDestroy() {
super.onDestroy();
mAdapter.clear();
mScollStates.clear();
super.onDestroy();
}
private void openDir(File file) {
......
......@@ -34,6 +34,7 @@ public class CompatErrorActivity extends Activity {
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.not_compatible);
String errorMsg = Util.getErrorMsg();
......@@ -47,8 +48,6 @@ public class CompatErrorActivity extends Activity {
TextView tv = (TextView)findViewById(R.id.errormsg);
tv.setText(getResources().getString(R.string.error_message_is) + "\n" + errorMsg);
super.onCreate(savedInstanceState);
//AsyncHttpRequest asyncHttpRequest = new AsyncHttpRequest();
//asyncHttpRequest.execute(Build.MODEL, Build.DEVICE);
}
......
......@@ -110,9 +110,10 @@ public class MainActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Util.hasCompatibleCPU()) {
Log.e(TAG, Util.getErrorMsg());
super.onCreate(savedInstanceState);
Intent i = new Intent(this, CompatErrorActivity.class);
startActivity(i);
finish();
......@@ -166,7 +167,6 @@ public class MainActivity extends SherlockFragmentActivity {
LibVLC.getInstance();
} catch (LibVlcException e) {
e.printStackTrace();
super.onCreate(null);
Intent i = new Intent(this, CompatErrorActivity.class);
i.putExtra("runtimeError", true);
i.putExtra("message", "LibVLC failed to initialize (LibVlcException)");
......@@ -175,8 +175,6 @@ public class MainActivity extends SherlockFragmentActivity {
return;
}
super.onCreate(savedInstanceState);
/* Initialize UI variables */
mInfoLayout = v_main.findViewById(R.id.info_layout);
mInfoProgress = (ProgressBar) v_main.findViewById(R.id.info_progress);
......@@ -279,6 +277,7 @@ public class MainActivity extends SherlockFragmentActivity {
@Override
protected void onResume() {
super.onResume();
mAudioController.addAudioPlayer(mAudioPlayer);
AudioServiceController.getInstance().bindAudioService(this);
......@@ -313,8 +312,6 @@ public class MainActivity extends SherlockFragmentActivity {
/* Load media items from database and storage */
if (mScanNeeded)
MediaLibrary.getInstance(this).loadMediaItems(this);
super.onResume();
}
/**
......@@ -322,6 +319,8 @@ public class MainActivity extends SherlockFragmentActivity {
*/
@Override
protected void onPause() {
super.onPause();
/* Check for an ongoing scan that needs to be resumed during onResume */
mScanNeeded = MediaLibrary.getInstance(this).isWorking();
/* Stop scanning for files */
......@@ -334,11 +333,12 @@ public class MainActivity extends SherlockFragmentActivity {
editor.commit();
mAudioController.removeAudioPlayer(mAudioPlayer);
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
unregisterReceiver(messageReceiver);
} catch (IllegalArgumentException e) {}
......
......@@ -196,13 +196,13 @@ public class PreferencesActivity extends PreferenceActivity {
@Override
protected void onResume() {
AudioServiceController.getInstance().bindAudioService(this);
super.onResume();
AudioServiceController.getInstance().bindAudioService(this);
}
@Override
protected void onPause() {
AudioServiceController.getInstance().unbindAudioService(this);
super.onPause();
AudioServiceController.getInstance().unbindAudioService(this);
}
}
......@@ -89,21 +89,21 @@ public class SearchActivity extends ListActivity {
@Override
protected void onResume() {
AudioServiceController.getInstance().bindAudioService(this);
super.onResume();
AudioServiceController.getInstance().bindAudioService(this);
}
@Override
protected void onPause() {
AudioServiceController.getInstance().unbindAudioService(this);
super.onPause();
AudioServiceController.getInstance().unbindAudioService(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
mHistoryAdapter.clear();
mResultAdapter.clear();
super.onDestroy();
}
private void search(CharSequence key, int type) {
......
......@@ -332,11 +332,11 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
@Override
public void onDestroy() {
super.onDestroy();
mSongsAdapter.clear();
mArtistsAdapter.clear();
mAlbumsAdapter.clear();
mGenresAdapter.clear();
super.onDestroy();
}
private final ViewSwitchListener mViewSwitchListener = new ViewSwitchListener() {
......
......@@ -111,8 +111,8 @@ public class AudioListFragment extends SherlockListFragment {
@Override
public void onDestroy() {
mSongsAdapter.clear();
super.onDestroy();
mSongsAdapter.clear();
}
public static void set(Intent intent, String name, String name2, int mode) {
......
......@@ -101,16 +101,16 @@ public class AudioPlayerActivity extends Activity implements IAudioPlayer {
@Override
protected void onResume() {
super.onResume();
AudioServiceController.getInstance().bindAudioService(this);
mAudioController.addAudioPlayer(this);
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
mAudioController.removeAudioPlayer(this);
AudioServiceController.getInstance().unbindAudioService(this);
super.onPause();
}
public static void start(Context context) {
......
......@@ -126,6 +126,7 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
@Override
public void onResume() {
super.onResume();
//Get & highlight the last media
SharedPreferences preferences = getActivity().getSharedPreferences(PreferencesActivity.NAME, Context.MODE_PRIVATE);
String lastPath = preferences.getString(PreferencesActivity.LAST_MEDIA, null);
......@@ -133,7 +134,6 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
mVideoAdapter.setLastMedia(lastPath, times);
mVideoAdapter.notifyDataSetChanged();
mMediaLibrary.addUpdateHandler(mHandler);
super.onResume();
}
@Override
......@@ -144,9 +144,9 @@ public class VideoListFragment extends SherlockListFragment implements ISortable
@Override
public void onDestroy() {
super.onDestroy();
mBarrier.reset();
mVideoAdapter.clear();
super.onDestroy();
}
@Override
......
......@@ -316,10 +316,11 @@ public class VideoPlayerActivity extends Activity {
@Override
protected void onPause() {
if(mSwitchingView) {
super.onPause();
if(mSwitchingView)
return;
}
long time = mLibVLC.getTime();
long length = mLibVLC.getLength();
//remove saved position if in the last 5 seconds
......@@ -358,11 +359,11 @@ public class VideoPlayerActivity extends Activity {
DatabaseManager.mediaColumn.MEDIA_TIME,
time);
}
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mBatteryReceiver);
if (mLibVLC != null && !mSwitchingView) {
mLibVLC.stop();
......@@ -379,11 +380,11 @@ public class VideoPlayerActivity extends Activity {
AudioPlayerActivity.start(this, true);
}
//AudioServiceController.getInstance().unbindAudioService(this);
super.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
AudioServiceController.getInstance().bindAudioService(this);
load();
......@@ -404,8 +405,6 @@ public class VideoPlayerActivity extends Activity {
}}, 500);
showOverlay();
super.onResume();
}
@Override
......
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