tweaking some MarqueeTextView code style, no functionality change
This commit is contained in:
parent
a5b1d57fad
commit
71f59d5dcc
2 changed files with 15 additions and 19 deletions
|
@ -7,16 +7,23 @@ import android.util.AttributeSet
|
|||
import android.view.View
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
|
||||
class MarqueeTextView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : AppCompatTextView(context!!, attrs, defStyleAttr),
|
||||
View.OnLayoutChangeListener {
|
||||
|
||||
class MarqueeTextView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
|
||||
AppCompatTextView(context!!, attrs, defStyleAttr), View.OnLayoutChangeListener {
|
||||
constructor(context: Context?) : this(context, null) {}
|
||||
constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0) {}
|
||||
constructor(context: Context?) : this(context, null)
|
||||
|
||||
override fun isFocused(): Boolean {
|
||||
return true
|
||||
constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
|
||||
init {
|
||||
setSingleLine()
|
||||
ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||
marqueeRepeatLimit = -1
|
||||
isSelected = true
|
||||
addOnLayoutChangeListener(this)
|
||||
}
|
||||
|
||||
override fun isFocused() = true
|
||||
|
||||
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
|
||||
if (hasWindowFocus) super.onWindowFocusChanged(hasWindowFocus)
|
||||
}
|
||||
|
@ -25,22 +32,11 @@ class MarqueeTextView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int
|
|||
if (focused) super.onFocusChanged(focused, direction, previouslyFocusedRect)
|
||||
}
|
||||
|
||||
override fun onLayoutChange(
|
||||
v: View?, left: Int, top: Int, right: Int, bottom: Int,
|
||||
oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int
|
||||
) {
|
||||
override fun onLayoutChange(v: View?, left: Int, top: Int, right: Int, bottom: Int, oldLeft: Int, oldTop: Int, oldRight: Int, oldBottom: Int) {
|
||||
val layoutParams = layoutParams
|
||||
layoutParams.height = bottom - top
|
||||
layoutParams.width = right - left
|
||||
removeOnLayoutChangeListener(this)
|
||||
setLayoutParams(layoutParams)
|
||||
}
|
||||
|
||||
init {
|
||||
setSingleLine()
|
||||
ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||
marqueeRepeatLimit = -1
|
||||
isSelected = true
|
||||
addOnLayoutChangeListener(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.2.0'
|
||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
Loading…
Reference in a new issue