private void moveLeft(cgCacheView holder, cgCache cache, boolean force) { if (cache == null) { return; } holder.checkbox.setChecked(cache.isStatusChecked()); // slide cache info final Animation hideCheckbox = new TranslateAnimation((int) (SWIPE_DISTANCE * pixelDensity), 0, 0, 0); hideCheckbox.setRepeatCount(0); hideCheckbox.setDuration(force ? 0 : 400); hideCheckbox.setFillEnabled(true); hideCheckbox.setFillAfter(true); hideCheckbox.setInterpolator(new AccelerateDecelerateInterpolator()); // brighten cache info final Animation brightenInfo = new AlphaAnimation(SWIPE_OPACITY, 1.0f); brightenInfo.setRepeatCount(0); brightenInfo.setDuration(force ? 0 : 400); brightenInfo.setFillEnabled(true); brightenInfo.setFillAfter(true); brightenInfo.setInterpolator(new AccelerateDecelerateInterpolator()); // animation set (container) final AnimationSet selectAnimation = new AnimationSet(true); selectAnimation.setFillEnabled(true); selectAnimation.setFillAfter(true); selectAnimation.addAnimation(hideCheckbox); selectAnimation.addAnimation(brightenInfo); holder.oneInfo.startAnimation(selectAnimation); cache.setStatusCheckedView(false); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); filenameList = new ArrayList<String>(); quizCountriesList = new ArrayList<String>(); regionsMap = new HashMap<String, Boolean>(); guessRows = 1; random = new Random(); handler = new Handler(); shakeAnimation = AnimationUtils.loadAnimation(this, R.anim.incorrect_shake); shakeAnimation.setRepeatCount(3); String[] regionNames = getResources().getStringArray(R.array.regionsList); for (String region : regionNames) { regionsMap.put(region, true); } questionNumberTextView = (TextView) findViewById(R.id.questionNumberTextView); flagImageView = (ImageView) findViewById(R.id.flagImageView); buttonTableLayout = (TableLayout) findViewById(R.id.buttonTableLayout); answerTextView = (TextView) findViewById(R.id.answerTextView); questionNumberTextView.setText( getResources().getString(R.string.question) + " 1 " + getResources().getString(R.string.of) + " 10 "); resetQuiz(); }
private void setStartMode(Animation animation) { String repeat = (String) repeatModes.getSelectedItem(); switch (repeat) { case "restart": animation.setRepeatCount(1); break; case "infinite": animation.setRepeatCount(Animation.INFINITE); break; case "reverse": animation.setRepeatMode(Animation.REVERSE); animation.setRepeatCount(1); break; } }
/** * 初始化 * * @param context context */ private void init(Context context) { mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content); mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow); mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview); mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time); mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text); mArrowImageView.setScaleType(ScaleType.CENTER); mArrowImageView.setImageResource(R.drawable.default_ptr_rotate); float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE float toDegree = 720.0f; // SUPPRESS CHECKSTYLE mRotateAnimation = new RotateAnimation( 0.0f, toDegree, Animation.RELATIVE_TO_SELF, pivotValue, Animation.RELATIVE_TO_SELF, pivotValue); mRotateAnimation.setFillAfter(true); mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
private void initView(Context context) { // 初始情况,设置下拉刷新view高度为0 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0); mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.xlistview_header, null); addView(mContainer, lp); setGravity(Gravity.BOTTOM); mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow); mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview); mProgressBar = (ImageView) findViewById(R.id.xlistview_header_progressbar); mProgressBar.setVisibility(View.GONE); mRotateUpAnim = new RotateAnimation( 0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); mLoadingAni = new RotateAnimation( 0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mLoadingAni.setDuration(1000); mLoadingAni.setRepeatCount(Animation.INFINITE); mLoadingAni.setRepeatMode(Animation.RESTART); mLoadingAni.setInterpolator(new LinearInterpolator()); }
// para animar el imageButton public void startAnimation(ImageView ivDH) { Animation rotateAnim = new RotateAnimation(0, 360); rotateAnim.setDuration(5000); rotateAnim.setRepeatCount(1); rotateAnim.setInterpolator(new AccelerateInterpolator()); rotateAnim.setRepeatMode(Animation.REVERSE); ivDH.startAnimation(rotateAnim); }
public Animation getBlinkAnimation() { Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible animation.setDuration(600); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode( Animation.REVERSE); // Reverse animation at the end so the button will fade back in return animation; }
private void startRefreshAnimation() { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ImageView iv = (ImageView) inflater.inflate(R.layout.refreshing_layout, null); Animation rotation = AnimationUtils.loadAnimation(context, R.anim.refresh_rotate); rotation.setRepeatCount(Animation.INFINITE); iv.startAnimation(rotation); refreshItem.setActionView(iv); }
/** * 得到自定义的progressDialog * * @param context * @return */ @SuppressWarnings("deprecation") public static Dialog createLoadingDialog( Context context, String loadingText, boolean cancelable) { LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.loading_dialog, null); // 得到加载view LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view); // 加载布局 // main.xml中的ImageView ImageView outerImg = (ImageView) v.findViewById(R.id.loading_img_outer); ImageView innerImg = (ImageView) v.findViewById(R.id.loading_img_inner); // 加载动画 Animation outerRotateAnimation = new RotateAnimation( 0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); outerRotateAnimation.setRepeatCount(-1); outerRotateAnimation.setDuration(1000); outerRotateAnimation.setInterpolator(new LinearInterpolator()); Animation innerRotateAnimation = new RotateAnimation( 360, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); innerRotateAnimation.setRepeatCount(-1); innerRotateAnimation.setDuration(1300); innerRotateAnimation.setInterpolator(new LinearInterpolator()); // 使用ImageView显示动画 outerImg.startAnimation(outerRotateAnimation); innerImg.startAnimation(innerRotateAnimation); TextView loadingTextView = (TextView) v.findViewById(R.id.loading_text); loadingTextView.setText("" + loadingText); Dialog loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog loadingDialog.setCancelable(cancelable); // 不可以用“返回键”取消 loadingDialog.setContentView( layout, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); // 设置布局 return loadingDialog; }
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
public void balance() { Animation an = new RotateAnimation( 0, -1 * parent.get_pinnded_childs_rotation_angle(), this.getHeight() / 2, this.getWidth() / 2); an.setDuration(300); // duration in ms an.setRepeatCount(0); // -1 = infinite repeated an.setRepeatMode(Animation.REVERSE); // reverses each repeat an.setFillAfter(true); this.setAnimation(an); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (convertView == null) { v = inflater.inflate(R.layout.list_radio_item, null); } ImageView stt = (ImageView) v.findViewById(R.id.imageViewRadioStat); TextView tvNama = (TextView) v.findViewById(R.id.textViewNamaRadio); TextView tvKota = (TextView) v.findViewById(R.id.textViewKota); ImageView blink = (ImageView) v.findViewById(R.id.imageViewRadioBlink); TextView tvStat = (TextView) v.findViewById(R.id.textViewStatus); Radio r = data.get(position); Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(500); anim.setStartOffset(200); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); if (url.equals(r.getUrl()) && isPlayed && serviceRunning && onRadio) { r.setPlayedAtm(true); r.setStatusMessage("Menjalankan"); isPlayed = false; } tvNama.setText(r.getNamaRadio()); // int c = tvNama.getTextColors().getDefaultColor(); tvKota.setText(r.getKota()); if (r.isPlayedAtm()) { tvNama.setTextColor(_ac.getResources().getColor(R.color.hijau_1)); stt.setImageResource(R.drawable.ic_radio_on); blink.setImageResource(R.drawable.lingkaran_kecil); blink.startAnimation(anim); tvStat.setText(r.getStatusMessage()); tvStat.startAnimation(anim); } else { tvNama.setTextColor(Color.WHITE); stt.setImageResource(R.drawable.ic_radio_off); blink.setImageResource(android.R.color.transparent); blink.clearAnimation(); if (r.getStatusMessage().equalsIgnoreCase("Error")) { tvStat.setText("Tidak ada koneksi."); } else { tvStat.setText(""); } tvStat.clearAnimation(); } return v; }
/** 初始化 */ public void init() { baseGestureLockView = (BaseGestureLockView) findViewById(R.id.gestureLockView); gesture_set_textview = (TextView) findViewById(R.id.gesture_set_textview); animation = new TranslateAnimation(-20, 20, 0, 0); animation.setDuration(50); animation.setRepeatCount(2); animation.setRepeatMode(Animation.REVERSE); TextView login_by_text = (TextView) findViewById(R.id.login_by_text); login_by_text.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO 自动生成的方法存根 Intent intent2 = new Intent(); intent2.setClass(mContext, BaseLoginActivity.class); startActivity(intent2); finish(); } }); // final String handPassword = SharePreferenceUtil.getString(mContext, "handpassword", ""); final String loginName = SharePreferenceUtil.getString(mContext, "loginName", ""); final String password = SharePreferenceUtil.getString(mContext, "password", ""); // 设置密码 baseGestureLockView.setKey(handPassword); // 手势完成后回调 baseGestureLockView.setOnGestureFinishListener( new OnGestureFinishListener() { @Override public void OnGestureFinish(boolean success, String key) { baseGestureLockView.clearPassWord(); if (success) { mdialog = UtilsTool.initProgressDialog(mContext, "请稍等....."); mdialog.show(); UserLoginResult userloginresult = new UserLoginResult(); userloginresult.execute(mdialog, loginName, password); } else { gesture_set_textview.setTextColor(Color.parseColor("#FF2525")); gesture_set_textview.setVisibility(View.VISIBLE); gesture_set_textview.setText("密码错误!"); gesture_set_textview.startAnimation(animation); } } }); }
@Override public void onClick(View v) { if (v.getId() == R.id.iv_refresh) { // Do animation start Animation rotation = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_refresh); rotation.setRepeatCount(Animation.INFINITE); iv_refresh.startAnimation(rotation); if (AppFunctions.isNetworkAvailable(getActivity())) { new GetAdvicesTask(access_token, patientId).execute(); } else { iv_refresh.clearAnimation(); Toast.makeText(getActivity(), "Netwerk niet beschikbaar", Toast.LENGTH_SHORT).show(); } } }
/** Refresh the fragment's list */ public void refresh() { MobclickAgent.onEvent(this, "refresh"); mGaTracker.sendEvent("ui_action", "button_press", "refresh_button", new Long(12345)); /* Attach a rotating ImageView to the refresh item as an ActionView */ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_action_view, null); Animation rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_refresh); rotation.setRepeatCount(Animation.INFINITE); iv.startAnimation(rotation); mSGV.setVisibility(View.INVISIBLE); mProgress.setVisibility(View.VISIBLE); mRefreshItem.setActionView(iv); refreshGoodsItems(); }
public RotateLoadingLayout( Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) { super(context, mode, scrollDirection, attrs); mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true); mHeaderImage.setScaleType(ScaleType.MATRIX); mHeaderImageMatrix = new Matrix(); mHeaderImage.setImageMatrix(mHeaderImageMatrix); mRotateAnimation = new RotateAnimation( 0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
@Override protected View onCreateDialogView() { View dialogLayout = View.inflate(mContext, R.layout.dialog_sql_pref, null); // анимация поворота стрелки final Animation rotationAnim = AnimationUtils.loadAnimation(mContext, R.anim.rotate); rotationAnim.setRepeatCount(Animation.INFINITE); mInputServerName = (TextInputLayout) dialogLayout.findViewById(R.id.preference_item_sql_input_server); mServerName = mInputServerName.getEditText(); mCheckServerConnect = (ImageView) dialogLayout.findViewById(R.id.preference_item_sql_check_connect); mServerStatus = (ImageView) dialogLayout.findViewById(R.id.preference_item_sql_status); mServerName.setText(SharedPrefs.getServerName()); mCheckServerConnect.startAnimation(rotationAnim); connect(mServerName.getText().toString(), mCallback); mCheckServerConnect.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mInputServerName.getEditText().getText().length() == 0) { mInputServerName.setErrorEnabled(true); mInputServerName.setError( App.getAppContext().getString(R.string.input_sql_server_name_error)); } else { mCheckServerConnect.startAnimation(rotationAnim); connect(mServerName.getText().toString(), mCallback); } } }); // если android по 4.4 включительно, то включаем программное ускорение // иначе анимация не работает if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { mCheckServerConnect.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } return dialogLayout; }
@Override protected void onPostExecute(Void result) { vBody = textResult.split("<body>"); for (int i = 0; i < vBody.length; i++) { if (i == 1) { auxcad = vBody[1]; vBr = auxcad.split("<br>"); } } if (vBr.length >= 4) { for (int j = 0; j < 8; j++) { if (j == 0) { v2p = vBr[j].split(":"); scodqr = v2p[1]; } else if (j == 1) { v2p = vBr[j].split(":"); cConcepto = v2p[1]; byte[] bytes = new byte[] {}; try { bytes = cConcepto.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { cConcepto = new String(bytes, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } sconcepto = cConcepto; } else if (j == 2) { v2p = vBr[j].split(":"); cCanal = v2p[1]; } else if (j == 3) { v2p = vBr[j].split(":"); if (v2p.length > 2) { cResumen = v2p[1] + ":" + v2p[2]; } } else if (j == 4) { v2p = vBr[j].split(":"); if (v2p.length > 2) { cDDetallada = v2p[1] + ":" + v2p[2]; } } else if (j == 5) { v2p = vBr[j].split(":"); if (v2p.length > 2) { cImagen = v2p[1] + ":" + v2p[2]; imgManager.fetchDrawableOnThread(cImagen, img); } } } masinf.setVisibility(Button.VISIBLE); ira.setVisibility(Button.VISIBLE); Animation mAnimation = new AlphaAnimation(1, 0); mAnimation.setDuration(400); mAnimation.setInterpolator(new LinearInterpolator()); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.REVERSE); masinf.startAnimation(mAnimation); ira.startAnimation(mAnimation); mAnimation.setRepeatCount(3); if (!cURL.equals("")) { // new LeeConceptoTexto().execute(cURL); } else { tv2.setText("Estás en: " + "\n" + cConcepto); } if (!cResumen.equals("")) { new LeeResumenTexto().execute(cResumen); } else { tv3.setText("No se encontró información asociada al resumen"); } } else { tv3.setText("No se encontró información"); } Dialog.dismiss(); super.onPostExecute(result); }
private void setupAnimators() { final Ring ring = mRing; final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { if (mFinishing) { applyFinishTranslation(interpolatedTime, ring); } else { // The minProgressArc is calculated from 0 to create an // angle that // matches the stroke width. final float minProgressArc = (float) Math.toRadians( ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is // located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); if (mFinishing) { // finished closing the last ring from the swipe gesture; go // into progress mode mFinishing = false; animation.setDuration(ANIMATION_DURATION); ring.setShowArrow(false); } else { mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } } }); mAnimation = animation; }
public MaterialProgressDrawable(Context paramContext, View paramView) { this.mParent = paramView; this.mResources = paramContext.getResources(); this.mRing = new Ring(this.mCallback); this.mRing.setColors(this.COLORS); updateSizes(1); final Ring localRing = this.mRing; Animation local1 = new Animation() { public final void applyTransformation( float paramAnonymousFloat, Transformation paramAnonymousTransformation) { if (MaterialProgressDrawable.this.mFinishing) { MaterialProgressDrawable.access$000( MaterialProgressDrawable.this, paramAnonymousFloat, localRing); return; } float f1 = MaterialProgressDrawable.access$100$6f9943cf(localRing); float f2 = localRing.mStartingEndTrim; float f3 = localRing.mStartingStartTrim; float f4 = localRing.mStartingRotation; MaterialProgressDrawable.updateRingColor( MaterialProgressDrawable.this, paramAnonymousFloat, localRing); if (paramAnonymousFloat <= 0.5F) { float f10 = paramAnonymousFloat / 0.5F; float f11 = f3 + (0.8F - f1) * MaterialProgressDrawable.MATERIAL_INTERPOLATOR.getInterpolation(f10); localRing.setStartTrim(f11); } if (paramAnonymousFloat > 0.5F) { float f7 = 0.8F - f1; float f8 = (paramAnonymousFloat - 0.5F) / 0.5F; float f9 = f2 + f7 * MaterialProgressDrawable.MATERIAL_INTERPOLATOR.getInterpolation(f8); localRing.setEndTrim(f9); } float f5 = f4 + 0.25F * paramAnonymousFloat; localRing.setRotation(f5); float f6 = 216.0F * paramAnonymousFloat + 1080.0F * (MaterialProgressDrawable.this.mRotationCount / 5.0F); MaterialProgressDrawable.this.setRotation(f6); } }; local1.setRepeatCount(-1); local1.setRepeatMode(1); local1.setInterpolator(LINEAR_INTERPOLATOR); local1.setAnimationListener( new Animation.AnimationListener() { public final void onAnimationEnd(Animation paramAnonymousAnimation) {} public final void onAnimationRepeat(Animation paramAnonymousAnimation) { localRing.storeOriginals(); MaterialProgressDrawable.Ring localRing = localRing; localRing.setColorIndex(localRing.getNextColorIndex()); localRing.setStartTrim(localRing.mEndTrim); if (MaterialProgressDrawable.this.mFinishing) { MaterialProgressDrawable.this.mFinishing = false; paramAnonymousAnimation.setDuration(1332L); localRing.setShowArrow(false); return; } MaterialProgressDrawable.access$402( MaterialProgressDrawable.this, (1.0F + MaterialProgressDrawable.this.mRotationCount) % 5.0F); } public final void onAnimationStart(Animation paramAnonymousAnimation) { MaterialProgressDrawable.access$402(MaterialProgressDrawable.this, 0.0F); } }); this.mAnimation = local1; }
private void setupAnimators() { final Ring ring = mRing; final Animation finishRingAnimation = new Animation() { public void applyTransformation(float interpolatedTime, Transformation t) { // shrink back down and complete a full rotation before starting other circles // Rotation goes between [0..1]. float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f); final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime; ring.setStartTrim(startTrim); final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime); ring.setRotation(rotation); ring.setArrowScale(1 - interpolatedTime); } }; finishRingAnimation.setInterpolator(EASE_INTERPOLATOR); finishRingAnimation.setDuration(ANIMATION_DURATION / 2); finishRingAnimation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { ring.goToNextColor(); ring.storeOriginals(); ring.setShowArrow(false); mParent.startAnimation(mAnimation); } @Override public void onAnimationRepeat(Animation animation) {} }); final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // The minProgressArc is calculated from 0 to create an angle that // matches the stroke width. final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setDuration(ANIMATION_DURATION); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } }); mFinishAnimation = finishRingAnimation; mAnimation = animation; }
private void initAnimation() { // TODO Auto-generated method stub animationUp = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0.1f, Animation.RELATIVE_TO_SELF, -1); animationUp.setDuration(1000); animationUp.setRepeatCount(0); animationUp.setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation animation) { // TODO Auto-generated method stub infoHint.setVisibility(View.INVISIBLE); } }); animationDown = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0.1f); animationDown.setDuration(1000); animationDown.setRepeatCount(0); animationDown.setFillAfter(true); animationDown.setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub infoHint.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation animation) { // TODO Auto-generated method stub new Handler() .postDelayed( new Runnable() { @Override public void run() { // TODO Auto-generated method stub infoHint.startAnimation(animationUp); } }, 1000); } }); }