List of usage examples for android.view.animation Animation setDuration
public void setDuration(long durationMillis)
From source file:com.spoiledmilk.ibikecph.map.MapActivity.java
private void translate(float deltaX, final boolean finalAnim) { if (leftMenu != null && leftMenu.getView() != null) { newX = posX + deltaX;/*from w ww. ja va 2 s .c om*/ if (slidden) { if (newX < -maxSlide) newX = -maxSlide; else if (newX > 0) newX = 0; } else { if (newX < 0) newX = 0; else if (newX > maxSlide) newX = maxSlide; } if (((int) newX) <= 0) { mapDisabledView.setVisibility(View.GONE); } final boolean newSlidden = slidden ? newX > -SLIDE_THRESHOLD : newX > SLIDE_THRESHOLD; if (finalAnim) { newX = (slidden == newSlidden) ? 0 : (slidden ? -maxSlide : maxSlide); } if (animation != null && animation.isInitialized()) { parentContainer.clearAnimation(); animation.cancel(); leftMenu.getView().invalidate(); } LOG.d("translate animation from posX " + posX + " to " + newX); animation = new TranslateAnimation(posX, newX, 0, 0); animation.setDuration(finalAnim ? 100 : 0); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (!finalAnim) { animation.setFillEnabled(true); animation.setFillAfter(true); } else { parentContainer.clearAnimation(); if (slidden == newSlidden) { if (!slidden) { leftContainer.setVisibility(View.GONE); mapDisabledView.setVisibility(View.GONE); leftMenu.getView().invalidate(); } else { mapDisabledView.setVisibility(View.VISIBLE); leftMenu.getView().invalidate(); } return; } slidden = newSlidden; int leftmargin = slidden ? maxSlide : 0; int rightMargin = slidden ? 0 : maxSlide; RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) parentContainer .getLayoutParams(); lp.setMargins(leftmargin, lp.topMargin, rightMargin, lp.bottomMargin); parentContainer.setLayoutParams(lp); if (leftmargin == 0) { leftContainer.setVisibility(View.GONE); mapDisabledView.setVisibility(View.GONE); leftMenu.getView().invalidate(); } posX = 0; Fragment fr = getSupportFragmentManager().findFragmentById(R.id.leftContainer); if (fr != null && fr instanceof EditFavoriteFragment) { ((EditFavoriteFragment) fr).hideKeyboard(); } else if (fr != null && fr instanceof AddFavoriteFragment) { ((AddFavoriteFragment) fr).hideKeyboard(); } } } }); posX = newX; parentContainer.startAnimation(animation); } }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
public Animation fadeInAnimation() { Animation fadeInAnimation = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); fadeInAnimation.setStartOffset(200); fadeInAnimation.setDuration(300); return fadeInAnimation; }
From source file:com.mojtaba.materialdatetimepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView: "); getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, null); mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day); mYearView = (TextView) view.findViewById(R.id.date_picker_year); mYearView.setOnClickListener(this); int listPosition = -1; int listPositionOffset = 0; int currentView = MONTH_AND_DAY_VIEW; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (PersianCalendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (PersianCalendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (PersianCalendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (PersianCalendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); }/*from w w w . ja v a 2 s .c o m*/ final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mPersianCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (mCallBack != null) { mCallBack.onDateSet(DatePickerDialog.this, mPersianCalendar.getPersianYear(), mPersianCalendar.getPersianMonth(), mPersianCalendar.getPersianDay()); } dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDayOfWeekView != null) mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor); okButton.setTextColor(mAccentColor); cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.views.ui.snackbar.Snackbar.java
private void animateViewOut(final int event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.animate(mView).translationY(mView.getHeight()).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override// w w w.j a v a 2s . c o m public void onAnimationStart(View view) { mView.animateChildrenOut(0, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(View view) { onViewHidden(event); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out); anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewHidden(event); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.views.ui.snackbar.Snackbar.java
private void animateViewIn() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { ViewCompat.setTranslationY(mView, mView.getHeight()); ViewCompat.animate(mView).translationY(0f).setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR) .setDuration(ANIMATION_DURATION).setListener(new ViewPropertyAnimatorListenerAdapter() { @Override// w w w .ja va 2 s . co m public void onAnimationStart(View view) { mView.animateChildrenIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(View view) { onViewShown(); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in); anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:chinanurse.cn.nurse.list.WaveSwipeRefreshLayout.java
/** * @param listener {@link Animation.AnimationListener} *//*from ww w . j ava 2s .c om*/ private void startScaleDownAnimation(Animation.AnimationListener listener) { Animation scaleDownAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { mCircleView.scaleWithKeepingAspectRatio(1 - interpolatedTime); } }; scaleDownAnimation.setDuration(SCALE_DOWN_DURATION); mCircleView.setAnimationListener(listener); mCircleView.clearAnimation(); mCircleView.startAnimation(scaleDownAnimation); }
From source file:com.mark.quick.ui.view.snackbar.BaseTransientBottomBar.java
private void animateViewOut(final int event) { if (Build.VERSION.SDK_INT >= 12) { //TODO CHANGE 0 mView.setTranslationY(0);/*from w w w .j a va 2s .co m*/ final ValueAnimator animator = new ValueAnimator(); //TODO CHANGE ? animator.setIntValues(0, -mView.getHeight()); animator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); animator.setDuration(ANIMATION_DURATION); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(Animator animator) { onViewHidden(event); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { private int mPreviousAnimatedIntValue = 0; @Override public void onAnimationUpdate(ValueAnimator animator) { int currentAnimatedIntValue = (int) animator.getAnimatedValue(); if (USE_OFFSET_API) { ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - mPreviousAnimatedIntValue); } else { mView.setTranslationY(currentAnimatedIntValue); } mPreviousAnimatedIntValue = currentAnimatedIntValue; } }); animator.start(); } else { final Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out); anim.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewHidden(event); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:com.mark.quick.ui.view.snackbar.BaseTransientBottomBar.java
void animateViewIn() { if (Build.VERSION.SDK_INT >= 12) { //TODO CHANGE ? final int viewHeight = -mView.getHeight(); if (USE_OFFSET_API) { ViewCompat.offsetTopAndBottom(mView, viewHeight); } else {/* w w w .ja v a 2 s . com*/ mView.setTranslationY(viewHeight); } final ValueAnimator animator = new ValueAnimator(); animator.setIntValues(viewHeight, 0); animator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); animator.setDuration(ANIMATION_DURATION); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { mContentViewCallback.animateContentIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION); } @Override public void onAnimationEnd(Animator animator) { onViewShown(); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { private int mPreviousAnimatedIntValue = viewHeight; @Override public void onAnimationUpdate(ValueAnimator animator) { int currentAnimatedIntValue = (int) animator.getAnimatedValue(); if (USE_OFFSET_API) { ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - mPreviousAnimatedIntValue); } else { mView.setTranslationY(currentAnimatedIntValue); } mPreviousAnimatedIntValue = currentAnimatedIntValue; } }); animator.start(); } else { final Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in); anim.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); anim.setDuration(ANIMATION_DURATION); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { onViewShown(); } @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); mView.startAnimation(anim); } }
From source file:de.fahrgemeinschaft.RideDetailsFragment.java
private void fadeOutFast(final View view) { Animation fade_out = new AlphaAnimation(0.5f, 0f); fade_out.setAnimationListener(new AnimationListener() { @Override//from ww w .ja v a2 s .c o m public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } }); fade_out.setDuration(300); fade_out.setFillAfter(true); view.startAnimation(fade_out); }
From source file:ly.kite.journey.selection.ProductOverviewFragment.java
/***************************************************** * * Returns the content view for this fragment * *****************************************************/ @Override/* ww w .j av a 2 s .co 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); }