Skip to content

Commit 5cd521d

Browse files
authored
Merge pull request #163 from pravinyo/development
Book details screen bugs fixed
2 parents 4706334 + 626c3df commit 5cd521d

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
.externalNativeBuild
1414
.cxx
1515
/feature_main_player/build/
16+
/.idea/jarRepositories.xml
17+
/buildSource/build/

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
/release/

feature_book_details/src/main/java/com/allsoftdroid/feature/book_details/presentation/AudioBookDetailsFragment.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
6262
private lateinit var dataBindingReference : FragmentAudiobookDetailsBinding
6363

6464
private var mBottomSheetBehavior: BottomSheetBehavior<View?>? = null
65+
private var mDescriptionLoadingAnimation:ViewLoadingAnimation?=null
6566

6667
override fun onCreateView(
6768
inflater: LayoutInflater,
@@ -185,6 +186,10 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
185186
}
186187

187188
private fun setupUI(dataBinding: FragmentAudiobookDetailsBinding) {
189+
190+
mDescriptionLoadingAnimation = ViewLoadingAnimation(dataBinding.textViewBookIntro)
191+
mDescriptionLoadingAnimation?.colorize()
192+
188193
val trackAdapter = AudioBookTrackAdapter(
189194
downloadStore,
190195
argBookId,
@@ -255,6 +260,7 @@ class AudioBookDetailsFragment : BaseUIFragment(),KoinComponent {
255260
}
256261

257262
removeLoading()
263+
mDescriptionLoadingAnimation?.stop()
258264
})
259265

260266
bookDetailsViewModel.isAddedToListenLater.observe(viewLifecycleOwner, Observer {

feature_book_details/src/main/java/com/allsoftdroid/feature/book_details/utils/BindingUtil.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,18 @@ fun TextView.setTrackLength(item : AudioBookTrackDomainModel?){
4646
text = if(!length.contains(":")){
4747
val timeInSec = length.toFloat().toInt().seconds
4848
timeInSec.toComponents { minutes, seconds, _ ->
49-
"$minutes:$seconds"
49+
var sec = seconds.toString()
50+
var min = minutes.toString()
51+
52+
if(seconds.toString().length==1){
53+
sec = "0$seconds"
54+
}
55+
56+
if (minutes.toString().length==1){
57+
min = "0$minutes"
58+
}
59+
60+
"$min:$sec"
5061
}
5162
} else length
5263
}
@@ -134,7 +145,7 @@ fun setBookBanner(layout: ConstraintLayout, item: AudioBookMetadataDomainModel?)
134145

135146
paletteBuilder.generate{
136147
it?.let {
137-
val dark = it.getDarkMutedColor(it.getMutedColor(0))
148+
val dark = it.getDarkMutedColor(it.getDarkVibrantColor(0))
138149
val dominant = it.getDominantColor(it.getVibrantColor(0))
139150
val light = it.getLightMutedColor(it.getLightVibrantColor(0))
140151

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

146-
this.findViewById<TextView>(R.id.tv_toolbar_title).apply {
147-
this.setTextColor(light)
157+
if(dark!=light){
158+
this.findViewById<TextView>(R.id.tv_toolbar_title).apply {
159+
this.setTextColor(light)
160+
}
148161
}
149162
}
150163
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.allsoftdroid.feature.book_details.utils
2+
3+
import android.animation.ObjectAnimator
4+
import android.graphics.Color
5+
import android.view.View
6+
7+
class ViewLoadingAnimation(private val view: View) {
8+
9+
private lateinit var animator:ObjectAnimator
10+
11+
fun colorize(){
12+
animator = ObjectAnimator.ofArgb(view,"backgroundColor",Color.GRAY,Color.LTGRAY)
13+
animator.duration = 500
14+
animator.repeatCount = ObjectAnimator.INFINITE
15+
animator.repeatMode = ObjectAnimator.REVERSE
16+
animator.start()
17+
}
18+
19+
fun stop(){
20+
animator.cancel()
21+
view.setBackgroundColor(Color.TRANSPARENT)
22+
}
23+
}

0 commit comments

Comments
 (0)