Browse Source

Log activity/fragment life cycle

main
M66B 6 years ago
parent
commit
42a4de8931
3 changed files with 53 additions and 6 deletions
  1. +19
    -0
      app/src/main/java/eu/faircode/email/ActivityBase.java
  2. +0
    -6
      app/src/main/java/eu/faircode/email/ActivityView.java
  3. +34
    -0
      app/src/main/java/eu/faircode/email/FragmentEx.java

+ 19
- 0
app/src/main/java/eu/faircode/email/ActivityBase.java View File

@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
@ -37,6 +38,24 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
Log.i(Helper.TAG, "Resume " + this.getClass().getName());
super.onResume();
}
@Override
protected void onPause() {
Log.i(Helper.TAG, "Pause " + this.getClass().getName());
super.onPause();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "Config " + this.getClass().getName());
super.onConfigurationChanged(newConfig);
}
@Override
protected void onDestroy() {
Log.i(Helper.TAG, "Destroy " + this.getClass().getName());


+ 0
- 6
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -92,7 +92,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "View create");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
@ -256,7 +255,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override
protected void onPostCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "View post create");
super.onPostCreate(savedInstanceState);
drawerToggle.syncState();
}
@ -270,7 +268,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override
protected void onResume() {
Log.i(Helper.TAG, "View resume");
super.onResume();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
@ -288,7 +285,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override
protected void onPause() {
Log.i(Helper.TAG, "View pause");
super.onPause();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.unregisterReceiver(receiver);
@ -296,14 +292,12 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "View configuration changed");
super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig);
}
@Override
protected void onDestroy() {
Log.i(Helper.TAG, "View destroyed");
super.onDestroy();
}


+ 34
- 0
app/src/main/java/eu/faircode/email/FragmentEx.java View File

@ -1,5 +1,8 @@
package eu.faircode.email;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@ -19,12 +22,31 @@ public class FragmentEx extends Fragment {
updateSubtitle();
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this.getClass().getName());
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Activity " + this.getClass().getName());
super.onActivityCreated(savedInstanceState);
}
@Override
public void onResume() {
Log.i(Helper.TAG, "Resume " + this.getClass().getName());
super.onResume();
updateSubtitle();
}
@Override
public void onPause() {
Log.i(Helper.TAG, "Pause " + this.getClass().getName());
super.onPause();
}
@Override
public void onDetach() {
super.onDetach();
@ -35,6 +57,18 @@ public class FragmentEx extends Fragment {
im.hideSoftInputFromWindow(focused.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "Config " + this.getClass().getName());
super.onConfigurationChanged(newConfig);
}
@Override
public void onDestroy() {
Log.i(Helper.TAG, "Destroy " + this.getClass().getName());
super.onDestroy();
}
private void updateSubtitle() {
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null) {


Loading…
Cancel
Save