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