mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-23 13:26:15 +03:00
#550 In-note-search doesn't jump to occurrence of searchstring
- Fix Exception when wrapping from last to first occurrence
This commit is contained in:
parent
92588de19f
commit
cba2868551
1 changed files with 18 additions and 6 deletions
|
@ -229,11 +229,19 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
|
|||
if (currentVisibility != View.VISIBLE) {
|
||||
colorWithText("");
|
||||
searchQuery = "";
|
||||
if(prev != null) { prev.hide(); }
|
||||
if(next != null) { next.hide(); }
|
||||
if (prev != null) {
|
||||
prev.hide();
|
||||
}
|
||||
if (next != null) {
|
||||
next.hide();
|
||||
}
|
||||
} else {
|
||||
if(prev != null) { prev.show(); }
|
||||
if(next != null) { next.show(); }
|
||||
if (prev != null) {
|
||||
prev.show();
|
||||
}
|
||||
if (next != null) {
|
||||
next.show();
|
||||
}
|
||||
}
|
||||
|
||||
oldVisibility = currentVisibility;
|
||||
|
@ -287,8 +295,12 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
|
|||
String currentContent = getContent().toLowerCase();
|
||||
int indexOfNewText = indexOfNth(currentContent, searchQuery.toLowerCase(), 0, occurrence);
|
||||
if (indexOfNewText <= 0) {
|
||||
// Search term not in text
|
||||
occurrence = 1;
|
||||
// Search term is not n times in text
|
||||
// Go back to first search result
|
||||
if (occurrence != 1) {
|
||||
occurrence = 1;
|
||||
jumpToOccurrence();
|
||||
}
|
||||
return;
|
||||
}
|
||||
String textUntilFirstOccurrence = currentContent.substring(0, indexOfNewText);
|
||||
|
|
Loading…
Reference in a new issue