Skip to content

Commit

Permalink
Merge pull request #163 from pravinyo/development
Browse files Browse the repository at this point in the history
Book details screen bugs fixed
  • Loading branch information
pravinyo authored Jun 10, 2020
2 parents 4706334 + 626c3df commit 5cd521d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
.externalNativeBuild
.cxx
/feature_main_player/build/
/.idea/jarRepositories.xml
/buildSource/build/
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/release/
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
private lateinit var dataBindingReference : FragmentAudiobookDetailsBinding

private var mBottomSheetBehavior: BottomSheetBehavior<View?>? = null
private var mDescriptionLoadingAnimation:ViewLoadingAnimation?=null

override fun onCreateView(
inflater: LayoutInflater,
Expand Down Expand Up @@ -185,6 +186,10 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
}

private fun setupUI(dataBinding: FragmentAudiobookDetailsBinding) {

mDescriptionLoadingAnimation = ViewLoadingAnimation(dataBinding.textViewBookIntro)
mDescriptionLoadingAnimation?.colorize()

val trackAdapter = AudioBookTrackAdapter(
downloadStore,
argBookId,
Expand Down Expand Up @@ -255,6 +260,7 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
}

removeLoading()
mDescriptionLoadingAnimation?.stop()
})

bookDetailsViewModel.isAddedToListenLater.observe(viewLifecycleOwner, Observer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,18 @@ fun TextView.setTrackLength(item : AudioBookTrackDomainModel?){
text = if(!length.contains(":")){
val timeInSec = length.toFloat().toInt().seconds
timeInSec.toComponents { minutes, seconds, _ ->
"$minutes:$seconds"
var sec = seconds.toString()
var min = minutes.toString()

if(seconds.toString().length==1){
sec = "0$seconds"
}

if (minutes.toString().length==1){
min = "0$minutes"
}

"$min:$sec"
}
} else length
}
Expand Down Expand Up @@ -134,7 +145,7 @@ fun setBookBanner(layout: ConstraintLayout, item: AudioBookMetadataDomainModel?)

paletteBuilder.generate{
it?.let {
val dark = it.getDarkMutedColor(it.getMutedColor(0))
val dark = it.getDarkMutedColor(it.getDarkVibrantColor(0))
val dominant = it.getDominantColor(it.getVibrantColor(0))
val light = it.getLightMutedColor(it.getLightVibrantColor(0))

Expand All @@ -143,8 +154,10 @@ fun setBookBanner(layout: ConstraintLayout, item: AudioBookMetadataDomainModel?)
with(layout.rootView.findViewById<View>(R.id.toolbar)){
setBackgroundColor(dark)

this.findViewById<TextView>(R.id.tv_toolbar_title).apply {
this.setTextColor(light)
if(dark!=light){
this.findViewById<TextView>(R.id.tv_toolbar_title).apply {
this.setTextColor(light)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.allsoftdroid.feature.book_details.utils

import android.animation.ObjectAnimator
import android.graphics.Color
import android.view.View

class ViewLoadingAnimation(private val view: View) {

private lateinit var animator:ObjectAnimator

fun colorize(){
animator = ObjectAnimator.ofArgb(view,"backgroundColor",Color.GRAY,Color.LTGRAY)
animator.duration = 500
animator.repeatCount = ObjectAnimator.INFINITE
animator.repeatMode = ObjectAnimator.REVERSE
animator.start()
}

fun stop(){
animator.cancel()
view.setBackgroundColor(Color.TRANSPARENT)
}
}

0 comments on commit 5cd521d

Please sign in to comment.