diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java index 08bb89dc8..decb29d7f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/SearchResultTabActivity.java @@ -70,6 +70,7 @@ public class SearchResultTabActivity extends BaseBarActivity { private String search; private ActivitySearchResultTabsBinding binding; private TabLayout.Tab initial; + public Boolean tagEmpty, accountEmpty; @Override protected void onCreate(Bundle savedInstanceState) { @@ -277,9 +278,17 @@ public class SearchResultTabActivity extends BaseBarActivity { public void moveToAccount() { + tagEmpty = null; + accountEmpty = null; binding.searchViewpager.setCurrentItem(1); } + public void moveToMessage() { + tagEmpty = null; + accountEmpty = null; + binding.searchViewpager.setCurrentItem(2); + } + /** * Pager adapter for the 4 fragments */ diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java index d0567bc74..3a38671c0 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonAccount.java @@ -36,6 +36,7 @@ import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.FragmentPaginationBinding; +import app.fedilab.android.mastodon.activities.SearchResultTabActivity; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Accounts; import app.fedilab.android.mastodon.client.entities.api.Pagination; @@ -223,10 +224,25 @@ public class FragmentMastodonAccount extends Fragment { router(true); }); if (accounts == null || accounts.accounts == null || accounts.accounts.size() == 0) { + if (requireActivity() instanceof SearchResultTabActivity) { + ((SearchResultTabActivity) requireActivity()).accountEmpty = true; + if (((SearchResultTabActivity) requireActivity()).tagEmpty != null) { + if (((SearchResultTabActivity) requireActivity()).tagEmpty) { + ((SearchResultTabActivity) requireActivity()).moveToMessage(); + } + } + } binding.noAction.setVisibility(View.VISIBLE); binding.noActionText.setText(R.string.no_accounts); return; } + if (requireActivity() instanceof SearchResultTabActivity) { + if (((SearchResultTabActivity) requireActivity()).tagEmpty != null) { + if (((SearchResultTabActivity) requireActivity()).tagEmpty) { + ((SearchResultTabActivity) requireActivity()).moveToAccount(); + } + } + } binding.recyclerView.setVisibility(View.VISIBLE); if (accountAdapter != null && this.accounts != null) { int size = this.accounts.size(); diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTag.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTag.java index 24dcc9eef..13254a168 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTag.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTag.java @@ -146,7 +146,15 @@ public class FragmentMastodonTag extends Fragment { }); if (tags == null || tags.size() == 0) { if (requireActivity() instanceof SearchResultTabActivity) { - ((SearchResultTabActivity) requireActivity()).moveToAccount(); + ((SearchResultTabActivity) requireActivity()).tagEmpty = true; + if (((SearchResultTabActivity) requireActivity()).accountEmpty != null) { + if (((SearchResultTabActivity) requireActivity()).accountEmpty) { + ((SearchResultTabActivity) requireActivity()).moveToMessage(); + } else { + ((SearchResultTabActivity) requireActivity()).moveToAccount(); + } + } + } binding.recyclerView.setVisibility(View.GONE); binding.noAction.setVisibility(View.VISIBLE);