Skip to content

Convert Plaid to use AndroidX #524

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Oct 21, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update palette params for applyFullImage and applyTopPalette
  • Loading branch information
tiembo committed Oct 17, 2018
commit 7aad3005ea8ab222443f1a2ea34252e25328d677
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ShotActivity : AppCompatActivity() {
Palette.from(bitmap)
.clearFilters() /* by default palette ignore certain hues
(e.g. pure black/white) but we don't want this. */
.generate { palette -> applyFullImagePalette(palette!!) }
.generate { palette -> applyFullImagePalette(palette) }

val twentyFourDip = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
Expand All @@ -98,7 +98,7 @@ class ShotActivity : AppCompatActivity() {
.clearFilters()
.setRegion(0, 0, bitmap.width - 1, twentyFourDip) /* - 1 to work around
https://code.google.com/p/android/issues/detail?id=191013 */
.generate { palette -> applyTopPalette(bitmap, palette!!) }
.generate { palette -> applyTopPalette(bitmap, palette) }

// TODO should keep the background if the image contains transparency?!
binding.shot.background = null
Expand Down Expand Up @@ -252,7 +252,7 @@ class ShotActivity : AppCompatActivity() {
}
}

internal fun applyFullImagePalette(palette: Palette) {
internal fun applyFullImagePalette(palette: Palette?) {
// color the ripple on the image spacer (default is grey)
binding.shotSpacer.background = ViewUtils.createRipple(
palette, 0.25f, 0.5f,
Expand All @@ -265,7 +265,7 @@ class ShotActivity : AppCompatActivity() {
)
}

internal fun applyTopPalette(bitmap: Bitmap, palette: Palette) {
internal fun applyTopPalette(bitmap: Bitmap, palette: Palette?) {
val lightness = ColorUtils.isDark(palette)
val isDark = if (lightness == ColorUtils.LIGHTNESS_UNKNOWN) {
ColorUtils.isDark(bitmap, bitmap.width / 2, 0)
Expand Down