Esempio n. 1
0
  private void showZoomedView() {
    // no animation if the zoomed view is already visible
    if (getVisibility() != View.VISIBLE) {
      final Animation anim =
          new ScaleAnimation(
              0f,
              1f, // Start and end values for the X axis scaling
              0f,
              1f, // Start and end values for the Y axis scaling
              Animation.ABSOLUTE,
              animationStart.x, // Pivot point of X scaling
              Animation.ABSOLUTE,
              animationStart.y); // Pivot point of Y scaling
      anim.setFillAfter(true); // Needed to keep the result of the animation
      anim.setDuration(OPENING_ANIMATION_DURATION_MS);
      anim.setInterpolator(new OvershootInterpolator(OVERSHOOT_INTERPOLATOR_TENSION));
      anim.setAnimationListener(
          new AnimationListener() {
            public void onAnimationEnd(Animation animation) {
              setListeners();
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationStart(Animation animation) {
              removeListeners();
            }
          });
      setAnimation(anim);
    }
    setVisibility(View.VISIBLE);
    shouldSetVisibleOnUpdate = false;
  }
  public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height =
                interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
          }

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

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
  }
Esempio n. 3
0
  private Animation buildFlipAnimation(
      final LinearLayout currentUpper,
      final LinearLayout currentBottom,
      final LinearLayout nextUpper,
      final LinearLayout nextBottom,
      final boolean forward) {
    final float centerY = 240;
    final float centerX = 160;

    long duration = getFlipDurationFromPreference();

    verticalAnimationStep1 =
        forward
            ? AnimationFactory.buildVerticalFlipAnimation(
                0, 90, duration, centerX, 0, shadow, shadow2)
            : AnimationFactory.buildVerticalFlipAnimation(
                0, -90, duration, centerX, centerY, shadow, shadow2);

    verticalAnimationStep2 =
        forward
            ? AnimationFactory.buildVerticalFlipAnimation(
                -90, 0, duration, centerX, centerY, shadow, shadow2)
            : AnimationFactory.buildVerticalFlipAnimation(
                90, 0, duration, centerX, 0, shadow, shadow2);

    verticalAnimationStep2.setAnimationListener(verticalAnimationListenerStep2);

    verticalAnimationStep1.setAnimationListener(verticalAnimationListenerStep1);
    // Log.d("ANI", "currentBottom");
    return verticalAnimationStep1;
  }
Esempio n. 4
0
  public void load() {
    final View view = View.inflate(this, R.layout.activity_start, null);
    setContentView(view);
    loadingImg = (ImageView) view.findViewById(R.id.imageView2);

    // ½¥±ä´ó չʾÆô¶¯ÆÁ
    Animation aa = AnimationUtils.loadAnimation(this, R.anim.entrance);
    aa.setDuration(2000);
    aa.setAnimationListener(
        new AnimationListener() {
          @Override
          public void onAnimationEnd(Animation arg0) {
            startActivity(new Intent(StartActivity.this, ActivityMain.class));
            StartActivity.this.finish();

            // ¼ì²é¸üÐÂ
            //				Api.get().sendPost(UrlEntry.CHECK_VERSION_URL, new RequestParams(), mHandler, 2);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationStart(Animation animation) {}
        });
    loadingImg.startAnimation(aa);
  }
Esempio n. 5
0
        @Override
        public void onClick(View v) {
          if (refreshing) return;
          Animation operatingAnim =
              AnimationUtils.loadAnimation(getActivity(), R.anim.refresh_route);
          LinearInterpolator lin = new LinearInterpolator();
          operatingAnim.setInterpolator(lin);
          if (operatingAnim != null) {
            v.startAnimation(operatingAnim);
          }

          swipeRefreshLayout.setRefreshing(true);

          mListView.post(
              new Runnable() {
                @Override
                public void run() {
                  mListView.smoothScrollToPosition(0);
                }
              });

          mListView.postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  onRefresh();
                }
              },
              800);
        }
Esempio n. 6
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);
  }
  public static boolean expand(final View v, Activity activity) {
    if (isExtraServicesVisible) return false;

    final int targetHeight = AnimationManager.getHeightToExpand(65, activity, null);
    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height =
                interpolatedTime == 1 ? targetHeight : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
          }

          @Override
          public boolean willChangeBounds() {
            return true;
          }
        };
    a.setAnimationListener(
        new BaseAnimationListener() {
          @Override
          public void onAnimationEnd(Animation arg0) {
            isExtraServicesVisible = true;
          }
        });
    a.setDuration(SLIDE_UP_DURATION);
    v.startAnimation(a);
    return true;
  }
Esempio n. 8
0
  public void hideAutoLogin(boolean animate) {
    if (mUseQuickControls) {
      mBaseUi.hideTitleBar();
      mAutoLogin.setVisibility(View.GONE);
      mBaseUi.refreshWebView();
    } else {
      if (animate) {
        Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.autologin_exit);
        anim.setAnimationListener(
            new AnimationListener() {
              @Override
              public void onAnimationEnd(Animation a) {
                mAutoLogin.setVisibility(View.GONE);
                mBaseUi.refreshWebView();
              }

              @Override
              public void onAnimationStart(Animation a) {}

              @Override
              public void onAnimationRepeat(Animation a) {}
            });
        mAutoLogin.startAnimation(anim);
      } else if (mAutoLogin.getAnimation() == null) {
        mAutoLogin.setVisibility(View.GONE);
        mBaseUi.refreshWebView();
      }
    }
  }
Esempio n. 9
0
  private void animateSelectedBricks() {
    if (!animatedBricks.isEmpty()) {

      for (final Brick animationBrick : animatedBricks) {
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink);

        animation.setAnimationListener(
            new AnimationListener() {

              @Override
              public void onAnimationStart(Animation animation) {
                animationBrick.setAnimationState(true);
              }

              @Override
              public void onAnimationRepeat(Animation animation) {}

              @Override
              public void onAnimationEnd(Animation animation) {
                animationBrick.setAnimationState(false);
              }
            });
        int position = animatedBricks.indexOf(animationBrick);
        animationBrick.setAnimationState(true);
        View view = animationBrick.getView(context, position, this);

        if (view.hasWindowFocus()) {
          view.startAnimation(animation);
        }
      }
    }
    animatedBricks.clear();
  }
  public void setPtrFrameLayout(PtrFrameLayout layout) {

    final PtrUIHandlerHook mPtrUIHandlerHook =
        new PtrUIHandlerHook() {
          @Override
          public void run() {
            startAnimation(mScaleAnimation);
          }
        };

    mScaleAnimation.setDuration(200);
    mScaleAnimation.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            mPtrUIHandlerHook.resume();
          }

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

    mPtrFrameLayout = layout;
    mPtrFrameLayout.setRefreshCompleteHook(mPtrUIHandlerHook);
  }
Esempio n. 11
0
 // Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout
 // enters
 private void animateIn(FloatingActionButton button) {
   button.setVisibility(View.VISIBLE);
   Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.abc_slide_in_bottom);
   anim.setDuration(600L);
   anim.setInterpolator(INTERPOLATOR);
   button.startAnimation(anim);
 }
 private void showBitmapForView(ImageView v, final Bitmap bitmap) {
   v.setImageBitmap(bitmap);
   Animation a = AnimUtils.FadeIn.loadAnimation(UI.getActivity(), 500);
   a.setStartOffset(500);
   v.startAnimation(a);
   topicView
       .findViewById(R.id.forum_image_btn)
       .setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               File f;
               try {
                 f = Utils.saveTmpBitmap(bitmap);
                 Intent intent = new Intent(Intent.ACTION_VIEW);
                 intent.setDataAndType(Uri.fromFile(f), "image/*");
                 startActivity(intent);
               } catch (IOException e) {
                 e.printStackTrace();
                 UI.toast("图片保存出错");
               } catch (ActivityNotFoundException e) {
                 UI.toast("无法查看图片,无图库程序");
               }
             }
           });
 }
  /**
   * Takes an ImageView and alternately rotates it clockwise and counterclockwise Based on the
   * previous rotation. This change is applied directly to the ImageView This animation lasts for
   * half a second
   *
   * @param v {ImageView} : the source view
   */
  public static void rotateImage(final ImageView v) {
    // Initialize the tag on the imageview
    // Signals if we rotate clockwise or counterclockwise
    if (v.getTag() == null) v.setTag(false);
    final boolean tag = (boolean) v.getTag();

    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            Matrix matrix = new Matrix();
            v.setScaleType(ImageView.ScaleType.MATRIX);
            // Rotates counterclockwise if the tag is true
            float rotation = interpolatedTime * 180f;
            if (tag) rotation = 180f - rotation;
            matrix.postRotate(
                rotation,
                v.getDrawable().getBounds().width() / 2,
                v.getDrawable().getBounds().height() / 2);
            v.setImageMatrix(matrix);
            // Inverse the tag, so next run it will rotate the inverse direction
            v.setTag(!tag);
          }

          @Override
          public boolean willChangeBounds() {
            return false;
          }
        };
    a.setDuration(500);
    v.startAnimation(a);
  }
Esempio n. 14
0
  private void hideZoomedView(boolean withAnimation) {
    if (withAnimation) {
      final Animation anim =
          new ScaleAnimation(
              1f,
              0f, // Start and end values for the X axis scaling
              1f,
              0f, // Start and end values for the Y axis scaling
              Animation.ABSOLUTE,
              animationStart.x, // Pivot point of X scaling
              Animation.ABSOLUTE,
              animationStart.y); // Pivot point of Y scaling
      anim.setFillAfter(true); // Needed to keep the result of the animation
      anim.setDuration(CLOSING_ANIMATION_DURATION_MS);
      anim.setAnimationListener(
          new AnimationListener() {
            public void onAnimationEnd(Animation animation) {}

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationStart(Animation animation) {
              removeListeners();
            }
          });
      setAnimation(anim);
    } else {
      removeListeners();
      setAnimation(null);
    }
    setVisibility(View.GONE);
    shouldSetVisibleOnUpdate = false;
  }
Esempio n. 15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    setContentView(R.layout.splash);

    final ImageView imageView = (ImageView) findViewById(R.id.splashimage);
    final Animation animation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.fade_out);

    imageView.startAnimation(animation);
    animation.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            finish();
            Intent intent_splash = new Intent(Splash.this, MainActivity.class);
            startActivity(intent_splash);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
Esempio n. 16
0
  public void refreshViews() {
    layout.removeAllViews();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    profilePictures = new ArrayList<MLRoundedImageView>();

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }

    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }
  }
Esempio n. 17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    final ImageView iv = (ImageView) findViewById(R.id.splash_icon);

    Animation an1 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.fadein);
    iv.startAnimation(an1);
    an1.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            Handler handler = new Handler();
            handler.postDelayed(
                new Runnable() {
                  public void run() {
                    moveOn();
                  }
                },
                750);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
Esempio n. 18
0
  public void animate() {

    final AnimationSet animationSet = new AnimationSet(false);

    final AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0.25f);
    alphaAnimation.setDuration(350);
    animationSet.addAnimation(alphaAnimation);

    final Animation moveAnimation = animationType.create();
    moveAnimation.setDuration(500);
    animationSet.addAnimation(moveAnimation);

    animationSet.setRepeatCount(0);

    if (postAction != null) {
      animationSet.setAnimationListener(
          new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              postAction.run();
            }

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

    listView.startAnimation(animationSet);
  }
Esempio n. 19
0
        @Override
        public void handleMessage(Message msg) {
          if (msg.what == 0) {
            // 加载成功
            if (_appList.size() == 0) {
              // 没有数据
              _loadingTextView.setText("暂时没有数据!");
              _loadingAnimation.cancel();
              _loadingImageView.setAnimation(null);
              _loadingImageView.setVisibility(View.GONE);
            } else {
              // TODO: update
              _adapter.notifyDataSetChanged();
              _listView.setVisibility(View.VISIBLE);

              _loadingAnimation.cancel();
              _loadingImageView.setAnimation(null);
              _loadingLayer.setVisibility(View.INVISIBLE);
            }
          } else {
            _loadingAnimation.cancel();
            _loadingImageView.setAnimation(null);
            _loadingImageView.setVisibility(View.GONE);
            _loadingTextView.setText("加载数据失败,请稍后再试一次!");
          }
        }
  @Override
  public void dismiss() {
    Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);

    anim.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            view.post(
                new Runnable() {
                  @Override
                  public void run() {
                    ColorSelector.super.dismiss();
                  }
                });
          }
        });

    Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);

    view.startAnimation(anim);
    backView.startAnimation(backAnim);
  }
  public static boolean collapse(Activity activity, final View webView) {
    if (!isExtraServicesVisible) return false;

    final int targetHeight = AnimationManager.getHeightToExpand(65, activity, null);
    Animation a =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
              webView.setVisibility(View.GONE);
            } else {
              webView.getLayoutParams().height =
                  targetHeight - (int) (targetHeight * interpolatedTime);
              webView.requestLayout();
            }
          }

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

    a.setAnimationListener(
        new BaseAnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            isExtraServicesVisible = false;
          }
        });
    a.setDuration(SLIDE_DOWN_DURATION);
    webView.startAnimation(a);
    return true;
  }
Esempio n. 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    final ImageView iv = (ImageView) findViewById(R.id.imageView);
    final Animation an = AnimationUtils.loadAnimation(getBaseContext(), R.anim.rotate);
    final Animation an2 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_fade_out);

    iv.startAnimation(an);
    an.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            iv.startAnimation(an2);
            finish();
            Intent i = new Intent(getBaseContext(), MainActivity.class);
            startActivity(i);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
Esempio n. 23
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();
    }
  }
Esempio n. 24
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);
  }
  /**
   * 初始化
   *
   * @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);
  }
Esempio n. 26
0
  public FolderPicker(Context context, OnClickListener listener, int themeId, boolean acceptFiles) {
    super(context, themeId);
    mListener = listener;
    mAcceptFiles = acceptFiles;
    setTitle(acceptFiles ? R.string.pick_file : R.string.pick_folder);
    setContentView(R.layout.folders);

    mRootSDCard = Environment.getExternalStorageDirectory();

    mOkButton = findViewById(R.id.ok_btn);
    mOkButton.setOnClickListener(this);
    findViewById(R.id.cancel_btn).setOnClickListener(this);
    mCurrentFolder = (TextView) findViewById(R.id.current_folder);
    mCurrentFolder.setSelected(true);
    mFolders = (ListView) findViewById(R.id.folders);
    mFolders.setOnItemClickListener(this);

    Animation animation = new AlphaAnimation(0, 1);
    animation.setDuration(250);
    LayoutAnimationController controller = new LayoutAnimationController(animation);
    mFolders.setLayoutAnimation(controller);

    mAdapter = new FolderAdapter();
    mFolders.setAdapter(mAdapter);
    mPath = new Folder(mRootSDCard.getAbsolutePath());
    updateAdapter();
  }
  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);
  }
  @Override
  public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    if (nextAnim != 0) {
      Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);

      anim.setAnimationListener(
          new Animation.AnimationListener() {

            public void onAnimationStart(Animation animation) {
              ChatProfileChangeNameActivity.this.onAnimationStart();
            }

            public void onAnimationRepeat(Animation animation) {}

            public void onAnimationEnd(Animation animation) {
              ChatProfileChangeNameActivity.this.onAnimationEnd();
              firstNameField.requestFocus();
              Utilities.showKeyboard(firstNameField);
            }
          });

      return anim;
    } else {
      return super.onCreateAnimation(transit, enter, nextAnim);
    }
  }
Esempio n. 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 void setIsLoading(boolean isLoading) {

    if (isLoading == mLoading || getActivity() == null) {
      return;
    }

    mLoading = isLoading;

    if (isLoading) {
      setListShown(false, true);
      mProgressContainer.startAnimation(
          AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
      mProgressContainer.setVisibility(View.VISIBLE);
    } else {
      Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
      fadeOut.setAnimationListener(
          new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              if (mProgressContainer != null) {
                mProgressContainer.setVisibility(View.GONE);
              }
              updateEmpty();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}
          });
      mProgressContainer.startAnimation(fadeOut);
    }
  }