mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix a crash when starting the app with new elements in the list
This commit is contained in:
parent
b6f8dbf1ce
commit
0c8f2a4a03
4 changed files with 25 additions and 29 deletions
|
@ -613,7 +613,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, null);
|
||||
//Fetch remote lists for the authenticated account and update them
|
||||
new ViewModelProvider(BaseMainActivity.this).get(TimelinesVM.class).getLists(currentInstance, currentToken)
|
||||
.observe(this, mastodonLists -> PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, mastodonLists));
|
||||
.observe(this, mastodonLists ->
|
||||
PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, mastodonLists)
|
||||
);
|
||||
});
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
|
|
@ -122,7 +122,7 @@ public class LoginActivity extends BaseActivity {
|
|||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> {
|
||||
Intent mainActivity = new Intent(LoginActivity.this, BaseMainActivity.class);
|
||||
Intent mainActivity = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(mainActivity);
|
||||
finish();
|
||||
};
|
||||
|
|
|
@ -121,6 +121,7 @@ import java.util.regex.Pattern;
|
|||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.LoginActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.WebviewActivity;
|
||||
import app.fedilab.android.broadcastreceiver.ToastMessage;
|
||||
import app.fedilab.android.client.entities.Account;
|
||||
|
@ -629,7 +630,7 @@ public class Helper {
|
|||
BaseMainActivity.currentToken = newAccount.token;
|
||||
BaseMainActivity.currentInstance = newAccount.instance;
|
||||
editor.apply();
|
||||
Intent changeAccount = new Intent(activity, BaseMainActivity.class);
|
||||
Intent changeAccount = new Intent(activity, MainActivity.class);
|
||||
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
activity.startActivity(changeAccount);
|
||||
}
|
||||
|
|
|
@ -93,14 +93,11 @@ public class PinnedTimelineHelper {
|
|||
if (!present) {
|
||||
pinnedToRemove.add(pinnedTimeline);
|
||||
needRedraw = true; //Something changed, redraw must be done
|
||||
Pinned finalPinned2 = pinned;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
new Pinned(activity).updatePinned(finalPinned2);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
try {
|
||||
new Pinned(activity).updatePinned(pinned);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,26 +115,22 @@ public class PinnedTimelineHelper {
|
|||
}
|
||||
//Needs to be added
|
||||
if (!present) {
|
||||
Pinned finalPinned1 = pinned;
|
||||
needRedraw = true; //Something changed, redraw must be done
|
||||
new Thread(() -> {
|
||||
PinnedTimeline pinnedTimeline = new PinnedTimeline();
|
||||
pinnedTimeline.type = Timeline.TimeLineEnum.LIST;
|
||||
pinnedTimeline.position = finalPinned1.pinnedTimelines.size();
|
||||
pinnedTimeline.mastodonList = mastodonList;
|
||||
finalPinned1.pinnedTimelines.add(pinnedTimeline);
|
||||
try {
|
||||
boolean exist = new Pinned(activity).pinnedExist(finalPinned1);
|
||||
if (exist) {
|
||||
new Pinned(activity).updatePinned(finalPinned1);
|
||||
} else {
|
||||
new Pinned(activity).insertPinned(finalPinned1);
|
||||
}
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
PinnedTimeline pinnedTimeline = new PinnedTimeline();
|
||||
pinnedTimeline.type = Timeline.TimeLineEnum.LIST;
|
||||
pinnedTimeline.position = pinned.pinnedTimelines.size();
|
||||
pinnedTimeline.mastodonList = mastodonList;
|
||||
pinned.pinnedTimelines.add(pinnedTimeline);
|
||||
try {
|
||||
boolean exist = new Pinned(activity).pinnedExist(pinned);
|
||||
if (exist) {
|
||||
new Pinned(activity).updatePinned(pinned);
|
||||
} else {
|
||||
new Pinned(activity).insertPinned(pinned);
|
||||
}
|
||||
}).start();
|
||||
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue