mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-03-24 23:30:28 -05:00
Fix crash on new app (#1082)
Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@noreply.codeberg.org> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1082 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
@@ -11,6 +11,7 @@ import android.widget.EditText;
|
||||
import android.widget.RadioGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import org.gitnex.tea4j.ApiInterface;
|
||||
import org.gitnex.tea4j.models.GiteaVersion;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserTokens;
|
||||
@@ -219,9 +220,15 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||
|
||||
callVersion =
|
||||
(loginOTP != 0) ? RetrofitClient.getApiInterface(ctx).getGiteaVersionWithOTP(credential, loginOTP) :
|
||||
RetrofitClient.getApiInterface(ctx).getGiteaVersionWithBasic(credential);
|
||||
ApiInterface apiClient = RetrofitClient.getApiInterface(ctx);
|
||||
|
||||
if (loginOTP != 0) {
|
||||
|
||||
callVersion = apiClient.getGiteaVersionWithOTP(credential, loginOTP);
|
||||
} else {
|
||||
|
||||
callVersion = apiClient.getGiteaVersionWithBasic(credential);
|
||||
}
|
||||
}
|
||||
|
||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||
@@ -584,7 +591,7 @@ public class LoginActivity extends BaseActivity {
|
||||
instanceUrlET.setText(tinyDB.getString("instanceUrlRaw"));
|
||||
}
|
||||
|
||||
if(getAccount() != null) {
|
||||
if(getAccount() != null && getAccount().getAccount() != null) {
|
||||
|
||||
loginUidET.setText(getAccount().getAccount().getUserName());
|
||||
}
|
||||
|
||||
@@ -107,13 +107,14 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
// DO NOT MOVE
|
||||
|
||||
instanceToken = getAccount().getAuthorization();
|
||||
noConnection = false;
|
||||
|
||||
if(tinyDB.getInt("currentActiveAccountId", -1) <= 0) {
|
||||
AppUtil.logout(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
instanceToken = getAccount().getAuthorization();
|
||||
noConnection = false;
|
||||
|
||||
Toolbar toolbar = activityMainBinding.toolbar;
|
||||
toolbarTitle = activityMainBinding.toolbarTitle;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user