Java Code Examples for android.animation.AnimatorInflater#loadAnimator()

The following examples show how to use android.animation.AnimatorInflater#loadAnimator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyPreviewDrawParams.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public Animator createShowUpAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mShowUpStartXScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mShowUpStartYScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final AnimatorSet showUpAnimator = new AnimatorSet();
        showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
        showUpAnimator.setDuration(mShowUpDuration);
        showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
        return showUpAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mShowUpAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(DECELERATE_INTERPOLATOR);
    return animator;
}
 
Example 2
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
 * use property animation by xml;
 *
 * @return
 */
private Animator getAnimationByXml() {
    final int height = mPuppet.getLayoutParams().height;
    final int width = mPuppet.getLayoutParams().width;
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset);

    //ValueAnimator usage:add AnimatorUpdateListener;
    ArrayList<Animator> childAnimations = animatorSet.getChildAnimations();
    ((ValueAnimator) childAnimations.get(childAnimations.size() - 1))
            .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float animatedValue = (float) valueAnimator.getAnimatedValue();
                    mPuppet.getLayoutParams().height = (int) (height * animatedValue);
                    mPuppet.getLayoutParams().width = (int) (width * animatedValue);
                    mPuppet.requestLayout();
                }
            });

    animatorSet.setTarget(mPuppet);
    return animatorSet;
}
 
Example 3
Source File: KeyPreviewDrawParams.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public Animator createDismissAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mDismissEndXScale);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mDismissEndYScale);
        final AnimatorSet dismissAnimator = new AnimatorSet();
        dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
        final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
        dismissAnimator.setDuration(dismissDuration);
        dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
        return dismissAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mDismissAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(ACCELERATE_INTERPOLATOR);
    return animator;
}
 
Example 4
Source File: BubbleTrashLayout.java    From Andzu with MIT License 5 votes vote down vote up
private void playAnimation(int animationResourceId) {
    if (!isInEditMode()) {
        AnimatorSet animator = (AnimatorSet) AnimatorInflater
                .loadAnimator(getContext(), animationResourceId);
        animator.setTarget(getChildAt(0));
        animator.start();
    }
}
 
Example 5
Source File: MainKeyboardView.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
    if (resId == 0) {
        // TODO: Stop returning null.
        return null;
    }
    final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
            getContext(), resId);
    if (animator != null) {
        animator.setTarget(target);
    }
    return animator;
}
 
Example 6
Source File: BubbleLayout.java    From bubbles-for-android with Apache License 2.0 5 votes vote down vote up
private void playAnimationClickDown() {
    if (!isInEditMode()) {
        AnimatorSet animator = (AnimatorSet) AnimatorInflater
                .loadAnimator(getContext(), R.animator.bubble_down_click_animator);
        animator.setTarget(this);
        animator.start();
    }
}
 
Example 7
Source File: LocalLyricsFragment.java    From QuickLyric with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    Animator anim = null;
    if (showTransitionAnim) {
        if (nextAnim != 0)
            anim = AnimatorInflater.loadAnimator(getActivity(), nextAnim);
        showTransitionAnim = false;
    } else
        anim = AnimatorInflater.loadAnimator(getActivity(), R.animator.none);
    return anim;
}
 
Example 8
Source File: CircleIndicator.java    From MNImageBrowser with GNU General Public License v3.0 5 votes vote down vote up
private Animator createAnimatorIn(Context context) {
    Animator animatorIn;
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}
 
Example 9
Source File: DefaultResourceProvider.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
private Animator getAnimator(@NonNull String resName) {
    try {
        return AnimatorInflater.loadAnimator(
                context,
                ResourceUtils.nonNull(getResId(context, resName, "animator"))
        );
    } catch (Exception e) {
        return null;
    }
}
 
Example 10
Source File: StaticObjectDetectionActivity.java    From mlkit-material-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onSearchCompleted(DetectedObject object, List<Product> productList) {
  Log.d(TAG, "Search completed for object index: " + object.getObjectIndex());
  searchedObjectMap.put(
      object.getObjectIndex(), new SearchedObject(getResources(), object, productList));
  if (searchedObjectMap.size() < detectedObjectNum) {
    // Hold off showing the result until the search of all detected objects completes.
    return;
  }

  showBottomPromptChip(getString(R.string.static_image_prompt_detected_results));
  loadingView.setVisibility(View.GONE);
  previewCardCarousel.setAdapter(
      new PreviewCardAdapter(ImmutableList.copyOf(searchedObjectMap.values()), this));
  previewCardCarousel.addOnScrollListener(
      new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
          Log.d(TAG, "New card scroll state: " + newState);
          if (newState == RecyclerView.SCROLL_STATE_IDLE) {
            for (int i = 0; i < recyclerView.getChildCount(); i++) {
              View childView = recyclerView.getChildAt(i);
              if (childView.getX() >= 0) {
                int cardIndex = recyclerView.getChildAdapterPosition(childView);
                if (cardIndex != currentSelectedObjectIndex) {
                  selectNewObject(cardIndex);
                }
                break;
              }
            }
          }
        }
      });

  for (SearchedObject searchedObject : searchedObjectMap.values()) {
    StaticObjectDotView dotView = createDotView(searchedObject);
    dotView.setOnClickListener(
        v -> {
          if (searchedObject.getObjectIndex() == currentSelectedObjectIndex) {
            showSearchResults(searchedObject);
          } else {
            selectNewObject(searchedObject.getObjectIndex());
            showSearchResults(searchedObject);
            previewCardCarousel.smoothScrollToPosition(searchedObject.getObjectIndex());
          }
        });

    dotViewContainer.addView(dotView);
    AnimatorSet animatorSet =
        ((AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.static_image_dot_enter));
    animatorSet.setTarget(dotView);
    animatorSet.start();
  }
}
 
Example 11
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 4 votes vote down vote up
public void loadXml(View v){
	//����xml��������Զ���
	Animator at = AnimatorInflater.loadAnimator(this, R.animator.objectanimator);
	at.setTarget(iv);
	at.start();
}
 
Example 12
Source File: CommonUtils.java    From Yuan-WanAndroid with Apache License 2.0 4 votes vote down vote up
public static void collectAnimator(Context context, View view){
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(context, R.animator.collect_anim);
    animatorSet.setTarget(view);
    animatorSet.start();
}
 
Example 13
Source File: AnimatorFromXmlFragment.java    From AndroidAll with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    super.onClick(v);
    if (left == 0) {
        left = tvTarget.getLeft();
    }
    if (top == 0) {
        top = tvTarget.getTop();
    }
    switch (v.getId()) {
        case R.id.btn_start_1:
            ValueAnimator valueAnimator = (ValueAnimator) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.value_animtor);
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    int value = (int) animation.getAnimatedValue();
                    tvTarget.layout(
                            value + left,
                            value + top,
                            value + left + tvTarget.getWidth(),
                            value + top + tvTarget.getHeight());
                }
            });
            valueAnimator.start();
            break;
        case R.id.btn_start_2:
            ObjectAnimator objectAnimator = (ObjectAnimator) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.object_animtor);
            objectAnimator.setTarget(tvTarget);
            objectAnimator.start();
            break;

        case R.id.btn_start_3:
            AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater
                    .loadAnimator(getActivity(), R.animator.animtor_set);
            animatorSet.setTarget(tvTarget);
            animatorSet.start();
            break;
    }
}
 
Example 14
Source File: AnimatorStrategyBuilder.java    From AndroidAutoSwitcher with Apache License 2.0 4 votes vote down vote up
public AnimatorStrategyBuilder(Context context, int resourceIDIn, int resourceIDOut) {
    mAnimatorIn = (ObjectAnimator) AnimatorInflater.loadAnimator(context, resourceIDIn);
    mAnimatorOut = (ObjectAnimator) AnimatorInflater.loadAnimator(context, resourceIDOut);
}
 
Example 15
Source File: PlayActivity.java    From Yuan-SxMusic with Apache License 2.0 4 votes vote down vote up
@Override
public void showLoveAnim() {
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(PlayActivity.this, R.animator.favorites_anim);
    animatorSet.setTarget(mLoveBtn);
    animatorSet.start();
}
 
Example 16
Source File: ConversationsOverviewFragment.java    From Pix-Art-Messenger with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    int animator = enter ? R.animator.fade_left_in : R.animator.fade_left_out;
    return AnimatorInflater.loadAnimator(getActivity(), animator);
}
 
Example 17
Source File: CircleIndicator.java    From MNImageBrowser with GNU General Public License v3.0 4 votes vote down vote up
private Animator createAnimatorOut(Context context) {
    return AnimatorInflater.loadAnimator(context, mAnimatorResId);
}
 
Example 18
Source File: PlaybackOverlaySupportFragment.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
private static ValueAnimator loadAnimator(Context context, int resId) {
    ValueAnimator animator = (ValueAnimator) AnimatorInflater.loadAnimator(context, resId);
    animator.setDuration(animator.getDuration() * ANIMATION_MULTIPLIER);
    return animator;
}
 
Example 19
Source File: PhotoDetailActivity.java    From LiuAGeAndroid with MIT License 2 votes vote down vote up
/**
 * 给view添加指定属性动画
 *
 * @param target 需要添加动画的对象
 * @param id     动画id
 */
private void setupAnimation(View target, int id) {
    AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(this, id);
    set.setTarget(target);
    set.start();
}
 
Example 20
Source File: PhotoDetailActivity.java    From BaoKanAndroid with MIT License 2 votes vote down vote up
/**
 * 给view添加指定属性动画
 *
 * @param target 需要添加动画的对象
 * @param id     动画id
 */
private void setupAnimation(View target, int id) {
    AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(this, id);
    set.setTarget(target);
    set.start();
}