@Override
 public void run() {
   mReturningToStart = true;
   // Timeout fired since the user last moved their finger; animate the
   // trigger to 0 and put the target back at its original position
   if (mProgressBar != null || mProgressBarBottom != null) {
     mFromPercentage = mCurrPercentage;
     if (mDirection > 0 && ((mMode == Mode.PULL_FROM_START) || (mMode == Mode.BOTH))) {
       mShrinkTrigger.setDuration(mMediumAnimationDuration);
       mShrinkTrigger.setAnimationListener(mShrinkAnimationListener);
       mShrinkTrigger.reset();
       mShrinkTrigger.setInterpolator(mDecelerateInterpolator);
       startAnimation(mShrinkTrigger);
     } else if (mDirection < 0 && ((mMode == Mode.PULL_FROM_END) || (mMode == Mode.BOTH))) {
       mShrinkTriggerBottom.setDuration(mMediumAnimationDuration);
       mShrinkTriggerBottom.setAnimationListener(mShrinkAnimationListener);
       mShrinkTriggerBottom.reset();
       mShrinkTriggerBottom.setInterpolator(mDecelerateInterpolator);
       startAnimation(mShrinkTriggerBottom);
     }
   }
   mDirection = 0;
   animateOffsetToStartPosition(
       mCurrentTargetOffsetTop + getPaddingTop(), mReturnToStartPositionListener);
 }
Пример #2
0
  private synchronized void startAnimation() {
    isAnimating = true;
    if (mShowImageAnimation == null) {
      mShowImageAnimation = new AlphaAnimation(0, 1);
      mShowImageAnimation.setDuration(500);
      mShowImageAnimation.setAnimationListener(
          new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationRepeat(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              Log.e(TAG, "动画结束");
              isAnimating = false;
              doNextLoad();
            }
          });
    } else {
      Log.e(TAG, "重新设置动画");
      mShowImageAnimation.reset();
    }

    mCurrentLoadingImageView.imageView.startAnimation(mShowImageAnimation);
  }
Пример #3
0
  // animation
  public void anim(RelativeLayout l, int anim) {

    Animation anim_ee = AnimationUtils.loadAnimation(getApplicationContext(), anim);
    anim_ee.reset();
    l.setVisibility(View.VISIBLE);
    l.startAnimation(anim_ee);
  }
Пример #4
0
  private void remainingSecondsChanged(int newVal) {
    mRemainingSecs = newVal;
    if (newVal == 0) {
      // Countdown has finished
      setVisibility(View.INVISIBLE);
      if (mListener != null) mListener.onCountDownFinished();
    } else {
      Locale locale = getResources().getConfiguration().locale;
      String localizedValue = String.format(locale, "%d", newVal);
      mRemainingSecondsView.setText(localizedValue);
      // Fade-out animation
      mCountDownAnim.reset();
      mRemainingSecondsView.clearAnimation();
      mRemainingSecondsView.startAnimation(mCountDownAnim);

      // Play sound effect for the last 3 seconds of the countdown
      //			if (mPlaySound) {
      //				if (newVal == 1) {
      //					mSoundPool.play(mBeepTwice, 1.0f, 1.0f, 0, 0, 1.0f);
      //				} else if (newVal <= 3) {
      //					mSoundPool.play(mBeepOnce, 1.0f, 1.0f, 0, 0, 1.0f);
      //				}
      //			}
      // Schedule the next remainingSecondsChanged() call in 1 second
      mHandler.sendEmptyMessageDelayed(SET_TIMER_TEXT, 1000);
    }
  }
 private void runFadeInAnimation() {
   Animation a = AnimationUtils.loadAnimation(this, R.anim.fadein);
   a.reset();
   LinearLayout ll = (LinearLayout) findViewById(R.id.categories);
   ll.clearAnimation();
   ll.startAnimation(a);
 }
Пример #6
0
 public void moverLogo() {
   Animation mover;
   mover = AnimationUtils.loadAnimation(this.getApplicationContext(), R.anim.mover);
   mover.reset();
   mover.setFillAfter(true);
   imgLogo.startAnimation(mover);
 }
Пример #7
0
 public void mostrarVistas(boolean state) {
   if (state) {
     Animation show;
     show = AnimationUtils.loadAnimation(this.getApplicationContext(), R.anim.fade);
     show.reset();
     contenedor_credenciales.startAnimation(show);
   }
 }
 // 对子控件进行移动
 private void animateOffsetToStartPosition(int from, AnimationListener listener) {
   mFrom = from;
   mAnimateToStartPosition.reset();
   mAnimateToStartPosition.setDuration(mMediumAnimationDuration);
   mAnimateToStartPosition.setAnimationListener(listener);
   mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
   mTarget.startAnimation(mAnimateToStartPosition);
 }
Пример #9
0
  protected void transitionIntoActivity(Intent i) {
    mTopElements.clearAnimation();
    mBottomElements.clearAnimation();

    mSlideOutAnim.reset();
    mSlideOutAnim.setAnimationListener(new StartActivityAfterAnimation(i));
    mTopElements.startAnimation(mSlideOutAnim);
    mBottomElements.startAnimation(mSlideOutAnim);
  }
Пример #10
0
  /** Disables the animations. */
  public void reset() {
    mCancelled = true;

    if (mAnimationStartRunnable != null) {
      removeCallbacks(mAnimationStartRunnable);
    }

    mTextField.clearAnimation();
    mStarted = false;

    mMoveTextOut.reset();
    mMoveTextIn.reset();

    //        mScrollView.removeView(mTextField);
    //        mScrollView.addView(mTextField);

    invalidate();
  }
  private void doAnimation() {

    if (mPreviousConfiguration == mCurrentConfiguration) return;

    switch (mCurrentConfiguration) {
      case CONFIG_MAIN_ONLY:
        switch (mPreviousConfiguration) {
          case CONFIG_LEFT_OPEN:
            mLeftView.startAnimation(mLeftViewGoOut);
            mMainView.startAnimation(mMainViewTranslateInFromRight);
            break;
          case CONFIG_RIGHT_OPEN:
            mRightView.startAnimation(mRightViewGoOut);
            mMainView.startAnimation(mMainViewTranslateInFromLeft);
            break;
        }
        break;
      case CONFIG_LEFT_OPEN:
        switch (mPreviousConfiguration) {
          case CONFIG_MAIN_ONLY:
            // main view translate from 0 to leftViewWidth
            mMainViewTranslateOutToRight.reset();
            mLeftViewTranslateIn.reset();

            mMainView.startAnimation(mMainViewTranslateOutToRight);
            // left view tranlsate from -leftViewWidth to 0
            mLeftView.startAnimation(mLeftViewTranslateIn);
            break;
        }
        break;
      case CONFIG_RIGHT_OPEN:
        switch (mPreviousConfiguration) {
          case CONFIG_MAIN_ONLY:
            // rightView translate from totalWidth to (totalWidth - rightViewWidth)
            mRightView.startAnimation(mRightViewTranslateIn);
            // mainView translate from 0 to -rightViewWidth
            mMainView.startAnimation(mMainViewTranslateOutToLeft);
            break;
        }
        break;
    }
  }
 private void peek(int from, AnimationListener listener) {
   mFrom = from;
   mPeek.reset();
   mPeek.setDuration(500);
   mPeek.setInterpolator(mDecelerateInterpolator);
   if (listener != null) {
     mCircleView.setAnimationListener(listener);
   }
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mPeek);
 }
 private void animateOffsetToCorrectPosition(int from, AnimationListener listener) {
   mFrom = from;
   mAnimateToCorrectPosition.reset();
   mAnimateToCorrectPosition.setDuration(ANIMATE_TO_TRIGGER_DURATION);
   mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator);
   if (listener != null) {
     mCircleView.setAnimationListener(listener);
   }
   mCircleView.clearAnimation();
   mCircleView.startAnimation(mAnimateToCorrectPosition);
 }
 @Override
 public void start() {
   mAnimation.reset();
   mRing.storeOriginals();
   // Already showing some part of the ring
   if (mRing.getEndTrim() != mRing.getStartTrim()) {
     mParent.startAnimation(mFinishAnimation);
   } else {
     mRing.setColorIndex(0);
     mRing.resetOriginals();
     mParent.startAnimation(mAnimation);
   }
 }
  public void reset() {
    Log.d(TAG, "Resetting animation.");

    mCancelled = true;

    if (mAnimation1StartRunnable != null) {
      removeCallbacks(mAnimation1StartRunnable);
    }

    mTextField1.clearAnimation();

    prepareTextFields();

    mMoveText1TextOut.reset();
    mMoveText1TextIn.reset();

    mScrollView1.removeView(mTextField1);
    mScrollView1.addView(mTextField1);

    mTextField1.setEllipsize(TextUtils.TruncateAt.END);

    invalidate();
  }
Пример #16
0
 @Override
 public void onBackPressed() {
   View dialogView = findViewById(R.id.dialogDatos);
   fullName = ((EditText) findViewById(R.id.textFullName)).getText().toString();
   if (validar()) {
     getValores();
     dialogRefresh.refresh(sexo, edad, _fuma, selectedProfesion, fullName);
     super.dismiss(dialogView);
   } else {
     Animation tween = AnimationUtils.loadAnimation(getContext(), R.anim.tilt);
     tween.reset();
     dialogView.clearAnimation();
     dialogView.startAnimation(tween);
   }
 }
 public void start()
 {
   mAnimation.reset();
   mRing.storeOriginals();
   if (mRing.getEndTrim() != mRing.getStartTrim())
   {
     mFinishing = true;
     mAnimation.setDuration(666L);
     mParent.startAnimation(mAnimation);
     return;
   }
   mRing.setColorIndex(0);
   mRing.resetOriginals();
   mAnimation.setDuration(1332L);
   mParent.startAnimation(mAnimation);
 }
 private void animateOffsetToStartPosition(int from, AnimationListener listener) {
   if (mScale) {
     // Scale the item back down
     startScaleDownReturnToStartAnimation(from, listener);
   } else {
     mFrom = from;
     mAnimateToStartPosition.reset();
     mAnimateToStartPosition.setDuration(ANIMATE_TO_START_DURATION);
     mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator);
     if (listener != null) {
       mCircleView.setAnimationListener(listener);
     }
     mCircleView.clearAnimation();
     mCircleView.startAnimation(mAnimateToStartPosition);
   }
 }
 @Override
 public void run() {
   mReturningToStart = true;
   // Timeout fired since the user last moved their finger; animate the
   // trigger to 0 and put the target back at its original position
   if (mProgressBar != null) {
     mFromPercentage = mCurrPercentage;
     mShrinkTrigger.setDuration(mMediumAnimationDuration);
     mShrinkTrigger.setAnimationListener(mShrinkAnimationListener);
     mShrinkTrigger.reset();
     mShrinkTrigger.setInterpolator(mDecelerateInterpolator);
     startAnimation(mShrinkTrigger);
   }
   animateOffsetToStartPosition(
       mCurrentTargetOffsetTop + getPaddingTop(), mReturnToStartPositionListener);
 }
  @Override
  public void start() {
    mAnimation.reset();
    mRing.storeOriginals();
    mRing.setShowArrow(mShowArrowOnFirstStart);

    // Already showing some part of the ring
    if (mRing.getEndTrim() != mRing.getStartTrim()) {
      mFinishing = true;
      mAnimation.setDuration(ANIMATION_DURATION / 2);
      mAnimExcutor.startAnimation(mAnimation);
    } else {
      mRing.setColorIndex(0);
      mRing.resetOriginals();
      mAnimation.setDuration(ANIMATION_DURATION);
      mAnimExcutor.startAnimation(mAnimation);
    }
  }
Пример #21
0
  /**
   * Method that creates the second animation which causes the animation to persist for two
   * seconds..
   */
  private void StartSecondAnimation() {
    Animation stay = AnimationUtils.loadAnimation(this, R.anim.alpha);
    stay.reset();
    LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
    l.clearAnimation();
    l.startAnimation(stay);

    stay.setAnimationListener(
        new Animation.AnimationListener() {

          /**
           * Method that does not do anything when the second animation starts.
           *
           * @param animation The second animation which causes image to persist.
           */
          @Override
          public void onAnimationStart(Animation animation) {}

          /**
           * Method that starts the main activity once the second animation is completed.
           *
           * @param animation The second animation which causes image to persist.
           */
          @Override
          public void onAnimationEnd(Animation animation) {
            finish();
            Intent intent = new Intent(SplashScreenActivity.this, IngredientSearch.class);
            startActivity(intent);
          }

          /**
           * Method that does not do anything to repeat the animation.
           *
           * @param animation The second animation which causes image to persist.
           */
          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
Пример #22
0
  /**
   * Method that creates the first animation which drags the activity_splashscreen screen from the
   * bottom to the top.
   */
  private void StartFirstAnimation() {
    Animation scrollUp = AnimationUtils.loadAnimation(this, R.anim.translate);
    scrollUp.reset();
    ImageView iv = (ImageView) findViewById(R.id.logo);
    iv.clearAnimation();
    iv.startAnimation(scrollUp);

    scrollUp.setAnimationListener(
        new Animation.AnimationListener() {

          /**
           * Method that does not do anything when the first animation starts.
           *
           * @param animation The first animation which scrolls up the page.
           */
          @Override
          public void onAnimationStart(Animation animation) {}

          /**
           * Method which starts the second animation after the first is completed.
           *
           * @param animation The first animation which scrolls up the page.
           */
          @Override
          public void onAnimationEnd(Animation animation) {
            StartSecondAnimation();
          }

          /**
           * Method that does not do anything to repeat the animation.
           *
           * @param animation The first animation which scrolls up the page.
           */
          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
 private void StartAnimations() {
   Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.translate);
   anim.reset();
   mViewLogo.clearAnimation();
   mViewLogo.startAnimation(anim);
 }
 public void reset() {
   super.reset();
   b = a.a.a();
   c = (a() - b);
 }
 @Override
 public void start() {
   mAnimation.reset();
   isRefreshing = true;
   mParent.startAnimation(mAnimation);
 }
Пример #26
0
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MessageWhat.NET_REQUEST_NUMBER:
       if (null == msg.obj) {
         break;
       }
       mInfoString = (String) msg.obj;
       mInfoTextView.setText(mInfoString);
       if (mType == PhoneReceiver.INCOMING_CALL_MSG) {
         // 来电播报
         if (BaseUtil.isWiredHeadsetOn(mContext)) {
           if (SharedPreferencesHelper.getInstance()
               .getBoolean(
                   SharedPreferencesHelper.SETTING_BROADCAST_WHEN_WIREDHEADSETON, true)) {
             broadcastContent(createCallBroadcastContent());
             // 日志
             LogOperate.updateLog(mContext, LogCode.CALL_BROADCAST);
           }
         }
       }
       String[] infosStrings = mInfoString.split(" ");
       String city = "";
       if (infosStrings.length == 1) {
         if (infosStrings[0].length() < 5) {
           city = infosStrings[0];
         }
       } else if (infosStrings.length == 2) {
         if (infosStrings[1].contains("中国")) {
           city = infosStrings[0];
         } else {
           city = infosStrings[1];
         }
       } else {
         city = infosStrings[1];
       }
       if (!StringUtil.isEmpty(city)) {
         BusinessHelper.getWeatherInfo(mContext, city, myHandler);
       }
       break;
     case MessageWhat.NET_REQUEST_WEATHER:
       if (null != msg.obj) {
         mWeatherTextView.setText((String) msg.obj);
         mWeatherTextView.setVisibility(View.VISIBLE);
       }
       break;
     case MessageWhat.CALL_RECORDS:
       if (null != msg.obj) {
         mRecordsTextView.setText((String) msg.obj);
       }
       break;
     case MessageWhat.MSG_SHOW_COMMENTS:
       if (null != msg.obj) {
         mCommentsArray = null;
         try {
           mCommentsArray = new JSONArray((String) msg.obj);
           if (mCommentsArray.length() > 0) {
             mFlashingIndex = -1;
             mCommentLayout.setVisibility(View.VISIBLE);
             showFlashComment();
           }
         } catch (JSONException e) {
           DebugLog.d(TAG, e.toString());
         }
       }
       break;
     case MSG_SHOW_ONE_COMMENT:
       if (null != msg.obj) {
         mCommentTextView.setText((String) msg.obj);
         mFlashingAnimation.reset();
         mCommentTextView.startAnimation(mFlashingAnimation);
       }
       break;
     case MSG_REMOVE:
       remove();
       break;
     case MessageWhat.MSG_LAST_RECORD_DATE:
       if (null != msg.obj) {
         mLastRecordTextView.setText((String) msg.obj);
         mLastRecordTextView.setVisibility(View.VISIBLE);
       }
       break;
     default:
       break;
   }
   super.handleMessage(msg);
 }
Пример #27
0
  public View getView(int position, View convertView, ViewGroup parent) {
    NodeViewHolder holder;

    if (convertView == null) {
      // ProgressBar sfumata
      final ShapeDrawable pgDrawable =
          new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
      final LinearGradient gradient =
          new LinearGradient(
              0,
              0,
              250,
              0,
              context.getResources().getColor(color.aa_red),
              context.getResources().getColor(color.aa_green),
              android.graphics.Shader.TileMode.CLAMP);

      convertView = mInflater.inflate(R.layout.listview, parent, false);
      holder = new NodeViewHolder();
      holder.text = (TextView) convertView.findViewById(R.id.TextView01);
      holder.textTyp = (TextView) convertView.findViewById(R.id.TextViewTypicals);
      holder.textHlt = (TextView) convertView.findViewById(R.id.TextViewHealth);
      holder.image = (ImageView) convertView.findViewById(R.id.node_icon);
      holder.hlt = (ProgressBar) convertView.findViewById(R.id.progressBarHealth);
      holder.hlt.setIndeterminate(false);
      holder.hlt.setMax(50);
      holder.hlt.setProgress(20);
      holder.hlt.setProgress(0);
      holder.hlt.setMax((int) Constants.MAX_HEALTH);
      holder.hlt.setBackgroundResource(android.R.drawable.progress_horizontal);
      holder.imageRes = nodi[position].getIconResourceId();
      // pgDrawable.getPaint().setStrokeWidth(3);
      pgDrawable.getPaint().setDither(true);
      pgDrawable.getPaint().setShader(gradient);

      ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);

      // Rect bounds = holder.hlt.getProgressDrawable().getBounds();
      holder.hlt.setProgressDrawable(progress);
      // holder.hlt.getProgressDrawable().setBounds(bounds);

      convertView.setTag(holder);
    } else {

      holder = (NodeViewHolder) convertView.getTag();
      // ClipDrawable progress = new ClipDrawable(pgDrawable,
      // Gravity.LEFT, ClipDrawable.HORIZONTAL);
      // holder.hlt.setProgressDrawable(progress);
    }
    holder.text.setText(nodi[position].getNiceName());
    // holder.text.setTextAppearance(context, R.style.CodeFontTitle);

    // Progress = health
    holder.hlt.setProgress(0);
    holder.hlt.setProgress(nodi[position].getHealth());
    /* Dimensioni del testo settate dalle opzioni */
    // holder.textTyp.setTextSize(TypedValue.COMPLEX_UNIT_SP,holder.textTyp.getTextSize()
    // + opzioni.getListDimensTesto());
    // holder.textTyp.setTextAppearance(context, R.style.CodeFontMain);

    holder.textTyp.setText(
        nodi[position].getActiveTypicals().size()
            + " "
            + context.getString(R.string.manual_typicals)
            + " - "
            + context.getString(R.string.update)
            + " "
            + Constants.getTimeAgo(nodi[position].getRefreshedAt()));

    if (opzioni.isLightThemeSelected()) {
      holder.textTyp.setTextColor(context.getResources().getColor(R.color.black));
      holder.text.setTextColor(context.getResources().getColor(R.color.black));
      holder.textHlt.setTextColor(context.getResources().getColor(R.color.black));
    }

    /* Icona del nodo */
    holder.image.setImageResource(holder.imageRes);

    if (opzioni.getTextFx()) {
      Animation a2 = AnimationUtils.loadAnimation(context, R.anim.alpha);
      a2.reset();
      // a2.setStartTime(System.currentTimeMillis() + 400 * position);
      a2.setStartOffset(250 * position);
      // Animazione immagine holder.image.clearAnimation();
      holder.image.startAnimation(a2);
      // holder.text.clearAnimation();
      // holder.text.startAnimation(a2);
    }

    holder.data = nodi[position];

    return convertView;
  }