Fix some crashes

This commit is contained in:
Thomas 2023-01-15 14:48:23 +01:00
parent 80f6fb2382
commit 3ab25e3333
4 changed files with 10 additions and 2 deletions

View file

@ -109,6 +109,7 @@ public class HashTagActivity extends BaseActivity {
pinned = new Pinned();
pinned.pinnedTimelines = new ArrayList<>();
}
this.pinned = pinned;
pinnedTag = false;
if (pinned.pinnedTimelines != null) {
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
@ -173,6 +174,9 @@ public class HashTagActivity extends BaseActivity {
unpinConfirm.setMessage(getString(R.string.unpin_timeline_description));
unpinConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
unpinConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
if (pinned == null || pinned.pinnedTimelines == null) {
return;
}
pinned.pinnedTimelines.remove(pinnedTimeline);
try {
new Pinned(HashTagActivity.this).updatePinned(pinned);

View file

@ -113,6 +113,10 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload
attachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ARRAY);
status = (Status) b.getSerializable(Helper.ARG_STATUS);
}
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
if (attachments == null || attachments.size() == 0)
finish();

View file

@ -90,7 +90,7 @@ public class FragmentMediaProfile extends Fragment {
@Override
public void federatedAccount(Account account) {
if (account != null) {
if (account != null && !requireActivity().isFinishing() && isAdded()) {
accountId = account.id;
accountsVM.getAccountStatuses(tempInstance, null, accountId, null, null, null, null, null, true, false, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), statuses -> initializeStatusesCommonView(statuses));

View file

@ -1067,7 +1067,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
@Override
public void federatedAccount(Account account) {
if (account != null) {
if (account != null && !requireActivity().isFinishing() && isAdded()) {
accountIDInRemoteInstance = account.id;
accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity()))
.observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(tempInstance, null, accountIDInRemoteInstance, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity()))