use of android.view.animation.TranslateAnimation in project android_frameworks_base by ResurrectionRemix.
the class AbsListView method setAnimation.
private View setAnimation(View view) {
if (view == null) {
return view;
}
int scrollY = 0;
boolean down = false;
Animation anim = null;
try {
scrollY = getChildAt(0).getTop();
} catch (NullPointerException e) {
scrollY = mPositionV;
}
if (mPositionV < scrollY) {
down = true;
}
mPositionV = scrollY;
switch(mListAnimationMode) {
case 1:
anim = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f);
break;
case 2:
anim = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
break;
case 3:
anim = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
break;
case 4:
anim = new AlphaAnimation(0.0f, 1.0f);
break;
case 5:
anim = new TranslateAnimation(0.0f, 0.0f, -mHeight, 0.0f);
break;
case 6:
anim = new TranslateAnimation(0.0f, 0.0f, mHeight, 0.0f);
break;
case 7:
if (down) {
anim = new TranslateAnimation(0.0f, 0.0f, -mHeight, 0.0f);
} else {
anim = new TranslateAnimation(0.0f, 0.0f, mHeight, 0.0f);
}
break;
case 8:
if (down) {
anim = new TranslateAnimation(0.0f, 0.0f, mHeight, 0.0f);
} else {
anim = new TranslateAnimation(0.0f, 0.0f, -mHeight, 0.0f);
}
break;
case 9:
anim = new TranslateAnimation(-mWidth, 0.0f, 0.0f, 0.0f);
break;
case 10:
anim = new TranslateAnimation(mWidth, 0.0f, 0.0f, 0.0f);
break;
}
if (mListAnimationInterpolatorMode == 0) {
return applyAnimationToView(view, anim);
}
switch(mListAnimationInterpolatorMode) {
case 1:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.accelerate_interpolator));
break;
case 2:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.decelerate_interpolator));
break;
case 3:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.accelerate_decelerate_interpolator));
break;
case 4:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.anticipate_interpolator));
break;
case 5:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.overshoot_interpolator));
break;
case 6:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.anticipate_overshoot_interpolator));
break;
case 7:
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.anim.bounce_interpolator));
break;
}
return applyAnimationToView(view, anim);
}
use of android.view.animation.TranslateAnimation in project android_frameworks_base by ResurrectionRemix.
the class TransformsAndAnimationsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transforms_and_animations);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1a = (Button) findViewById(R.id.button1a);
button2a = (Button) findViewById(R.id.button2a);
button3a = (Button) findViewById(R.id.button3a);
button1b = (Button) findViewById(R.id.button1b);
button2b = (Button) findViewById(R.id.button2b);
button3b = (Button) findViewById(R.id.button3b);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_NONE);
layersHardwareCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_SOFTWARE);
layersHardwareCB.setChecked(false);
layersNoneCB.setChecked(false);
}
}
});
layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setLayerType(View.LAYER_TYPE_HARDWARE);
layersNoneCB.setChecked(false);
layersSoftwareCB.setChecked(false);
}
}
});
button1a.setAlpha(.5f);
button2a.setAlpha(.5f);
button3a.setAlpha(.5f);
button3.setTranslationX(50);
button7.setTranslationX(50);
button8.setTranslationX(50);
final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(Animation.INFINITE);
alphaAnim.setRepeatMode(Animation.REVERSE);
final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
transAnim.setDuration(1000);
transAnim.setRepeatCount(Animation.INFINITE);
transAnim.setRepeatMode(Animation.REVERSE);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
button1.startAnimation(alphaAnim);
button2.startAnimation(alphaAnim);
button3.startAnimation(alphaAnim);
button1a.startAnimation(alphaAnim);
button2a.startAnimation(alphaAnim);
button3a.startAnimation(alphaAnim);
button1b.startAnimation(alphaAnim);
button2b.startAnimation(alphaAnim);
button3b.startAnimation(alphaAnim);
startAnimator(button1b);
startAnimator(button2b);
startAnimator(button3b);
button7.startAnimation(transAnim);
button8.startAnimation(transAnim);
}
}, 2000);
}
use of android.view.animation.TranslateAnimation in project android_frameworks_base by ResurrectionRemix.
the class DragState method createReturnAnimationLocked.
private Animation createReturnAnimationLocked() {
final AnimationSet set = new AnimationSet(false);
set.addAnimation(new TranslateAnimation(0, mOriginalX - mCurrentX, 0, mOriginalY - mCurrentY));
set.addAnimation(new AlphaAnimation(mOriginalAlpha, mOriginalAlpha / 2));
set.setDuration(ANIMATION_DURATION_MS);
set.setInterpolator(mCubicEaseOutInterpolator);
set.initialize(0, 0, 0, 0);
// Will start on the first call to getTransformation.
set.start();
return set;
}
use of android.view.animation.TranslateAnimation in project android_frameworks_base by ResurrectionRemix.
the class BatteryBar method start.
@Override
public void start() {
if (!shouldAnimateCharging)
return;
if (vertical) {
TranslateAnimation a = new TranslateAnimation(getX(), getX(), getHeight(), mBatteryBarLayout.getHeight());
a.setInterpolator(new AccelerateInterpolator());
a.setDuration(ANIM_DURATION);
a.setRepeatCount(Animation.INFINITE);
mChargerLayout.startAnimation(a);
mChargerLayout.setVisibility(View.VISIBLE);
} else {
TranslateAnimation a = new TranslateAnimation(getWidth(), mBatteryBarLayout.getWidth(), getTop(), getTop());
a.setInterpolator(new AccelerateInterpolator());
a.setDuration(ANIM_DURATION);
a.setRepeatCount(Animation.INFINITE);
mChargerLayout.startAnimation(a);
mChargerLayout.setVisibility(View.VISIBLE);
}
isAnimating = true;
}
use of android.view.animation.TranslateAnimation in project newsrob by marianokamp.
the class ShowArticleActivity method toggleFullScreenMode.
private void toggleFullScreenMode() {
final View v = findViewById(R.id.outter_container);
if (inFullScreenMode) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (false) {
Animation animation = new TranslateAnimation(0f, 0f, 0f, v.getHeight());
animation.setDuration(500);
v.startAnimation(animation);
}
v.setVisibility(View.VISIBLE);
hideTitlePreview();
inFullScreenMode = false;
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (false) {
Animation animation = new TranslateAnimation(0f, 0f, 0f, -v.getHeight());
animation.setDuration(500);
v.startAnimation(animation);
}
v.setVisibility(View.GONE);
Toast.makeText(this, "- Fullscreen Mode -\n (Tap twice to exit)", Toast.LENGTH_SHORT).show();
inFullScreenMode = true;
}
}
Aggregations