Example usage for android.view.animation ScaleAnimation setDuration

List of usage examples for android.view.animation ScaleAnimation setDuration

Introduction

In this page you can find the example usage for android.view.animation ScaleAnimation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.example.android.animationsdemo.CameraActivity.java

private void startFocusAniamtion(int pointX, int pointY) {
    RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(focusView.getLayoutParams());
    layout.setMargins(pointX - 60, pointY - 60, 0, 0);
    focusView.setLayoutParams(layout);/*from   w ww. java  2s. co m*/
    focusView.setVisibility(View.VISIBLE);
    ScaleAnimation sa = new ScaleAnimation(3f, 1f, 3f, 1f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
            ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(800);
    focusView.startAnimation(sa);
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            focusView.setVisibility(View.INVISIBLE);
        }
    }, 800);
}

From source file:net.mEmoZz.PopMovies.frags.DetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Bundle bundle = this.getArguments();
    helper = new DBHelper(getActivity());
    Configuration conf = getActivity().getResources().getConfiguration();
    if (conf.smallestScreenWidthDp >= 600) {
        if (bundle != null) {
            movie = bundle.getParcelable("movie");
            position = bundle.getInt("pos");
            if (movie != null) {
                posterEndPoint = movie.getPoster();
                backdropEndPoint = movie.getBackdrop();
                overviewEndPoint = movie.getOverview();
                dateEndPoint = movie.getDate();
                voteEndPoint = movie.getVoteAvr();
                titleEndPoint = movie.getTitle();
                idEndpoint = movie.getId();
                if (dateEndPoint.equals("")) {
                    year = "Unknown";
                } else {
                    year = dateEndPoint.substring(0, 4);
                }/*from   ww  w. j a v  a  2  s .  c  o  m*/
                if (titleEndPoint.equals("")) {
                    titleEndPoint = "Not available.";
                } else {
                    titleEndPoint = movie.getTitle();
                }
                if (overviewEndPoint.equals("")) {
                    overviewEndPoint = "No overview found.";
                } else {
                    overviewEndPoint = movie.getOverview();
                }
            }
        }
    } else {
        posterEndPoint = getActivity().getIntent().getExtras().getString("poster");
        backdropEndPoint = getActivity().getIntent().getExtras().getString("backdrop");
        overviewEndPoint = getActivity().getIntent().getExtras().getString("overview");
        dateEndPoint = getActivity().getIntent().getExtras().getString("date");
        voteEndPoint = getActivity().getIntent().getExtras().getString("vote");
        titleEndPoint = getActivity().getIntent().getExtras().getString("title");
        idEndpoint = getActivity().getIntent().getExtras().getString("id");
        position = getActivity().getIntent().getExtras().getInt("position");
    }
    boolean ifExist = helper.ifExist(idEndpoint);
    if (ifExist) {
        detailUnFav.setVisibility(VISIBLE);
        detailFav.setVisibility(GONE);
    } else {
        detailUnFav.setVisibility(GONE);
        detailFav.setVisibility(VISIBLE);
    }
    String posterUrl = Url.POSTERS_URL + "w342" + posterEndPoint;

    DisplayImageOptions mOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(false)
            .displayer(new FadeInBitmapDisplayer(1500)).showImageOnFail(R.drawable.no_poster)
            .showImageForEmptyUri(R.drawable.no_poster).build();

    ImageLoader.getInstance().displayImage(posterUrl, detailPoster, mOptions, new SimpleImageLoadingListener() {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            Palette p = Palette.from(loadedImage).generate();
            detailCard.setCardBackgroundColor(p.getVibrantColor(0));
            if (p.getVibrantColor(0) == Color.TRANSPARENT) {
                detailCard.setCardBackgroundColor(p.getMutedColor(0));
            }
        }
    });

    String backdropUrl = Url.POSTERS_URL + "w780" + backdropEndPoint;
    if (conf.smallestScreenWidthDp >= 600) {
        ImageLoader.getInstance().displayImage(backdropUrl, tabBackdrop, mOptions,
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                        Palette p = Palette.from(loadedImage).generate();
                        tabBackdrop.setBackgroundColor(p.getVibrantColor(0));
                        if (p.getVibrantColor(0) == Color.TRANSPARENT) {
                            tabBackdrop.setBackgroundColor(p.getMutedColor(0));
                        }
                    }
                });
        detailDate.setText(year);
        detailTitle.setText(titleEndPoint);
    } else {
        detailDate.setText(dateEndPoint);
    }
    detailVoteAvr.setText(voteEndPoint);
    detailOverview.setText(overviewEndPoint);

    final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(165);

    detailFav.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.notifyDataSetChanged();
            detailFav.setVisibility(GONE);
            detailUnFav.startAnimation(animation);
            detailUnFav.setVisibility(VISIBLE);
            helper.insertRow(posterEndPoint, backdropEndPoint, idEndpoint, titleEndPoint, dateEndPoint,
                    voteEndPoint, overviewEndPoint);
        }
    });

    detailUnFav.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.notifyDataSetChanged();
            detailUnFav.setVisibility(GONE);
            detailFav.startAnimation(animation);
            detailFav.setVisibility(VISIBLE);
            helper.deleteRow(idEndpoint);
            if (fav.isChecked()) {
                CoreAdapter.movies.remove(position);
                adapter.notifyItemRemoved(position);
                adapter.notifyDataSetChanged();
            }
        }
    });
    new DurationTask().execute();

    trailsAdapter = new TrailersAdapter(trailers, getActivity());
    new TrailersTask().execute();

    revsAdapter = new ReviewsAdapter(reviews, getActivity());
    new ReviewsTask().execute();
}

From source file:com.rodrigopontes.androidbubbles.BubblesManager.java

private void playScaleAnimation(ScaleAnimation scaleAnimation, int duration, BubbleBase bubble) {
    scaleAnimation.setDuration(duration);
    scaleAnimation.setFillAfter(true);//from  w ww.j  a  v  a 2 s.c  om
    bubble.getImageView().startAnimation(scaleAnimation);
}

From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java

private void hideViewPager() {
    pagerContainer.setVisibility(View.GONE);
    gridView.setVisibility(View.VISIBLE);
    findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.VISIBLE);
    AnimationSet set = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation(1, (float) 0.9, 1, (float) 0.9,
            pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2);
    scaleAnimation.setDuration(200);
    set.addAnimation(scaleAnimation);/*from w w  w .  j a  v a  2s . c  om*/
    AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
    alphaAnimation.setDuration(200);
    set.addAnimation(alphaAnimation);
    pagerContainer.startAnimation(set);
    ((BaseAdapter) gridView.getAdapter()).notifyDataSetChanged();
}

From source file:net.evendanan.pushingpixels.PassengerFragmentSupport.java

@Nullable
public static Animation onCreateAnimation(@NonNull Fragment passengerFragment, int transit, boolean enter,
        int nextAnim) {
    Log.d(TAG, "onCreateAnimation: transit: " + transit + ", enter: " + enter + ", nextAnim: " + nextAnim);
    final boolean validTransitionToModify = nextAnim == R.anim.ui_context_expand_add_in
            || nextAnim == R.anim.ui_context_expand_pop_out;
    if (!validTransitionToModify)
        return null;

    ScaleAnimation scale = null;
    PointF originateViewCenterPoint = PointFCompat.getPointFromBundle(passengerFragment.getArguments(),
            EXTRA_ORIGINATE_VIEW_CENTER);
    PointF originateViewScale = PointFCompat.getPointFromBundle(passengerFragment.getArguments(),
            EXTRA_ORIGINATE_VIEW_SCALE);
    if (originateViewCenterPoint != null && originateViewScale != null) {
        Log.d(TAG, "originateViewCenterPoint: " + originateViewCenterPoint.toString());
        if (enter && nextAnim == R.anim.ui_context_expand_add_in) {
            scale = new ScaleAnimation(originateViewScale.x, 1.0f, originateViewScale.y, 1.0f,
                    ScaleAnimation.ABSOLUTE, originateViewCenterPoint.x, ScaleAnimation.ABSOLUTE,
                    originateViewCenterPoint.y);
        } else if (!enter && nextAnim == R.anim.ui_context_expand_pop_out) {
            scale = new ScaleAnimation(1.0f, originateViewScale.x, 1.0f, originateViewScale.y,
                    ScaleAnimation.ABSOLUTE, originateViewCenterPoint.x, ScaleAnimation.ABSOLUTE,
                    originateViewCenterPoint.y);
        }/*from w  ww  . j  a v  a 2  s  .  c  o m*/
    }

    if (scale == null) {
        //no originate view, so I'll add generic scale-animation
        if (enter) {
            scale = new ScaleAnimation(0.4f, 1.0f, 0.4f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
                    ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        } else {
            scale = new ScaleAnimation(1.0f, 0.4f, 1.0f, 0.4f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
                    ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        }
    }
    scale.setDuration(passengerFragment.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    AnimationSet set = (AnimationSet) AnimationUtils
            .loadAnimation(passengerFragment.getActivity().getApplicationContext(), nextAnim);
    set.addAnimation(scale);
    return set;
}

From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java

private void showViewPager(int index) {
    pagerContainer.setVisibility(View.VISIBLE);
    gridView.setVisibility(View.GONE);
    findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.GONE);
    viewpager.setAdapter(viewpager.new LocalViewPagerAdapter(currentFolder));
    viewpager.setCurrentItem(index);/*w w w.  j  ava  2s.  c  om*/
    mCountView.setText((index + 1) + "/" + currentFolder.size());
    //?
    if (index == 0) {
        checkBox.setTag(currentFolder.get(index));
        checkBox.setChecked(checkedItems.contains(currentFolder.get(index)));
    }
    AnimationSet set = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation((float) 0.9, 1, (float) 0.9, 1,
            pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2);
    scaleAnimation.setDuration(300);
    set.addAnimation(scaleAnimation);
    AlphaAnimation alphaAnimation = new AlphaAnimation((float) 0.1, 1);
    alphaAnimation.setDuration(200);
    set.addAnimation(alphaAnimation);
    pagerContainer.startAnimation(set);
}

From source file:com.umeng.comm.ui.adapters.viewholders.FeedItemViewHolder.java

private void clickAnima(View targetView) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
    scaleAnimation.setDuration(100);
    targetView.startAnimation(scaleAnimation);
}

From source file:com.aniruddhc.acemusic.player.Drawers.QueueDrawerFragment.java

/**
 * Animates the play button to a pause button.
 *///from ww  w  . j a va2  s.  co m
private void animatePlayToPause() {

    //Check to make sure the current icon is the play icon.
    if (mPlayPauseButton.getId() != R.drawable.play_light)
        return;

    //Fade out the play button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());

    //Scale in the pause button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());

    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.pause_light);
            mPlayPauseButton.setPadding(0, 0, 0, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.pause_light);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    mPlayPauseButton.startAnimation(scaleOut);
}

From source file:com.aniruddhc.acemusic.player.Drawers.QueueDrawerFragment.java

/**
 * Animates the pause button to a play button.
 *//*from  w  ww  .  jav a2  s .  co m*/
private void animatePauseToPlay() {

    //Check to make sure the current icon is the pause icon.
    if (mPlayPauseButton.getId() != R.drawable.pause_light)
        return;

    //Scale out the pause button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());

    //Scale in the play button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());

    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.play_light);
            mPlayPauseButton.setPadding(0, 0, -5, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.play_light);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    mPlayPauseButton.startAnimation(scaleOut);
}

From source file:demo.camera.library.ui.CameraCaptureActivity.java

public void setUpUi() {
    mBlockerSpinner = (RelativeLayout) findViewById(R.id.blocker);
    mBlockerSpinner.setVisibility(View.GONE);

    mTouchIndicator = (ImageView) findViewById(R.id.touchIndicator);
    mTouchInterceptor = (RelativeLayout) findViewById(R.id.touch_interceptor);
    mTouchInterceptor.setOnTouchListener(new View.OnTouchListener() {
        @Override// w w w  . j a  v  a 2  s  .co  m
        public boolean onTouch(View v, MotionEvent event) {
            mTouchIndicator.setImageResource(R.drawable.white_circle);
            mTouchIndicator.setVisibility(View.VISIBLE);
            final int X = (int) event.getRawX();
            final int Y = (int) event.getRawY();

            RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) mTouchIndicator
                    .getLayoutParams();
            lParams.leftMargin = X - mTouchIndicator.getWidth() / 2;
            lParams.topMargin = Y - mTouchIndicator.getHeight() / 2;
            mTouchIndicator.setLayoutParams(lParams);
            mTouchIndicator.invalidate();

            ScaleAnimation scaleUpAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF,
                    (float) 0.5, Animation.RELATIVE_TO_SELF, (float) 0.5);

            scaleUpAnimation.setDuration(350);
            scaleUpAnimation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    mTouchIndicator.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mTouchIndicator.setVisibility(View.GONE);
                        }
                    }, 100);

                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            mTouchIndicator.startAnimation(scaleUpAnimation);
            return false;
        }
    });

    //            mTouchInterceptor.setVisibility(View.GONE);

    mRecordButton = (Button) findViewById(R.id.recordButton);

    mExtrasContainer = (LinearLayout) findViewById(R.id.settings_container);
    mMoreOptions = (ImageView) findViewById(R.id.icon_more);
    mMoreOptions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMoreOptions.setSelected(!mMoreOptions.isSelected());
            if (mMoreOptions.isSelected()) {
                mExtrasContainer.setVisibility(View.VISIBLE);
            } else {
                mExtrasContainer.setVisibility(View.GONE);
            }

        }
    });

    //            mRecordButton .setOnClickListener(mRecordButtonClickListener);
    setUpTouchInterceptor(mRecordButton);

    setUpHeaders();
    setUpFlashButton();
    setUpProgressIndicator();

    //        setupFilterSpinner();
    setupCameraFlipper();
}