Merge "Dump additional AnimatableClock updates" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d8769634c8
@@ -47,7 +47,12 @@ class AnimatableClockView @JvmOverloads constructor(
|
|||||||
defStyleRes: Int = 0
|
defStyleRes: Int = 0
|
||||||
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
|
) : TextView(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
|
|
||||||
private var lastMeasureCall: CharSequence = ""
|
private var lastMeasureCall: CharSequence? = null
|
||||||
|
private var lastDraw: CharSequence? = null
|
||||||
|
private var lastTextUpdate: CharSequence? = null
|
||||||
|
private var lastOnTextChanged: CharSequence? = null
|
||||||
|
private var lastInvalidate: CharSequence? = null
|
||||||
|
private var lastTimeZoneChange: CharSequence? = null
|
||||||
|
|
||||||
private val time = Calendar.getInstance()
|
private val time = Calendar.getInstance()
|
||||||
|
|
||||||
@@ -135,18 +140,19 @@ class AnimatableClockView @JvmOverloads constructor(
|
|||||||
// relayout if the text didn't actually change.
|
// relayout if the text didn't actually change.
|
||||||
if (!TextUtils.equals(text, formattedText)) {
|
if (!TextUtils.equals(text, formattedText)) {
|
||||||
text = formattedText
|
text = formattedText
|
||||||
|
lastTextUpdate = getTimestamp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onTimeZoneChanged(timeZone: TimeZone?) {
|
fun onTimeZoneChanged(timeZone: TimeZone?) {
|
||||||
time.timeZone = timeZone
|
time.timeZone = timeZone
|
||||||
refreshFormat()
|
refreshFormat()
|
||||||
|
lastTimeZoneChange = "${getTimestamp()} timeZone=${time.timeZone}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("DrawAllocation")
|
@SuppressLint("DrawAllocation")
|
||||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
lastMeasureCall = DateFormat.format(descFormat, System.currentTimeMillis())
|
|
||||||
val animator = textAnimator
|
val animator = textAnimator
|
||||||
if (animator == null) {
|
if (animator == null) {
|
||||||
textAnimator = TextAnimator(layout) { invalidate() }
|
textAnimator = TextAnimator(layout) { invalidate() }
|
||||||
@@ -155,13 +161,34 @@ class AnimatableClockView @JvmOverloads constructor(
|
|||||||
} else {
|
} else {
|
||||||
animator.updateLayout(layout)
|
animator.updateLayout(layout)
|
||||||
}
|
}
|
||||||
|
lastMeasureCall = getTimestamp()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
|
lastDraw = getTimestamp()
|
||||||
// intentionally doesn't call super.onDraw here or else the text will be rendered twice
|
// intentionally doesn't call super.onDraw here or else the text will be rendered twice
|
||||||
textAnimator?.draw(canvas)
|
textAnimator?.draw(canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun invalidate() {
|
||||||
|
super.invalidate()
|
||||||
|
lastInvalidate = getTimestamp()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getTimestamp(): CharSequence {
|
||||||
|
return "${DateFormat.format("HH:mm:ss", System.currentTimeMillis())} text=$text"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTextChanged(
|
||||||
|
text: CharSequence,
|
||||||
|
start: Int,
|
||||||
|
lengthBefore: Int,
|
||||||
|
lengthAfter: Int
|
||||||
|
) {
|
||||||
|
super.onTextChanged(text, start, lengthBefore, lengthAfter)
|
||||||
|
lastOnTextChanged = "${getTimestamp()}"
|
||||||
|
}
|
||||||
|
|
||||||
fun setLineSpacingScale(scale: Float) {
|
fun setLineSpacingScale(scale: Float) {
|
||||||
lineSpacingScale = scale
|
lineSpacingScale = scale
|
||||||
setLineSpacing(0f, lineSpacingScale)
|
setLineSpacing(0f, lineSpacingScale)
|
||||||
@@ -354,7 +381,12 @@ class AnimatableClockView @JvmOverloads constructor(
|
|||||||
pw.println(" measuredWidth=$measuredWidth")
|
pw.println(" measuredWidth=$measuredWidth")
|
||||||
pw.println(" measuredHeight=$measuredHeight")
|
pw.println(" measuredHeight=$measuredHeight")
|
||||||
pw.println(" singleLineInternal=$isSingleLineInternal")
|
pw.println(" singleLineInternal=$isSingleLineInternal")
|
||||||
|
pw.println(" lastTextUpdate=$lastTextUpdate")
|
||||||
|
pw.println(" lastOnTextChanged=$lastOnTextChanged")
|
||||||
|
pw.println(" lastInvalidate=$lastInvalidate")
|
||||||
pw.println(" lastMeasureCall=$lastMeasureCall")
|
pw.println(" lastMeasureCall=$lastMeasureCall")
|
||||||
|
pw.println(" lastDraw=$lastDraw")
|
||||||
|
pw.println(" lastTimeZoneChange=$lastTimeZoneChange")
|
||||||
pw.println(" currText=$text")
|
pw.println(" currText=$text")
|
||||||
pw.println(" currTimeContextDesc=$contentDescription")
|
pw.println(" currTimeContextDesc=$contentDescription")
|
||||||
pw.println(" time=$time")
|
pw.println(" time=$time")
|
||||||
|
|||||||
Reference in New Issue
Block a user