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() {
|
public void onUserInteraction() {
|
||||||
Log.i("User interaction");
|
Log.i("User interaction");
|
||||||
|
|
||||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this)) {
|
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this))
|
||||||
finishAndRemoveTask();
|
restart(null);
|
||||||
startActivity(new Intent(this, ActivityMain.class));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,13 +203,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAuthentication() {
|
private void checkAuthentication() {
|
||||||
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this)) {
|
if (!this.getClass().equals(ActivityMain.class) && Helper.shouldAuthenticate(this))
|
||||||
Intent intent = getIntent();
|
restart(getIntent());
|
||||||
finishAndRemoveTask();
|
|
||||||
startActivity(
|
|
||||||
new Intent(this, ActivityMain.class)
|
|
||||||
.putExtra("intent", intent));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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() {
|
protected boolean backHandled() {
|
||||||
for (IBackPressedListener listener : backPressedListeners)
|
for (IBackPressedListener listener : backPressedListeners)
|
||||||
if (listener.onBackPressed())
|
if (listener.onBackPressed())
|
||||||
|
|
|
@ -116,10 +116,7 @@ public class FragmentBase extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restart() {
|
protected void restart() {
|
||||||
Intent intent = new Intent(getContext(), ActivityMain.class);
|
((ActivityBase) getActivity()).restart(null);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
Runtime.getRuntime().exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue