Assorted crash fixes

This commit is contained in:
Grishka 2023-11-21 21:46:41 +03:00
parent 8f3a9c265c
commit a05c917b2c
6 changed files with 21 additions and 1 deletions

View File

@ -248,6 +248,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
@Override
public void photoViewerDismissed(){
currentPhotoViewer=null;
gridHolder.itemView.setHasTransientState(false);
}
@Override
@ -259,6 +260,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
return gridHolder.getViewController(index);
}
});
gridHolder.itemView.setHasTransientState(true);
}
@Override

View File

@ -314,6 +314,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
}
private void markAsRead(){
if(data.isEmpty())
return;
String id=data.get(0).id;
if(ObjectIdComparator.INSTANCE.compare(id, realUnreadMarker)>0){
new SaveMarkers(null, id).exec(accountID);

View File

@ -153,7 +153,7 @@ public class SettingsMainFragment extends BaseSettingsFragment<Void>{
}
private void onManageAccountsClick(ListItem<?> item){
new AccountSwitcherSheet(getActivity(), null).show();
new AccountSwitcherSheet(getActivity(), null).setOnLoggedOutCallback(()->loggedOut=true).show();
}
private void onLogOutClick(ListItem<?> item_){

View File

@ -60,6 +60,7 @@ public class AccountSwitcherSheet extends BottomSheet{
private UsableRecyclerView list;
private List<WrappedAccount> accounts;
private ListImageLoaderWrapper imgLoader;
private Runnable onLoggedOutCallback;
public AccountSwitcherSheet(@NonNull Activity activity, @Nullable HomeFragment fragment){
super(activity);
@ -95,6 +96,11 @@ public class AccountSwitcherSheet extends BottomSheet{
UiUtils.getThemeColor(activity, R.attr.colorM3Primary), 0.05f)), !UiUtils.isDarkTheme());
}
public AccountSwitcherSheet setOnLoggedOutCallback(Runnable onLoggedOutCallback){
this.onLoggedOutCallback=onLoggedOutCallback;
return this;
}
private void confirmLogOut(String accountID){
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
new M3AlertDialogBuilder(activity)
@ -113,7 +119,10 @@ public class AccountSwitcherSheet extends BottomSheet{
}
private void logOut(String accountID){
String activeAccount=AccountSessionManager.getInstance().getLastActiveAccountID();
AccountSessionManager.get(accountID).logOut(activity, ()->{
if(accountID.equals(activeAccount) && onLoggedOutCallback!=null)
onLoggedOutCallback.run();
dismiss();
((MainActivity)activity).restartHomeFragment();
});
@ -133,6 +142,8 @@ public class AccountSwitcherSheet extends BottomSheet{
AccountSessionManager.getInstance().removeAccount(session.getID());
sessions.remove(session);
if(sessions.isEmpty()){
if(onLoggedOutCallback!=null)
onLoggedOutCallback.run();
progress.dismiss();
Nav.goClearingStack(activity, SplashFragment.class, null);
dismiss();
@ -144,6 +155,8 @@ public class AccountSwitcherSheet extends BottomSheet{
AccountSessionManager.getInstance().removeAccount(session.getID());
sessions.remove(session);
if(sessions.isEmpty()){
if(onLoggedOutCallback!=null)
onLoggedOutCallback.run();
progress.dismiss();
Nav.goClearingStack(activity, SplashFragment.class, null);
dismiss();

View File

@ -181,6 +181,8 @@ public class ToolbarDropdownMenuController{
public void resizeOnNextFrame(){
if(currentTransition!=null)
currentTransition.cancel();
if(windowView==null)
return;
int origBottom=menuContainer.getBottom();
menuContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
@Override

View File

@ -173,6 +173,7 @@ public class ReorderableLinearLayout extends LinearLayout implements CustomViewH
else
bottomSibling=null;
dragListener.onSwapItems(prevIndex, index);
final View draggedView=this.draggedView;
draggedView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
@Override
public boolean onPreDraw(){