Refactoring

This commit is contained in:
M66B 2021-12-30 21:35:58 +01:00
parent 3cb480d72f
commit 618be15466
1 changed files with 14 additions and 20 deletions

View File

@ -201,7 +201,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
*/ */
} }
checkAuthentication(); checkAuthentication(true);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -247,7 +247,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
finish(); finish();
startActivity(getIntent()); startActivity(getIntent());
} else } else
checkAuthentication(); checkAuthentication(true);
} }
@Override @Override
@ -257,9 +257,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
visible = false; visible = false;
if (!this.getClass().equals(ActivityMain.class) && checkAuthentication(false);
Helper.shouldAuthenticate(this, true))
finishAndRemoveTask();
} }
@Override @Override
@ -271,14 +269,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
@Override @Override
public void onUserInteraction() { public void onUserInteraction() {
Log.d("User interaction"); Log.d("User interaction");
checkAuthentication(true);
if (!this.getClass().equals(ActivityMain.class) &&
Helper.shouldAuthenticate(this, false)) {
finishAndRemoveTask();
Intent main = new Intent(this, ActivityMain.class);
main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(main);
}
} }
@Override @Override
@ -379,18 +370,21 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
private void checkAuthentication() { private void checkAuthentication(boolean auth) {
if (!this.getClass().equals(ActivityMain.class) && if (!this.getClass().equals(ActivityMain.class) &&
Helper.shouldAuthenticate(this, false)) { Helper.shouldAuthenticate(this, false)) {
Intent intent = getIntent();
finishAndRemoveTask(); finishAndRemoveTask();
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
finishAffinity(); finishAffinity();
processStreams(intent);
Intent main = new Intent(this, ActivityMain.class) if (auth) {
.putExtra("intent", intent); Intent intent = getIntent();
main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); processStreams(intent);
startActivity(main); Intent main = new Intent(this, ActivityMain.class)
.putExtra("intent", intent);
main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(main);
}
} }
} }