Crash fixes

This commit is contained in:
Grishka 2022-05-05 22:05:18 +03:00
parent 4ad9fa030b
commit 88504531d4
7 changed files with 35 additions and 9 deletions

View File

@ -9,8 +9,8 @@ android {
applicationId "org.joinmastodon.android"
minSdk 23
targetSdk 31
versionCode 36
versionName "1.1.0"
versionCode 37
versionName "1.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -26,6 +26,8 @@ public class MastodonErrorResponse extends ErrorResponse{
@Override
public void showToast(Context context){
if(context==null)
return;
Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
}
}

View File

@ -609,6 +609,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
@Override
public void onSuccess(Status result){
wm.removeView(sendingOverlay);
sendingOverlay=null;
Nav.finish(ComposeFragment.this);
E.post(new StatusCreatedEvent(result));
if(replyTo!=null){
@ -620,6 +621,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
@Override
public void onError(ErrorResponse error){
wm.removeView(sendingOverlay);
sendingOverlay=null;
sendProgress.setVisibility(View.GONE);
sendError.setVisibility(View.VISIBLE);
publishButton.setEnabled(true);
@ -647,6 +649,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
confirmDiscardDraftAndFinish();
return true;
}
if(sendingOverlay!=null)
return true;
return false;
}

View File

@ -128,6 +128,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private View fab;
private WindowInsets childInsets;
private PhotoViewer currentPhotoViewer;
private boolean editModeLoading;
public ProfileFragment(){
super(R.layout.loader_fragment_overlay_toolbar);
@ -664,17 +665,26 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
}
private void loadAccountInfoAndEnterEditMode(){
if(editModeLoading)
return;
editModeLoading=true;
setActionProgressVisible(true);
new GetOwnAccount()
.setCallback(new Callback<>(){
@Override
public void onSuccess(Account result){
editModeLoading=false;
if(getActivity()==null)
return;
enterEditMode(result);
setActionProgressVisible(false);
}
@Override
public void onError(ErrorResponse error){
editModeLoading=false;
if(getActivity()==null)
return;
error.showToast(getActivity());
setActionProgressVisible(false);
}

View File

@ -13,6 +13,8 @@ public interface ScrollableToTop{
* @param list
*/
default void smoothScrollRecyclerViewToTop(RecyclerView list){
if(list==null) // TODO find out why this happens because it should not be possible
return;
if(list.getChildCount()>0 && list.getChildAdapterPosition(list.getChildAt(0))>10){
list.scrollToPosition(0);
list.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){

View File

@ -117,6 +117,8 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
protected void doLoadData(int offset, int count){
if(isInRecentMode()){
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{
if(getActivity()==null)
return;
unfilteredResults=sr;
prevDisplayItems=new ArrayList<>(displayItems);
onDataLoaded(sr, false);

View File

@ -2,6 +2,7 @@ package org.joinmastodon.android.ui.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
@ -29,6 +30,7 @@ import android.webkit.MimeTypeMap;
import android.widget.Button;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import org.joinmastodon.android.E;
import org.joinmastodon.android.GlobalUserPreferences;
@ -87,13 +89,17 @@ public class UiUtils{
private UiUtils(){}
public static void launchWebBrowser(Context context, String url){
if(GlobalUserPreferences.useCustomTabs){
new CustomTabsIntent.Builder()
.setShowTitle(true)
.build()
.launchUrl(context, Uri.parse(url));
}else{
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
try{
if(GlobalUserPreferences.useCustomTabs){
new CustomTabsIntent.Builder()
.setShowTitle(true)
.build()
.launchUrl(context, Uri.parse(url));
}else{
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
}catch(ActivityNotFoundException x){
Toast.makeText(context, R.string.no_app_to_handle_action, Toast.LENGTH_SHORT).show();
}
}