ExtendedListFragment: Remove ViewTreeObserver on search frame

This was incorrectly setting empty message when switching search types. And it makes no sense: search is only executed when submitted.

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-03-15 18:43:27 +01:00
parent e8e18609e5
commit 0af297735c
No known key found for this signature in database
GPG key ID: 2585783189A62105

View file

@ -235,38 +235,6 @@ public class ExtendedListFragment extends Fragment implements
}
});
final View mSearchEditFrame = searchView
.findViewById(androidx.appcompat.R.id.search_edit_frame);
ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
int oldVisibility = -1;
@Override
public void onGlobalLayout() {
int currentVisibility = mSearchEditFrame.getVisibility();
if (currentVisibility != oldVisibility) {
if (currentVisibility == View.VISIBLE) {
setEmptyListMessage(SearchType.REGULAR_FILTER);
} else {
if (MainApp.isOnlyOnDevice()) {
setMessageForEmptyList(R.string.file_list_empty_headline,
R.string.file_list_empty_on_device,
R.drawable.ic_list_empty_folder,
true);
} else {
setEmptyListMessage(SearchType.NO_SEARCH);
}
}
oldVisibility = currentVisibility;
}
}
});
LinearLayout searchBar = searchView.findViewById(R.id.search_bar);
searchBar.setLayoutTransition(new LayoutTransition());
}