mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-22 10:46:50 +00:00
Add bubble resize animation.
This commit is contained in:
committed by
Greyson Parrelli
parent
f533a898f5
commit
68655194a6
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.conversation
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.animation.ValueAnimator
|
||||
import androidx.core.animation.addListener
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
class BodyBubbleLayoutTransition(bodyBubble: ConversationItemBodyBubble) : LayoutTransition() {
|
||||
|
||||
private val animator: ValueAnimator = ValueAnimator.ofFloat(0f, 1f)
|
||||
|
||||
init {
|
||||
disableTransitionType(APPEARING)
|
||||
disableTransitionType(DISAPPEARING)
|
||||
disableTransitionType(CHANGE_APPEARING)
|
||||
disableTransitionType(CHANGING)
|
||||
|
||||
setDuration(100L)
|
||||
|
||||
animator.duration = getAnimator(CHANGE_DISAPPEARING).duration
|
||||
animator.addUpdateListener {
|
||||
val parentRecycler: RecyclerView? = bodyBubble.parent.parent as? RecyclerView
|
||||
|
||||
try {
|
||||
parentRecycler?.invalidateItemDecorations()
|
||||
} catch (e: IllegalStateException) {
|
||||
// In scroll or layout. Skip this frame.
|
||||
}
|
||||
}
|
||||
|
||||
getAnimator(CHANGE_DISAPPEARING).addListener(
|
||||
onStart = {
|
||||
animator.start()
|
||||
},
|
||||
onEnd = {
|
||||
animator.end()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,17 @@ public class ConversationItemBodyBubble extends LinearLayout {
|
||||
|
||||
public ConversationItemBodyBubble(Context context) {
|
||||
super(context);
|
||||
setLayoutTransition(new BodyBubbleLayoutTransition(this));
|
||||
}
|
||||
|
||||
public ConversationItemBodyBubble(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayoutTransition(new BodyBubbleLayoutTransition(this));
|
||||
}
|
||||
|
||||
public ConversationItemBodyBubble(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setLayoutTransition(new BodyBubbleLayoutTransition(this));
|
||||
}
|
||||
|
||||
public void setOutliners(@NonNull List<Outliner> outliners) {
|
||||
|
||||
Reference in New Issue
Block a user