Java tutorial
/* 50AH-code ========= 50 Android Hacks (http://manning.com/sessa/) book source code Copyright (c) 2012 Manning Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package com.actionbarsherlock.internal.nineoldandroids.view; import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy; public abstract class NineViewGroup extends ViewGroup { private final AnimatorProxy mProxy; public NineViewGroup(Context context) { super(context); mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; } public NineViewGroup(Context context, AttributeSet attrs) { super(context, attrs); mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; } public NineViewGroup(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mProxy = AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : null; } @Override public void setVisibility(int visibility) { if (mProxy != null) { if (visibility == GONE) { clearAnimation(); } else if (visibility == VISIBLE) { setAnimation(mProxy); } } super.setVisibility(visibility); } public float getAlpha() { if (AnimatorProxy.NEEDS_PROXY) { return mProxy.getAlpha(); } else { return super.getAlpha(); } } public void setAlpha(float alpha) { if (AnimatorProxy.NEEDS_PROXY) { mProxy.setAlpha(alpha); } else { super.setAlpha(alpha); } } public float getTranslationX() { if (AnimatorProxy.NEEDS_PROXY) { return mProxy.getTranslationX(); } else { return super.getTranslationX(); } } public void setTranslationX(float translationX) { if (AnimatorProxy.NEEDS_PROXY) { mProxy.setTranslationX(translationX); } else { super.setTranslationX(translationX); } } public float getTranslationY() { if (AnimatorProxy.NEEDS_PROXY) { return mProxy.getTranslationY(); } else { return super.getTranslationY(); } } public void setTranslationY(float translationY) { if (AnimatorProxy.NEEDS_PROXY) { mProxy.setTranslationY(translationY); } else { super.setTranslationY(translationY); } } }