Fix crash when switching between color gradient tabs.

This commit is contained in:
Alex Hart
2021-10-28 10:58:10 -03:00
parent abde740ff7
commit de4cb931f3
3 changed files with 14 additions and 1 deletions

View File

@@ -44,5 +44,6 @@ class ColorizerView @JvmOverloads constructor(
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
projections.forEach { it.release() }
projections = emptyList()
}
}

View File

@@ -107,9 +107,19 @@ class ChatColorPreviewView @JvmOverloads constructor(
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
redrawChatColors()
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
redrawChatColors()
}
private fun redrawChatColors() {
if (chatColors != null) {
setChatColors(requireNotNull(chatColors))
}

View File

@@ -48,6 +48,7 @@ class CustomChatColorCreatorPageFragment :
private lateinit var hueSlider: AppCompatSeekBar
private lateinit var saturationSlider: AppCompatSeekBar
private lateinit var preview: ChatColorPreviewView
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val args: CustomChatColorCreatorFragmentArgs = CustomChatColorCreatorFragmentArgs.fromBundle(requireArguments())
@@ -59,7 +60,8 @@ class CustomChatColorCreatorPageFragment :
factory
)[CustomChatColorCreatorViewModel::class.java]
val preview: ChatColorPreviewView = view.findViewById(R.id.chat_color_preview)
preview = view.findViewById(R.id.chat_color_preview)
val hueThumb = ThumbDrawable(requireContext())
val saturationThumb = ThumbDrawable(requireContext())