Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stop persisting search icon's 'wash' state across sections (AIC-592) #312

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ui/src/main/kotlin/edu/artic/view/ArticMainAppBarLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ class ArticMainAppBarLayout(context: Context, attrs: AttributeSet? = null) : App
// update our content when offset changes.
addOnOffsetChangedListener(OnOffsetChangedListener { aBarLayout, verticalOffset ->
val progress: Double = 1 - Math.abs(verticalOffset) / aBarLayout.totalScrollRange.toDouble()
searchIcon.background.alpha = (progress * 255).toInt()
icon.drawable.alpha = (progress * 255).toInt()
expandedImage.drawable.alpha = (progress * 255).toInt()
val progressOutOf255: Int = (progress * 255).toInt()

// The search icon's background is also known as the 'wash'. Its state
// must be distinct from that of its counterparts in other
// ArticMainAppBarLayouts - hence the `Drawable::mutate` call.
searchIcon.background.mutate().alpha = progressOutOf255
icon.drawable.alpha = progressOutOf255
expandedImage.drawable.alpha = progressOutOf255
subTitle.alpha = progress.toFloat()
})

Expand Down