-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
GifDrawable.getCurrentPosition() may return the negative? #657
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
Comments
Could you attach a code snippet which reproduces this issue? |
class TestActivity : AppCompatActivity() {
var mGif: GifDrawable? = null
@SuppressLint("CheckResult")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)
mGif = GifDrawable(resources, R.raw.test_gif)
Observable.interval(10, TimeUnit.MILLISECONDS)
.compose(RxLifecycleCompact.bind(this).withObservable())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { tick ->
mGif?.also {
if (it.currentPosition < 0) {
if (BuildConfig.LOG_ENABLE) {
Log.e("GIF", "current position: ${it.currentPosition}")
}
}
pb_gif?.progress = ((it.currentPosition / it.duration.toFloat()) * 100).toInt()
}
}
iv_gif_test.setImageDrawable(mGif)
}
override fun onResume() {
super.onResume()
mGif?.start()
}
override fun onPause() {
super.onPause()
mGif?.pause()
}
} <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:id="@+id/iv_gif_test"/>
<ProgressBar android:layout_width="match_parent"
android:layout_height="3dp"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:id="@+id/pb_gif"
android:indeterminate="false"
android:layout_gravity="bottom"
android:max="100"
tools:progress="50"
/>
</FrameLayout> |
Can you reproduce this problem? @koral-- |
Yep, I was able to reproduce this bug. I'll fix it ASAP. |
Sorry for the very long delay. The current position was miscalculated when the animation was on the last frame (in terms of what is displayed) on the subsequent animation loops. |
Uh oh!
There was an error while loading. Please reload this page.
I call GifDrawable.getCurrentPosition() every 10ms to update the UI progress. This method will return a negative value when the gif is closing to the end.
The text was updated successfully, but these errors were encountered: