use of android.animation.ObjectAnimator in project weiciyuan by qii.
the class ContainerFragment method displayPicture.
private void displayPicture(String path, boolean animateIn) {
GalleryAnimationActivity activity = (GalleryAnimationActivity) getActivity();
AnimationRect rect = getArguments().getParcelable("rect");
boolean firstOpenPage = getArguments().getBoolean("firstOpenPage");
if (firstOpenPage) {
if (animateIn) {
ObjectAnimator animator = activity.showBackgroundAnimate();
animator.start();
} else {
activity.showBackgroundImmediately();
}
getArguments().putBoolean("firstOpenPage", false);
}
if (!ImageUtility.isThisBitmapTooLargeToRead(path)) {
Fragment fragment = null;
if (ImageUtility.isThisPictureGif(path)) {
fragment = GifPictureFragment.newInstance(path, rect, animateIn);
} else {
fragment = GeneralPictureFragment.newInstance(path, rect, animateIn);
}
getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
} else {
LargePictureFragment fragment = LargePictureFragment.newInstance(path, animateIn);
getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
}
}
use of android.animation.ObjectAnimator in project weiciyuan by qii.
the class GalleryAnimationActivity method onBackPressed.
@Override
public void onBackPressed() {
ContainerFragment fragment = fragmentMap.get(pager.getCurrentItem());
if (fragment != null && fragment.canAnimateCloseActivity()) {
backgroundColor = new ColorDrawable(Color.BLACK);
ObjectAnimator bgAnim = ObjectAnimator.ofInt(backgroundColor, "alpha", 0);
bgAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
background.setBackground(backgroundColor);
}
});
bgAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
GalleryAnimationActivity.super.finish();
overridePendingTransition(-1, -1);
}
});
fragment.animationExit(bgAnim);
} else {
super.onBackPressed();
}
}
use of android.animation.ObjectAnimator in project weiciyuan by qii.
the class AnimationUtility method translateFragmentX.
public static void translateFragmentX(Fragment fragment, int from, int to) {
final View fragmentView = fragment.getView();
if (fragmentView == null) {
return;
}
FragmentViewXWrapper wrapper = new FragmentViewXWrapper(fragmentView);
ObjectAnimator objectAnimator = ObjectAnimator.ofInt(wrapper, "change", from, to);
objectAnimator.setDuration(300);
objectAnimator.setInterpolator(new DecelerateInterpolator());
objectAnimator.start();
}
use of android.animation.ObjectAnimator in project platform_frameworks_base by android.
the class AnimatedVectorDrawable method inflate.
@Override
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
final AnimatedVectorDrawableState state = mAnimatedVectorState;
int eventType = parser.getEventType();
float pathErrorScale = 1;
final int innerDepth = parser.getDepth() + 1;
// Parse everything until the end of the animated-vector element.
while (eventType != XmlPullParser.END_DOCUMENT && (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
if (eventType == XmlPullParser.START_TAG) {
final String tagName = parser.getName();
if (ANIMATED_VECTOR.equals(tagName)) {
final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawable);
int drawableRes = a.getResourceId(R.styleable.AnimatedVectorDrawable_drawable, 0);
if (drawableRes != 0) {
VectorDrawable vectorDrawable = (VectorDrawable) res.getDrawable(drawableRes, theme).mutate();
vectorDrawable.setAllowCaching(false);
vectorDrawable.setCallback(mCallback);
pathErrorScale = vectorDrawable.getPixelSize();
if (state.mVectorDrawable != null) {
state.mVectorDrawable.setCallback(null);
}
state.mVectorDrawable = vectorDrawable;
}
a.recycle();
} else if (TARGET.equals(tagName)) {
final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawableTarget);
final String target = a.getString(R.styleable.AnimatedVectorDrawableTarget_name);
final int animResId = a.getResourceId(R.styleable.AnimatedVectorDrawableTarget_animation, 0);
if (animResId != 0) {
if (theme != null) {
// The animator here could be ObjectAnimator or AnimatorSet.
final Animator animator = AnimatorInflater.loadAnimator(res, theme, animResId, pathErrorScale);
updateAnimatorProperty(animator, target, state.mVectorDrawable, state.mShouldIgnoreInvalidAnim);
state.addTargetAnimator(target, animator);
} else {
// The animation may be theme-dependent. As a
// workaround until Animator has full support for
// applyTheme(), postpone loading the animator
// until we have a theme in applyTheme().
state.addPendingAnimator(animResId, pathErrorScale, target);
}
}
a.recycle();
}
}
eventType = parser.next();
}
// If we don't have any pending animations, we don't need to hold a
// reference to the resources.
mRes = state.mPendingAnims == null ? null : res;
}
use of android.animation.ObjectAnimator in project platform_frameworks_base by android.
the class TransformsAndAnimationsActivity method startAnimator.
private void startAnimator(View target) {
ObjectAnimator anim1b = ObjectAnimator.ofFloat(target, View.ALPHA, 0);
anim1b.setRepeatCount(ValueAnimator.INFINITE);
anim1b.setRepeatMode(ValueAnimator.REVERSE);
anim1b.setDuration(1000);
anim1b.start();
}
Aggregations