This commit is contained in:
Negue 2015-12-13 02:32:47 +01:00
parent 3b6bb4439f
commit 32ba6ec14e
2 changed files with 12 additions and 3 deletions

View file

@ -151,10 +151,17 @@ public class HabiticaApplication extends Application {
context.startActivity(intent);
}
public static void checkUserAuthentication(Context context, HostConfig hostConfig) {
public static boolean checkUserAuthentication(Context context, HostConfig hostConfig) {
if (hostConfig == null || hostConfig.getApi() == null || hostConfig.getApi().equals("") || hostConfig.getUser() == null || hostConfig.getUser().equals("")) {
context.startActivity(new Intent(context, LoginActivity.class));
Intent intent = new Intent(context, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return false;
}
return true;
}
// endregion

View file

@ -129,7 +129,9 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
Fabric.with(this, crashlytics);
this.hostConfig = PrefsActivity.fromContext(this);
HabiticaApplication.checkUserAuthentication(this, hostConfig);
if(!HabiticaApplication.checkUserAuthentication(this, hostConfig))
return;
HabiticaApplication.ApiHelper = this.mAPIHelper = new APIHelper(this, hostConfig);
new Select().from(HabitRPGUser.class).where(Condition.column("id").eq(hostConfig.getUser())).async().querySingle(userTransactionListener);