11package org .schabi .newpipe .fragments .list .search ;
22
33import static androidx .recyclerview .widget .ItemTouchHelper .Callback .makeMovementFlags ;
4+ import static org .schabi .newpipe .extractor .utils .Utils .isBlank ;
45import static org .schabi .newpipe .ktx .ViewUtils .animate ;
56import static org .schabi .newpipe .util .ExtractorHelper .showMetaInfoInTextView ;
67import static java .util .Arrays .asList ;
@@ -398,7 +399,7 @@ public void onSaveInstanceState(@NonNull final Bundle bundle) {
398399 @ Override
399400 public void reloadContent () {
400401 if (!TextUtils .isEmpty (searchString ) || (searchEditText != null
401- && TextUtils . getTrimmedLength (searchEditText .getText ()) > 0 )) {
402+ && ! isBlank (searchEditText .getText (). toString ()) )) {
402403 search (!TextUtils .isEmpty (searchString )
403404 ? searchString
404405 : searchEditText .getText ().toString (), this .contentFilter , "" );
@@ -496,7 +497,7 @@ private void showSearchOnStart() {
496497 searchEditText .setText (searchString );
497498
498499 if (TextUtils .isEmpty (searchString )
499- || TextUtils . getTrimmedLength (searchEditText .getText ()) == 0 ) {
500+ || isBlank (searchEditText .getText (). toString ()) ) {
500501 searchToolbarContainer .setTranslationX (100 );
501502 searchToolbarContainer .setAlpha (0.0f );
502503 searchToolbarContainer .setVisibility (View .VISIBLE );
@@ -520,7 +521,7 @@ private void initSearchListeners() {
520521 if (DEBUG ) {
521522 Log .d (TAG , "onClick() called with: v = [" + v + "]" );
522523 }
523- if (TextUtils . getTrimmedLength (searchEditText .getText ()) == 0 ) {
524+ if (isBlank (searchEditText .getText (). toString ()) ) {
524525 NavigationHelper .gotoMainFragment (getFM ());
525526 return ;
526527 }
@@ -582,12 +583,9 @@ public void onSuggestionItemLongClick(final SuggestionItem item) {
582583 searchEditText .removeTextChangedListener (textWatcher );
583584 }
584585 textWatcher = new TextWatcher () {
585- private boolean isPastedText = false ;
586-
587586 @ Override
588587 public void beforeTextChanged (final CharSequence s , final int start ,
589588 final int count , final int after ) {
590- isPastedText = TextUtils .isEmpty (s ) && after > 1 ;
591589 }
592590
593591 @ Override
@@ -604,11 +602,6 @@ public void afterTextChanged(final Editable s) {
604602
605603 final String newText = searchEditText .getText ().toString ().trim ();
606604 suggestionPublisher .onNext (newText );
607-
608- if (isPastedText ) {
609- // trim pasted text
610- searchEditText .setText (newText );
611- }
612605 }
613606 };
614607 searchEditText .addTextChangedListener (textWatcher );
@@ -817,7 +810,7 @@ private void search(final String theSearchString,
817810 Log .d (TAG , "search() called with: query = [" + theSearchString + "]" );
818811 final String trimmedSearchString = theSearchString .trim ();
819812 if (!trimmedSearchString .equals (theSearchString )) {
820- Log .d (TAG , "The precondition is not satisfied. "
813+ Log .w (TAG , "The precondition is not satisfied. "
821814 + "\" theSearchString\" is not allowed to have leading or trailing spaces" );
822815 }
823816 }
0 commit comments