Skip to content

Commit

Permalink
Remove buggy progress animation (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
shockbytes committed Feb 2, 2020
1 parent 16303ff commit 1df4da8
Showing 1 changed file with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package at.shockbytes.dante.ui.fragment

import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.app.DatePickerDialog
import android.content.BroadcastReceiver
import androidx.lifecycle.ViewModelProvider
Expand All @@ -14,10 +13,10 @@ import android.os.Bundle
import androidx.palette.graphics.Palette
import android.view.HapticFeedbackConstants
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.DecelerateInterpolator
import android.widget.TextView
import androidx.core.app.SharedElementCallback
import androidx.lifecycle.Observer
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import at.shockbytes.dante.R
import at.shockbytes.dante.core.book.BookEntity
Expand Down Expand Up @@ -155,7 +154,7 @@ class BookDetailFragment : BaseFragment(),
val currentLines = txt_detail_description.maxLines

val lines = if (currentLines == defaultLines) 100 else defaultLines
val animationDuration = if (currentLines == defaultLines) 500L else 100L
val animationDuration = if (currentLines == defaultLines) 250L else 100L

ObjectAnimator.ofInt(
txt_detail_description,
Expand All @@ -173,7 +172,7 @@ class BookDetailFragment : BaseFragment(),
}

override fun bindViewModel() {
viewModel.getViewState().observe(this, androidx.lifecycle.Observer { viewState ->
viewModel.getViewState().observe(this, Observer { viewState ->
viewState?.let {
initializeBookInformation(viewState.book, viewState.showSummary)
initializeTimeInformation(viewState.book)
Expand Down Expand Up @@ -456,7 +455,7 @@ class BookDetailFragment : BaseFragment(),

btn_detail_pages.text = if (state == BookState.READING)
// Initially set currentPage to 0 for progress animation
getString(R.string.detail_pages, 0, pageCount)
getString(R.string.detail_pages, currentPage, pageCount)
else
pageCount.toString()
} else {
Expand All @@ -471,23 +470,12 @@ class BookDetailFragment : BaseFragment(),
private fun setupPageProgress(currentPage: Int, pageCount: Int) {

sb_detail_pages.apply {

value = 0 // Initially set to 0 for animation
value = currentPage
maxValue = pageCount
setCallback(this@BookDetailFragment)
setOnValueChangedListener { page ->
btn_detail_pages.text = getString(R.string.detail_pages, page, pageCount)
}

ValueAnimator.ofInt(0, currentPage).apply {
startDelay = 750L
addUpdateListener { animator ->
value = animator.animatedValue as Int
}
duration = 500
interpolator = AccelerateDecelerateInterpolator()
start()
}
}
}

Expand Down

0 comments on commit 1df4da8

Please sign in to comment.