mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
UI code cleanup.
This commit is contained in:
@@ -4,67 +4,61 @@ import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.MeasureSpec.UNSPECIFIED;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
public class CustomAnimations {
|
||||
|
||||
public static void animateHeight(
|
||||
final ViewGroup viewGroup, final boolean isExtending,
|
||||
public static void animateHeight(ViewGroup viewGroup, boolean isExtending,
|
||||
int duration) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
animateHeightPostGingerbread(viewGroup, isExtending, duration);
|
||||
} else {
|
||||
animateHeightGingerbread(viewGroup, isExtending, duration);
|
||||
animateHeightGingerbread(viewGroup, isExtending);
|
||||
}
|
||||
}
|
||||
|
||||
private static void animateHeightGingerbread(final ViewGroup viewGroup,
|
||||
final boolean isExtending, int duration) {
|
||||
private static void animateHeightGingerbread(ViewGroup viewGroup,
|
||||
boolean isExtending) {
|
||||
// No animations for Gingerbread
|
||||
if (isExtending) {
|
||||
viewGroup.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewGroup.setVisibility(View.GONE);
|
||||
}
|
||||
if (isExtending) viewGroup.setVisibility(VISIBLE);
|
||||
else viewGroup.setVisibility(GONE);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private static void animateHeightPostGingerbread(
|
||||
final ViewGroup viewGroup,
|
||||
final boolean isExtending,
|
||||
int duration) {
|
||||
private static void animateHeightPostGingerbread(final ViewGroup viewGroup,
|
||||
final boolean isExtending, int duration) {
|
||||
ValueAnimator anim;
|
||||
if (isExtending) {
|
||||
viewGroup.setVisibility(View.VISIBLE);
|
||||
viewGroup.measure(View.MeasureSpec.UNSPECIFIED,
|
||||
View.MeasureSpec.UNSPECIFIED);
|
||||
viewGroup.setVisibility(VISIBLE);
|
||||
viewGroup.measure(UNSPECIFIED, UNSPECIFIED);
|
||||
anim = ValueAnimator.ofInt(0, viewGroup.getMeasuredHeight());
|
||||
} else {
|
||||
anim = ValueAnimator.ofInt(viewGroup.getHeight(), 0);
|
||||
}
|
||||
anim.addListener(new Animator.AnimatorListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (!isExtending) {
|
||||
viewGroup.setVisibility(View.GONE);
|
||||
viewGroup.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@@ -76,7 +70,6 @@ public class CustomAnimations {
|
||||
layoutParams.height = val;
|
||||
viewGroup.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
});
|
||||
anim.setDuration(duration);
|
||||
anim.start();
|
||||
|
||||
Reference in New Issue
Block a user