A bunch of crash fixes

This commit is contained in:
Grishka 2023-07-02 12:03:21 +03:00
parent 66489d79be
commit 85d4c1fc24
10 changed files with 27 additions and 6 deletions

View File

@ -76,7 +76,7 @@ dependencies {
implementation 'me.grishka.litex:viewpager:1.0.0'
implementation 'me.grishka.litex:viewpager2:1.0.0'
implementation 'me.grishka.litex:palette:1.0.0'
implementation 'me.grishka.appkit:appkit:1.2.8'
implementation 'me.grishka.appkit:appkit:1.2.9'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'com.squareup:otto:1.3.8'

View File

@ -252,6 +252,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
selfAvatar=view.findViewById(R.id.avatar);
HtmlParser.setTextWithCustomEmoji(selfName, self.displayName, self.emojis);
selfUsername.setText('@'+self.username+'@'+instanceDomain);
if(self.avatar!=null)
ViewImageLoader.load(selfAvatar, null, new UrlImageLoaderRequest(self.avatar));
ViewOutlineProvider roundCornersOutline=new ViewOutlineProvider(){
@Override
@ -960,6 +961,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
}
private void updateVisibilityIcon(){
if(getActivity()==null)
return;
if(statusVisibility==null){ // TODO find out why this happens
statusVisibility=StatusPrivacy.PUBLIC;
}

View File

@ -349,7 +349,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
}
private void updateMarkAllReadButton(){
markAllReadItem.setEnabled(!data.isEmpty() && !realUnreadMarker.equals(data.get(0).id));
markAllReadItem.setEnabled(!data.isEmpty() && realUnreadMarker!=null && !realUnreadMarker.equals(data.get(0).id));
}
@Override

View File

@ -148,6 +148,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private boolean tabBarIsAtTop;
private Animator tabBarColorAnim;
private MenuItem editSaveMenuItem;
private boolean savingEdits;
@Override
public void onCreate(Bundle savedInstanceState){
@ -866,10 +867,12 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(!isInEditMode)
throw new IllegalStateException();
setActionProgressVisible(true);
savingEdits=true;
new UpdateAccountCredentials(nameEdit.getText().toString(), bioEdit.getText().toString(), editNewAvatar, editNewCover, aboutFragment.getFields())
.setCallback(new Callback<>(){
@Override
public void onSuccess(Account result){
savingEdits=false;
account=result;
AccountSessionManager.getInstance().updateAccountInfo(accountID, account);
exitEditMode();
@ -878,6 +881,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
@Override
public void onError(ErrorResponse error){
savingEdits=false;
error.showToast(getActivity());
setActionProgressVisible(false);
}
@ -901,6 +905,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
@Override
public boolean onBackPressed(){
if(isInEditMode){
if(savingEdits)
return true;
if(editDirty || aboutFragment.isEditDirty()){
new M3AlertDialogBuilder(getActivity())
.setTitle(R.string.discard_changes)

View File

@ -279,7 +279,7 @@ public class SearchQueryFragment extends MastodonRecyclerFragment<SearchResultVi
@Override
protected void onShown(){
super.onShown();
getActivity().getSystemService(InputMethodManager.class).showSoftInput(getActivity().getCurrentFocus(), 0);
getActivity().getSystemService(InputMethodManager.class).showSoftInput(searchViewHelper.getSearchEdit(), 0);
}
@Override

View File

@ -47,6 +47,7 @@ public class AccountActivationFragment extends ToolbarFragment{
private APIRequest currentRequest;
private Runnable resendTimer=this::updateResendTimer;
private long lastResendTime;
private boolean visible;
@Override
public void onCreate(Bundle savedInstanceState){
@ -111,12 +112,14 @@ public class AccountActivationFragment extends ToolbarFragment{
@Override
protected void onShown(){
super.onShown();
visible=true;
tryGetAccount();
}
@Override
protected void onHidden(){
super.onHidden();
visible=false;
if(currentRequest!=null){
currentRequest.cancel();
currentRequest=null;
@ -229,6 +232,8 @@ public class AccountActivationFragment extends ToolbarFragment{
}
private void proceed(){
if(!visible)
return;
Bundle args=new Bundle();
args.putString("account", accountID);
// Nav.goClearingStack(getActivity(), HomeFragment.class, args);

View File

@ -228,7 +228,7 @@ abstract class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInsta
}
loadingInstanceDomain=null;
showInstanceInfoLoadError(domain, error);
if(fakeInstance!=null){
if(fakeInstance!=null && getActivity()!=null){
fakeInstance.description=getString(R.string.error);
if(filteredData.size()>0 && filteredData.get(0)==fakeInstance){
if(list.findViewHolderForAdapterPosition(1) instanceof BindableViewHolder<?> ivh){

View File

@ -255,6 +255,7 @@ public class AccountSwitcherSheet extends BottomSheet{
}
return;
}
if(AccountSessionManager.getInstance().tryGetAccount(item.getID())!=null)
AccountSessionManager.getInstance().setLastActiveAccountID(item.getID());
activity.finish();
activity.startActivity(new Intent(activity, MainActivity.class));

View File

@ -126,4 +126,8 @@ public class SearchViewHelper{
public View getDivider(){
return divider;
}
public EditText getSearchEdit(){
return searchEdit;
}
}

View File

@ -280,6 +280,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
}
private void updateOptionsMenu(){
if(item.parentFragment.getActivity()==null)
return;
Account account=item.user;
Menu menu=optionsMenu.getMenu();
boolean isOwnPost=AccountSessionManager.getInstance().isSelf(item.parentFragment.getAccountID(), account);