improve search empty text
This commit is contained in:
parent
648c3a0c0d
commit
e0dd2e3a08
|
@ -62,6 +62,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
|||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
|
||||
setRetainInstance(true);
|
||||
loadData();
|
||||
resetEmptyText();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +71,10 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
|||
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){
|
||||
|
@ -119,6 +124,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
|||
|
||||
@Override
|
||||
protected void doLoadData(int offset, int count){
|
||||
resetEmptyText();
|
||||
if(isInRecentMode()){
|
||||
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{
|
||||
if(getActivity()==null)
|
||||
|
@ -128,11 +134,13 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
|||
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)
|
||||
|
@ -153,6 +161,7 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
|
|||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
resetEmptyText();
|
||||
currentRequest=null;
|
||||
Activity a=getActivity();
|
||||
if(a==null)
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue