Skip to content
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

Book details ui bug #139

Merged
merged 6 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class GetPlayingTrackProgressUsecase(private val audioManager: AudioManager) :

Timber.d("Current Progress is $progress")

mainHandler.postDelayed(this, 1000)
if(progress<100){
mainHandler.postDelayed(this, 1000)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class MainPlayerFragment : BaseContainerFragment(){
setImageResource(R.drawable.play_circle_green)
}
}

is Finished -> {
mainPlayerViewModel.bookFinished()
}
else -> Timber.d("Ignore event $event")
}
}
Expand Down Expand Up @@ -123,7 +127,7 @@ class MainPlayerFragment : BaseContainerFragment(){

private fun handleBackPressEvent(){
this.findNavController().navigateUp()
mainPlayerViewModel.showMiniPlayer()
mainPlayerViewModel.showMiniPlayerIfPlaying()
}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MainPlayerViewModel(
val playingTrackDetails : LiveData<PlayingTrackDetails> = _playingTrackDetails

private var currentPlayingIndex = 0
private var isBookFinished:Boolean = false

val trackProgress:LiveData<Int>
get() = trackProgressUsecase.trackProgress
Expand Down Expand Up @@ -106,6 +107,10 @@ class MainPlayerViewModel(
shouldPlayEvent()
}

fun bookFinished(isFinished: Boolean = true){
isBookFinished = isFinished
}

fun setBookDetails(bookId:String, bookName:String, trackName:String, currentPlayingTrack: Int, totalChapter:Int,isPlaying:Boolean){

_playingTrackDetails.value = PlayingTrackDetails(
Expand Down Expand Up @@ -166,8 +171,13 @@ class MainPlayerViewModel(
}
}

fun showMiniPlayer(){
userActionEventStore.publish(Event(OpenMiniPlayerUI(this::class.java.simpleName)))
fun showMiniPlayerIfPlaying(){
if (!isBookFinished){
Timber.d("Book is not finished: Sending open mini player")
userActionEventStore.publish(Event(OpenMiniPlayerUI(this::class.java.simpleName)))
}else{
Timber.d("Book is finished: No action required")
}
}

private suspend fun initTrackProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fun setTrackBookBanner(cardView: CardView, item: PlayingTrackDetails?) {
val dominant = it.getDominantColor(it.getVibrantColor(0))
val light = it.getLightMutedColor(it.getLightVibrantColor(0))

cardView.setBackgroundColor(dominant)
// cardView.setBackgroundColor(dominant)

with(cardView.rootView.findViewById<View>(R.id.parentContainer)){
setBackgroundColor(dark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class NotificationUtils {
if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.O) {
val notificationManager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val name = applicationContext.getString(R.string.app_name)
val importance = NotificationManager.IMPORTANCE_DEFAULT
val importance = NotificationManager.IMPORTANCE_LOW
NotificationChannel(NOTIFICATION_CHANNEL, name, importance).apply {
enableLights(false)
enableVibration(false)
Expand Down