1
0
mirror of https://codeberg.org/tom79/Fedilab synced 2025-01-31 19:44:59 +01:00

Clean code

This commit is contained in:
Thomas 2022-10-20 16:36:47 +02:00
parent 86f39fb4ee
commit 50f9cb2b7b

View File

@ -896,10 +896,8 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.binding.content.setOnItemClickListener((parent, view, position, id) -> { holder.binding.content.setOnItemClickListener((parent, view, position, id) -> {
app.fedilab.android.client.entities.api.Account account = accounts.get(position); app.fedilab.android.client.entities.api.Account account = accounts.get(position);
String deltaSearch = ""; String deltaSearch = "";
int searchLength = searchDeep; //Less than 15 characters are written before the cursor position
if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position int searchLength = Math.min(currentCursorPosition, searchDeep);
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else { else {
@ -951,10 +949,8 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
return; return;
Tag tag = results.hashtags.get(position); Tag tag = results.hashtags.get(position);
String deltaSearch = ""; String deltaSearch = "";
int searchLength = searchDeep; //Less than 15 characters are written before the cursor position
if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position int searchLength = Math.min(currentCursorPosition, searchDeep);
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else { else {
@ -1011,10 +1007,8 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.binding.content.setOnItemClickListener((parent, view, position, id) -> { holder.binding.content.setOnItemClickListener((parent, view, position, id) -> {
String shortcodeSelected = emojisToDisplay.get(position).shortcode; String shortcodeSelected = emojisToDisplay.get(position).shortcode;
String deltaSearch = ""; String deltaSearch = "";
int searchLength = searchDeep; //Less than 15 characters are written before the cursor position
if (currentCursorPosition < searchDeep) { //Less than 15 characters are written before the cursor position int searchLength = Math.min(currentCursorPosition, searchDeep);
searchLength = currentCursorPosition;
}
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else { else {