@@ -134,7 +134,6 @@ protected int getLayoutResId() {
134134 return R .layout .document__fragment__edit ;
135135 }
136136
137- @ SuppressLint ({"SetJavaScriptEnabled" , "WrongConstant" , "AddJavascriptInterface" , "JavascriptInterface" })
138137 @ Override
139138 public void onViewCreated (@ NonNull View view , Bundle savedInstanceState ) {
140139 super .onViewCreated (view , savedInstanceState );
@@ -628,6 +627,7 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
628627 }
629628 }
630629 }
630+
631631 public void checkTextChangeState () {
632632 final boolean isTextChanged = !_document .isContentSame (_hlEditor .getText ());
633633 Drawable d ;
@@ -684,14 +684,14 @@ private void setSearchView(SearchView searchView) {
684684 _menuSearchViewForViewMode .setQueryHint (getString (R .string .search ));
685685 _menuSearchViewForViewMode .setOnQueryTextListener (new SearchView .OnQueryTextListener () {
686686 private String searchText = "" ;
687- private final Runnable searchTask ;
687+ private Runnable searchTask ;
688688
689689 private boolean search (String text ) {
690690 if (_webView == null ) {
691691 return false ;
692692 }
693693 if (searchTask == null ) {
694- searchTask = TextViewUtils .makeDebounced (_webView .getHandler (), 500 , () -> _webView .findAllAsync (text ));
694+ searchTask = TextViewUtils .makeDebounced (_webView .getHandler (), 500 , () -> _webView .findAllAsync (searchText ));
695695 }
696696
697697 searchText = text ;
@@ -753,17 +753,27 @@ public boolean onQueryTextChange(String text) {
753753 searchPlate .addView (linearLayout , 1 );
754754
755755 // Set listeners
756- previousButton .setOnClickListener (v -> _webView .findNext (false ));
757- nextButton .setOnClickListener (v -> _webView .findNext (true ));
758- _webView .setFindListener ((activeMatchOrdinal , numberOfMatches , isDoneCounting ) -> {
759- if (isDoneCounting ) {
760- String searchResult = "" ;
761- if (numberOfMatches > 0 ) {
762- searchResult = (activeMatchOrdinal + 1 ) + "/" + numberOfMatches ;
763- }
764- resultTextView .setText (searchResult );
756+ previousButton .setOnClickListener (v -> {
757+ if (_webView != null ) {
758+ _webView .findNext (false );
759+ }
760+ });
761+ nextButton .setOnClickListener (v -> {
762+ if (_webView != null ) {
763+ _webView .findNext (true );
765764 }
766765 });
766+ if (_webView != null ) {
767+ _webView .setFindListener ((activeMatchOrdinal , numberOfMatches , isDoneCounting ) -> {
768+ if (isDoneCounting ) {
769+ String searchResult = "" ;
770+ if (numberOfMatches > 0 ) {
771+ searchResult = (activeMatchOrdinal + 1 ) + "/" + numberOfMatches ;
772+ }
773+ resultTextView .setText (searchResult );
774+ }
775+ });
776+ }
767777 }
768778
769779 private void setMarginBottom (final View view , final int marginBottom ) {
@@ -933,6 +943,7 @@ public void setViewModeVisibility(final boolean show) {
933943 setViewModeVisibility (show , true );
934944 }
935945
946+ @ SuppressLint ({"SetJavaScriptEnabled" })
936947 private void setupWebViewIfNeeded (final Activity activity ) {
937948 if (_webView == null ) {
938949 _webView = (WebView ) _webViewStub .inflate ();
0 commit comments