mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Finished refactoring
This commit is contained in:
@@ -208,6 +208,7 @@ class NodesAdapter (
|
||||
&& oldItem.foregroundColor == newItem.foregroundColor
|
||||
&& oldItem.getOtpElement() == newItem.getOtpElement()
|
||||
&& oldItem.containsAttachment() == newItem.containsAttachment()
|
||||
&& oldItem.tags == newItem.tags
|
||||
} else if (oldItem is Group && newItem is Group) {
|
||||
typeContentTheSame = oldItem.numberOfChildEntries == newItem.numberOfChildEntries
|
||||
&& oldItem.notes == newItem.notes
|
||||
|
||||
@@ -35,6 +35,7 @@ class TagsListView @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
field = value
|
||||
expandBtn?.setColorFilter(value!!)
|
||||
}
|
||||
var bgColor: Int? = null
|
||||
set(value) {
|
||||
@@ -49,17 +50,17 @@ class TagsListView @JvmOverloads constructor(
|
||||
drawAllTagsAndMeasure()
|
||||
}
|
||||
|
||||
private var flow: Flow? = null
|
||||
private var expandBtn: AppCompatImageView? = null
|
||||
private var hiddenViews: MutableList<View> = mutableListOf()
|
||||
private var currentState: State = State.IDLE
|
||||
private var animationHelper: AnimationHelper? = null
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.tags_list_view, this)
|
||||
initialize()
|
||||
}
|
||||
|
||||
private var flow: Flow? = null
|
||||
private var expandBtn: View? = null
|
||||
private var hiddenViews: MutableList<View> = mutableListOf()
|
||||
private var currentState: State = State.IDLE
|
||||
private var animationHelper: AnimationHelper? = null
|
||||
|
||||
private fun initialize() {
|
||||
viewTreeObserver.addOnGlobalLayoutListener(InitialMeasuringObserver())
|
||||
flow = findViewById(R.id.flow)
|
||||
@@ -120,8 +121,10 @@ class TagsListView @JvmOverloads constructor(
|
||||
}
|
||||
hiddenViews[ind].animate().setListener(object : StubAnimatorListener() {
|
||||
override fun onAnimationEnd(p0: Animator?) {
|
||||
if (isGone) return
|
||||
hiddenViews[ind].isGone = !isGone
|
||||
if (!isGone) {
|
||||
hiddenViews[ind].isGone = !isGone
|
||||
}
|
||||
requestLayout()
|
||||
}
|
||||
}).alpha(alpha).start()
|
||||
}
|
||||
@@ -182,10 +185,8 @@ class TagsListView @JvmOverloads constructor(
|
||||
when (currentState) {
|
||||
State.MEASURING_EXPANDED -> {
|
||||
expandedHeight = measuredHeight
|
||||
post {
|
||||
currentState = currentState.next()
|
||||
toggleHiddenViews(false)
|
||||
}
|
||||
currentState = currentState.next()
|
||||
toggleHiddenViews(false)
|
||||
}
|
||||
State.MEASURING_COLLAPSED -> {
|
||||
currentState = currentState.next()
|
||||
@@ -224,6 +225,8 @@ class TagsListView @JvmOverloads constructor(
|
||||
|
||||
private val VERTICAL_PADDING = 2.dp.intPx
|
||||
private val HORIZONTAL_PADDING = 5.dp.intPx
|
||||
private const val TAG_TEXT_SIZE = 13f
|
||||
private val TAG_STROKE = 1.2f.dp.intPx
|
||||
|
||||
private fun TagsListView.createTagView(tag: String): View {
|
||||
val view = AppCompatTextView(context)
|
||||
@@ -251,7 +254,7 @@ private fun TagsListView.styleTagView(view: AppCompatTextView): View {
|
||||
}
|
||||
|
||||
view.setPadding(HORIZONTAL_PADDING, VERTICAL_PADDING, HORIZONTAL_PADDING, VERTICAL_PADDING)
|
||||
view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
|
||||
view.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAG_TEXT_SIZE)
|
||||
|
||||
return view
|
||||
}
|
||||
@@ -263,7 +266,7 @@ private fun TagsListView.createTagBg(): Drawable? {
|
||||
) as? GradientDrawable
|
||||
|
||||
bgColor?.let {
|
||||
bg?.setStroke(1.2f.dp.intPx, it)
|
||||
bg?.setStroke(TAG_STROKE, it)
|
||||
}
|
||||
|
||||
return bg
|
||||
|
||||
@@ -73,6 +73,17 @@ class Tags: Parcelable {
|
||||
return mTags.joinToString(DELIMITER.toString())
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return when (other) {
|
||||
!is Tags -> false
|
||||
else -> mTags == other.toList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return mTags.hashCode()
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Tags> {
|
||||
const val DELIMITER= ','
|
||||
const val DELIMITER1= ';'
|
||||
|
||||
Reference in New Issue
Block a user