VectorAnimWrapper

Additional

Language
Kotlin
Version
N/A
Created
Apr 17, 2019
Updated
Jun 27, 2019 (Retired)
Owner
Evgen Tretsyak (Rizlee)
Contributor
Evgen Tretsyak (Rizlee)
1
Activity
Badge
Generate
Download
Source code

Usage

Gradle

implementation "com.rizlee.wrapper:vector-anim-wrapper:$last_version"

XML

<com.rizlee.animatedicon.AnimatedIcon
        android:id="@+id/animatedIcon"
        android:layout_width="50dp"
        android:layout_height="50dp"
        app:first_state="@drawable/play_to_pause"
        app:last_state="@drawable/pause_to_play" />

Kotlin

just implement:
AnimatedIcon.OnAnimatedIconClickListener
AnimatedIcon.OnAnimatedIconCallback // only for api >= 23
 
then animatedIcon.listener = this
animatedIcon.animCallback = this // only for api >= 23
        
override fun onClickEvent(newState: AnimatedIcon.State) {
        when (newState) {
            AnimatedIcon.State.FIRST_STATE -> Log.i(TAG, "First state")
            AnimatedIcon.State.LAST_STATE -> Log.i(TAG, "Last state")
        }
    }

override fun onStateChanged(newState: AnimatedIcon.State) {
        when (newState) {
            AnimatedIcon.State.FIRST_STATE -> Log.i(TAG, "First state")
            AnimatedIcon.State.LAST_STATE -> Log.i(TAG, "Last state")
        }
    }
    
override fun onAnimationStart() {
        Log.i(TAG, "onAnimationStart")
    }

override fun onAnimationEnd() {
        Log.i(TAG, "onAnimationEnd")
    }
    
animatedIcon.setCurrentStateWithAnim(AnimatedIcon.State.FIRST_STATE)
animatedIcon.currentState // get the current state

Animated drawables you can make with the help of this, In sample you can find examples of vector drawables