-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix gifs animating on app resume android
- Loading branch information
Showing
3 changed files
with
37 additions
and
47 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...-gif-view/android/src/main/java/expo/modules/blueskygifview/AppCompatImageViewExtended.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package expo.modules.blueskygifview | ||
|
||
import android.content.Context | ||
import android.graphics.Canvas | ||
import android.graphics.drawable.Animatable | ||
import android.util.Log | ||
import androidx.appcompat.widget.AppCompatImageView | ||
|
||
class AppCompatImageViewExtended(context: Context, val parent: GifView): AppCompatImageView(context) { | ||
override fun onDraw(canvas: Canvas) { | ||
Log.d("AppCompatImageViewExtended", "onDraw") | ||
super.onDraw(canvas) | ||
if (!parent.isPlaying) { | ||
this.pause() | ||
} | ||
} | ||
|
||
fun pause() { | ||
val drawable = this.drawable | ||
if (drawable is Animatable) { | ||
drawable.stop() | ||
} | ||
} | ||
|
||
fun play() { | ||
val drawable = this.drawable | ||
if (drawable is Animatable) { | ||
drawable.start() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters