forked from mirrors/Fedilab
Automatically switch to tabs when searching
This commit is contained in:
parent
d9e92b13b6
commit
44676707f0
3 changed files with 34 additions and 1 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -146,8 +146,16 @@ public class FragmentMastodonTag extends Fragment {
|
|||
});
|
||||
if (tags == null || tags.size() == 0) {
|
||||
if (requireActivity() instanceof SearchResultTabActivity) {
|
||||
((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);
|
||||
binding.noActionText.setText(R.string.no_tags);
|
||||
|
|
Loading…
Reference in a new issue