@Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mAdapter = new EventListArrayAdapter(getActivity(), R.layout.event_list_item, R.id.eventText);

    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(300);
    set.addAnimation(animation);
    animation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            -1.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f);
    animation.setDuration(300);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.3f);
    getListView().setLayoutAnimation(controller);
    setListAdapter(mAdapter);
  }
 @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);
 }
예제 #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings));

    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);
    set.addAnimation(animation); // 添加一个透明度变化的动画(加在arrayList里面)

    animation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            -1.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f);
    animation.setDuration(300);
    set.addAnimation(animation); // 添加一个翻转/平移的动画(加在arrayList里面)

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    ListView listView = getListView();
    listView.setLayoutAnimation(controller);
  }
  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());
  }
예제 #5
0
  @SuppressLint("InflateParams")
  private void initView(Context context) {
    // 初始情况,设置下拉刷新view高度为0
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0);
    mContainer =
        (RelativeLayout) 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 = (ProgressBar) findViewById(R.id.xlistview_header_progressbar);
    mHeaderTimeView = (TextView) findViewById(R.id.xlistview_header_time);
    mHeaderTimeLabel = (TextView) findViewById(R.id.xlistview_header_time_label);

    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);
  }
  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);
  }
  private void updateNextPrevControls() {
    boolean showPrev = mCurrentPosition > 0;
    boolean showNext = mCurrentPosition < mAllImages.getCount() - 1;

    boolean prevIsVisible = mPrevImageView.getVisibility() == View.VISIBLE;
    boolean nextIsVisible = mNextImageView.getVisibility() == View.VISIBLE;

    if (showPrev && !prevIsVisible) {
      Animation a = mShowPrevImageViewAnimation;
      a.setDuration(500);
      mPrevImageView.startAnimation(a);
      mPrevImageView.setVisibility(View.VISIBLE);
    } else if (!showPrev && prevIsVisible) {
      Animation a = mHidePrevImageViewAnimation;
      a.setDuration(500);
      mPrevImageView.startAnimation(a);
      mPrevImageView.setVisibility(View.GONE);
    }

    if (showNext && !nextIsVisible) {
      Animation a = mShowNextImageViewAnimation;
      a.setDuration(500);
      mNextImageView.startAnimation(a);
      mNextImageView.setVisibility(View.VISIBLE);
    } else if (!showNext && nextIsVisible) {
      Animation a = mHideNextImageViewAnimation;
      a.setDuration(500);
      mNextImageView.startAnimation(a);
      mNextImageView.setVisibility(View.GONE);
    }
  }
  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);

    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);

    mProgressBar.setImageResource(R.anim.loadmore_animation);
    animationDrawable = (AnimationDrawable) mProgressBar.getDrawable();
    animationDrawable.setOneShot(false);
  }
예제 #9
0
  private void init(Context context, View target, int tabIndex) {

    this.context = context;
    this.target = target;
    this.targetTabIndex = tabIndex;

    // apply defaults
    badgePosition = DEFAULT_POSITION;
    badgeMarginH = dipToPixels(DEFAULT_MARGIN_DIP);
    badgeMarginV = badgeMarginH;
    badgeColor = DEFAULT_BADGE_COLOR;

    setTypeface(Typeface.DEFAULT_BOLD);
    int paddingPixels = dipToPixels(DEFAULT_LR_PADDING_DIP);
    setPadding(paddingPixels, 0, paddingPixels, 0);
    setTextColor(DEFAULT_TEXT_COLOR);

    fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(200);

    fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(200);

    isShown = false;

    if (this.target != null) {
      applyTo(this.target);
    } else {
      show();
    }
  }
예제 #10
0
  public void showProgressBar() {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);
    set.addAnimation(animation);

    animation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            -1.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f);
    animation.setDuration(500);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    RelativeLayout loading = (RelativeLayout) findViewById(R.id.loading);
    loading.setVisibility(View.VISIBLE);
    loading.setLayoutAnimation(controller);
  }
예제 #11
0
  private void initView(Context context) {

    setOrientation(LinearLayout.VERTICAL);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    mContainer =
        (LinearLayout)
            LayoutInflater.from(context).inflate(R.layout.zlibrary_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 = (ProgressBar) findViewById(R.id.xlistview_header_progressbar);
    mProgressBar.setVisibility(View.INVISIBLE);

    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);
  }
예제 #12
0
  // AnimationSet as;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    words = getResources().getStringArray(R.array.quotes);
    _handler = new Handler();

    _quote = (TextSwitcher) findViewById(R.id.quote_text);

    _quote.setFactory(
        new ViewFactory() {
          public View makeView() {
            TextView quote = new TextView(getApplicationContext());
            quote.setGravity(Gravity.CENTER);
            quote.setTextColor(color.GhostWhite);
            quote.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large);
            quote.setTypeface(null, Typeface.ITALIC);
            return quote;
          }
        });

    in = new AlphaAnimation(0.0f, 1.0f);
    in.setDuration(2000);

    out = new AlphaAnimation(1.0f, 0.0f);
    out.setDuration(2000);

    _quote.setInAnimation(in);
    _quote.setOutAnimation(out);

    _handler.postDelayed(_updateQuoteTask, 0);
  }
예제 #13
0
  /**
   * 初始化
   *
   * @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);
    mProgressBar = (ProgressBar) findViewById(R.id.pull_to_refresh_header_progressbar);
    mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time);
    mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text);

    float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE
    float toDegree = -180f; // SUPPRESS CHECKSTYLE
    // 初始化旋转动画
    mRotateUpAnim =
        new RotateAnimation(
            0.0f,
            toDegree,
            Animation.RELATIVE_TO_SELF,
            pivotValue,
            Animation.RELATIVE_TO_SELF,
            pivotValue);
    mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateUpAnim.setFillAfter(true);
    mRotateDownAnim =
        new RotateAnimation(
            toDegree,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            pivotValue,
            Animation.RELATIVE_TO_SELF,
            pivotValue);
    mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateDownAnim.setFillAfter(true);
  }
예제 #14
0
 private void initAnimation() {
   mAnimationHide = new AlphaAnimation(1.0f, 0.0f);
   mAnimationHide.setInterpolator(new DecelerateInterpolator());
   mAnimationHide.setDuration(200);
   mAnimationShow = new AlphaAnimation(0.0f, 1.0f);
   mAnimationShow.setInterpolator(new AccelerateInterpolator());
   mAnimationShow.setDuration(600);
 }
예제 #15
0
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    float vx = Math.abs(velocityX); // 取其绝对值
    float vy = Math.abs(velocityY);
    // ----begin设置浮动框的弹出和收回--------------------
    if (vy > vx) {
      if (velocityY > 0) { // 设置弹出
        if (flag == false) {

          int height = myRelativeLayout.getHeight();
          Animation myTranslateAnimation = new TranslateAnimation(0, 0, -height, 0);
          myTranslateAnimation.setDuration(500);
          myRelativeLayout.setAnimation(myTranslateAnimation);
          myRelativeLayout.setVisibility(View.VISIBLE);

          flag = true;
        }

      } else if (velocityY < 0) { // 设置收回

        if (flag == true) {
          int height = myRelativeLayout.getHeight();
          Animation myTranslateAnimation = new TranslateAnimation(0, 0, 0, -height);
          myTranslateAnimation.setDuration(500);
          myRelativeLayout.setAnimation(myTranslateAnimation);
          myRelativeLayout.setVisibility(View.GONE);
          flag = false;
        }
      }

    } else
    // -----end设置浮动框的弹出和收回---------------------------------
    // -----begin设置左右滑动翻页-----------------------
    if (vx > vy) {
      if (velocityX > 0) { // 前一页
        if (myWebView.canGoBack()) {

          myWebView.goBack();

          int width = myWebView.getWidth();
          Animation myTranslateAnimation = new TranslateAnimation(0, width, 0, 0);
          myTranslateAnimation.setDuration(400);
          myWebView.setAnimation(myTranslateAnimation);
        }
      } else if (velocityX < 0) { // 后一页
        if (myWebView.canGoForward()) {

          myWebView.goForward();

          int width = myWebView.getWidth();
          Animation myTranslateAnimation = new TranslateAnimation(0, -width, 0, 0);
          myTranslateAnimation.setDuration(400);
          myWebView.setAnimation(myTranslateAnimation);
        }
      }
    }
    // -----end设置左右滑动翻页------------------------
    return false;
  }
예제 #16
0
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   //		initTitle();
   displayanimation = new AlphaAnimation(0.1f, 1.0f);
   displayanimation.setDuration(500);
   dismissanimation = new AlphaAnimation(1.0f, 0.1f);
   dismissanimation.setDuration(500);
 }
예제 #17
0
 /** 初始化动画 */
 private void initAnim() {
   mFadeIn = AnimationUtils.loadAnimation(Welcome_Guide.this, R.anim.v5_0_1_guide_welcome_fade_in);
   mFadeIn.setDuration(1000);
   mFadeInScale =
       AnimationUtils.loadAnimation(Welcome_Guide.this, R.anim.v5_0_1_guide_welcome_fade_in_scale);
   mFadeInScale.setDuration(6000);
   mFadeOut =
       AnimationUtils.loadAnimation(Welcome_Guide.this, R.anim.v5_0_1_guide_welcome_fade_out);
   mFadeOut.setDuration(1000);
 }
예제 #18
0
 // 确定进入\淡出动画
 private void initData() {
   mLeftInAnim = AnimationUtils.loadAnimation(mContext, R.anim.push_left_in);
   mLeftOutAnim = AnimationUtils.loadAnimation(mContext, R.anim.push_left_out);
   mRightInAnim = AnimationUtils.loadAnimation(mContext, R.anim.push_right_in);
   mRightOutAnim = AnimationUtils.loadAnimation(mContext, R.anim.push_right_out);
   mLeftInAnim.setDuration(mAnimationPeriod);
   mLeftOutAnim.setDuration(mAnimationPeriod);
   mRightInAnim.setDuration(mAnimationPeriod);
   mRightOutAnim.setDuration(mAnimationPeriod);
 }
  public void setContentEditingModeVisible(boolean isVisible) {
    if (!isAdded()) {
      return;
    }
    ActionBar actionBar = getActionBar();
    if (isVisible) {
      Animation fadeAnimation = new AlphaAnimation(1, 0);
      fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION);
      fadeAnimation.setAnimationListener(
          new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
              mTitleEditText.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
              mPostSettingsLinearLayout.setVisibility(View.GONE);
              mFormatBar.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}
          });

      mPostContentLinearLayout.startAnimation(fadeAnimation);
      if (actionBar != null) {
        actionBar.hide();
      }
    } else {
      mTitleEditText.setVisibility(View.VISIBLE);
      mFormatBar.setVisibility(View.GONE);
      Animation fadeAnimation = new AlphaAnimation(0, 1);
      fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION);
      fadeAnimation.setAnimationListener(
          new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              mPostSettingsLinearLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}
          });
      mPostContentLinearLayout.startAnimation(fadeAnimation);
      getActivity().invalidateOptionsMenu();
      if (actionBar != null) {
        actionBar.show();
      }
    }
  }
예제 #20
0
  /**
   * The function responsible for fade-in fade-out effect
   *
   * @imageView <-- The View which displays the images
   * @images[] <-- Holds R references to the images to display
   * @imageIndex <-- index of the first image to show in images[]
   * @forever <-- If equals true then after the last image it starts all over again with the first
   *     image resulting in an infinite loop. You have been warned.
   */
  private void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {

    int fadeInDuration = 800; // Configure time values here
    int timeBetween = 200;
    int fadeOutDuration = 400;

    // imageView.setVisibility(View.INVISIBLE);    //Visible or invisible by default - this will
    // apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    Animation fadeIn = new AlphaAnimation((float) 0.1, (float) 1.0);
    fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
    fadeIn.setDuration(fadeInDuration);
    Animation fadeOut = new AlphaAnimation((float) 1.0, (float) 1.0);
    fadeOut.setInterpolator(new AccelerateInterpolator()); // and this
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    AnimationSet animation = new AnimationSet(false); // change to false
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(
                  imageView,
                  images,
                  imageIndex + 1,
                  forever); // Calls itself until it gets to the end of the array
            } else {
              if (forever == true) {
                animate(
                    imageView, images, 0,
                    forever); // Calls itself to start the animation all over again in a loop if
                // forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub
          }

          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
          }
        });
  }
예제 #21
0
  /**
   * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code
   * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in
   * transition.
   *
   * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
   *
   * @param fromView the view transition away from
   * @param toView the view transition to
   * @param dir the flip direction
   * @param duration the transition duration in milliseconds
   * @param interpolator the interpolator to use (pass {@code null} to use the {@link
   *     AccelerateInterpolator} interpolator)
   * @return
   */
  public static Animation[] flipAnimation(
      final View fromView,
      final View toView,
      FlipDirection dir,
      long duration,
      Interpolator interpolator) {
    Animation[] result = new Animation[2];
    float centerX;
    float centerY;

    centerX = fromView.getWidth() / 2.0f;
    centerY = fromView.getHeight() / 2.0f;

    Animation outFlip =
        new FlipAnimation(
            dir.getStartDegreeForFirstView(),
            dir.getEndDegreeForFirstView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_DOWN);
    outFlip.setDuration(duration);
    outFlip.setFillAfter(true);
    outFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);

    AnimationSet outAnimation = new AnimationSet(true);
    outAnimation.addAnimation(outFlip);
    result[0] = outAnimation;

    // Uncomment the following if toView has its layout established (not the case if using
    // ViewFlipper and on first show)
    // centerX = toView.getWidth() / 2.0f;
    // centerY = toView.getHeight() / 2.0f;

    Animation inFlip =
        new FlipAnimation(
            dir.getStartDegreeForSecondView(),
            dir.getEndDegreeForSecondView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_UP);
    inFlip.setDuration(duration);
    inFlip.setFillAfter(true);
    inFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);
    inFlip.setStartOffset(duration);

    AnimationSet inAnimation = new AnimationSet(true);
    inAnimation.addAnimation(inFlip);
    result[1] = inAnimation;

    return result;
  }
예제 #22
0
  public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);

    int inAnimResId, outAnimResId;
    switch (mode) {
      case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
      default:
      case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation =
        new RotateAnimation(
            0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation =
        new RotateAnimation(
            -180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);
  }
예제 #23
0
  private void initSubViews() {
    mText = (TextView) findViewById(R.id.checkbox_txt);
    mImage = (ImageView) findViewById(R.id.checkbox_img);

    setOnClickListener(this);
    mDisabledAnim = new AlphaAnimation(0.4f, 0.4f);
    mDisabledAnim.setDuration(0);
    mDisabledAnim.setFillAfter(true);

    mEnabledAnim = new AlphaAnimation(1.0f, 1.0f);
    mEnabledAnim.setDuration(0);
    mEnabledAnim.setFillAfter(true);
  }
  private void setupText1Marquee() {
    final int duration = (int) (mText1Difference * MS_PER_PX);

    mMoveText1TextOut = new TranslateAnimation(0, -mText1Difference, 0, 0);
    mMoveText1TextOut.setDuration(duration);
    mMoveText1TextOut.setInterpolator(new LinearInterpolator());
    mMoveText1TextOut.setFillAfter(true);

    mMoveText1TextIn = new TranslateAnimation(-mText1Difference, 0, 0, 0);
    mMoveText1TextIn.setDuration(duration);
    mMoveText1TextIn.setStartOffset(PAUSE_BETWEEN_ANIMATIONS);
    mMoveText1TextIn.setInterpolator(new LinearInterpolator());
    mMoveText1TextIn.setFillAfter(true);

    mMoveText1TextOut.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {
            //                mMoveText1TextOutPlaying = true;
            expandTextView(mTextField1);
          }

          public void onAnimationEnd(Animation animation) {
            //                mMoveText1TextOutPlaying = false;

            if (mCancelled) {
              return;
            }

            mTextField1.startAnimation(mMoveText1TextIn);
          }

          public void onAnimationRepeat(Animation animation) {}
        });

    mMoveText1TextIn.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {}

          public void onAnimationEnd(Animation animation) {

            cutTextView(mTextField1);

            if (mCancelled) {
              return;
            }
            startTextField1Animation();
          }

          public void onAnimationRepeat(Animation animation) {}
        });
  }
예제 #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.skinresult1);

    image1 = (ImageView) findViewById(R.id.image1);
    image2 = (ImageView) findViewById(R.id.image2);
    image3 = (ImageView) findViewById(R.id.image3);
    image4 = (ImageView) findViewById(R.id.image4);

    int width = 400;
    int height = 370;
    Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.apimage1);
    Bitmap bmp2 = BitmapFactory.decodeResource(getResources(), R.drawable.apimage2);
    Bitmap bmp3 = BitmapFactory.decodeResource(getResources(), R.drawable.apimage3);
    Bitmap bmp4 = BitmapFactory.decodeResource(getResources(), R.drawable.apimage4);

    Bitmap resizedbitmap1 = Bitmap.createScaledBitmap(bmp1, width, height, true);
    Bitmap resizedbitmap2 = Bitmap.createScaledBitmap(bmp2, width, height, true);
    Bitmap resizedbitmap3 = Bitmap.createScaledBitmap(bmp3, width, height, true);
    Bitmap resizedbitmap4 = Bitmap.createScaledBitmap(bmp4, width, height, true);
    image1.setImageBitmap(resizedbitmap1);
    image2.setImageBitmap(resizedbitmap2);
    image3.setImageBitmap(resizedbitmap3);
    image4.setImageBitmap(resizedbitmap4);

    animationSlideInLeft = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    animationSlideOutRight = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right);
    animationSlideInLeft.setDuration(2000);
    animationSlideOutRight.setDuration(4000);
    animationSlideInLeft.setAnimationListener(animationSlideInLeftListener);
    animationSlideOutRight.setAnimationListener(animationSlideOutRightListener);

    curSlidingImage = image1;
    image1.startAnimation(animationSlideInLeft);
    image1.setVisibility(View.VISIBLE);

    Button button2 = (Button) findViewById(R.id.go_buy);
    button2.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent openBrowser =
                new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse(
                        "http://www.amorepacificmall.com/main.do?source=https://www.google.co.kr/"));
            startActivity(openBrowser);
          }
        });
  }
예제 #26
0
  private void initAnim() {

    long duration = 300;
    long durationS = 160;
    float alpha = 0.3f;
    AccelerateInterpolator accInterpolator = new AccelerateInterpolator();

    tab_left = new TranslateAnimation(tabW, 0, 0, 0);
    tab_right = new TranslateAnimation(0, tabW, 0, 0);
    tab_alpha_1 = new AlphaAnimation(1.0f, alpha);
    tab_alpha_2 = new AlphaAnimation(alpha, 1.0f);
    pop_in =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    pop_out =
        new ScaleAnimation(
            1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);

    pop_in.setDuration(durationS);
    pop_in.setInterpolator(accInterpolator);
    pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN));

    pop_out.setDuration(durationS);
    pop_out.setInterpolator(accInterpolator);
    pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT));

    tab_left.setFillAfter(true);
    tab_left.setFillEnabled(true);
    tab_left.setDuration(duration);
    tab_left.setInterpolator(accInterpolator);

    tab_right.setFillAfter(true);
    tab_right.setFillEnabled(true);
    tab_right.setDuration(duration);
    tab_right.setInterpolator(accInterpolator);

    tab_alpha_1.setFillAfter(true);
    tab_alpha_1.setFillEnabled(true);
    tab_alpha_1.setDuration(duration);
    tab_alpha_1.setInterpolator(accInterpolator);

    tab_alpha_2.setFillAfter(true);
    tab_alpha_2.setFillEnabled(true);
    tab_alpha_2.setDuration(duration);
    tab_alpha_2.setInterpolator(accInterpolator);

    AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha);
    alphaInit.setFillAfter(true);
    alphaInit.setFillEnabled(true);
    tv_tab_box.startAnimation(alphaInit);
  }
  /**
   * Code from http://stackoverflow.com/a/10471479/3399351
   *
   * <p>Cycles through an array of images in one ImageView, sequentially fading them out and fading
   * the new photo in.
   *
   * @param imageView ImageView : The View which displays the images
   * @param images int[] : Holds R references to the images to display
   * @param imageIndex int : index of the first image to show in images[]
   * @param forever boolean : If equals true than it loops back to the first image
   */
  public static void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {
    // TODO: Smooth fade between images instead of fade through white
    int fadeInDuration = 500; // Configure time values here
    int timeBetween = 5000;
    int fadeOutDuration = 1000;

    imageView.setVisibility(View.VISIBLE);
    // Visible or invisible by default - this will apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    // Initialize the fade in animation
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(fadeInDuration);

    // Initialize the fade out animation
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    // Apply the animation set
    AnimationSet animation = new AnimationSet(false);
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    // Overriding this function causes the animations to loop
    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(imageView, images, imageIndex + 1, forever);
              // Calls itself until it gets to the end of the array
              if (forever) {
                animate(imageView, images, 0, forever);
                // Calls itself to start the animation
                // all over again in a loop, if forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationStart(Animation animation) {}
        });
  }
예제 #28
0
 public void setAnimationPeroid(int period) {
   if (period > 0) {
     mAnimationPeriod = period;
     mLeftInAnim.setDuration(period);
     mLeftOutAnim.setDuration(period);
     mRightInAnim.setDuration(period);
     mRightOutAnim.setDuration(period);
   } else {
     try {
       throw new Throwable("Please set right animation period");
     } catch (Throwable throwable) {
       throwable.printStackTrace();
     }
   }
 }
예제 #29
0
  /*
  * TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
  *
  * float fromXDelta:这个参数表示动画开始的点离当前View X坐标上的差值;
     *
         * float toXDelta, 这个参数表示动画结束的点离当前View X坐标上的差值;
     *
         * float fromYDelta, 这个参数表示动画开始的点离当前View Y坐标上的差值;
     *
         * float toYDelta)这个参数表示动画开始的点离当前View Y坐标上的差值;
  */
  protected Animation animTranslate(
      float toX,
      float toY,
      final int lastX,
      final int lastY,
      final Button button,
      long durationMillis) {
    animationTranslate = new TranslateAnimation(0, toX, 0, toY);
    animationTranslate.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            params = new LayoutParams(0, 0);
            params.height = 50;
            params.width = 50;
            params.setMargins(lastX, lastY, 0, 0);
            button.setLayoutParams(params);
            button.clearAnimation();
          }
        });
    animationTranslate.setDuration(durationMillis);
    return animationTranslate;
  }
  public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
              v.setVisibility(View.GONE);
            } else {
              v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
              v.requestLayout();
            }
          }

          @Override
          public boolean willChangeBounds() {
            return true;
          }
        };

    // 1dp/ms
    a.setDuration(
        (int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
  }