Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bca35c2

Browse files
Use lazy loading so the animation isn't inflated every time, and isn't even created until it needs to be ran.
1 parent 6830d11 commit bca35c2

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎app/src/main/java/tk/superl2/xwifi/MainActivity.kt‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,20 @@ class MainActivity: AppCompatActivity() {
167167
wifi_RecyclerView.layoutManager.findViewByPosition(position)?.label?.setTypeface(null, Typeface.BOLD)
168168
return (wifi_RecyclerView.layoutManager.findViewByPosition(position)?.label?.text ?: " ")[0].toUpperCase().toString()
169169
}
170-
fun unboldOldScrollPosition() {
171-
wifi_RecyclerView.layoutManager.findViewByPosition(oldPos)?.label?.let {
172-
it.startAnimation(AnimationUtils.loadAnimation(this@MainActivity, R.anim.textview_unbold).apply {
173-
setAnimationListener(object: Animation.AnimationListener {
174-
override fun onAnimationStart(animation: Animation?) {}
170+
private val animation by lazy {
171+
AnimationUtils.loadAnimation(this@MainActivity, R.anim.textview_unbold).apply {
172+
setAnimationListener(object: Animation.AnimationListener {
173+
override fun onAnimationStart(animation: Animation?) {}
175174

176-
override fun onAnimationRepeat(animation: Animation?) {}
175+
override fun onAnimationRepeat(animation: Animation?) {}
177176

178-
override fun onAnimationEnd(animation: Animation?) {
179-
it.setTypeface(null, Typeface.NORMAL)
180-
}
181-
})
182-
})
183-
}
177+
override fun onAnimationEnd(animation: Animation?) {
178+
wifi_RecyclerView.layoutManager.findViewByPosition(oldPos)?.label?.setTypeface(null, Typeface.NORMAL)
179+
}
180+
})
181+
}}
182+
fun unboldOldScrollPosition() {
183+
wifi_RecyclerView.layoutManager.findViewByPosition(oldPos)?.label?.startAnimation(animation)
184184
}
185185
}
186186

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /