mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix crashes
This commit is contained in:
parent
bc70576a63
commit
4ae5e73b76
4 changed files with 41 additions and 38 deletions
|
@ -657,7 +657,7 @@ public class PinnedTimelineHelper {
|
|||
itemFilter.setTitle(show_filtered);
|
||||
}
|
||||
popup.setOnDismissListener(menu1 -> {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null) {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
|
||||
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
|
||||
|
@ -830,19 +830,21 @@ public class PinnedTimelineHelper {
|
|||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(activity.getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
||||
editor.commit();
|
||||
Fragment fragmentMastodonTimeline = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragmentMastodonTimeline instanceof FragmentMastodonTimeline && fragmentMastodonTimeline.isVisible()) {
|
||||
FragmentTransaction fragTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(fragmentMastodonTimeline).commit();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG);
|
||||
bundle.putSerializable(Helper.ARG_TAG_TIMELINE, tagTimeline);
|
||||
bundle.putSerializable(Helper.ARG_INITIALIZE_VIEW, false);
|
||||
fragmentMastodonTimeline.setArguments(bundle);
|
||||
FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction2.attach(fragmentMastodonTimeline);
|
||||
fragTransaction2.commit();
|
||||
((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate();
|
||||
if (activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragmentMastodonTimeline = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragmentMastodonTimeline instanceof FragmentMastodonTimeline && fragmentMastodonTimeline.isVisible()) {
|
||||
FragmentTransaction fragTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(fragmentMastodonTimeline).commit();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.TAG);
|
||||
bundle.putSerializable(Helper.ARG_TAG_TIMELINE, tagTimeline);
|
||||
bundle.putSerializable(Helper.ARG_INITIALIZE_VIEW, false);
|
||||
fragmentMastodonTimeline.setArguments(bundle);
|
||||
FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction2.attach(fragmentMastodonTimeline);
|
||||
fragTransaction2.commit();
|
||||
((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1058,19 +1060,21 @@ public class PinnedTimelineHelper {
|
|||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(activity.getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null);
|
||||
editor.commit();
|
||||
Fragment fragmentMastodonTimeline = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragmentMastodonTimeline instanceof FragmentMastodonTimeline && fragmentMastodonTimeline.isVisible()) {
|
||||
FragmentTransaction fragTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(fragmentMastodonTimeline).commit();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.BUBBLE);
|
||||
bundle.putSerializable(Helper.ARG_BUBBLE_TIMELINE, bubbleTimeline);
|
||||
bundle.putSerializable(Helper.ARG_INITIALIZE_VIEW, false);
|
||||
fragmentMastodonTimeline.setArguments(bundle);
|
||||
FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction2.attach(fragmentMastodonTimeline);
|
||||
fragTransaction2.commit();
|
||||
((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate();
|
||||
if (activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragmentMastodonTimeline = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragmentMastodonTimeline instanceof FragmentMastodonTimeline && fragmentMastodonTimeline.isVisible()) {
|
||||
FragmentTransaction fragTransaction = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction.detach(fragmentMastodonTimeline).commit();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.ARG_TIMELINE_TYPE, Timeline.TimeLineEnum.BUBBLE);
|
||||
bundle.putSerializable(Helper.ARG_BUBBLE_TIMELINE, bubbleTimeline);
|
||||
bundle.putSerializable(Helper.ARG_INITIALIZE_VIEW, false);
|
||||
fragmentMastodonTimeline.setArguments(bundle);
|
||||
FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction();
|
||||
fragTransaction2.attach(fragmentMastodonTimeline);
|
||||
fragTransaction2.commit();
|
||||
((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1301,7 +1305,7 @@ public class PinnedTimelineHelper {
|
|||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (activityMainBinding.viewPager.getAdapter() != null) {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
|
||||
fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
|
||||
|
@ -1349,7 +1353,7 @@ public class PinnedTimelineHelper {
|
|||
int finalOffSetPosition1 = offSetPosition;
|
||||
item.setOnMenuItemClickListener(item1 -> {
|
||||
FragmentMastodonTimeline fragmentMastodonTimeline = null;
|
||||
if (activityMainBinding.viewPager.getAdapter() != null) {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
|
||||
fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
|
||||
|
@ -1442,7 +1446,7 @@ public class PinnedTimelineHelper {
|
|||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (activityMainBinding.viewPager.getAdapter() != null) {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
|
||||
fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
|
||||
|
@ -1551,7 +1555,7 @@ public class PinnedTimelineHelper {
|
|||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (activityMainBinding.viewPager.getAdapter() != null) {
|
||||
if (activityMainBinding.viewPager.getAdapter() != null && activityMainBinding.tabLayout.getSelectedTabPosition() != -1) {
|
||||
Fragment fragment = (Fragment) activityMainBinding.viewPager.getAdapter().instantiateItem(activityMainBinding.viewPager, activityMainBinding.tabLayout.getSelectedTabPosition());
|
||||
if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) {
|
||||
fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
|
||||
|
|
|
@ -255,14 +255,14 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
|
||||
holderFollow.binding.rejectButton.setOnClickListener(v -> accountsVM.rejectFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, notification.account.id)
|
||||
.observe((LifecycleOwner) context, relationShip -> {
|
||||
if (notificationList.size() > holderFollow.getBindingAdapterPosition()) {
|
||||
if (notificationList.size() > holderFollow.getBindingAdapterPosition() && holderFollow.getBindingAdapterPosition() >= 0) {
|
||||
notificationList.remove(holderFollow.getBindingAdapterPosition());
|
||||
notifyItemRemoved(holderFollow.getBindingAdapterPosition());
|
||||
}
|
||||
}));
|
||||
holderFollow.binding.acceptButton.setOnClickListener(v -> accountsVM.acceptFollow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, notification.account.id)
|
||||
.observe((LifecycleOwner) context, relationShip -> {
|
||||
if (notificationList.size() > holderFollow.getBindingAdapterPosition()) {
|
||||
if (notificationList.size() > holderFollow.getBindingAdapterPosition() && holderFollow.getBindingAdapterPosition() >= 0) {
|
||||
notificationList.remove(holderFollow.getBindingAdapterPosition());
|
||||
notifyItemRemoved(holderFollow.getBindingAdapterPosition());
|
||||
}
|
||||
|
|
|
@ -1476,7 +1476,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.media.moreMedia.setVisibility(View.GONE);
|
||||
} else if (statusToDeal.media_attachments.size() == 3) {
|
||||
holder.binding.media.media1Container.mediaRoot.setVisibility(View.VISIBLE);
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
constraintSet.clone(holder.binding.media.mediaContainer);
|
||||
constraintSet.connect(holder.binding.media.media4Container.getRoot().getId(), ConstraintSet.START, holder.binding.media.media1Container.getRoot().getId(), ConstraintSet.END);
|
||||
|
@ -1520,7 +1520,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
if (mediaPosition == 1) {
|
||||
layoutMediaBinding = holder.binding.media.media1Container;
|
||||
} else if (mediaPosition == 2 && statusToDeal.media_attachments.size() == 3) {
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.small.width < statusToDeal.media_attachments.get(0).meta.small.height) {
|
||||
layoutMediaBinding = holder.binding.media.media2Container;
|
||||
} else {
|
||||
layoutMediaBinding = holder.binding.media.media3Container;
|
||||
|
@ -2413,7 +2413,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
|
||||
float focusX = 0.f;
|
||||
float focusY = 0.f;
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.small != null && statusToDeal.media_attachments.get(0).meta.focus != null) {
|
||||
focusX = statusToDeal.media_attachments.get(0).meta.focus.x;
|
||||
focusY = statusToDeal.media_attachments.get(0).meta.focus.y;
|
||||
}
|
||||
|
|
|
@ -226,8 +226,7 @@ public class FragmentLoginMain extends Fragment {
|
|||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_proxy) {
|
||||
Intent intent = new Intent(requireActivity(), ProxyActivity.class);
|
||||
startActivity(intent);
|
||||
(new ProxyActivity()).show(requireActivity().getSupportFragmentManager(), null);
|
||||
} else if (itemId == R.id.action_request_admin) {
|
||||
|
||||
item.setChecked(!item.isChecked());
|
||||
|
|
Loading…
Reference in a new issue