Fix some crashes

maths
Thomas 2 years ago
parent ab9b367a38
commit c7420a8760

@ -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);

@ -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 -> {
accountList.remove(position);
notifyItemRemoved(position);
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 -> {
accountList.remove(position);
notifyItemRemoved(position);
if (accountList.size() > position) {
accountList.remove(position);
notifyItemRemoved(position);
}
}));
holderFollow.binding.avatar.setOnClickListener(v -> {
Intent intent = new Intent(context, ProfileActivity.class);

@ -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();

@ -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;

Loading…
Cancel
Save