Example usage for android.view.animation RotateAnimation RotateAnimation

List of usage examples for android.view.animation RotateAnimation RotateAnimation

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation RotateAnimation.

Prototype

public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType,
        float pivotYValue) 

Source Link

Document

Constructor to use when building a RotateAnimation from code

Usage

From source file:org.videolan.vlc.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("VLC " + BuildConfig.VERSION_NAME);
    View v = inflater.inflate(R.layout.about, container, false);

    View aboutMain = v.findViewById(R.id.about_main);
    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = getString(R.string.build_revision);
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = getString(R.string.build_time);
    String builder = getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*  www .  j  a  va 2  s.  co  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    List<View> lists = Arrays.asList(aboutMain, t);
    String[] titles = new String[] { getString(R.string.about), getString(R.string.licence) };
    mViewPager = (ViewPager) v.findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
    mViewPager.setAdapter(new AudioPagerAdapter(lists, titles));

    mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
    mTabLayout.setupWithViewPager(mViewPager);

    return v;
}

From source file:org.videolan.vlc2.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("VLC " + getVersion(getActivity()));

    View v = inflater.inflate(R.layout.about, container, false);

    mTabHost = (TabHost) v.findViewById(android.R.id.tabhost);
    mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.fling_view_group);

    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = Util.readAsset("revision.txt", "Unknown revision");
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*from   w  w w.j av a2  s .  co  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    mTabHost.setup();

    addNewTab(mTabHost, "about", getResources().getString(R.string.about));
    addNewTab(mTabHost, "licence", getResources().getString(R.string.licence));

    mTabHost.setCurrentTab(mCurrentTab);
    mFlingViewGroup.snapToScreen(mCurrentTab);

    mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            mCurrentTab = mTabHost.getCurrentTab();
            mFlingViewGroup.smoothScrollTo(mCurrentTab);
        }
    });

    mFlingViewGroup.setOnViewSwitchedListener(new FlingViewGroup.ViewSwitchListener() {
        @Override
        public void onSwitching(float progress) {
        }

        @Override
        public void onSwitched(int position) {
            mTabHost.setCurrentTab(position);
        }

        @Override
        public void onTouchDown() {
        }

        @Override
        public void onTouchUp() {
        }

        @Override
        public void onTouchClick() {
        }

        @Override
        public void onBackSwitched() {
            MainActivity activity = (MainActivity) getActivity();
            activity.popSecondaryFragment();
        }
    });

    return v;
}

From source file:de.fahrgemeinschaft.util.SpinningZebraListFragment.java

@Override
public void onViewCreated(View layout, Bundle state) {
    super.onViewCreated(layout, state);
    layout.setOnClickListener(null);/*from  w w  w .  j  av  a  2s .c  om*/
    setListAdapter(new CursorAdapter(getActivity(), null, 0) {

        @Override
        public int getCount() {
            if (spinningEnabled)
                return super.getCount() + 1;
            else
                return super.getCount();
        }

        @Override
        public int getViewTypeCount() {
            if (spinningEnabled)
                return 2;
            else
                return 1;
        }

        @Override
        public int getItemViewType(int position) {
            if (!spinningEnabled || position < getCount() - 1)
                return 0;
            else
                return 1;
        }

        @Override
        public View getView(int position, View v, ViewGroup parent) {
            if (!spinningEnabled || position < getCount() - 1)
                v = super.getView(position, v, parent);
            else {
                if (v == null) {
                    v = getLayoutInflater(null).inflate(R.layout.view_spinning_wheel, parent, false);
                }
                ((TextView) v.findViewById(R.id.small)).setText(smallText);
                ((TextView) v.findViewById(R.id.large)).setText(largeText);
                if (spinning && onScreen) {
                    v.findViewById(R.id.progress).startAnimation(rotate);
                } else if (onScreen) {
                    v.findViewById(R.id.progress).clearAnimation();
                }
            }
            if (position % 2 == 0) {
                v.setBackgroundColor(getResources().getColor(R.color.medium_green));
            } else {
                v.setBackgroundColor(getResources().getColor(R.color.almost_medium_green));
            }
            return v;
        }

        @Override
        public View newView(Context ctx, Cursor rides, ViewGroup parent) {
            return getLayoutInflater(null).inflate(R.layout.view_ride_list_entry, parent, false);
        }

        @Override
        public void bindView(View view, Context ctx, Cursor ride) {
            if (ride.getPosition() == ride.getCount())
                return;
            bindListItemView(view, ride);
        }
    });
    registerForContextMenu(getListView());
    rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(600);
    rotate.setRepeatMode(Animation.RESTART);
    rotate.setRepeatCount(Animation.INFINITE);
    stopSpinning(getString(R.string.search_continue));
    if (state != null) {
        code = state.getInt(ID);
        setSpinningEnabled(state.getBoolean(SPIN));
        uri = (Uri) (state.getParcelable(URI));
        getActivity().getSupportLoaderManager().initLoader(code, state, this);
    } else if (uri != null) {
        getActivity().getSupportLoaderManager().restartLoader(code, state, this);
    }
    getListView().requestFocus();
}

From source file:com.capricorn.ArcMenu.java

private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);/* w  w w .  j ava  2s.  co  m*/
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}

From source file:org.runbuddy.tomahawk.views.PageIndicator.java

private void rotateArrow(View arrow, boolean reverse) {
    RotateAnimation rotate;/*w w  w .  j  a v a  2s  .co  m*/
    if (reverse) {
        rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
    } else {
        rotate = new RotateAnimation(360, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
    }
    rotate.setDuration(AnimationUtils.DURATION_ARROWROTATE);
    arrow.startAnimation(rotate);
    rotate.setFillAfter(true);
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void initializeFab(View rootView) {
    final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container);
    final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar);
    final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar);
    Fab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override//from   w  ww  .ja v a2 s .co  m
        public void onClick(View v) {

            //Menu Button Icon Animation
            //Setting up necessary variables
            long animationDuration = 500;
            float containerHeight = buttonContainer.getHeight();
            float containerCenterY = containerHeight / 2;
            float containerCenterX = buttonContainer.getWidth() / 2;
            float topBarCenter = topBar.getTop() + topBar.getHeight() / 2;
            float widthOfBar = topBar.getWidth();
            float heightOfBar = topBar.getHeight();
            final float distanceBetweenBars = (containerCenterY - topBarCenter);

            /**
             *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties
             *and objects at the same time. Also, will try to break intialization into smaller functions.
             */

            //Setting up animations of hamburger bars and rotation

            /**
             * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar.
             * Y Translation is 1/2 the height of the hamburger bar minus the distance.
             * Subtracting the distance from the height because the distance between bars is
             * calculated of the exact center of the button.
             * With out the subtraction the bar would translate slightly below the middle bar.
             */
            float yTranslation = heightOfBar / 2 - distanceBetweenBars;
            float xTranslation = widthOfBar / 2 + heightOfBar / 2;
            TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars);
            topBarTranslationAnim.setDuration((long) (animationDuration * 0.8));
            topBarTranslationAnim.setFillAfter(true);

            //Animation for bottom hamburger bar. Translates and Rotates to create 'X'
            AnimationSet bottomBarAnimation = new AnimationSet(true);
            bottomBarAnimation.setFillAfter(true);

            //Rotate to create cross. (The cross becomes the X after the button rotation completes"
            RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f,
                    Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f);
            bottomBarRotationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarRotationAnimation);

            //Translate to correct X alignment
            TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE,
                    -yTranslation);
            bottomBarTranslationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarTranslationAnimation);

            //Button Specific Animations
            //Rotate Button Container
            RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            containerRotationAnimation.setDuration(animationDuration);
            containerRotationAnimation.setFillAfter(true);

            //Animate change of button color between Active and Disabled colors that have been
            //defined in color.xml
            int activeColor = getResources().getColor(R.color.active_button);
            int disabledColor = getResources().getColor(R.color.disabled_button);

            //Need to use ValueAnimator because property animator does not support BackgroundTint
            ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor);
            buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue()));
                }
            });
            buttonColorAnimation.setDuration(animationDuration);

            //Start all the animations
            topBar.startAnimation(topBarTranslationAnim);
            bottomBar.startAnimation(bottomBarAnimation);
            buttonContainer.startAnimation(containerRotationAnimation);
            buttonColorAnimation.start();

            //Toogle mMenu open and closed
            if (mMenu.isOpen()) {
                //If mMenu is open, do the reverse of the animation
                containerRotationAnimation
                        .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator()));
                mMenu.close();
            } else {
                bottomBarAnimation.setInterpolator(new AccelerateInterpolator());
                mMenu.open();
            }
        }
    });
}

From source file:com.capricorn.ArcMenu.java

private static Animation createQuickHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);//from   www  .  java 2s .co m
    animation.setDuration(10);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}

From source file:com.javadog.cgeowear.CompassActivity.java

/**
 * Handles rotation of the compass to a new direction.
 *
 * @param newDirectionRaw Direction to turn to, in degrees.
 *///from w w w  .ja  v a  2 s.  c om
private void rotateCompass(final float newDirectionRaw) {

    //Rotate through smallest angle
    float apparent;
    apparent = newRot % 360;
    if (apparent < 0) {
        apparent += 360;
    }
    if (apparent < 180 && (newDirectionRaw > (apparent + 180))) {
        newRot -= 360;
    }
    if (apparent >= 180 && (newDirectionRaw <= (apparent - 180))) {
        newRot += 360;
    }
    newRot += (newDirectionRaw - apparent);

    if (currentRotation != newDirectionRaw) {
        RotateAnimation anim = new RotateAnimation(currentRotation, newRot, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(200l);
        anim.setFillAfter(true);
        iv_compass.startAnimation(anim);

        currentRotation = newRot;
    }
}

From source file:com.cyj.ui.component.listview.CusSwipeRefreshLayout.java

private void addDefaultHeadView(Context context) {
    mHeadView = LayoutInflater.from(context).inflate(R.layout.default_listview_header, null);
    mRefreshImageview = (ImageView) mHeadView.findViewById(R.id.pull_to_refresh_image);
    mRefreshTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_text);
    mRefreshSubTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_sub_text);
    mRefreshProgress = (ProgressBar) mHeadView.findViewById(R.id.pull_to_refresh_progress);
    addView(mHeadView, 0);/* www .  j  a  v  a 2s .  c  om*/

    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(150);
    mRotateAnimation.setFillAfter(true);

    mIsDefaultHeadView = true;
}

From source file:com.juick.android.MessagesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final ViewConfiguration configuration = ViewConfiguration.get(getActivity());
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
    databaseGetter = new Utils.ServiceGetter<DatabaseService>(getActivity(), DatabaseService.class);
    handler = new Handler();
    sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    trackLastRead = sp.getBoolean("lastReadMessages", true);
    alternativeLongClick = sp.getBoolean("alternativeLongClick", false);

    Bundle args = getArguments();//from  ww  w. j  a  v a2 s  .  c om

    if (args != null) {
        messagesSource = (MessagesSource) args.getSerializable("messagesSource");
    }

    if (messagesSource == null)
        messagesSource = new JuickCompatibleURLMessagesSource(getActivity(), "dummy");
    if (messagesSource.getContext() == null)
        messagesSource.setContext(JuickAdvancedApplication.instance);
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    if (Build.VERSION.SDK_INT >= 8) {
        mScaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener());
    }

}