diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 08b715c7..2f733a7c 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -747,12 +747,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt itemFilter.setTitle(show_filtered); } popup.setOnDismissListener(menu1 -> { - if (binding.viewPager.getAdapter() != null) { - Fragment fragment = getSupportFragmentManager().findFragmentByTag("f" + binding.viewPager.getCurrentItem()); - if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { - FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); - fragmentMastodonTimeline.refreshAllAdapters(); - } + Fragment fragment = getSupportFragmentManager().findFragmentByTag("f" + binding.viewPager.getCurrentItem()); + if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { + FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); + fragmentMastodonTimeline.refreshAllAdapters(); } }); String finalShow_filtered = show_filtered; diff --git a/app/src/main/java/app/fedilab/android/client/entities/app/Account.java b/app/src/main/java/app/fedilab/android/client/entities/app/Account.java index 341e6e93..1be6458b 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/app/Account.java +++ b/app/src/main/java/app/fedilab/android/client/entities/app/Account.java @@ -277,7 +277,7 @@ public class Account extends BaseAccount implements Serializable { throw new DBException("db is null. Wrong initialization."); } try { - Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_API + " = 'MASTODON'", null, null, null, null, null); + Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, null, null, null, null, null, null); return cursorToListUser(c); } catch (Exception e) { return null; diff --git a/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java b/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java index 74fe0a22..72089125 100644 --- a/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/CrossActionHelper.java @@ -83,7 +83,7 @@ public class CrossActionHelper { AlertDialog.Builder builderSingle = new AlertDialog.Builder(context, Helper.dialogStyle()); builderSingle.setTitle(context.getString(R.string.choose_accounts)); final AccountsSearchAdapter accountsSearchAdapter = new AccountsSearchAdapter(context, accountList); - final BaseAccount[] accountArray = new Account[accounts.size()]; + final BaseAccount[] accountArray = new BaseAccount[accounts.size()]; int i = 0; for (BaseAccount account : accounts) { accountArray[i] = account; diff --git a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java index fb5769b1..d04c89c0 100644 --- a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java @@ -312,22 +312,19 @@ public class PinnedTimelineHelper { popup.setOnDismissListener(menu1 -> { if (changes[0]) { FragmentMastodonTimeline fragmentMastodonTimeline; - if (activityMainBinding.viewPager.getAdapter() != null) { - Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); - if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { - fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); - 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); - fragmentMastodonTimeline.setArguments(bundle); - FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); - fragTransaction2.attach(fragmentMastodonTimeline); - fragTransaction2.commit(); - } + Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); + if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { + fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); + 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); + fragmentMastodonTimeline.setArguments(bundle); + FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); + fragTransaction2.attach(fragmentMastodonTimeline); + fragTransaction2.commit(); } - } }); @@ -529,11 +526,9 @@ public class PinnedTimelineHelper { }); changes[0] = true; FragmentMastodonTimeline fragmentMastodonTimeline = null; - if (activityMainBinding.viewPager.getAdapter() != null) { - Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); - if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { - fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); - } + Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); + if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { + fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); } if (fragmentMastodonTimeline == null) return false; @@ -576,12 +571,10 @@ public class PinnedTimelineHelper { MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title); item.setOnMenuItemClickListener(item1 -> { FragmentMastodonTimeline fragmentMastodonTimeline = null; - if (activityMainBinding.viewPager.getAdapter() != null) { - Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); - if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { - fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); - fragmentMastodonTimeline.refreshAllAdapters(); - } + Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); + if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { + fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); + fragmentMastodonTimeline.refreshAllAdapters(); } FragmentTransaction fragTransaction1 = activity.getSupportFragmentManager().beginTransaction(); if (fragmentMastodonTimeline == null) @@ -659,12 +652,10 @@ public class PinnedTimelineHelper { popup.setOnDismissListener(menu -> { if (changes[0]) { FragmentMastodonTimeline fragmentMastodonTimeline = null; - if (activityMainBinding.viewPager.getAdapter() != null) { - Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); - if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { - fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); - fragmentMastodonTimeline.refreshAllAdapters(); - } + Fragment fragment = activity.getSupportFragmentManager().findFragmentByTag("f" + activityMainBinding.viewPager.getCurrentItem()); + if (fragment instanceof FragmentMastodonTimeline && fragment.isVisible()) { + fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); + fragmentMastodonTimeline.refreshAllAdapters(); } FragmentTransaction fragTransaction1 = activity.getSupportFragmentManager().beginTransaction(); if (fragmentMastodonTimeline == null) diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index 2b31b7db..d04ea780 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -247,7 +247,7 @@ public class SpannableHelper { content.setSpan(new LongClickableSpan() { @Override public void onLongClick(View view) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(view.getContext(), Helper.dialogStyle()); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, Helper.dialogStyle()); PopupLinksBinding popupLinksBinding = PopupLinksBinding.inflate(LayoutInflater.from(context)); dialogBuilder.setView(popupLinksBinding.getRoot()); AlertDialog alertDialog = dialogBuilder.create(); diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java index 7d544ce1..e46dc045 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonContext.java @@ -155,7 +155,7 @@ public class FragmentMastodonContext extends Fragment { focusedStatus = (Status) getArguments().getSerializable(Helper.ARG_STATUS); } if (focusedStatus == null) { - requireActivity().getSupportFragmentManager().beginTransaction().remove(this).commit(); + getChildFragmentManager().beginTransaction().remove(this).commit(); } binding = FragmentPaginationBinding.inflate(inflater, container, false); int c1 = getResources().getColor(R.color.cyanea_accent_reference); diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java index b02a6048..a7aec672 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java @@ -267,7 +267,7 @@ public class FragmentNotificationContainer extends Fragment { @Override public void onTabReselected(TabLayout.Tab tab) { - Fragment fragment = requireActivity().getSupportFragmentManager().findFragmentByTag("f" + binding.viewpager.getCurrentItem()); + Fragment fragment = getChildFragmentManager().findFragmentByTag("f" + binding.viewpager.getCurrentItem()); if (fragment instanceof FragmentMastodonNotification) { FragmentMastodonNotification fragmentMastodonNotification = ((FragmentMastodonNotification) fragment); fragmentMastodonNotification.scrollToTop(); @@ -280,7 +280,7 @@ public class FragmentNotificationContainer extends Fragment { public void scrollToTop() { if (binding != null) { - Fragment fragment = requireActivity().getSupportFragmentManager().findFragmentByTag("f" + binding.viewpager.getCurrentItem()); + Fragment fragment = getChildFragmentManager().findFragmentByTag("f" + binding.viewpager.getCurrentItem()); if (fragment instanceof FragmentMastodonNotification) { ((FragmentMastodonNotification) fragment).scrollToTop(); }