Format code

This commit is contained in:
Naveen
2024-04-03 10:02:27 +05:30
parent 9b9944a0c8
commit 883f9d6e32

View File

@@ -11,12 +11,7 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.fossify.commons.activities.BaseSimpleActivity
import org.fossify.commons.adapters.MyRecyclerViewAdapter
import org.fossify.commons.extensions.beGoneIf
import org.fossify.commons.extensions.beVisibleIf
import org.fossify.commons.extensions.getColoredDrawableWithColor
import org.fossify.commons.extensions.isBlackAndWhiteTheme
import org.fossify.commons.extensions.applyColorFilter
import org.fossify.commons.extensions.toast
import org.fossify.commons.extensions.*
import org.fossify.commons.helpers.LOWER_ALPHA_INT
import org.fossify.commons.helpers.SORT_BY_CUSTOM
import org.fossify.commons.views.MyRecyclerView
@@ -27,8 +22,10 @@ import org.fossify.notes.models.Note
import org.fossify.notes.models.NoteType
class OpenNoteAdapter(
activity: BaseSimpleActivity, var items: List<Note>,
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
activity: BaseSimpleActivity,
var items: List<Note>,
recyclerView: MyRecyclerView,
itemClick: (Any) -> Unit,
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
override fun getActionMenuId() = 0
@@ -54,9 +51,10 @@ class OpenNoteAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = items[position]
holder.bindView(item, true, false) { itemView, layoutPosition ->
holder.bindView(item, allowSingleClick = true, allowLongClick = false) { itemView, _ ->
setupView(itemView, item)
}
bindViewHolder(holder)
}
@@ -69,6 +67,7 @@ class OpenNoteAdapter(
text = note.title
setTextColor(properPrimaryColor)
}
val formattedText = note.getFormattedValue(root.context)
openNoteItemText.beGoneIf(formattedText.isNullOrBlank() || note.isLocked())
iconLock.beVisibleIf(note.isLocked())
@@ -77,6 +76,7 @@ class OpenNoteAdapter(
text = formattedText
setTextColor(textColor)
}
openNoteItemIcon.apply {
beVisibleIf(note.path.isNotEmpty())
applyColorFilter(textColor)
@@ -96,11 +96,13 @@ class OpenNoteAdapter(
} else {
Color.BLACK
}
val cardBackground = if (context.config.isUsingSystemTheme) {
org.fossify.commons.R.drawable.dialog_you_background
} else {
org.fossify.commons.R.drawable.dialog_bg
}
background =
activity.resources.getColoredDrawableWithColor(cardBackground, cardBackgroundColor, LOWER_ALPHA_INT)
}
@@ -127,6 +129,7 @@ class OpenNoteAdapter(
it
}
}
val linePrefix = ""
val stringifiedItems = items.joinToString(separator = System.lineSeparator()) {
"${linePrefix}${it.title}"
@@ -142,6 +145,7 @@ class OpenNoteAdapter(
currentPos += item.title.length
currentPos += System.lineSeparator().length
}
formattedText
}
}