List of usage examples for android.view.animation Animation setFillAfter
public void setFillAfter(boolean fillAfter)
From source file:ly.kite.journey.selection.ProductOverviewFragment.java
/***************************************************** * * Returns the content view for this fragment * *****************************************************/ @Override/*from w w w . jav a2s. c om*/ 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.vaguehope.onosendai.widget.SidebarLayout.java
protected void animateSidebar(final boolean gotoOpen) { final View host = getHostView(); if (host.getAnimation() != null) return;/*from w w w . j ava 2 s .c o m*/ final float deltaX; final Animation animation; if (gotoOpen) { deltaX = host.getTranslationX() > 0 ? -host.getTranslationX() : -this.sidebarWidth; animation = new TranslateAnimation(0, deltaX, 0, 0); animation.setAnimationListener(this.openListener); } else { deltaX = this.sidebarWidth - host.getTranslationX(); animation = new TranslateAnimation(0, deltaX, 0, 0); animation.setAnimationListener(this.closeListener); } animation.setDuration((long) (SLIDE_DURATION * (Math.abs(deltaX) / this.sidebarWidth))); animation.setFillAfter(true); animation.setFillEnabled(true); host.startAnimation(animation); }
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/*w w w . j a v a 2 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:com.example.haber.ui.activity.TabbedActivity.java
private void addListener() { mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/*from w w w . j a v a 2 s . com*/ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { LogUtil.i(TAG, "PageScrolled" + position + " " + positionOffset + " " + positionOffsetPixels); } @Override public void onPageSelected(int position) { LogUtil.i(TAG, "PageSelected" + position + " "); } @Override public void onPageScrollStateChanged(int state) { LogUtil.i(TAG, "PageScrollStateChanged " + state); } }); ibHangUp.setOnClickListener(onClickListener); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } private int preIndex = 0; @Override public void onPageSelected(int position) { Animation animation = new TranslateAnimation(preIndex * (displayWidth / 3), position * (displayWidth / 3), 0, 0); animation.setDuration(200); animation.setFillAfter(true); tvLine.startAnimation(animation); preIndex = position; } @Override public void onPageScrollStateChanged(int state) { } }); btnPanZoomOut.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "zoom_out", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanZoomIn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "zoom_in", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanRight.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "right", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanLeft.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "left", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanUp.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "up", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanDown.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "down", -1); LogUtil.i(TAG, "DOWN"); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); LogUtil.i(TAG, "STOP"); break; } return true; } }); }
From source file:Steps.StepsFragment.java
/** * Animate the new sticker rotating them on left and right and back again * * @param sticker// ww w . ja v a2 s . c om * @param durationMillis */ private void animate(final RelativeLayout sticker, long durationMillis) { //final AnimationSet as = new AnimationSet(true); as.setFillEnabled(true); as.setFillAfter(true); //left rotations final RotateAnimation rotateLeft = new RotateAnimation((float) 320, (float) 375, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateLeft.setDuration(durationMillis); rotateLeft.setFillEnabled(true); if (firstTime) as.addAnimation(rotateLeft); //right rotations Animation rotateRight = new RotateAnimation((float) 375, (float) 320, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateRight.setStartOffset(durationMillis); rotateRight.setDuration(durationMillis); rotateRight.setFillEnabled(true); rotateRight.setFillAfter(true); if (firstTime) as.addAnimation(rotateRight); //sticker.clearAnimation(); sticker.startAnimation(as); firstTime = false; }
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;/*w ww. j a v a 2 s . com*/ 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:de.fahrgemeinschaft.RideDetailsFragment.java
private void animatePulse(final View view) { Animation fade_in = new AlphaAnimation(0f, 1f); fade_in.setAnimationListener(new AnimationListener() { @Override/*from w w w. ja v a 2 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.yahala.ui.LaunchActivity.java
public void checkConnectionState() { final Animation animScalin; try {// w w w. j a v a 2 s . c o m final Animation animScalout; animScalin = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down); animScalin.setFillEnabled(true); animScalin.setFillAfter(true); animScalin.setFillBefore(true); animScalout = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up); animScalout.setFillEnabled(true); animScalout.setFillAfter(true); animScalout.setStartOffset(3000); connectionStatusLayout.setVisibility(View.VISIBLE); connectionStatusLayout.setAlpha(1); isVisible = true; animScalout.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { isVisible = false; } @Override public void onAnimationEnd(Animation animation) { isVisible = false; connectionStatusLayout.setVisibility(View.GONE); connectionStatusLayout.setAlpha(0); } @Override public void onAnimationRepeat(Animation animation) { } }); // connectionStatusLayout.startAnimation(animScalin); if (XMPPManager.getInstance().connectionState == ConnectionState.ONLINE) { connectionStatus.setText(LocaleController.getString("WaitingForNetwork", R.string.Updating)); connectionStatusLayout.startAnimation(animScalout); } else if (XMPPManager.getInstance().connectionState == ConnectionState.RECONNECT_NETWORK) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.DISCONNECTED) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.RECONNECT_DELAYED) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.CONNECTING) { connectionStatusLayout.startAnimation(animScalin); connectionStatus.setText(LocaleController.getString("WaitingForNetwork", R.string.Connecting)); } } catch (Exception e) { FileLog.e("Yahala", e); } }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void fadeInAddedRoutes() { Animation.AnimationListener listener = new Animation.AnimationListener() { @Override//ww w . j a v a 2s. c om public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { finishAnimation(true); } @Override public void onAnimationRepeat(Animation animation) { } }; boolean listenerRegistered = false; int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (mGroupMemberRoutesAdded.contains(route)) { Animation alphaAnim = new AlphaAnimation(0.0f, 1.0f); alphaAnim.setDuration(mGroupListFadeInDurationMs); alphaAnim.setFillEnabled(true); alphaAnim.setFillAfter(true); if (!listenerRegistered) { listenerRegistered = true; alphaAnim.setAnimationListener(listener); } view.clearAnimation(); view.startAnimation(alphaAnim); } } }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java
void translate(float deltaX, final boolean finalAnim) { // mapFragment.mapView.setEnabled(false); float newX = posX + deltaX; if (slidden) { if (newX < -maxSlide) newX = -maxSlide;/* w ww . j av a 2 s . com*/ 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()) { animation.cancel(); parentContainer.clearAnimation(); leftContainer.invalidate(); } 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); // mapFragment.mapView.setEnabled(true); // mapFragment.mapView.invalidate(); leftContainer.invalidate(); } else { leftContainer.setVisibility(View.VISIBLE); mapDisabledView.setVisibility(View.VISIBLE); leftContainer.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); // mapFragment.mapView.setEnabled(true); // mapFragment.mapView.invalidate(); leftContainer.invalidate(); } posX = 0; } } }); posX = newX; parentContainer.startAnimation(animation); }