List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.savvasdalkitsis.betwixt.demo.InterpolatorView.java
private void init() { paint = new Paint(); paint.setColor(Color.BLACK);//from w w w .j av a 2s . co m paint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.interpolation_width)); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setAntiAlias(true); paint.setStrokeCap(Paint.Cap.ROUND); linePaint.setColor(Color.WHITE); linePaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.interpolation_width)); float dashSize = getResources().getDimensionPixelSize(R.dimen.dash_size); linePaint.setPathEffect(new DashPathEffect(new float[] { dashSize, dashSize }, 0)); linePaint.setStyle(Paint.Style.STROKE); rectPaint = new Paint(); rectPaint.setARGB(255, 255, 200, 200); radius = getResources().getDimensionPixelSize(R.dimen.circle_radius); animationInset = getResources().getDimensionPixelSize(R.dimen.play_inset); circlePaint.setColor(Color.RED); circlePaint.setAntiAlias(true); textPaint.setColor(Color.BLACK); textPaint.setAntiAlias(true); textPaint.setTextSize(getResources().getDimensionPixelSize(R.dimen.interpolator_description_size)); textPaddingLeft = getResources().getDimensionPixelSize(R.dimen.text_padding_left); dim.setColor(ColorUtils.setAlphaComponent(Color.BLACK, 200)); setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { play(); } }); playAnimator.setStartDelay(500); playAnimator.setDuration(1000); playAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { progress = animation.getAnimatedFraction(); postInvalidate(); } }); playAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { endAnimation(); } @Override public void onAnimationEnd(final Animator animation) { postDelayed(new Runnable() { @Override public void run() { endAnimation(); } }, 500); } }); }
From source file:com.achow101.bitcointalkforum.fragments.HomeFragment.java
/** * Shows the progress UI and hides the login form. *//*from w w w .j a v a 2 s. c om*/ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) public void showProgress(final boolean show) { // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow // for very easy animations. If available, use these APIs to fade-in // the progress spinner. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); mExpListView.setVisibility(show ? View.GONE : View.VISIBLE); mExpListView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mExpListView.setVisibility(show ? View.GONE : View.VISIBLE); } }); mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); mProgressView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); } }); } else { // The ViewPropertyAnimator APIs are not available, so simply show // and hide the relevant UI components. mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); mExpListView.setVisibility(show ? View.GONE : View.VISIBLE); } }
From source file:com.jaspervanriet.huntingthatproduct.Views.FeedContextMenuManager.java
private void performShowAnimation() { contextMenuView.setPivotX(contextMenuView.getWidth() / 2); contextMenuView.setPivotY(contextMenuView.getHeight()); contextMenuView.setScaleX(0.1f);//w w w . j a v a2s. c o m contextMenuView.setScaleY(0.1f); contextMenuView.animate().scaleX(1f).scaleY(1f).setDuration(150) .setInterpolator(new OvershootInterpolator()).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { isContextMenuShowing = false; } }); }
From source file:com.example.zayankovsky.homework.ui.ImageDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_detail); getWindow().getDecorView().setBackgroundResource( PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "light").equals("dark") ? R.color.darkColorTransparent : R.color.lightColorTransparent); // Set up activity to go full screen getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); // Locate the main ImageView and TextView mImageView = (ImageView) findViewById(R.id.imageView); final TextView mTextView = (TextView) findViewById(R.id.textView); mSectionNumber = getIntent().getIntExtra(SECTION_NUMBER, 0); registerForContextMenu(mImageView);//from w ww . j a v a2 s.c o m mImageView.setLongClickable(false); // Enable some additional newer visibility and ActionBar features // to create a more immersive photo viewing experience final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Set home as up actionBar.setDisplayHomeAsUpEnabled(true); // Hide and show the ActionBar and TextView as the visibility changes mImageView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) { actionBar.hide(); if (mSectionNumber == 1) { mTextView.animate().translationY(mTextView.getHeight()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTextView.setVisibility(View.GONE); } }); } } else { actionBar.show(); if (mSectionNumber == 1) { mTextView.animate().translationY(0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mTextView.setVisibility(View.VISIBLE); } }); } } } }); // Start low profile mode and hide ActionBar mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); actionBar.hide(); } GestureListener.init(this, mImageView); ScaleGestureListener.init(mImageView); // Use the ImageWorker to load the image into the ImageView // (so a single cache can be used over all pages in the ViewPager) // based on the extra passed in to this activity int position = getIntent().getIntExtra(POSITION, 0); switch (mSectionNumber) { case 0: GalleryWorker.loadImage(position, mImageView); break; case 1: FotkiWorker.loadImage(position, mImageView); mTextView.setText(getResources().getString(R.string.detail_text, FotkiWorker.getAuthor(), new SimpleDateFormat("d MMMM yyyy", Locale.getDefault()).format(FotkiWorker.getPublished()))); break; case 2: ResourcesWorker.loadImage(position, mImageView); break; } setTitle(ImageWorker.getTitle()); // First we create the GestureListener that will include all our callbacks. // Then we create the GestureDetector, which takes that listener as an argument. GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener(); final GestureDetector gd = new GestureDetector(this, gestureListener); ScaleGestureDetector.SimpleOnScaleGestureListener scaleGestureListener = new ScaleGestureListener(); final ScaleGestureDetector sgd = new ScaleGestureDetector(this, scaleGestureListener); /* For the view where gestures will occur, we create an onTouchListener that sends * all motion events to the gesture detectors. When the gesture detectors * actually detects an event, it will use the callbacks we created in the * SimpleOnGestureListener and SimpleOnScaleGestureListener to alert our application. */ findViewById(R.id.frameLayout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { gd.onTouchEvent(motionEvent); sgd.onTouchEvent(motionEvent); return true; } }); }
From source file:com.microsoft.artcurator.ui.emaildetails.EmailDetailsFragment.java
private void animateAway(final View which) { btnHeight = mButtonLayout.getHeight(); mButtonLayout.animate().translationY(btnHeight).setListener(new AnimatorListenerAdapter() { @Override/*from www . j a va 2 s . co m*/ public void onAnimationEnd(Animator animation) { mButtonLayout.setVisibility(View.GONE); mScrollView.setLayoutParams(adjustMargins(Direction.DOWN)); boolean liked = which.getId() == R.id.btn_like; String msg; Context context = getActivity(); if (liked) { msg = context.getString(R.string.liked); } else { msg = context.getString(R.string.disliked); } Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } }); }
From source file:com.dm.material.dashboard.candybar.fragments.IconsBaseFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_search, menu); MenuItem search = menu.findItem(R.id.menu_search); MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() { @Override/*from www . j a va 2 s. co m*/ public boolean onMenuItemActionExpand(MenuItem item) { FragmentManager fm = getActivity().getSupportFragmentManager(); if (fm == null) return false; setHasOptionsMenu(false); View view = getActivity().findViewById(R.id.shadow); if (view != null) view.animate().translationY(-mTabLayout.getHeight()).setDuration(200).start(); mTabLayout.animate().translationY(-mTabLayout.getHeight()).setDuration(200) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(android.animation.Animator animation) { super.onAnimationEnd(animation); Fragment prev = fm.findFragmentByTag("home"); if (prev != null) return; PagerIconsAdapter adapter = (PagerIconsAdapter) mPager.getAdapter(); if (adapter == null) return; SearchListener listener = (SearchListener) getActivity(); listener.onSearchExpanded(true); FragmentTransaction ft = fm.beginTransaction() .replace(R.id.container, new IconsSearchFragment(), IconsSearchFragment.TAG) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .addToBackStack(null); try { ft.commit(); } catch (Exception e) { ft.commitAllowingStateLoss(); } } }).start(); return false; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { return true; } }); }
From source file:android.support.design.widget.FloatingActionButtonIcs.java
@Override void show(@Nullable final FloatingActionButtonImpl.InternalVisibilityChangedListener listener, final boolean fromUser) { if (isOrWillBeShown()) { // We either are or will soon be visible, skip the call return;//from w w w . jav a 2s .c om } mView.animate().cancel(); if (shouldAnimateVisibilityChange()) { mAnimState = ANIM_STATE_SHOWING; if (mView.getVisibility() != View.VISIBLE) { // If the view isn't visible currently, we'll animate it from a single pixel mView.setAlpha(0f); mView.setScaleY(0f); mView.setScaleX(0f); } mView.animate().scaleX(1f).scaleY(1f).alpha(1f).setDuration(SHOW_HIDE_ANIM_DURATION) .setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mView.internalSetVisibility(View.VISIBLE, fromUser); } @Override public void onAnimationEnd(Animator animation) { mAnimState = ANIM_STATE_NONE; if (listener != null) { listener.onShown(); } } }); } else { mView.internalSetVisibility(View.VISIBLE, fromUser); mView.setAlpha(1f); mView.setScaleY(1f); mView.setScaleX(1f); if (listener != null) { listener.onShown(); } } }
From source file:com.gudong.appkit.ui.helper.AppItemAnimator.java
private void animateAddImpl(final RecyclerView.ViewHolder viewHolder) { final View target = viewHolder.itemView; mAddAnimations.add(viewHolder);// w ww . ja va2 s. com final AnimatorSet animator = new AnimatorSet(); animator.playTogether(ObjectAnimator.ofFloat(target, "translationX", -target.getMeasuredWidth(), 0, 0f), ObjectAnimator.ofFloat(target, "alpha", 0.5f, 1.0f)); animator.setTarget(target); animator.setDuration(KEY_DURATION_TIME); animator.setInterpolator(new AccelerateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); dispatchAddStarting(viewHolder); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); ViewCompat.setAlpha(target, 1); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animator.removeAllListeners(); dispatchAddFinished(viewHolder); mAddAnimations.remove(viewHolder); dispatchFinishedWhenDone(); } }); animator.start(); }
From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java
private void animateTranslation(int to, Interpolator interpolator) { toolbar.animate().translationY(to).setDuration(ANIMATION_DURATION).setInterpolator(interpolator) .setListener(new AnimatorListenerAdapter() { @Override/* w ww . j a v a 2s . c o m*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingTranslation = false; } }).start(); isUpdatingTranslation = true; }
From source file:MainActivity.java
private void zoomFromThumbnail(final ImageView imageViewThumb) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel();/* ww w. j ava 2 s . c o m*/ } final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); imageViewThumb.getGlobalVisibleRect(startBounds); findViewById(R.id.frameLayout).getGlobalVisibleRect(finalBounds, globalOffset); mImageViewExpanded .setImageBitmap(loadSampledResource(R.drawable.image, finalBounds.height(), finalBounds.width())); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } imageViewThumb.setVisibility(View.GONE); mImageViewExpanded.setVisibility(View.VISIBLE); mImageViewExpanded.setPivotX(0f); mImageViewExpanded.setPivotY(0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(ObjectAnimator.ofFloat(mImageViewExpanded, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_Y, startScale, 1f)); animatorSet.setDuration(1000); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); animatorSet.start(); mCurrentAnimator = animatorSet; }