mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge pull request #8972 from Stypox/fix-suggestions-listadapter
Fix various issues in the search suggestions list
This commit is contained in:
commit
bf55ed262f
@ -340,6 +340,8 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||||||
super.initViews(rootView, savedInstanceState);
|
super.initViews(rootView, savedInstanceState);
|
||||||
|
|
||||||
searchBinding.suggestionsList.setAdapter(suggestionListAdapter);
|
searchBinding.suggestionsList.setAdapter(suggestionListAdapter);
|
||||||
|
// animations are just strange and useless, since the suggestions keep changing too much
|
||||||
|
searchBinding.suggestionsList.setItemAnimator(null);
|
||||||
new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
new ItemTouchHelper(new ItemTouchHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public int getMovementFlags(@NonNull final RecyclerView recyclerView,
|
public int getMovementFlags(@NonNull final RecyclerView recyclerView,
|
||||||
@ -944,8 +946,8 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "handleSuggestions() called with: suggestions = [" + suggestions + "]");
|
Log.d(TAG, "handleSuggestions() called with: suggestions = [" + suggestions + "]");
|
||||||
}
|
}
|
||||||
searchBinding.suggestionsList.smoothScrollToPosition(0);
|
suggestionListAdapter.submitList(suggestions,
|
||||||
suggestionListAdapter.submitList(suggestions);
|
() -> searchBinding.suggestionsList.scrollToPosition(0));
|
||||||
|
|
||||||
if (suggestionsPanelVisible && isErrorPanelVisible()) {
|
if (suggestionsPanelVisible && isErrorPanelVisible()) {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
@ -80,13 +80,14 @@ public class SuggestionListAdapter
|
|||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(@NonNull final SuggestionItem oldItem,
|
public boolean areItemsTheSame(@NonNull final SuggestionItem oldItem,
|
||||||
@NonNull final SuggestionItem newItem) {
|
@NonNull final SuggestionItem newItem) {
|
||||||
return oldItem.query.equals(newItem.query);
|
return oldItem.fromHistory == newItem.fromHistory
|
||||||
|
&& oldItem.query.equals(newItem.query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(@NonNull final SuggestionItem oldItem,
|
public boolean areContentsTheSame(@NonNull final SuggestionItem oldItem,
|
||||||
@NonNull final SuggestionItem newItem) {
|
@NonNull final SuggestionItem newItem) {
|
||||||
return oldItem.equals(newItem);
|
return true; // items' contents never change; the list of items themselves does
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user