List of usage examples for android.view.animation AnimationUtils loadAnimation
public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException
From source file:com.sim2dial.dialer.InCallActivity.java
private void hideAnimatedLandscapeCallOptions() { Animation animation = slideOutTopToBottom; if (isTransferAllowed) { animation.setAnimationListener(new AnimationListener() { @Override// ww w . j ava2s .c o m public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { transfer.setAnimation(null); transfer.setVisibility(View.INVISIBLE); animation = AnimationUtils.loadAnimation(InCallActivity.this, R.anim.slide_out_top_to_bottom); // Reload // animation // to // prevent // transfer // button // to // blink animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // addCall.setVisibility(View.INVISIBLE); } }); addCall.startAnimation(animation); } }); transfer.startAnimation(animation); } else { animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // addCall.setVisibility(View.INVISIBLE); } }); addCall.startAnimation(animation); } }
From source file:com.arthurtimberly.fragments.CaptureFragment.java
/** * Prepares for the next capture or jump to next fragment if all frames have been collected. *///from w w w. ja v a2s . c o m private void prepareNextCapture() { if (isActivityAlive()) { // Cancel review overlay touch listener. mReviewOverlay.setOnTouchListener(null); // Increment frame index. mFrameIndex++; // Check if we need more frames. if (mFrameIndex < mFramesTotal) { // Update title. mTitle.setText( String.format(getString(R.string.capture__title_frame), mFrameIndex + 1, mFramesTotal)); // Restart preview. if (mCamera != null && mPreview != null) { try { mPreview.restart(); } catch (RuntimeException exception) { final LaunchActivity activity = (LaunchActivity) getActivity(); if (activity != null && !activity.isFinishing()) { String title = getString(R.string.capture__error_camera_dialog_title); String message = getString(R.string.capture__error_camera_dialog_message_dead); activity.showDialogFragment(ErrorDialogFragment.newInstance(title, message)); } } } // Fade out review overlay. Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { // Do nothing. } @Override public void onAnimationRepeat(Animation animation) { // Do nothing. } @Override public void onAnimationEnd(Animation animation) { // Hide the review overlay. mReviewOverlay.setVisibility(View.GONE); mReviewImage.setImageBitmap(null); // Capture next frames. if (mTriggerMode == TRIGGER_MODE_COUNTDOWN) { kickoffCountdownCapture(); } else if (mTriggerMode == TRIGGER_MODE_BURST) { kickoffBurstCapture(); } else { // Enable start button. mStartButton.setEnabled(true); mStartButton.setVisibility(View.VISIBLE); } } }); mReviewOverlay.startAnimation(animation); } else { // Set flag to indicate capture sequence is no longer running. mIsCaptureSequenceRunning = false; // Transition to next fragment since enough frames have been captured. nextFragment(); } } }
From source file:com.github.jthuraisamy.yellowusage.ui.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem refreshItem = menu.findItem(R.id.action_refresh); Log.d(TAG, "isMobileDataEnabled = " + isMobileDataEnabled(connectivityManager)); Log.d(TAG, "isMobileDataConnected = " + isMobileDataConnected(telephonyManager)); Log.d(TAG, "isWifiConnected = " + isWifiConnected(wifiManager)); // Stop refresh icon animation if it's already ongoing. if (refreshItemActionView != null) refreshItemActionView.clearAnimation(); refreshItem.setActionView(null);/*from w w w . j a v a 2 s.co m*/ boolean waitingForData = (!taskQueue.isEmpty()) && (!isMobileDataConnected(telephonyManager)); // (Re-)Start preparing refresh icon animation while waiting for mobile data connection. if (waitingForData) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") ImageView animatingRefreshIcon = (ImageView) layoutInflater.inflate(R.layout.icon_refresh, null); Animation clockwiseRotation = AnimationUtils.loadAnimation(this, R.anim.counterclockwise_refresh); animatingRefreshIcon.startAnimation(clockwiseRotation); refreshItem.setActionView(animatingRefreshIcon); // getActionView() always returns null in the else block, so it's assigned to a member variable. refreshItemActionView = refreshItem.getActionView(); } // (Re-)Start refresh icon animation only if there are ongoing tasks. if (ongoingTasks > 0) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") ImageView animatingRefreshIcon = (ImageView) layoutInflater.inflate(R.layout.icon_refresh, null); Animation clockwiseRotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_refresh); animatingRefreshIcon.startAnimation(clockwiseRotation); refreshItem.setActionView(animatingRefreshIcon); // getActionView() always returns null in the else block, so it's assigned to a member variable. refreshItemActionView = refreshItem.getActionView(); } return super.onPrepareOptionsMenu(menu); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public void setCandidatesViewShown(boolean shown) { // we show predication only in on-screen keyboard // (onEvaluateInputViewShown) // or if the physical keyboard supports candidates // (mPredictionLandscape) final boolean shouldShow = shouldCandidatesStripBeShown() && shown; final boolean currentlyShown = mCandidatesParent != null && mCandidatesParent.getVisibility() == View.VISIBLE; super.setCandidatesViewShown(shouldShow); if (shouldShow != currentlyShown) { // I believe (can't confirm it) that candidates animation is kinda rare, // and it is better to load it on demand, then to keep it in memory always.. if (shouldShow) { mCandidatesParent/*from ww w . j a v a 2 s .co m*/ .setAnimation(AnimationUtils.loadAnimation(this, R.anim.candidates_bottom_to_up_enter)); } else { mCandidatesParent .setAnimation(AnimationUtils.loadAnimation(this, R.anim.candidates_up_to_bottom_exit)); } } }
From source file:com.dirkgassen.wator.ui.activity.MainActivity.java
/** * Handle post-create initialization. We cannot find fragments in the activity in {@link #onCreate(Bundle)}. * We also need to synchronize the state of the {@link #drawerToggle} to get the hamburger menu. * @param savedInstanceState Bundle with state to restore (ignored) *//*from w w w . j a va 2s.c om*/ @Override protected void onPostCreate(@Nullable Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); drawerToggle.syncState(); FragmentManager fm = getSupportFragmentManager(); Fragment newWorldFragment = fm.findFragmentByTag(NEW_WORLD_FRAGMENT_TAG); if (newWorldFragment != null) { newWorldView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_down)); newWorldView.setVisibility(View.VISIBLE); } }
From source file:com.android.argb.edhlc.Utils.java
public static void expand(Context context, final CardView card, TextView title, ImageView selector, int minHeight, int maxHeight) { title.setTextColor(ContextCompat.getColor(context, R.color.accent_color_dark)); Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate_180_anticlockwise); selector.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.arrow_up)); selector.setRotation(0);/*w w w . ja v a2 s .co m*/ selector.startAnimation(rotation); selector.setColorFilter(ContextCompat.getColor(context, R.color.accent_color_dark)); ValueAnimator anim = ValueAnimator.ofInt(minHeight, maxHeight); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = card.getLayoutParams(); layoutParams.height = val; card.setLayoutParams(layoutParams); Utils.makeViewVisible(card); } }); anim.start(); }
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.Dialog.java
@Override protected void onStart() { super.onStart(); mCardView.setVisibility(View.VISIBLE); if (mInAnimationId != 0) mCardView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override//from w w w. ja v a2 s . c om public boolean onPreDraw() { mCardView.getViewTreeObserver().removeOnPreDrawListener(this); Animation anim = AnimationUtils.loadAnimation(mCardView.getContext(), mInAnimationId); mCardView.startAnimation(anim); return false; } }); }
From source file:com.saphion.stencilweather.activities.MainActivity.java
public void bounceScaleAnimation(View mView, int delay) { // YoYo.with(Techniques.ZoomIn).interpolate(new BounceInterpolator()).duration(180).delay(delay).playOn(mView); Animation pulse = AnimationUtils.loadAnimation(this, R.anim.pulse); pulse.setStartOffset(delay);/* ww w .ja v a 2s . c om*/ mView.startAnimation(pulse); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
private void setScrollContent() { // collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); // final RelativeLayout img_container1=(RelativeLayout)findViewById(R.id.img_container1); // load the animation final Animation animFadein = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fadein); // start the animation // set animation listener animFadein.setAnimationListener(new Animation.AnimationListener() { @Override// w w w . j a va 2 s .co m public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { /* if(img_container1.getVisibility() == View.VISIBLE) { img_container1.setVisibility(View.GONE); }*/ } @Override public void onAnimationRepeat(Animation animation) { } }); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { boolean isShow = false; int scrollRange = -1; @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (scrollRange == -1) { scrollRange = appBarLayout.getTotalScrollRange(); // Log.e("val","-1 choti imge ko hide kerna h"); // img_container1.setVisibility(View.GONE); } if (scrollRange + verticalOffset == 0) { // collapsingToolbarLayout.setTitle("Title"); // Log.e("val","0 choti imge ko show kerna h"); // img_container1.setVisibility(View.VISIBLE); // img_container1.startAnimation(animFadein); isShow = true; } else if (isShow) { // collapsingToolbarLayout.setTitle(" ");//carefull there should a space between double quote otherwise it wont work //Log.e("val","Showing choti imge ko hide kerna h"); // img_container1.setVisibility(View.GONE); isShow = false; } } }); }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public void setCandidatesView(@NonNull View view) { super.setCandidatesView(view); mCandidatesParent = view.getParent() instanceof View ? (View) view.getParent() : null; mCandidateView = (CandidateView) view.findViewById(R.id.candidates); mCandidateView.setService(this); setCandidatesViewShown(false);/*from w w w .j a v a2 s . com*/ final KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(getApplicationContext()); final TypedArray a = theme.getPackageContext().obtainStyledAttributes(null, R.styleable.AnyKeyboardViewTheme, 0, theme.getThemeResId()); int closeTextColor = ContextCompat.getColor(this, R.color.candidate_other); float fontSizePixel = getResources().getDimensionPixelSize(R.dimen.candidate_font_height); Drawable suggestionCloseDrawable = null; try { closeTextColor = a.getColor(R.styleable.AnyKeyboardViewTheme_suggestionOthersTextColor, closeTextColor); fontSizePixel = a.getDimension(R.styleable.AnyKeyboardViewTheme_suggestionTextSize, fontSizePixel); suggestionCloseDrawable = a.getDrawable(R.styleable.AnyKeyboardViewTheme_suggestionCloseImage); } catch (Exception e) { e.printStackTrace(); } a.recycle(); mCandidateCloseText = (TextView) view.findViewById(R.id.close_suggestions_strip_text); ImageView closeIcon = (ImageView) view.findViewById(R.id.close_suggestions_strip_icon); if (suggestionCloseDrawable != null) closeIcon.setImageDrawable(suggestionCloseDrawable); closeIcon.setOnClickListener(new OnClickListener() { // two seconds is enough. private static final long DOUBLE_TAP_TIMEOUT = 2 * 1000 - 50; public void onClick(View v) { mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); mCandidateCloseText.setVisibility(View.VISIBLE); mCandidateCloseText.startAnimation( AnimationUtils.loadAnimation(getApplicationContext(), R.anim.close_candidates_hint_in)); mKeyboardHandler.sendMessageDelayed( mKeyboardHandler.obtainMessage(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT), DOUBLE_TAP_TIMEOUT); } }); mCandidateCloseText.setTextColor(closeTextColor); mCandidateCloseText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSizePixel); mCandidateCloseText.setOnClickListener(new OnClickListener() { public void onClick(View v) { mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); mCandidateCloseText.setVisibility(View.GONE); abortCorrectionAndResetPredictionState(true); } }); }