List of usage examples for android.view View startAnimation
public void startAnimation(Animation animation)
From source file:com.devbrackets.android.recyclerext.decoration.ReorderDecoration.java
/** * Animates the dragged views position to the final resting position * * @param view The view to animate/*from w w w .jav a 2 s . c o m*/ */ private void finishReorder(View view) { if (smoothFinishAnimationListener != null) { smoothFinishAnimationListener.setPositions(selectedDragItemPosition, selectedDragItemNewPosition); } selectedDragItemPosition = NO_POSITION; view.setVisibility(View.VISIBLE); //Performs the ending animation if (recyclerView.getChildAdapterPosition(view) == selectedDragItemNewPosition) { selectedDragItemNewPosition = NO_POSITION; int startYDelta = orientation == LayoutOrientation.VERTICAL ? floatingItemBounds.top - newViewStart : 0; int startXDelta = orientation == LayoutOrientation.HORIZONTAL ? floatingItemBounds.left - newViewStart : 0; SmoothFinishAnimation anim = new SmoothFinishAnimation(startYDelta, startXDelta, smoothFinishAnimationListener); view.startAnimation(anim); } }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;// w ww .j ava 2 s .co m if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
protected void shiftCurrentTerminal(final int direction) { View overlay; synchronized (flip) { boolean shouldAnimate = flip.getChildCount() > 1; // Only show animation if there is something else to go to. if (shouldAnimate) { // keep current overlay from popping up again overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) overlay.startAnimation(fade_stay_hidden); if (direction == SHIFT_LEFT) { flip.setInAnimation(slide_left_in); flip.setOutAnimation(slide_left_out); flip.showNext();/*from w w w . java2 s . co m*/ } else if (direction == SHIFT_RIGHT) { flip.setInAnimation(slide_right_in); flip.setOutAnimation(slide_right_out); flip.showPrevious(); } } ConsoleActivity.this.updateDefault(); if (shouldAnimate) { // show overlay on new slide and start fade overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) overlay.startAnimation(fade_out_delayed); } updatePromptVisible(); } }
From source file:com.univ.helsinki.app.MainActivity.java
/** * Handling of Splash screen/*from w w w. j ava2s.c om*/ */ private void activateSplashScreen(final View view) { // UP to DOWN Animation final float direction = -1; final float yDelta = (getScreenHeight() - (2 * view.getHeight())); final Animation animation = new TranslateAnimation(0, 0, 0, yDelta * direction); animation.setDuration(1500); animation.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation animation) { getActionBar().show(); } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { view.setVisibility(View.GONE); showTitle(); View titleView = getWindow().findViewById(android.R.id.title); if (titleView != null) { ViewParent parent = titleView.getParent(); if (parent != null && (parent instanceof View)) { View parentView = (View) parent; parentView.setVisibility(View.VISIBLE); } } } }); view.startAnimation(animation); }
From source file:de.fahrgemeinschaft.RideDetailsFragment.java
private void animatePulse(final View view) { Animation fade_in = new AlphaAnimation(0f, 1f); fade_in.setAnimationListener(new AnimationListener() { @Override/* w w w . j a v a2 s .c o m*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { Animation fade_out = new AlphaAnimation(1f, 0f); fade_out.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } }); fade_out.setDuration(1700); fade_out.setFillAfter(true); view.startAnimation(fade_out); } }); fade_in.setDuration(200); view.startAnimation(fade_in); }
From source file:com.afayear.android.client.activity.DualPaneActivity.java
@Override public void onBackStackChanged() { if (isDualPaneMode()) { final FragmentManager fm = getSupportFragmentManager(); final int count = fm.getBackStackEntryCount(); final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT); final Fragment right_pane_fragment = fm.findFragmentById(PANE_RIGHT); final View main_view = findViewById(R.id.main); final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded(); final boolean right_pane_used = right_pane_fragment != null && right_pane_fragment.isAdded(); if (count > 0) { final BackStackEntry entry = fm.getBackStackEntryAt(count - 1); if (entry == null) return; final Fragment fragment = BackStackEntryTrojan.getFragmentInBackStackRecord(entry); if (fragment instanceof Panes.Right) { showRightPane();//w w w. j av a2 s . c om } else if (fragment instanceof Panes.Left) { showLeftPane(); } } else { if (fm.findFragmentById(R.id.main) != null || left_pane_used) { showLeftPane(); } else if (right_pane_used) { showRightPane(); } } if (main_view != null) { final int visibility = left_pane_used ? View.GONE : View.VISIBLE; // Visibility changed, so start animation. if (main_view.getVisibility() != visibility) { final Animation anim = AnimationUtils.loadAnimation(this, left_pane_used ? android.R.anim.fade_out : android.R.anim.fade_in); main_view.startAnimation(anim); } main_view.setVisibility(visibility); } } }
From source file:org.thomasamsler.android.flashcards.fragment.CardFragment.java
private void turnPage(final View view) { /*/*from w w w. j a v a2 s . c om*/ * If in edit mode, we don't allow the user to switch between the front and back page. */ if (mEditTextWord.isShown()) { return; } final Animation flip1 = AnimationUtils.loadAnimation(view.getContext(), R.anim.flip1); final Animation flip2 = AnimationUtils.loadAnimation(view.getContext(), R.anim.flip2); flip1.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation animation) { /* Nothing to do here */ } public void onAnimationRepeat(Animation animation) { /* Nothing to do here */ } public void onAnimationEnd(Animation animation) { mWordToggle ^= true; if (mWordToggle) { mTextViewQuestion.setVisibility(View.INVISIBLE); mTextViewAnswer.setVisibility(View.VISIBLE); mCounterTextView.setText(mCounterStringBuilder.toString()); mCounterTextView.append(BACK); } else { mTextViewQuestion.setVisibility(View.VISIBLE); mTextViewAnswer.setVisibility(View.INVISIBLE); mCounterTextView.setText(mCounterStringBuilder.toString()); mCounterTextView.append(FRONT); } view.startAnimation(flip2); } }); view.startAnimation(flip1); }
From source file:com.javierarboleda.visualtilestogether.activities.SignInActivity.java
private void animateSignInButton(float fromAlpha, float toAlpha, final boolean invisible) { final View googleIconImageView = findViewById(R.id.ivGoogleIcon); final View signInTextView = findViewById(R.id.tvSignIn); final View buttonOutlineView = findViewById(R.id.viewButtonOutline); Animation animation = new AlphaAnimation(fromAlpha, toAlpha); if (invisible) { animation.setDuration(300);/* w w w . j a v a 2 s. c o m*/ mSignInButton.setIndeterminateProgressMode(true); mSignInButton.setProgress(50); mSignInButton.setClickable(false); } else { animation.setDuration(900); mSignInButton.setProgress(0); mSignInButton.setClickable(true); } animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (invisible) { googleIconImageView.setVisibility(View.INVISIBLE); signInTextView.setVisibility(View.INVISIBLE); buttonOutlineView.setVisibility(View.INVISIBLE); } else { googleIconImageView.setVisibility(View.VISIBLE); signInTextView.setVisibility(View.VISIBLE); buttonOutlineView.setVisibility(View.VISIBLE); } } @Override public void onAnimationRepeat(Animation animation) { } }); googleIconImageView.startAnimation(animation); signInTextView.startAnimation(animation); buttonOutlineView.startAnimation(animation); }
From source file:org.ale.openwatch.feeds.RemoteRecordingsListFragment.java
private void addListViewHeader() { if (feed.compareTo(Constants.OWFeedType.MISSION.toString().toLowerCase()) == 0) { if (getActivity() == null) return; LayoutInflater inflater = (LayoutInflater) parentActivity .getSystemService(parentActivity.LAYOUT_INFLATER_SERVICE); View missionHeader = inflater.inflate(R.layout.mission_header, (ViewGroup) getListView(), false); if (missionHeader != null) { missionHeader.setOnClickListener(new View.OnClickListener() { @Override/* w w w . j av a2s . c o m*/ public void onClick(View v) { final View missionHeader = v; SharedPreferences.Editor profile = getActivity() .getSharedPreferences(Constants.PROFILE_PREFS, 0).edit(); profile.putBoolean(Constants.MISSION_TIP, true); profile.commit(); Animation fadeOut = AnimationUtils.loadAnimation(v.getContext(), R.anim.fadeout); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { missionHeader.findViewById(R.id.missionBadge).setVisibility(View.GONE); missionHeader.findViewById(R.id.missionButton).setVisibility(View.GONE); missionHeader.findViewById(R.id.tapToDismiss).setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(fadeOut); } }); } this.getListView().addHeaderView(missionHeader); } }
From source file:org.thomasamsler.android.flashcards.fragment.AddCardFragment.java
private void flipCard(final View v) { final Animation flip1 = AnimationUtils.loadAnimation(v.getContext(), R.anim.flip1); final Animation flip2 = AnimationUtils.loadAnimation(v.getContext(), R.anim.flip2); flip1.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation animation) { /* Nothing to do here */ } public void onAnimationRepeat(Animation animation) { /* Nothing to do here */ } public void onAnimationEnd(Animation animation) { mWordToggle ^= true;/*from w w w . j a v a 2s . co m*/ if (mWordToggle) { // Back side // Save front side word mFrontPageWord = mEditText.getText().toString().trim(); // Restore back side word if (null == mBackPageWord || "".equals(mBackPageWord)) { mEditText.setText(""); } else { mEditText.setText(mBackPageWord); } mTextViewTitle.setText(R.string.add_card_back_title); } else { // Front side // Save back side word mBackPageWord = mEditText.getText().toString().trim(); // Restore front side word if (null == mFrontPageWord || "".equals(mFrontPageWord)) { mEditText.setText(""); } else { mEditText.setText(mFrontPageWord); } mTextViewTitle.setText(R.string.add_card_front_title); } v.startAnimation(flip2); } }); v.startAnimation(flip1); }