Static
This commit is contained in:
parent
5e2d3431dc
commit
ca46bc290a
|
|
@ -57,19 +57,9 @@ public class Switcher extends FrameLayout {
|
|||
final View child = getChildAt(index);
|
||||
if (child.getId() == id) {
|
||||
found = true;
|
||||
if (child.getVisibility() != View.VISIBLE) {
|
||||
if (ViewCompat.isLaidOut(this) && inAnimation != null) {
|
||||
child.startAnimation(inAnimation);
|
||||
}
|
||||
child.setVisibility(View.VISIBLE);
|
||||
}
|
||||
setVisibilityWithAnimation(child, View.VISIBLE);
|
||||
} else {
|
||||
if (child.getVisibility() != View.GONE) {
|
||||
if (ViewCompat.isLaidOut(this) && outAnimation != null) {
|
||||
child.startAnimation(outAnimation);
|
||||
}
|
||||
child.setVisibility(View.GONE);
|
||||
}
|
||||
setVisibilityWithAnimation(child, View.GONE);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
|
@ -77,4 +67,14 @@ public class Switcher extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private void setVisibilityWithAnimation(@NonNull final View view, final int targetVisibility) {
|
||||
final Animation animation = targetVisibility == View.VISIBLE ? inAnimation : outAnimation;
|
||||
if (view.getVisibility() != targetVisibility) {
|
||||
if (ViewCompat.isLaidOut(this) && animation != null) {
|
||||
view.startAnimation(animation);
|
||||
}
|
||||
view.setVisibility(targetVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue