List of usage examples for android.view.animation AnimationSet setFillAfter
@Override public void setFillAfter(boolean fillAfter)
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Create dynamically an android animation for a coin or a bill droping into * the moneybox.//from ww w . j av a 2 s .c o m * * @param img * ImageView to receive the animation * @param layout * Layout that paint the image * @param curr * Currency value of the image * @return Set of animations to apply to the image */ private AnimationSet createDropAnimation(ImageView img, View layout, CurrencyValueDef curr) { AnimationSet result; result = new AnimationSet(false); result.setFillAfter(true); // Fade in AlphaAnimation fadeIn; fadeIn = new AlphaAnimation(0.0f, 1.0f); fadeIn.setDuration(300); result.addAnimation(fadeIn); // drop TranslateAnimation drop; int bottom; bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height); drop = new TranslateAnimation(1.0f, 1.0f, 1.0f, bottom); drop.setStartOffset(300); drop.setDuration(1500); if (curr.getType() == CurrencyValueDef.MoneyType.COIN) { drop.setInterpolator(new BounceInterpolator()); } else { // drop.setInterpolator(new DecelerateInterpolator(0.7f)); drop.setInterpolator(new AnticipateOvershootInterpolator()); } result.addAnimation(drop); return result; }
From source file:com.fabernovel.alertevoirie.HomeActivity.java
@Override public void onRequestcompleted(int requestCode, Object result) { try {/*from ww w . j a va 2s . c o m*/ JSONArray responses; //Log.d(Constants.PROJECT_TAG, (String) result); responses = new JSONArray((String) result); JSONObject response = responses.getJSONObject(0); final AnimationSet set = new AnimationSet(false); final float centerX = findViewById(R.id.LinearLayout02).getWidth() / 2; final float centerY = findViewById(R.id.LinearLayout02).getHeight() / 2; final Flip3dAnimation animation = new Flip3dAnimation(0, 360, centerX, centerY); animation.setDuration(500); set.setFillAfter(true); set.setFillBefore(true); animation.setInterpolator(new AccelerateInterpolator()); set.addAnimation(animation); if (requestCode == AVService.REQUEST_JSON) { if (JsonData.VALUE_REQUEST_GET_INCIDENTS_STATS.equals(response.getString(JsonData.PARAM_REQUEST))) { Last_Location.Incidents = response.getJSONObject(JsonData.PARAM_ANSWER); int resolved_incidents = response.getJSONObject(JsonData.PARAM_ANSWER) .getInt(JsonData.PARAM_RESOLVED_INCIDENTS); int ongoing_incidents = response.getJSONObject(JsonData.PARAM_ANSWER) .getInt(JsonData.PARAM_ONGOING_INCIDENTS); int updated_incidents = response.getJSONObject(JsonData.PARAM_ANSWER) .getInt(JsonData.PARAM_UPDATED_INCIDENTS); ((TextView) findViewById(R.id.Home_TextView_Solved)).setText(getResources().getQuantityString( R.plurals.home_label_solved, resolved_incidents, resolved_incidents)); ((TextView) findViewById(R.id.Home_TextView_Current)).setText(getResources() .getQuantityString(R.plurals.home_label_current, ongoing_incidents, ongoing_incidents)); ((TextView) findViewById(R.id.Home_TextView_Update)).setText(getResources() .getQuantityString(R.plurals.home_label_update, updated_incidents, updated_incidents)); } } findViewById(R.id.LinearLayout02).startAnimation(set); findViewById(R.id.LinearLayout04).startAnimation(set); findViewById(R.id.LinearLayout03).startAnimation(set); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "JSONException", e); } catch (ClassCastException e) { Log.e(Constants.PROJECT_TAG, "Invalid result. Trying to cast " + result.getClass() + "into String", e); } finally { if (hidedialog) dismissDialog(DIALOG_PROGRESS); dialog_shown = false; } }
From source file:com.alibaba.weex.extend.component.WXParallax.java
@Override public void onScrolled(View view, int dx, int dy) { if (ViewCompat.isInLayout(view)) { if (mBindingComponent == null && mBindingRef != null) { mBindingComponent = findComponent(mBindingRef); }//w ww . j a va2 s .co m if (mBindingComponent instanceof BasicListComponent && view instanceof RecyclerView) { BasicListComponent listComponent = (BasicListComponent) mBindingComponent; mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view)); } else if (mBindingComponent instanceof WXRecyclerTemplateList && view instanceof RecyclerView) { WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent; mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view)); } } else { mOffsetY = mOffsetY + dy; } AnimationSet animationSet = new AnimationSet(true); boolean hasAnimation = false; for (int i = 0; i < mTransformPropArrayList.size(); i++) { TransformCreator creator = mTransformPropArrayList.get(i); Animation animation = creator.getAnimation(dx, dy); if (animation != null) { animationSet.addAnimation(animation); hasAnimation = true; } } if (hasAnimation) { animationSet.setFillAfter(true); if (getHostView() != null) { getHostView().startAnimation(animationSet); } } if (mBackgroundColor != null) { int color = mBackgroundColor.getColor(dx, dy); if (mBackGroundColor != color) { getHostView().setBackgroundColor(color); mBackGroundColor = color; } } }
From source file:com.example.fragment.ScreenSlidePageFragment.java
public void startAnimation() { // SELECT LAYER ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;/*ww w . j a va 2 s . c o m*/ float toX = -8.0f / 100.0f;//0.0f; float fromX = 0.0f;//-8.0f / 100.0f; float toY = 0.0f; float fromY = 29.0f / 100.0f; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(2000); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:ly.kite.journey.selection.ProductOverviewFragment.java
/***************************************************** * * Returns the content view for this fragment * *****************************************************/ @Override/*from www . java2 s . c o m*/ public View onCreateView(LayoutInflater layoutInflator, ViewGroup container, Bundle savedInstanceState) { boolean slidingDrawerIsExpanded = false; // Get any saved instance state if (savedInstanceState != null) { slidingDrawerIsExpanded = savedInstanceState.getBoolean(BUNDLE_KEY_SLIDING_DRAWER_IS_EXPANDED, false); } else { Analytics.getInstance(mKiteActivity).trackProductOverviewScreenViewed(mProduct); } // Set up the screen. Note that the SDK allows for different layouts to be used in place of the standard // one, so some of these views are optional and may not actually exist in the current layout. View view = layoutInflator.inflate(R.layout.screen_product_overview, container, false); mProductImageViewPager = (ViewPager) view.findViewById(R.id.view_pager); mOverlaidComponents = view.findViewById(R.id.overlaid_components); mPagingDots = (PagingDots) view.findViewById(R.id.paging_dots); mOverlaidStartButton = (Button) view.findViewById(R.id.overlaid_start_button); mSlidingOverlayFrame = (SlidingOverlayFrame) view.findViewById(R.id.sliding_overlay_frame); mDrawerControlLayout = view.findViewById(R.id.drawer_control_layout); mOpenCloseDrawerIconImageView = (ImageView) view.findViewById(R.id.open_close_drawer_icon_image_view); mProceedOverlayButton = (Button) view.findViewById(R.id.proceed_overlay_button); TextView priceTextView = (TextView) view.findViewById(R.id.price_text_view); TextView summaryDescriptionTextView = (TextView) view.findViewById(R.id.summary_description_text_view); TextView summaryShippingTextView = (TextView) view.findViewById(R.id.summary_shipping_text_view); View descriptionLayout = view.findViewById(R.id.description_layout); TextView descriptionTextView = (TextView) view.findViewById(R.id.description_text_view); View sizeLayout = view.findViewById(R.id.size_layout); TextView sizeTextView = (TextView) view.findViewById(R.id.size_text_view); View quantityLayout = view.findViewById(R.id.quantity_layout); TextView quantityTextView = (TextView) view.findViewById(R.id.quantity_text_view); TextView shippingTextView = (TextView) view.findViewById(R.id.shipping_text_view); // Paging dots Animation pagingDotOutAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_OPAQUE, PAGING_DOT_ANIMATION_TRANSLUCENT); pagingDotOutAlphaAnimation.setFillAfter(true); pagingDotOutAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS); Animation pagingDotOutScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); pagingDotOutScaleAnimation.setFillAfter(true); pagingDotOutScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS); pagingDotOutScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 0.8f, true)); AnimationSet pagingDotOutAnimation = new AnimationSet(false); pagingDotOutAnimation.addAnimation(pagingDotOutAlphaAnimation); pagingDotOutAnimation.addAnimation(pagingDotOutScaleAnimation); pagingDotOutAnimation.setFillAfter(true); Animation pagingDotInAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_TRANSLUCENT, PAGING_DOT_ANIMATION_OPAQUE); pagingDotInAlphaAnimation.setFillAfter(true); pagingDotInAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS); Animation pagingDotInScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); pagingDotInScaleAnimation.setFillAfter(true); pagingDotInScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS); pagingDotInScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 1.2f)); AnimationSet pagingDotInAnimation = new AnimationSet(false); pagingDotInAnimation.addAnimation(pagingDotInAlphaAnimation); pagingDotInAnimation.addAnimation(pagingDotInScaleAnimation); pagingDotInAnimation.setFillAfter(true); mPagingDots.setProperties(mProduct.getImageURLList().size(), R.drawable.paging_dot_unselected, R.drawable.paging_dot_selected); mPagingDots.setOutAnimation(pagingDotOutAlphaAnimation); mPagingDots.setInAnimation(pagingDotInAnimation); mProductImageViewPager.setOnPageChangeListener(mPagingDots); mOverlaidComponents.setAlpha(slidingDrawerIsExpanded ? 0f : 1f); // If the drawer starts open, these components need to be invisible if (mSlidingOverlayFrame != null) { mSlidingOverlayFrame.snapToExpandedState(slidingDrawerIsExpanded); mSlidingOverlayFrame.setSlideAnimationDuration(SLIDE_ANIMATION_DURATION_MILLIS); mOpenCloseDrawerIconImageView.setRotation( slidingDrawerIsExpanded ? OPEN_CLOSE_ICON_ROTATION_DOWN : OPEN_CLOSE_ICON_ROTATION_UP); } SingleUnitSize size = mProduct.getSizeWithFallback(UnitOfLength.CENTIMETERS); boolean formatAsInt = size.getWidth() == (int) size.getWidth() && size.getHeight() == (int) size.getHeight(); String sizeFormatString = getString( formatAsInt ? R.string.product_size_format_string_int : R.string.product_size_format_string_float); String sizeString = String.format(sizeFormatString, size.getWidth(), size.getHeight(), size.getUnit().shortString(mKiteActivity)); int quantityPerSheet = mProduct.getQuantityPerSheet(); MultipleDestinationShippingCosts shippingCosts = mProduct.getShippingCosts(); Locale locale = Locale.getDefault(); Country country = Country.getInstance(locale); SingleCurrencyAmount singleCurrencyCost; // Price if (isVisible(priceTextView)) { singleCurrencyCost = mProduct.getCostWithFallback(locale); if (singleCurrencyCost != null) priceTextView.setText(singleCurrencyCost.getDisplayAmountForLocale(locale)); } // Summary description. This is a short description - not to be confused with the (full) description. if (isVisible(summaryDescriptionTextView)) { String summaryDescription = String.valueOf(quantityPerSheet) + " " + mProduct.getName() + (Product.isSensibleSize(size) ? " (" + sizeString + ")" : ""); summaryDescriptionTextView.setText(summaryDescription); } // (Full) description String description = mProduct.getDescription(); boolean haveDescription = (description != null && (!description.trim().equals(""))); if (haveDescription && descriptionLayout != null && descriptionTextView != null) { descriptionLayout.setVisibility(View.VISIBLE); descriptionTextView.setVisibility(View.VISIBLE); descriptionTextView.setText(description); } else { if (descriptionLayout != null) descriptionLayout.setVisibility(View.GONE); if (descriptionTextView != null) descriptionTextView.setVisibility(View.GONE); } // Size if (isVisible(sizeTextView)) { if (Product.isSensibleSize(size)) { sizeTextView.setText(String.format(sizeFormatString, size.getWidth(), size.getHeight(), size.getUnit().shortString(mKiteActivity))); } else { sizeLayout.setVisibility(View.GONE); } } // Quantity if (isVisible(quantityTextView)) { if (quantityPerSheet > 1) { quantityLayout.setVisibility(View.VISIBLE); quantityTextView.setText(getString(R.string.product_quantity_format_string, quantityPerSheet)); } else { quantityLayout.setVisibility(View.GONE); } } // Shipping description if (isVisible(summaryShippingTextView)) { // Currently we just check that shipping is free everywhere. If it isn't - we don't display // anything. boolean freeShippingEverywhere = true; MultipleDestinationShippingCosts multipleDestinationShippingCosts = shippingCosts; for (SingleDestinationShippingCost singleDestinationShippingCosts : multipleDestinationShippingCosts .asList()) { MultipleCurrencyAmount multipleCurrencyShippingCost = singleDestinationShippingCosts.getCost(); for (SingleCurrencyAmount singleCurrencyShippingCost : multipleCurrencyShippingCost .asCollection()) { if (singleCurrencyShippingCost.isNonZero()) { freeShippingEverywhere = false; } } } if (freeShippingEverywhere) { summaryShippingTextView.setText(R.string.product_free_worldwide_shipping); } else { summaryShippingTextView.setText(getString(R.string.product_shipping_summary_format_string, shippingCosts.getDisplayCost(locale))); } } // Shipping (postage) if (isVisible(shippingTextView)) { List<SingleDestinationShippingCost> sortedShippingCostList = mProduct.getSortedShippingCosts(country); StringBuilder shippingCostsStringBuilder = new StringBuilder(); String newlineString = ""; for (SingleDestinationShippingCost singleDestinationShippingCost : sortedShippingCostList) { // We want to prepend a new line for every shipping destination except the first shippingCostsStringBuilder.append(newlineString); newlineString = "\n"; // Get the cost in the default currency for the locale, and format the amount. singleCurrencyCost = singleDestinationShippingCost.getCost().getDefaultAmountWithFallback(); if (singleCurrencyCost != null) { String formatString = getString(R.string.product_shipping_format_string); String costString = (singleCurrencyCost.isNonZero() ? singleCurrencyCost.getDisplayAmountForLocale(locale) : getString(R.string.product_free_shipping)); shippingCostsStringBuilder.append(String.format(formatString, singleDestinationShippingCost.getDestinationDescription(mKiteActivity), costString)); } shippingTextView.setText(shippingCostsStringBuilder.toString()); } } if (mProceedOverlayButton != null) { mProceedOverlayButton.setText(R.string.product_overview_start_button_text); mProceedOverlayButton.setOnClickListener(this); } mProductImageViewPager.setOnClickListener(this); if (mDrawerControlLayout != null) mDrawerControlLayout.setOnClickListener(this); mOverlaidStartButton.setOnClickListener(this); return (view); }
From source file:com.wenwen.chatuidemo.activity.NewFragment.java
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { AnimationSet _AnimationSet = new AnimationSet(true); TranslateAnimation _TranslateAnimation; if (checkedId == R.id.btn1) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo1), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100);/*from w w w .j ava2 s .c o m*/ mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(1); mRadioButton1.setTextColor(Color.RED); } else if (checkedId == R.id.btn2) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo2), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(2); } else if (checkedId == R.id.btn3) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo3), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(3); } else if (checkedId == R.id.btn4) { _TranslateAnimation = new TranslateAnimation(mCurrentCheckedRadioLeft, getResources().getDimension(R.dimen.rdo4), 0f, 0f); _AnimationSet.addAnimation(_TranslateAnimation); _AnimationSet.setFillBefore(false); _AnimationSet.setFillAfter(true); _AnimationSet.setDuration(100); mImageView.startAnimation(_AnimationSet); mViewPager.setCurrentItem(4); } mCurrentCheckedRadioLeft = getCurrentCheckedRadioLeft(); DebugLog.i("zj", "getCurrentCheckedRadioLeft=" + getCurrentCheckedRadioLeft()); DebugLog.i("zj", "getDimension=" + getResources().getDimension(R.dimen.rdo2)); mHorizontalScrollView.smoothScrollTo( (int) mCurrentCheckedRadioLeft - (int) getResources().getDimension(R.dimen.rdo2), 0); }
From source file:com.example.fragment.PrimitiveFragment.java
public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;/*w w w .j ava 2 s . co m*/ float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.example.fragment.PrimitiveFragment.java
public void move(float destX, float destY) { if (!this.mIsAlive) return;//from w w w.j av a2 s . co m if (this.mIsMoving) { return;// ADD Array } this.mDestX = Factory.getAdjustedX(destX - this.mPaddingW); this.mDestY = Factory.getAdjustedY(destY - this.mPaddingH); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate; float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); this.mIsMoving = true; this.mIsMove = true; }
From source file:com.watasan.infospider.fragment.PrimitiveFragment.java
/** SCRIPT ACTION AREA --------------------------------------------------> */ public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;// w ww . j a v a 2 s. co m float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
protected void animateDragged() { View view = imgBarAvatar;//from w w w. j av a 2 s . c o m float x = 0; try { x = imgBarAvatar.getX(); } catch (NoSuchMethodError e) { } if (pager.getCurrentItem() == 0) { btnOptionsColumnsEdit.setVisibility(View.GONE); } else { btnOptionsColumnsEdit.setVisibility(View.VISIBLE); } view.layout(imgBarAvatar.getLeft(), imgBarAvatar.getTop(), imgBarAvatar.getRight(), imgBarAvatar.getBottom()); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, imgBarAvatar.getHeight() * 3 / 4, imgBarAvatar.getWidth() * 3 / 4); scale.setDuration(150); animSet.addAnimation(scale); animSet.setFillEnabled(true); animSet.setFillAfter(true); view.clearAnimation(); view.startAnimation(animSet); showOptionsColumns((int) x, pager.getCurrentItem(), false); }