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