From 50f9cb2b7bf571b3be74554f4777fef5b8baaffd Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 20 Oct 2022 16:36:47 +0200 Subject: [PATCH] Clean code --- .../android/ui/drawer/ComposeAdapter.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index d6239cac..6d39a35f 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -896,10 +896,8 @@ public class ComposeAdapter extends RecyclerView.Adapter { app.fedilab.android.client.entities.api.Account account = accounts.get(position); String deltaSearch = ""; - int searchLength = searchDeep; - if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position - searchLength = currentCursorPosition; - } + //Less than 15 characters are written before the cursor position + int searchLength = Math.min(currentCursorPosition, searchDeep); if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); else { @@ -951,10 +949,8 @@ public class ComposeAdapter extends RecyclerView.Adapter 0 && currentCursorPosition < oldContent.length()) deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); else { @@ -1011,10 +1007,8 @@ public class ComposeAdapter extends RecyclerView.Adapter { String shortcodeSelected = emojisToDisplay.get(position).shortcode; String deltaSearch = ""; - int searchLength = searchDeep; - if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position - searchLength = currentCursorPosition; - } + //Less than 15 characters are written before the cursor position + int searchLength = Math.min(currentCursorPosition, searchDeep); if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); else {