Fix one more crash

This commit is contained in:
Grishka 2024-11-22 00:28:20 +03:00
parent 0ccfa3fabb
commit 9ed95cc0d3
3 changed files with 9 additions and 6 deletions

View File

@ -13,8 +13,8 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 34
versionCode 131
versionName "2.9.2"
versionCode 132
versionName "2.9.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -125,7 +125,7 @@ public class AccountSessionManager{
public void addAccount(Instance instance, Token token, Account self, Application app, AccountActivationInfo activationInfo){
instances.put(instance.getDomain(), instance);
runOnDbThread(db->insertInstanceIntoDatabase(db, instance.getDomain(), instance, List.of(), 0));
runOnDbThread(db->insertInstanceIntoDatabase(db, instance.getDomain(), instance, null, 0));
AccountSession session=new AccountSession(token, self, app, instance.getDomain(), activationInfo==null, activationInfo);
sessions.put(session.getID(), session);
lastActiveAccountID=session.getID();
@ -351,7 +351,7 @@ public class AccountSessionManager{
@Override
public void onSuccess(Instance instance){
instances.put(domain, instance);
runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, List.of(), 0));
runOnDbThread(db->insertInstanceIntoDatabase(db, domain, instance, null, 0));
updateInstanceEmojis(instance, domain);
}
@ -628,7 +628,8 @@ public class AccountSessionManager{
ContentValues values=new ContentValues();
values.put("domain", domain);
values.put("instance_obj", MastodonAPIController.gson.toJson(instance));
values.put("emojis", MastodonAPIController.gson.toJson(emojis));
if(emojis!=null)
values.put("emojis", MastodonAPIController.gson.toJson(emojis));
values.put("last_updated", lastUpdated);
values.put("version", instance.getVersion());
db.insertWithOnConflict("instances", null, values, SQLiteDatabase.CONFLICT_REPLACE);

View File

@ -24,6 +24,7 @@ import org.joinmastodon.android.api.session.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.settings.SettingsMainFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Instance;
import org.joinmastodon.android.ui.sheets.AccountSwitcherSheet;
import org.joinmastodon.android.ui.utils.UiUtils;
@ -175,8 +176,9 @@ public class AccountActivationFragment extends ToolbarFragment{
currentRequest=null;
AccountSessionManager mgr=AccountSessionManager.getInstance();
AccountSession session=mgr.getAccount(accountID);
mgr.addAccount(mgr.getInstanceInfo(session.domain), session.token, result, session.app, null);
Instance instance=mgr.getInstanceInfo(session.domain);
mgr.removeAccount(accountID);
mgr.addAccount(instance, session.token, result, session.app, null);
String newID=mgr.getLastActiveAccountID();
accountID=newID;
if((session.self.avatar!=null || session.self.displayName!=null) && !getArguments().getBoolean("debug")){