mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
cd2396524f
commit
05885c6a71
|
@ -161,10 +161,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
public void onUserInteraction() {
|
||||
Log.i("User interaction");
|
||||
|
||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this)) {
|
||||
finishAndRemoveTask();
|
||||
startActivity(new Intent(this, ActivityMain.class));
|
||||
}
|
||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this))
|
||||
restart(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -205,13 +203,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
}
|
||||
|
||||
private void checkAuthentication() {
|
||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this)) {
|
||||
Intent intent = getIntent();
|
||||
finishAndRemoveTask();
|
||||
startActivity(
|
||||
new Intent(this, ActivityMain.class)
|
||||
.putExtra("intent", intent));
|
||||
}
|
||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this))
|
||||
restart(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -282,6 +275,15 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
}
|
||||
}
|
||||
|
||||
protected void restart(Intent intent) {
|
||||
Intent main = new Intent(this, ActivityMain.class);
|
||||
if (intent != null)
|
||||
main.putExtra("intent", intent);
|
||||
main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(main);
|
||||
finishAndRemoveTask();
|
||||
}
|
||||
|
||||
protected boolean backHandled() {
|
||||
for (IBackPressedListener listener : backPressedListeners)
|
||||
if (listener.onBackPressed())
|
||||
|
|
|
@ -116,10 +116,7 @@ public class FragmentBase extends Fragment {
|
|||
}
|
||||
|
||||
protected void restart() {
|
||||
Intent intent = new Intent(getContext(), ActivityMain.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
Runtime.getRuntime().exit(0);
|
||||
((ActivityBase) getActivity()).restart(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue