Example usage for android.animation ObjectAnimator ofFloat

List of usage examples for android.animation ObjectAnimator ofFloat

Introduction

In this page you can find the example usage for android.animation ObjectAnimator ofFloat.

Prototype

public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty,
        Path path) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

Usage

From source file:com.lichen.teacher.apps.ActivityLive.java

private void startEditContainViewAnim() {
    if (!mEditContainViewVisibility)
        return;/*from  w  w  w .j ava 2s. com*/
    mEditContainView.setVisibility(View.VISIBLE);
    ObjectAnimator mEditContainViewAnim = ObjectAnimator.ofFloat(mEditContainView, "alpha", 1, 0)
            .setDuration(300);
    mEditContainViewAnim.addListener(mEditContainViewAnimListener);
    mEditContainViewAnim.start();
    mEditContainViewVisibility = false;
}

From source file:com.aimfire.demo.CamcorderActivity.java

private Animator prepareRecordingAnimator(int durationSeconds) {
    final AnimatorSet animatorSet = new AnimatorSet();

    mProgDrawable.setIndeterminate(false);
    mProgDrawable.setUseRotation(false);
    mProgDrawable.setUseArc(false);/*from  w  w  w  .  java 2 s  .com*/
    mProgDrawable.setUseAlpha(false);
    mProgDrawable.setUseWifiBar(false);

    Animator determinateAnimator = ObjectAnimator.ofFloat(mProgDrawable,
            CircularProgressDrawable.PROGRESS_PROPERTY, 0, 1);
    determinateAnimator.setDuration(durationSeconds * 1000);

    animatorSet.playTogether(determinateAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            // we only need to execute this once
            if (mInSync) {
                syncStopRecording();
            } else {
                soloStopRecording();
            }
        }
    });

    return animatorSet;
}

From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java

@Override
public void onShowPickUser(IPickUserController.Destination destination, View anchorView) {
    if (LayoutSpec.isPhone(getActivity())) {
        return;//from  w  w w . j  a  va 2s . c  o m
    }
    if (!getCurrentPickerDestination().equals(destination)) {
        onHidePickUser(getCurrentPickerDestination(), true);
        return;
    }
    FragmentManager fragmentManager = getChildFragmentManager();

    int pickUserAnimation = LayoutSpec.isTablet(getActivity()) ? R.anim.fade_in
            : R.anim.slide_in_from_bottom_pick_user;

    if (!groupConversation && otherUser != null) {
        getControllerFactory().getPickUserController().addUser(otherUser);
    }
    fragmentManager.beginTransaction().setCustomAnimations(pickUserAnimation, R.anim.fade_out)
            .add(R.id.fl__add_to_conversation__pickuser__container,
                    PickUserFragment.newInstance(true, groupConversation), PickUserFragment.TAG)
            .addToBackStack(PickUserFragment.TAG).commit();

    if (LayoutSpec.isPhone(getActivity())) {
        getControllerFactory().getNavigationController().setRightPage(Page.PICK_USER_ADD_TO_CONVERSATION, TAG);
    }

    final ObjectAnimator hideParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView,
            View.ALPHA, 1f, 0f);
    hideParticipantsAnimator.setInterpolator(new Quart.EaseOut());
    hideParticipantsAnimator
            .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));
    hideParticipantsAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            participantsContainerView.setVisibility(View.GONE);
        }
    });
    hideParticipantsAnimator.start();
}

From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java

@Override
public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) {
    if (LayoutSpec.isPhone(getActivity())) {
        return;/*from   ww  w.j a  v  a2  s .c  o m*/
    }
    if (!destination.equals(getCurrentPickerDestination())) {
        return;
    }
    // Workaround for animation bug with nested child fragments
    // Animating fragment container views and then popping stack at end of animation

    int showParticipantsDelay = getResources().getInteger(R.integer.framework_animation_delay_long);
    int hidePickUserAnimDuration = getResources().getInteger(R.integer.framework_animation_duration_medium);
    TimeInterpolator hidePickUserInterpolator = new Expo.EaseIn();
    ObjectAnimator hidePickUserAnimator;
    // Fade animation in participants dialog on tablet
    if (LayoutSpec.isTablet(getActivity())) {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.ALPHA, 1f, 0f);
        hidePickUserAnimator.setInterpolator(new Linear.EaseIn());

    } else {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.TRANSLATION_Y, 0f,
                pickUserContainerView.getMeasuredHeight());
        hidePickUserAnimator.setInterpolator(hidePickUserInterpolator);
        hidePickUserAnimator.setDuration(hidePickUserAnimDuration);
    }
    hidePickUserAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!isResumed()) {
                return;
            }
            getChildFragmentManager().popBackStackImmediate(PickUserFragment.TAG,
                    FragmentManager.POP_BACK_STACK_INCLUSIVE);

            if (LayoutSpec.isTablet(getActivity())) {
                // Reset for fade animation in participants dialog on tablet
                pickUserContainerView.setAlpha(1f);
            } else {
                pickUserContainerView.setTranslationY(0f);
            }
        }
    });

    participantsContainerView.setAlpha(0);
    participantsContainerView.setVisibility(View.VISIBLE);
    ObjectAnimator showParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView, View.ALPHA, 0f,
            1f);
    showParticipantsAnimator.setInterpolator(new Quart.EaseOut());
    showParticipantsAnimator
            .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));
    showParticipantsAnimator.setStartDelay(showParticipantsDelay);

    AnimatorSet hideSet = new AnimatorSet();
    hideSet.playTogether(hidePickUserAnimator, showParticipantsAnimator);
    hideSet.start();

    if (LayoutSpec.isPhone(getActivity()) && getControllerFactory().getNavigationController()
            .getPagerPosition() == NavigationController.SECOND_PAGE) {
        // TODO: https://wearezeta.atlassian.net/browse/AN-3081
        if (getControllerFactory().getConversationScreenController().isShowingParticipant()) {
            getControllerFactory().getNavigationController().setRightPage(Page.PARTICIPANT, TAG);
        } else {
            getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG);
        }
    }
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * show search view with a circular reveal animation
 *///ww  w  .jav  a  2s  .co m
void revealSearchView() {
    final int START_RADIUS = 16;
    int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, START_RADIUS, endRadius);
    } else {
        // TODO:ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 0f, 1f);
    }

    utils.revealShow(fabBgView, true);

    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    searchViewLayout.setVisibility(View.VISIBLE);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewEditText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT);
            isSearchViewEnabled = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * hide search view with a circular reveal animation
 *///  w ww .  java 2 s . com
public void hideSearchView() {
    final int END_RADIUS = 16;
    int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight());
    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, startRadius, END_RADIUS);
    } else {
        // TODO: ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 1f, 0f);
    }

    // removing background fade view
    utils.revealShow(fabBgView, false);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewLayout.setVisibility(View.GONE);
            isSearchViewEnabled = false;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(),
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void changeIcon(ImageView imageView, Drawable newIcon, boolean withAnim) {
    imageView.setImageDrawable(newIcon);
    if (withAnim) {
        ObjectAnimator fadeInVoiceInputOrClear = ObjectAnimator.ofFloat(imageView, "alpha", 0.0f, 1.0f);
        fadeInVoiceInputOrClear.start();
    } else {// ww w.  j a  v  a  2 s  . co m
        imageView.setAlpha(1.0f);
    }
}

From source file:com.aimfire.demo.CamcorderActivity.java

private void accelScanAnim() {
    //mScanProgDrawable.setMessageText(getString(R.string.preparing_camera));
    if (mScanCurrAnimator != null) {
        mScanCurrAnimator.removeAllListeners();
        mScanCurrAnimator.cancel();/*from   ww w  .jav  a2s .c om*/
    }

    mScanCurrAnimator = ObjectAnimator.ofFloat(mScanProgDrawable, CircularProgressDrawable.PROGRESS_PROPERTY,
            mScanProgDrawable.getProgress(), 1);
    mScanCurrAnimator.setDuration(2000);
    mScanCurrAnimator.start();
}

From source file:com.aimfire.demo.CamcorderActivity.java

/**
 * Style 1 animation will simulate a determinate loading
 *
 * @return Animator/* w ww .  j av a 2 s . com*/
 */
private Animator prepare3DAnimator() {
    final AnimatorSet animatorSet = new AnimatorSet();

    mScanProgDrawable.setIndeterminate(false);
    mScanProgDrawable.setUseRotation(false);
    mScanProgDrawable.setUseArc(false);
    mScanProgDrawable.setUseAlpha(false);
    mScanProgDrawable.setUseWifiBar(true);

    mScanProgDrawable.setMessageText(getString(R.string.scanning));
    mScanProgDrawable.setSuppText(getString(R.string.tap_to_stop));

    //if(!mScanProgDrawable.getMessageText().equals(getString(R.string.connecting)))
    //{
    //mScanProgDrawable.setMessageText(getString(R.string.scanning) + (mAnimCyclesCnt+1) + " of " + CONNECT_ANIM_CYCLES);
    //}

    Animator determinateAnimator = ObjectAnimator.ofFloat(mScanProgDrawable,
            CircularProgressDrawable.PROGRESS_PROPERTY, 0, 1);
    determinateAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000);

    /*
     * wifi bar highlight changes 3 times a second
     */
    Animator wifiBarAnimator = ObjectAnimator.ofInt(mScanProgDrawable,
            CircularProgressDrawable.WIFI_BAR_PROPERTY, 0, 2 * CONNECT_ANIM_CYCLE_LENGTH_SECONDS);
    wifiBarAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000);
    wifiBarAnimator.setInterpolator(new LinearInterpolator());

    animatorSet.playTogether(wifiBarAnimator, determinateAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            restartScanAnim();
        }
    });

    return animatorSet;
}

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

private void showScaleAnimation(boolean post) {
    clearListAnimator();/*  ww  w. j a va2  s  .  c o  m*/
    if (allowScaleAnimation) {
        if (post) {
            listView.setVisibility(View.INVISIBLE);
            handler.post(showScaleRunnable);
        } else {
            final float fromScale = 0.925f;
            ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(listView, View.ALPHA, 0f, 1f);
            ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(listView, View.SCALE_X, fromScale, 1f);
            ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(listView, View.SCALE_Y, fromScale, 1f);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator);
            animatorSet.setDuration(100);
            startListAnimator(animatorSet);
        }
    }
}