Skip to content

Commit

Permalink
Fixed #231 with null-safety checking Top App Bar Background
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrave-dev committed Feb 13, 2024
1 parent 54aa7c0 commit 3299eac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.maxrave.simpmusic.ui.fragment.other
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.TransitionDrawable
import android.os.Build.ID
Expand Down Expand Up @@ -997,7 +999,9 @@ class LocalPlaylistFragment : Fragment() {
if (viewModel.gradientDrawable.value != null) {
viewModel.gradientDrawable.observe(viewLifecycleOwner) {
if (it != null) {
val start = binding.topAppBarLayout.background
val start = binding.topAppBarLayout.background ?: ColorDrawable(
Color.TRANSPARENT
)
val transition = TransitionDrawable(arrayOf(start, it))
binding.topAppBarLayout.background = transition
transition.isCrossFadeEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.maxrave.simpmusic.ui.fragment.other

import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.TransitionDrawable
import android.os.Bundle
Expand Down Expand Up @@ -776,7 +778,9 @@ class PlaylistFragment: Fragment() {
//fullRootLayout.background = gradient
// toolbarBackground = gradient?.colors?.get(0)
if (gradient != null) {
val start = topAppBarLayout.background
val start = topAppBarLayout.background ?: ColorDrawable(
Color.TRANSPARENT
)
val transition =
TransitionDrawable(arrayOf(start, gradient))
topAppBarLayout.background = transition
Expand Down Expand Up @@ -875,7 +879,9 @@ class PlaylistFragment: Fragment() {
// fullRootLayout.background = gradient
// toolbarBackground = gradient?.colors?.get(0)
if (gradient != null) {
val start = topAppBarLayout.background
val start = topAppBarLayout.background ?: ColorDrawable(
Color.TRANSPARENT
)
val transition =
TransitionDrawable(arrayOf(start, gradient))
topAppBarLayout.background = transition
Expand Down Expand Up @@ -944,7 +950,10 @@ class PlaylistFragment: Fragment() {
// toolbarBackground = gradient?.colors?.get(0)
// topAppBarLayout.background = ColorDrawable(toolbarBackground!!)
if (gradient != null) {
val start = topAppBarLayout.background
val start =
topAppBarLayout.background ?: ColorDrawable(
Color.TRANSPARENT
)
val transition =
TransitionDrawable(arrayOf(start, gradient))
topAppBarLayout.background = transition
Expand Down Expand Up @@ -1036,6 +1045,7 @@ class PlaylistFragment: Fragment() {
// topAppBarLayout.background = ColorDrawable(toolbarBackground!!)
if (gradient != null) {
val start = topAppBarLayout.background
?: ColorDrawable(Color.TRANSPARENT)
val transition = TransitionDrawable(arrayOf(start, gradient))
topAppBarLayout.background = transition
transition.isCrossFadeEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.maxrave.simpmusic.ui.fragment.other

import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.TransitionDrawable
import android.os.Bundle
Expand Down Expand Up @@ -272,7 +274,9 @@ class PodcastFragment : Fragment() {
viewModel.gradientDrawable.observe(viewLifecycleOwner)
{ gradient ->
if (gradient != null) {
val start = topAppBarLayout.background
val start = topAppBarLayout.background ?: ColorDrawable(
Color.TRANSPARENT
)
val transition =
TransitionDrawable(arrayOf(start, gradient))
topAppBarLayout.background = transition
Expand Down

0 comments on commit 3299eac

Please sign in to comment.