From 97672f06de29fb5f5def106a03fcc5d9c8ce938d Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 3 Nov 2020 13:28:21 +0530 Subject: [PATCH] Use view binding in SearchFragment. --- .../fragments/list/search/SearchFragment.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 3b48d9c84..0aaf87ea6 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -37,6 +37,7 @@ import androidx.recyclerview.widget.RecyclerView; import org.schabi.newpipe.R; import org.schabi.newpipe.ReCaptchaActivity; import org.schabi.newpipe.database.history.model.SearchHistoryEntry; +import org.schabi.newpipe.databinding.FragmentSearchBinding; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.MetaInfo; @@ -155,6 +156,8 @@ public class SearchFragment extends BaseListFragment()); @@ -640,7 +644,8 @@ public class SearchFragment extends BaseListFragment suggestionListAdapter.setItems(suggestions)); + searchBinding.suggestionsList.smoothScrollToPosition(0); + searchBinding.suggestionsList.post(() -> suggestionListAdapter.setItems(suggestions)); if (suggestionsPanelVisible && errorPanelRoot.getVisibility() == View.VISIBLE) { hideLoading(); @@ -1019,7 +1025,7 @@ public class SearchFragment extends BaseListFragment"; final String text = String.format(helperText, highlightedSearchSuggestion); - correctSuggestion.setText(HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY)); + searchBinding.correctSuggestion.setText(HtmlCompat.fromHtml(text, + HtmlCompat.FROM_HTML_MODE_LEGACY)); - correctSuggestion.setOnClickListener(v -> { - correctSuggestion.setVisibility(View.GONE); + searchBinding.correctSuggestion.setOnClickListener(v -> { + searchBinding.correctSuggestion.setVisibility(View.GONE); search(searchSuggestion, contentFilter, sortFilter); searchEditText.setText(searchSuggestion); }); - correctSuggestion.setOnLongClickListener(v -> { + searchBinding.correctSuggestion.setOnLongClickListener(v -> { searchEditText.setText(searchSuggestion); searchEditText.setSelection(searchSuggestion.length()); showKeyboardSearch(); return true; }); - correctSuggestion.setVisibility(View.VISIBLE); + searchBinding.correctSuggestion.setVisibility(View.VISIBLE); } }