Java Code Examples for android.view.animation.Animation#getDuration()

The following examples show how to use android.view.animation.Animation#getDuration() . 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: BaseFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
private static long getRemovingParentAnimationDuration(Fragment fragment, long defValue) {
  try {
    Field animInfoField = Fragment.class.getDeclaredField("mAnimationInfo");
    animInfoField.setAccessible(true);
    Object animationInfo = animInfoField.get(fragment);
    Field nextAnimField = animationInfo.getClass()
        .getDeclaredField("mNextAnim");
    nextAnimField.setAccessible(true);
    int nextAnimResource = nextAnimField.getInt(animationInfo);
    Animation nextAnim = AnimationUtils.loadAnimation(fragment.getActivity(), nextAnimResource);

    return (nextAnim == null) ? defValue : nextAnim.getDuration();
  } catch (NoSuchFieldException | IllegalAccessException | Resources.NotFoundException ex) {
    Logger.getInstance()
        .e("BASE FRAGMENT", "Unable to load next animation from parent.", ex);
    return defValue;
  }
}
 
Example 2
Source File: YMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
public void setMenuOpenAnimation(Animation menuOpenAnimation) {
    if (menuOpenAnimation == null) {
        menuOpenAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_null);
    }
    if (menuOpenAnimation.getDuration() == 0) {
        menuOpenAnimation.setDuration(mMenuAnimationDuration);
    }
    menuOpenAnimation.setAnimationListener(animationListener);
    this.menuOpenAnimation = menuOpenAnimation;


}
 
Example 3
Source File: YMenu.java    From YMenuView with Apache License 2.0 5 votes vote down vote up
public void setMenuCloseAnimation(Animation menuCloseAnimation) {
    if (menuCloseAnimation == null) {
        menuCloseAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_null);
    }
    if (menuCloseAnimation.getDuration() == 0) {
        menuCloseAnimation.setDuration(mOptionSD_AnimationDuration);
    }
    menuCloseAnimation.setAnimationListener(animationListener);
    this.menuCloseAnimation = menuCloseAnimation;
}
 
Example 4
Source File: PointViewAnimObject.java    From DragPointView with Apache License 2.0 5 votes vote down vote up
private void start(Animation object, final OnPointDragListener removeListener) {
    long duration = object.getDuration();
    object.cancel();
    view.startAnimation(object);
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            view.clearAnimation();
            end(removeListener);
        }
    }, duration);
}
 
Example 5
Source File: ImmersiveModeConfirmation.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private long getNavBarExitDuration() {
    Animation exit = AnimationUtils.loadAnimation(mContext, R.anim.dock_bottom_exit);
    return exit != null ? exit.getDuration() : 0;
}
 
Example 6
Source File: Game.java    From SchoolQuest with GNU General Public License v3.0 4 votes vote down vote up
public void setLoadingScreen(boolean loading, int... frames) {
    currentLoadingTime = 0;
    Animation loadingTextAnim;

    if (GameActivity.getInstance().findViewById(
            R.id.loading_text).getAnimation() != null) {
        loadingTextAnim = GameActivity.getInstance().findViewById(R.id.loading_text).
                getAnimation();
    } else if (GameActivity.getInstance().findViewById(
            R.id.loading_day_old).getAnimation() != null) {
        loadingTextAnim = GameActivity.getInstance().findViewById(R.id.loading_day_old).
                getAnimation();
    } else {
        loadingTextAnim = null;
    }

    int animDuration = 0;
    if (loadingTextAnim != null) {
        animDuration = (int) ((loadingTextAnim.getDuration() + loadingTextAnim.getStartOffset())
                * TARGET_FPS) / 1000;
        loadingTextAnim.start();
    }
    if (frames.length == 0) { loadingTime = 6 + animDuration; }
    else { loadingTime = frames[0] + animDuration; }

    if (loading) {
        this.loading = true;
        GameActivity.getInstance().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                GameActivity.getInstance().enableLoadingScreen();
            }
        });
    }
    else {
        GameActivity.getInstance().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                GameActivity.getInstance().disableLoadingScreen();
            }
        });
    }
}