List of usage examples for android.view.animation RotateAnimation RotateAnimation
public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
From source file:com.ottd.libs.ui.SwipeRefreshLayout.java
private void addDefaultHeadView(Context context) { mHeadView = LayoutInflater.from(context).inflate(R.layout.com_bihe0832_common_swipe_refresh, 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);/*from w ww. j a va 2s .c o m*/ 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.example.harris.onionweather.ui.swipe.SwipeRefreshLayout.java
private void addDefaultHeadView(Context context) { mHeadView = LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, 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);//from www . j a v a 2 s . co m 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.cmad.swipe.SwipeRefreshLayout.java
private void addDefaultHeadView(Context context) { // R.layout mHeadView = LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, 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);//from w w w . j av a 2s . co m 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:net.willwebberley.gowertides.ui.DayFragment.java
private void setWeatherInfo() { Weather weather = day.getWeather();/*from ww w.j a v a2 s. c om*/ String weather_description = weather.description; String unitType = prefs.getString("unitFormat", "true"); Boolean metric = false; if (unitType.equals("true")) { metric = true; } int max_temp = weather.getMaxTemp(metric); int min_temp = weather.getMinTemp(metric); int wind_speed = weather.getWindSpeed(metric); Double prep = weather.precipitation; String direction = weather.wind_direction; Spanned temp = null, wind = null; if (metric) { temp = Html.fromHtml("<b>" + min_temp + "°C - " + max_temp + "°C</b>"); wind = Html.fromHtml("<b>" + wind_speed + "km/h</b> from <b>" + direction + "</b>"); } else { temp = Html.fromHtml("<b>" + min_temp + "°F - " + max_temp + "°F</b>"); wind = Html.fromHtml("<b>" + wind_speed + "mph</b> from <b>" + direction + "</b>"); } Spanned precipitation = Html.fromHtml("<b>" + prep + "mm</b>"); ((TextView) layoutView.findViewById(R.id.weather_description)).setText(weather_description); ((TextView) layoutView.findViewById(R.id.weatherTemp)).setText(temp); ((TextView) layoutView.findViewById(R.id.weatherTemp)).setTextColor(Color.rgb(100, 100, 100)); ((TextView) layoutView.findViewById(R.id.weatherWind)).setText(wind); ((TextView) layoutView.findViewById(R.id.weatherWind)).setTextColor(Color.rgb(100, 100, 100)); ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setText(precipitation); ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setTextColor(Color.rgb(100, 100, 100)); String icon = weather.getWeatherIcon(); try { InputStream ims = getActivity().getAssets().open("icons/" + icon); Drawable d = Drawable.createFromStream(ims, null); ((ImageView) layoutView.findViewById(R.id.weatherIcon)).setImageDrawable(d); InputStream ims2 = getActivity().getAssets().open("icons/arrow.png"); Drawable d2 = Drawable.createFromStream(ims2, null); ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).setImageDrawable(d2); RotateAnimation rAnim = new RotateAnimation(0, weather.wind_degree, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rAnim.setDuration(500); rAnim.setFillEnabled(true); rAnim.setFillAfter(true); ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).startAnimation(rAnim); } catch (Exception e) { System.err.println(e); } }
From source file:org.bart452.runningshoesensor.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); requestPermission();/*from w w w. j a va 2s. c o m*/ context = getApplicationContext(); mHeaderImageView = (ImageView) findViewById(R.id.appBarIv); Picasso.with(context).load(R.drawable.sunset_road_landscape).into(mHeaderImageView); // Toolbar mToolbar = (Toolbar) findViewById(R.id.toolBar); setSupportActionBar(mToolbar); mCollapsingTb = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar); mCollapsingTb.setTitle("Shoe sensor"); mCollapsingTb.setExpandedTitleGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); // Bluetooth final BluetoothManager mBleMan = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBleAdapter = mBleMan.getAdapter(); mBleScanner = mBleAdapter.getBluetoothLeScanner(); mCharList = new ArrayList<>(); mBleSem = new Semaphore(1); mBleThread = new BleThread(mBleSem); mBleThread.start(); mBleReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) { if (mBleAdapter.getState() == BluetoothAdapter.STATE_ON) { Log.d(LOG_TAG, "BT ON"); mScanFab.setEnabled(true); if (mSnackBar != null) { if (mSnackBar.isShown()) mSnackBar.dismiss(); } } else { mScanFab.setEnabled(false); bleEnable(); } } } }; // Text mDevNameTv = (TextView) findViewById(R.id.devNameTv); mDevNameTv.setText(getString(R.string.device_name) + " No device found"); mRssiTv = (TextView) findViewById(R.id.rssiTv); mAddrTv = (TextView) findViewById(R.id.devAddrTv); // Buttons and switches mScanFab = (FloatingActionButton) findViewById(R.id.scanFab); mScanFab.setOnClickListener(this); mConnSwitch = (Switch) findViewById(R.id.connSwitch); mConnSwitch.setOnClickListener(this); //Graph mDataGraph = (GraphView) findViewById(R.id.dataGraph); mDataXSeries = new LineGraphSeries<>(); mDataYSeries = new LineGraphSeries<>(); mDataYSeries.setBackgroundColor(Color.RED); mDataGraph.addSeries(mDataXSeries); mDataGraph.addSeries(mDataYSeries); mDataGraph.getViewport().setXAxisBoundsManual(true); mDataGraph.getViewport().setMinX(0); mDataGraph.getViewport().setMaxX(20); // Animation mRotateAnim = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnim.setDuration(SCAN_PERIOD); mRotateAnim.setInterpolator(new LinearInterpolator()); bleEnable(); }
From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemActivity.java
private void startRefreshAnimation() { MenuItem item = mToolbar.getMenu().findItem(MENU_ITEM_REFRESH); if (item == null) { Log.e(TAG, "null"); return;//from w w w .j a va 2 s.co m } // define the animation for rotation Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setActionView(null); mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setIcon(R.drawable.ic_menu_refresh); } @Override public void onAnimationRepeat(Animation animation) { } }); ImageView imageView = new ImageView(this, null, android.R.style.Widget_Material_ActionButton); imageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu_refresh)); imageView.setPadding(31, imageView.getPaddingTop(), 32, imageView.getPaddingBottom()); imageView.startAnimation(animation); item.setActionView(imageView); }
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override public void onSensorChanged(SensorEvent event) { // get the angle around the z-axis rotated float degree = Math.round(event.values[0]); //tvHeading.setText("Heading: " + Float.toString(degree) + " degrees"); // create a rotation animation (reverse turn degree degrees) RotateAnimation ra = new RotateAnimation(currentDegree, degree, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // how long the animation will take place ra.setDuration(210);//from ww w . java 2 s . c o m // set the animation after the end of the reservation status ra.setFillAfter(true); // Start the animation image.startAnimation(ra); currentDegree = degree; editTextAngle.setText("AngleM : " + currentDegree + " DistM : " + distance + " GPSDir " + gpsDirection + " Dif " + diference + " Ponto " + index); }
From source file:com.example.android.tryanimationt.TryAnimationFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mCardView = (CardView) view.findViewById(R.id.cardview); fab1st = (android.widget.ImageButton) view.findViewById(R.id.fabBt); fab2nd = (android.widget.ImageButton) view.findViewById(R.id.fabBt2); fab3rd = (android.widget.ImageButton) view.findViewById(R.id.fab3); footer = view.findViewById(R.id.footer); animButtons(fab1st, true, 2500, 0);// www . jav a 2 s . c o m animButtons(fab2nd, true, 1000, 150); animButtons(fab3rd, true, 2000, 250); fab1st.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AnimatorSet animSet = new AnimatorSet(); ObjectAnimator anim2 = ObjectAnimator.ofFloat(fab1st, "rotationX", 0, 359); anim2.setDuration(1500); ObjectAnimator anim3 = ObjectAnimator.ofFloat(fab1st, "rotationY", 0, 359); anim3.setDuration(1500); ObjectAnimator animTrx = ObjectAnimator.ofFloat(fab1st, "translationX", 0, -20); animTrx.setDuration(2500); ObjectAnimator animTry = ObjectAnimator.ofFloat(fab1st, "translationY", 0, -20); animTry.setDuration(2500); animSet.setInterpolator(new BounceInterpolator()); animSet.playTogether(anim2, anim3, animTry, animTrx); animSet.start(); } }); fab1st.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab1st.setClipToOutline(true); final View vImage = view.findViewById(R.id.image); final View vCard = view.findViewById(R.id.cardview); final View vCardTextPart = view.findViewById(R.id.cardview_textpart2); final View vCardContentContainer = view.findViewById(R.id.cardContentContainer); vCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), // Now we provide a list of Pair items which contain the view we can transitioning // from, and the name of the view it is transitioning to, in the launched activity android.support.v4.util.Pair.create(vImage, "photo_hero"), android.support.v4.util.Pair.create(vCardTextPart, "sharedSceneTrasintionText")); Intent intent = new Intent(getActivity(), sceneTransitionActivity.class); intent.putExtra("photo_hero", R.drawable.image1); ActivityCompat.startActivity(getActivity(), intent, options.toBundle()); } }); fab2nd.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab2nd.setClipToOutline(true); final AnimationDrawable[] animDrawables = new AnimationDrawable[2]; animDrawables[0] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_off_to_on); animDrawables[1] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_on_to_off); animDrawables[0].setOneShot(true); animDrawables[1].setOneShot(true); fab2nd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int fab2InconIndex = mAnimationStateIndex; mAnimationStateIndex = (mAnimationStateIndex + 1) % 2; /*****************************************************/ // animate the card //final Animation myRotation = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_anim); //mCardView.startAnimation(myRotation); int start; int end; if (mAnimationStateIndex == 0) { start = Color.rgb(0x71, 0xc3, 0xde); end = Color.rgb(0x68, 0xe8, 0xee); } else { start = Color.rgb(0x68, 0xe8, 0xee); end = Color.rgb(0x71, 0xc3, 0xde); } AnimatorSet animSet = new AnimatorSet(); ValueAnimator valueAnimator = ObjectAnimator.ofInt(vCardContentContainer, "backgroundColor", start, end); valueAnimator.setInterpolator(new BounceInterpolator()); valueAnimator.setDuration(2000); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); } }); valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.setRadius(8); //mCardView.setElevation(0); } }); float rotateStart, rotateEnd; float scaleXStart, scaleXEnd; float rotateXStart, rotateXEnd; float rotateYStart, rotateYEnd; float transitionXStart, transitionXEnd; float transitionYStart, transitionYEnd; if (mAnimationStateIndex == 0) { rotateStart = 0f; rotateEnd = 80f; scaleXStart = 1f; scaleXEnd = 0.66f; rotateXStart = 0f; rotateXEnd = 30f; rotateYStart = 0f; rotateYEnd = 30f; transitionYStart = 0f; transitionYEnd = -100f; transitionXStart = 0f; transitionXEnd = 100f; } else { rotateStart = 80f; rotateEnd = 0f; scaleXStart = 0.66f; scaleXEnd = 1; rotateXStart = 30; rotateXEnd = 0f; rotateYStart = 30f; rotateYEnd = 0f; transitionYStart = -100f; transitionYEnd = 0f; transitionXStart = 100f; transitionXEnd = 0f; } ObjectAnimator anim = ObjectAnimator.ofFloat(mCardView, "rotation", rotateStart, rotateEnd); anim.setDuration(2000); ObjectAnimator anim1 = ObjectAnimator.ofFloat(mCardView, "scaleX", scaleXStart, scaleXEnd); anim1.setDuration(2000); ObjectAnimator anim2 = ObjectAnimator.ofFloat(mCardView, "rotationX", rotateXStart, rotateXEnd); anim2.setDuration(2000); ObjectAnimator anim3 = ObjectAnimator.ofFloat(mCardView, "rotationY", rotateYStart, rotateYEnd); anim3.setDuration(2000); ObjectAnimator animTry = ObjectAnimator.ofFloat(mCardView, "translationY", transitionYStart, transitionYEnd); animTry.setDuration(2000); ObjectAnimator animTrx = ObjectAnimator.ofFloat(mCardView, "translationX", transitionXStart, transitionXEnd); animTrx.setDuration(2000); animSet.setInterpolator(new BounceInterpolator()); animSet.playTogether(valueAnimator, anim, anim2, anim3, anim1, animTry, animTrx); float controlX1, controlY1, controlX2, controlY2; if (mAnimationStateIndex == 0) { controlX1 = 0f; controlY1 = 0.25f; controlX2 = 1; controlY2 = 1; } else { controlX1 = 1; controlY1 = 1; controlX2 = 0.25f; controlY2 = 1; } PathInterpolator pathInterpolator = new PathInterpolator(controlX1, controlY1, controlX2, controlY2); animTrx.setInterpolator(pathInterpolator); animSet.start(); /*****************************************************/ // animate rotate white button RotateAnimation r = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); r.setDuration(2000); r.setFillAfter(true); r.setInterpolator(new BounceInterpolator()); fab2nd.startAnimation(r); // change 2nd button image fab2nd.setImageDrawable(animDrawables[fab2InconIndex]); animDrawables[fab2InconIndex].start(); /*****************************************************/ // animate changing 3rd button image fab3rd.setImageDrawable(animDrawables[mAnimationStateIndex]); animDrawables[mAnimationStateIndex].start(); /*****************************************************/ // using AnimatedStateListDrawable to animate the 1st button image by its state { Drawable drawable = getActivity().getResources().getDrawable(R.drawable.icon_anim); fab1st.setImageDrawable(drawable); final int[] STATE_CHECKED = new int[] { android.R.attr.state_checked }; final int[] STATE_UNCHECKED = new int[] {}; // set state fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_UNCHECKED : STATE_CHECKED, false); drawable.jumpToCurrentState(); // change to state fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_CHECKED : STATE_UNCHECKED, false); } } }); fab3rd.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { int size = getResources().getDimensionPixelSize(R.dimen.fab_size); outline.setOval(0, 0, size, size); outline.setRoundRect(0, 0, size, size, size / 2); } }); fab3rd.setClipToOutline(true); final CheckBox circleFadeout = (CheckBox) view.findViewById(R.id.circleFadeout); circleFadeout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (((CheckBox) v).isChecked()) { } } }); final ImageButton vLogoBt = fab3rd; vLogoBt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { animButtons(fab1st, false, 2000, 0); animButtons(fab2nd, false, 600, 150); animButtons(fab3rd, false, 1500, 250); Handler delayHandler = new Handler(); delayHandler.postDelayed(new Runnable() { @Override public void run() { Intent logoIntent = new Intent(getActivity(), LogoActivity.class); logoIntent.putExtra(LogoActivity.LOGO_VIEW_IMAGE_FADEOUT, (circleFadeout.isChecked() ? 1 : 0)); logoIntent.putExtra(LogoActivity.LOGO_VIEW_TRANSTION_TYPE, logoActivityTransitionType); startActivityForResult(logoIntent, mRequestCode, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle()); } }, 1000); // footer slide down slideView(footer, false); } }); mRadioGrp = (RadioGroup) view.findViewById(R.id.radioGroup); mRadioGrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int selectedId = mRadioGrp.getCheckedRadioButtonId(); String transitionType = "using"; switch (selectedId) { case R.id.radioFade: logoActivityTransitionType = 0; transitionType = transitionType + " Fade"; break; case R.id.radioExplode: logoActivityTransitionType = 1; transitionType = transitionType + " Explode"; break; default: logoActivityTransitionType = 2; transitionType = transitionType + " Slide"; } mSwitcher.setText(transitionType + " transition"); } }); mSwitcher = (TextSwitcher) view.findViewById(R.id.textSwitcher); mSwitcher.setFactory(mFactory); Animation in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_top); Animation out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_top); mSwitcher.setInAnimation(in); mSwitcher.setOutAnimation(out); mSwitcher.setCurrentText("using Fade transition"); // footer slide up slideView(footer, true); }
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
private ImageView getRotationImage() { RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(1000L);//from ww w. jav a 2 s. c om rotateAnimation.setRepeatMode(Animation.INFINITE); rotateAnimation.setRepeatCount(Animation.INFINITE); rotateAnimation.setFillEnabled(false); rotateAnimation.setInterpolator(new LinearInterpolator()); Drawable drawable = MBResourceService.getInstance().getImageByID(_refreshToolDef.getIcon()); ImageView rotationImage = new ImageView(_context); rotationImage.setImageDrawable(drawable); rotationImage.setAnimation(rotateAnimation); return rotationImage; }
From source file:com.nextgis.mobile.fragment.LayersFragment.java
public void refresh(boolean start) { if (mSyncButton == null) { return;/* w w w . j a va 2 s. com*/ } if (start) { RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setFillAfter(true); rotateAnimation.setDuration(700); rotateAnimation.setRepeatCount(500); mSyncButton.startAnimation(rotateAnimation); } else { mSyncButton.clearAnimation(); } }