improve search empty text

This commit is contained in:
sk 2023-01-23 12:41:10 +01:00
parent dab0c560e9
commit 6916f435b3
2 changed files with 12 additions and 2 deletions

View File

@ -62,7 +62,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
setRetainInstance(true);
loadData();
setEmptyText(R.string.sk_recent_searches_placeholder);
resetEmptyText();
}
@Override
@ -71,6 +71,10 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
imm=activity.getSystemService(InputMethodManager.class);
}
private void resetEmptyText() {
setEmptyText(R.string.sk_recent_searches_placeholder);
}
@Override
protected List<StatusDisplayItem> buildDisplayItems(SearchResult s){
return switch(s.type){
@ -120,6 +124,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
@Override
protected void doLoadData(int offset, int count){
resetEmptyText();
if(isInRecentMode()){
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{
if(getActivity()==null)
@ -129,11 +134,13 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
onDataLoaded(sr, false);
});
}else{
setEmptyText(R.string.sk_searching);
progressVisibilityListener.onProgressVisibilityChanged(true);
currentRequest=new GetSearchResults(currentQuery, null, true)
.setCallback(new Callback<>(){
@Override
public void onSuccess(SearchResults result){
setEmptyText(R.string.sk_no_results);
ArrayList<SearchResult> results=new ArrayList<>();
if(result.accounts!=null){
for(Account acc:result.accounts)
@ -154,6 +161,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult> impleme
@Override
public void onError(ErrorResponse error){
resetEmptyText();
currentRequest=null;
Activity a=getActivity();
if(a==null)

View File

@ -143,7 +143,7 @@
<string name="sk_timeline_home">Home</string>
<string name="sk_timeline_local">Local</string>
<string name="sk_timeline_federated">Federation</string>
<string name="sk_recent_searches_placeholder">Type something to start searching</string>
<string name="sk_recent_searches_placeholder">Type to start searching</string>
<string name="sk_remove_follower">Remove as follower</string>
<string name="sk_remove_follower_confirm">Remove %s as a follower by blocking and immediately unblocking them?</string>
<string name="sk_do_remove_follower">Remove</string>
@ -227,4 +227,6 @@
<string name="sk_notification_type_update">Edited posts</string>
<string name="sk_notify_update">Edits a reblogged post</string>
<string name="sk_attach_file">Attach file</string>
<string name="sk_searching">Searching…</string>
<string name="sk_no_results">No results</string>
</resources>