List of usage examples for android.view.animation RotateAnimation setDuration
public void setDuration(long durationMillis)
From source file:org.videolan.myvlc.core.gui.about.AboutMainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about_main, container, false); 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"); String revision = Util.readAsset("revision.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.ja v a2 s.c om*/ 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); } }); return v; }
From source file:MainActivity.java
private void calculateCompassDirection(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: mAccelerationValues = event.values.clone(); break;//from w w w. j a v a2 s.com case Sensor.TYPE_MAGNETIC_FIELD: mGravityValues = event.values.clone(); break; } boolean success = SensorManager.getRotationMatrix(mRotationMatrix, null, mAccelerationValues, mGravityValues); if (success) { float[] orientationValues = new float[3]; SensorManager.getOrientation(mRotationMatrix, orientationValues); float azimuth = (float) Math.toDegrees(-orientationValues[0]); RotateAnimation rotateAnimation = new RotateAnimation(mLastDirectionInDegrees, azimuth, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(50); rotateAnimation.setFillAfter(true); mImageViewCompass.startAnimation(rotateAnimation); mLastDirectionInDegrees = azimuth; } }
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//from w w w . jav a 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.onebusaway.android.ui.ArrivalsListHeader.java
/** * Creates and returns a new rotation animation for the expand/collapse image based on the * provided startState and endState.//from w w w .j av a 2 s .c o m * * @param startState beginning state of the image, either ANIM_STATE_NORMAL or * ANIM_STATE_INVERTED * @param endState end state of the image, either ANIM_STATE_NORMAL or ANIM_STATE_INVERTED * @return a new rotation animation for the expand/collapse image */ private static RotateAnimation getRotation(float startState, float endState) { RotateAnimation r = new RotateAnimation(startState, endState, Animation.RELATIVE_TO_SELF, ANIM_PIVOT_VALUE, Animation.RELATIVE_TO_SELF, ANIM_PIVOT_VALUE); r.setDuration(ANIM_DURATION); r.setFillAfter(true); return r; }
From source file:com.actionbarsherlock.sample.styledactionbar.MainActivity.java
private void rotateLeftFrag() { if (leftFrag != null) { if (IS_HONEYCOMB) { ObjectAnimatorRotate.invoke(leftFrag.getView()); } else {/* w w w .j a v a 2 s . c om*/ RotateAnimation rotate = new RotateAnimation(0, 180, leftFrag.getView().getWidth() / 2.0f, leftFrag.getView().getHeight() / 2.0f); rotate.setDuration(500); leftFrag.getView().startAnimation(rotate); } } }
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 ww . ja va 2 s. c o 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:com.javadog.cgeowear.CompassActivity.java
/** * Handles rotation of the compass to a new direction. * * @param newDirectionRaw Direction to turn to, in degrees. *///ww w . j a v a2s .c o m 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.javadog.cgeowear.cgeoWear.java
/** * Handles rotation of the compass to a new direction. * * @param newDirection Direction to turn to, in degrees. *//*ww w. j a v a 2s . com*/ private void rotateCompass(float newDirection) { if (direction != newDirection) { RotateAnimation anim = new RotateAnimation(direction, newDirection, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setDuration(200l); anim.setFillAfter(true); iv_compass.startAnimation(anim); direction = newDirection; } }
From source file:io.realm.realmtasks.list.ItemViewHolder.java
public void setHintPanelVisible(boolean visible) { final int visibility = hintPanel.getVisibility(); boolean previousVisible = visibility == View.VISIBLE; if (previousVisible == visible) { return;//from ww w . ja va2 s . co m } if (visible) { hintPanel.setVisibility(View.VISIBLE); final AlphaAnimation alphaAnimation = new AlphaAnimation(0.2f, 1.0f); alphaAnimation.setDuration(150); hintPanel.setAnimation(alphaAnimation); final RotateAnimation rotateAnimation = new RotateAnimation(-90, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(500); arrow.startAnimation(rotateAnimation); } else { hintPanel.setVisibility(View.GONE); } }
From source file:org.runbuddy.tomahawk.views.PageIndicator.java
private void rotateArrow(View arrow, boolean reverse) { RotateAnimation rotate; if (reverse) { rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);//from ww w. ja v a 2s .c om } 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); }