use of android.view.animation.TranslateAnimation in project android_frameworks_base by ParanoidAndroid.
the class SlidingTab method startAnimating.
void startAnimating(final boolean holdAfter) {
mAnimating = true;
final Animation trans1;
final Animation trans2;
final Slider slider = mCurrentSlider;
final Slider other = mOtherSlider;
final int dx;
final int dy;
if (isHorizontal()) {
int right = slider.tab.getRight();
int width = slider.tab.getWidth();
int left = slider.tab.getLeft();
int viewWidth = getWidth();
// how much of tab to show at the end of anim
int holdOffset = holdAfter ? 0 : width;
dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset;
dy = 0;
} else {
int top = slider.tab.getTop();
int bottom = slider.tab.getBottom();
int height = slider.tab.getHeight();
int viewHeight = getHeight();
// how much of tab to show at end of anim
int holdOffset = holdAfter ? 0 : height;
dx = 0;
dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset);
}
trans1 = new TranslateAnimation(0, dx, 0, dy);
trans1.setDuration(ANIM_DURATION);
trans1.setInterpolator(new LinearInterpolator());
trans1.setFillAfter(true);
trans2 = new TranslateAnimation(0, dx, 0, dy);
trans2.setDuration(ANIM_DURATION);
trans2.setInterpolator(new LinearInterpolator());
trans2.setFillAfter(true);
trans1.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
Animation anim;
if (holdAfter) {
anim = new TranslateAnimation(dx, dx, dy, dy);
// plenty of time for transitions
anim.setDuration(1000);
mAnimating = false;
} else {
anim = new AlphaAnimation(0.5f, 1.0f);
anim.setDuration(ANIM_DURATION);
resetView();
}
anim.setAnimationListener(mAnimationDoneListener);
/* Animation can be the same for these since the animation just holds */
mLeftSlider.startAnimation(anim, anim);
mRightSlider.startAnimation(anim, anim);
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
slider.hideTarget();
slider.startAnimation(trans1, trans2);
}
use of android.view.animation.TranslateAnimation in project android_frameworks_base by ParanoidAndroid.
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 SnackBar by MrEngineer13.
the class SnackContainer method init.
private void init() {
mInAnimationSet = new AnimationSet(false);
TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
mInAnimationSet.addAnimation(mSlideInAnimation);
mInAnimationSet.addAnimation(mFadeInAnimation);
mOutAnimationSet = new AnimationSet(false);
TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f);
AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
mOutAnimationSet.addAnimation(mSlideOutAnimation);
mOutAnimationSet.addAnimation(mFadeOutAnimation);
mOutAnimationSet.setDuration(ANIMATION_DURATION);
mOutAnimationSet.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
removeAllViews();
if (!mSnacks.isEmpty()) {
sendOnHide(mSnacks.poll());
}
if (!isEmpty()) {
showSnack(mSnacks.peek());
} else {
setVisibility(View.GONE);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
use of android.view.animation.TranslateAnimation in project actor-platform by actorapp.
the class AttachFragment method hide.
@Override
public void hide() {
if (root != null && root.getVisibility() == View.VISIBLE) {
onHidden();
fastAttachAdapter.clearSelected();
messenger().getGalleryScannerActor().send(new GalleryScannerActor.Hide());
fastShare.scrollToPosition(0);
hideView(root);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP && !isFastShareFullScreen) {
View internal = fastShare;
int cx = internal.getWidth() - Screen.dp(56 + 56);
int cy = internal.getHeight() - Screen.dp(56 / 2);
float finalRadius = (float) Math.hypot(cx, cy);
Animator anim = ViewAnimationUtils.createCircularReveal(internal, cx, cy, finalRadius, 0);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
internal.setAlpha(1);
}
@Override
public void onAnimationEnd(Animator animator) {
internal.setAlpha(0);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
anim.setDuration(200);
anim.start();
} else {
TranslateAnimation animation = new TranslateAnimation(0, 0, 0, root.getHeight());
animation.setInterpolator(MaterialInterpolator.getInstance());
animation.setDuration(250);
fastShare.startAnimation(animation);
bottomBackground.startAnimation(animation);
}
}
}
use of android.view.animation.TranslateAnimation in project actor-platform by actorapp.
the class InputBarFragment method hideAudio.
protected void hideAudio(boolean cancel) {
if (!isAudioVisible) {
return;
}
isAudioVisible = false;
showView(attachButton);
showView(messageEditText);
showView(emojiButton);
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
voiceRecordActor.send(new VoiceCaptureActor.Stop(cancel));
TranslateAnimation animation = new TranslateAnimation(0, Screen.getWidth(), 0, 0);
animation.setDuration(160);
audioContainer.clearAnimation();
audioContainer.setAnimation(animation);
audioContainer.animate();
audioContainer.setVisibility(View.GONE);
messageEditText.requestFocus();
}
Aggregations