Commit c7420a87 authored by Thomas's avatar Thomas
Browse files

Fix some crashes

parent ab9b367a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -586,7 +586,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
            }
            Handler mainHandler = new Handler(Looper.getMainLooper());
            Runnable myRunnable = () -> {
                if (currentAccount == null || currentAccount.mastodon_account == null) {
                if (currentToken == null) {
                    currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
                }
                if (currentAccount == null) {
                    //It is not, the user is redirected to the login page
                    Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
                    startActivity(myIntent);
+9 −4
Original line number Diff line number Diff line
@@ -78,13 +78,18 @@ public class AccountFollowRequestAdapter extends RecyclerView.Adapter<RecyclerVi
        AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
        holderFollow.binding.acceptButton.setOnClickListener(v -> accountsVM.acceptFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
                .observe((LifecycleOwner) context, relationShip -> {
                    if (accountList.size() > position) {
                        accountList.remove(position);
                        notifyItemRemoved(position);
                    }
                }));
        holderFollow.binding.rejectButton.setOnClickListener(v -> accountsVM.rejectFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id)
                .observe((LifecycleOwner) context, relationShip -> {
                    if (accountList.size() > position) {
                        accountList.remove(position);
                        notifyItemRemoved(position);
                    }

                }));
        holderFollow.binding.avatar.setOnClickListener(v -> {
            Intent intent = new Intent(context, ProfileActivity.class);
+5 −0
Original line number Diff line number Diff line
@@ -941,6 +941,11 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                        composeAttachmentItemBinding.buttonOrderDown.setVisibility(View.INVISIBLE);
                    }
                    int finalMediaPosition = mediaPosition;
                    if (attachment.local_path.endsWith("png") || attachment.local_path.endsWith("jpg") || attachment.local_path.endsWith("jpeg")) {
                        composeAttachmentItemBinding.editPreview.setVisibility(View.VISIBLE);
                    } else {
                        composeAttachmentItemBinding.editPreview.setVisibility(View.GONE);
                    }
                    composeAttachmentItemBinding.editPreview.setOnClickListener(v -> {
                        Intent intent = new Intent(context, EditImageActivity.class);
                        Bundle b = new Bundle();
+2 −2
Original line number Diff line number Diff line
@@ -2341,7 +2341,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                    @Override
                    public void onGlobalLayout() {
                        holder.bindingArt.artMedia.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        if (status.art_attachment.meta != null) {
                        if (status.art_attachment.meta != null && status.art_attachment.meta.small != null) {
                            float viewWidth = holder.bindingArt.artMedia.getWidth();
                            ConstraintLayout.LayoutParams lp;
                            float mediaH = status.art_attachment.meta.small.height;
@@ -2357,7 +2357,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>

                    }
                });
                if (status.art_attachment.meta != null) {
                if (status.art_attachment.meta != null && status.art_attachment.meta.small != null) {
                    float viewWidth = holder.bindingArt.artMedia.getWidth();
                    ConstraintLayout.LayoutParams lp;
                    float mediaH = status.art_attachment.meta.small.height;