use of android.view.animation.AccelerateDecelerateInterpolator in project actor-platform by actorapp.
the class TourActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tour_activity);
final VerticalViewPager viewPager = (VerticalViewPager) findViewById(R.id.viewpager);
final View backToTopText = findViewById(R.id.back_to_top);
final View backToTopArrow = findViewById(R.id.back_to_top_arrow);
final View paralax = findViewById(R.id.paralax);
final View paralaxImage = findViewById(R.id.paralax_image);
final View background = findViewById(R.id.background);
final View loginHolder = findViewById(R.id.login_holder);
final View welcomeImage = findViewById(R.id.welcome_logo);
final View welcomeText = findViewById(R.id.welcome_text);
background.findViewById(R.id.background_colored).setBackgroundColor(ActorSDK.sharedActor().style.getMainColor());
TextView signupButtonText = (TextView) findViewById(R.id.signUpButtonText);
StateListDrawable states = SelectorFactory.get(ActorSDK.sharedActor().style.getPrimaryAltColor(), this);
signupButtonText.setBackgroundDrawable(states);
signupButtonText.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
signupButtonText.setTypeface(Fonts.medium());
TextView buttonSignUp = (TextView) findViewById(R.id.signIn);
buttonSignUp.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
buttonSignUp.setTypeface(Fonts.medium());
((TextView) findViewById(R.id.app_name)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
((TextView) findViewById(R.id.tour_welcome_subtitle)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor());
findViewById(R.id.signUpButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle authExtras = new Bundle();
authExtras.putInt(AuthActivity.SIGN_TYPE_KEY, AuthActivity.SIGN_TYPE_UP);
ActorSDK.sharedActor().startAuthActivity(TourActivity.this, authExtras);
finish();
}
});
findViewById(R.id.signIn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle authExtras = new Bundle();
authExtras.putInt(AuthActivity.SIGN_TYPE_KEY, AuthActivity.SIGN_TYPE_IN);
ActorSDK.sharedActor().startAuthActivity(TourActivity.this, authExtras);
finish();
}
});
View.OnClickListener jumpToTopListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
backToTopArrow.animate().alpha(0).setDuration(0).start();
backToTopText.animate().alpha(0).setDuration(0).start();
viewPager.setCurrentItem(0, true);
}
};
backToTopText.setOnClickListener(jumpToTopListener);
backToTopArrow.setOnClickListener(jumpToTopListener);
viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
if (position == 0 || position == lastPageIndex + 1)
return new Fragment();
return TourFragment.getInstance(position);
}
@Override
public int getCount() {
//6;
return 4;
}
});
//Necessary or the pager will only have one extra page to show
// make this at least however many pages you can see
viewPager.setOffscreenPageLimit(3);
//A little space between pages
viewPager.setPageMargin(-Screen.dp(165));
//If hardware acceleration is enabled, you should also remove
// clipping on the pager for its children.
viewPager.setClipChildren(false);
viewPager.setOnScrollListener(new ScrollListener() {
public static final int LOGINHOLDER_STATUS_OUT = 1;
public static final int LOGINHOLDER_STATUS_VISIBLE = 2;
public int loginHolderStatus;
public boolean welcomeShowed = false;
public boolean mainContentHidden = false;
public boolean loginHolderBackgroundVisible = false;
@Override
public void onScroll(int y, float page) {
if (page < 1) {
float alpha = 1 - page * 2;
backToTopArrow.animate().alpha(alpha).setDuration(0).start();
//status1.setText("alpha:" + alpha);
if (loginHolder.getTop() != 0) {
float loginY = (float) loginHolder.getTop() * ((float) 1 - (page));
loginHolder.animate().y(loginY).setDuration(0).setStartDelay(0).start();
background.animate().y(loginY - background.getHeight() + loginHolder.getHeight() + Screen.dp(8)).setDuration(0).start();
/*if(loginHolderBackgroundVisible){
loginHolderBackgroundVisible = false;
loginHolderBackground.animate().alpha(0).setDuration(0).start();
} else {
}*/
//loginHolderBackground.animate().alpha(page).setDuration(0).start();
background.animate().alpha(page).setDuration(0).start();
loginHolderStatus = LOGINHOLDER_STATUS_VISIBLE;
float welcomeImageY = welcomeImage.getTop() - y / 2;
float welcomeTextY = welcomeText.getTop() - y / 2;
if (alpha > 0) {
welcomeImage.animate().alpha(alpha).y(welcomeImageY).setDuration(0).start();
welcomeText.animate().alpha(alpha).y(welcomeTextY).setDuration(0).start();
} else {
welcomeImage.animate().alpha(0).setDuration(0).start();
welcomeText.animate().alpha(0).setDuration(0).start();
}
}
mainContentHidden = false;
} else {
if (page >= 1 && page <= lastPageIndex) {
// todo freeze?
if (!mainContentHidden) {
mainContentHidden = true;
loginHolderBackgroundVisible = true;
//signinLastView.setEnabled(false);
//signinView.setEnabled(false);
//signupLastView.setEnabled(false);
//signupView.setEnabled(false);
loginHolder.animate().y(0).setDuration(0).start();
//loginHolderBackground.animate().alpha(1).setDuration(0).start();
background.animate().y(-loginHolder.getTop() + Screen.dp(8)).alpha(1).setDuration(0).start();
welcomeImage.animate().alpha(0).setDuration(0).start();
welcomeText.animate().alpha(0).setDuration(0).start();
backToTopArrow.animate().alpha(0).setDuration(0).start();
backToTopText.animate().alpha(0).setDuration(0).start();
}
if (page > lastPageIndex - 1) {
float alpha = (page - (lastPageIndex - 1)) * 3 - 2;
if (alpha > 0) {
backToTopText.animate().scaleX(alpha).scaleY(alpha).alpha(alpha).setDuration(0).start();
} else {
backToTopText.animate().scaleX(0).scaleY(0).alpha(0).setDuration(0).start();
}
}
} else {
if (page > lastPageIndex) {
float progress = page - lastPageIndex;
if (progress > 0.5) {
if (loginHolderStatus == LOGINHOLDER_STATUS_VISIBLE) {
loginHolderStatus = LOGINHOLDER_STATUS_OUT;
loginHolder.animate().y(-loginHolder.getHeight()).setDuration(200).setInterpolator(new AccelerateDecelerateInterpolator()).setStartDelay(0).start();
}
mainContentHidden = false;
} else {
if (loginHolderStatus == LOGINHOLDER_STATUS_OUT) {
loginHolderStatus = LOGINHOLDER_STATUS_VISIBLE;
loginHolder.animate().y(0).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(200).setStartDelay(0).start();
}
if (!mainContentHidden) {
backToTopArrow.animate().alpha(0).setDuration(0).start();
backToTopText.animate().alpha(0).setDuration(0).start();
}
}
}
}
}
int paralaxHolderHeight = paralax.getHeight();
int paralaxImageHeight = paralaxImage.getHeight();
float paralaxY = -(((float) paralaxImageHeight - paralaxHolderHeight) * ((float) page / (lastPageIndex)));
paralaxImage.animate().y(paralaxY).setDuration(0).setStartDelay(0).start();
}
});
if (Build.VERSION.SDK_INT >= 19) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
contentTopPadding = Screen.getStatusBarHeight();
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) findViewById(R.id.pager_container).getLayoutParams();
params.topMargin = contentTopPadding;
findViewById(R.id.pager_container).setLayoutParams(params);
params = (RelativeLayout.LayoutParams) backToTopArrow.getLayoutParams();
params.topMargin = contentTopPadding + params.topMargin;
backToTopArrow.setLayoutParams(params);
params = (RelativeLayout.LayoutParams) welcomeImage.getLayoutParams();
params.topMargin = contentTopPadding + params.topMargin;
welcomeImage.setLayoutParams(params);
params = (RelativeLayout.LayoutParams) welcomeText.getLayoutParams();
params.topMargin = contentTopPadding + params.topMargin;
welcomeText.setLayoutParams(params);
params = (RelativeLayout.LayoutParams) backToTopText.getLayoutParams();
params.topMargin = contentTopPadding + params.topMargin;
backToTopText.setLayoutParams(params);
}
}
use of android.view.animation.AccelerateDecelerateInterpolator in project CoCoin by Nightonke.
the class SplashActivity method startCircularReveal.
private void startCircularReveal() {
// get the center for the clipping circle
int[] location = new int[2];
image.getLocationOnScreen(location);
int cx = location[0] + CoCoinUtil.dpToPx(24);
int cy = location[1] + CoCoinUtil.dpToPx(24);
// get the final radius for the clipping circle
int dx = Math.max(cx, ly.getWidth() - cx);
int dy = Math.max(cy, ly.getHeight() - cy);
float finalRadius = (float) Math.hypot(dx, dy);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(ly, cx, cy, 0, finalRadius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(3000);
animator.start();
animator.addListener(new SupportAnimator.AnimatorListener() {
@Override
public void onAnimationStart() {
}
@Override
public void onAnimationEnd() {
Log.d("CoCoin", "Showing animation completed");
showAnimationCompleted = true;
if (loadDataCompleted && showAnimationCompleted && !activityStarted) {
activityStarted = true;
startActivity(new Intent(mContext, MainActivity.class));
finish();
}
}
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationRepeat() {
}
});
hasAnimationStarted = true;
}
use of android.view.animation.AccelerateDecelerateInterpolator in project CoCoin by Nightonke.
the class RippleView method onTouchEvent.
@Override
public boolean onTouchEvent(final MotionEvent event) {
Log.d("TouchEvent", String.valueOf(event.getActionMasked()));
Log.d("mIsAnimating", String.valueOf(mIsAnimating));
Log.d("mAnimationIsCancel", String.valueOf(mAnimationIsCancel));
boolean superResult = super.onTouchEvent(event);
if (event.getActionMasked() == MotionEvent.ACTION_DOWN && this.isEnabled() && mHover) {
mRect = new Rect(getLeft(), getTop(), getRight(), getBottom());
mAnimationIsCancel = false;
mDownX = event.getX();
mDownY = event.getY();
mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", 0, dp(50)).setDuration(400);
mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mRadiusAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mIsAnimating = true;
}
@Override
public void onAnimationEnd(Animator animator) {
setRadius(0);
ViewHelper.setAlpha(RippleView.this, 1);
mIsAnimating = false;
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mRadiusAnimator.start();
if (!superResult) {
return true;
}
} else if (event.getActionMasked() == MotionEvent.ACTION_MOVE && this.isEnabled() && mHover) {
mDownX = event.getX();
mDownY = event.getY();
// Cancel the ripple animation when moved outside
if (mAnimationIsCancel = !mRect.contains(getLeft() + (int) event.getX(), getTop() + (int) event.getY())) {
setRadius(0);
} else {
setRadius(dp(50));
}
if (!superResult) {
return true;
}
} else if (event.getActionMasked() == MotionEvent.ACTION_UP && !mAnimationIsCancel && this.isEnabled()) {
mDownX = event.getX();
mDownY = event.getY();
final float tempRadius = (float) Math.sqrt(mDownX * mDownX + mDownY * mDownY);
float targetRadius = Math.max(tempRadius, mMaxRadius);
if (mIsAnimating) {
mRadiusAnimator.cancel();
}
mRadiusAnimator = ObjectAnimator.ofFloat(this, "radius", dp(50), targetRadius);
mRadiusAnimator.setDuration(500);
mRadiusAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mRadiusAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
mIsAnimating = true;
}
@Override
public void onAnimationEnd(Animator animator) {
setRadius(0);
ViewHelper.setAlpha(RippleView.this, 1);
mIsAnimating = false;
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
mRadiusAnimator.start();
if (!superResult) {
return true;
}
}
return superResult;
}
use of android.view.animation.AccelerateDecelerateInterpolator in project Anki-Android by Ramblurr.
the class Reviewer method fillFlashcard.
public void fillFlashcard(boolean flip) {
if (!flip) {
Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
if (mCurrentSimpleInterface && mSimpleCard != null) {
mSimpleCard.setText(mCardContent);
} else if (!mUseQuickUpdate && mCard != null && mNextCard != null) {
mNextCard.setBackgroundColor(mCurrentBackgroundColor);
mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
mNextCard.setVisibility(View.VISIBLE);
mCardFrame.removeView(mCard);
mCard.destroy();
mCard = mNextCard;
mNextCard = createWebView();
mNextCard.setVisibility(View.GONE);
mCardFrame.addView(mNextCard, 0);
// hunt for input issue 720, like android issue 3341
if (AnkiDroidApp.SDK_VERSION <= 7) {
mCard.setFocusableInTouchMode(true);
}
} else if (mCard != null) {
mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
mCard.setBackgroundColor(mCurrentBackgroundColor);
}
if (mChangeBorderStyle) {
switch(mCurrentBackgroundColor) {
case Color.WHITE:
if (mInvertedColors) {
mInvertedColors = false;
invertColors(false);
}
break;
case Color.BLACK:
if (!mInvertedColors) {
mInvertedColors = true;
invertColors(true);
}
break;
default:
if (Themes.getTheme() != Themes.THEME_BLUE) {
mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
}
if (mInvertedColors != mNightMode) {
mInvertedColors = mNightMode;
invertColors(mNightMode);
}
}
}
if (!mShowAnimations && mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
switchTopBarVisibility(View.VISIBLE);
}
if (!sDisplayAnswer) {
updateForNewCard();
if (mShowWhiteboard) {
mWhiteboard.clear();
}
setNextCardAnimation(false);
}
} else {
Animation3D rotation;
boolean directionToLeft = true;
switch(mNextAnimation) {
case ANIMATION_TURN:
rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9, Animation3D.ANIMATION_TURN, true, true, this);
rotation.setDuration(mAnimationDurationTurn);
rotation.setInterpolator(new AccelerateDecelerateInterpolator());
break;
case ANIMATION_NEXT_CARD_FROM_LEFT:
directionToLeft = false;
case ANIMATION_NEXT_CARD_FROM_RIGHT:
rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
rotation.setDuration(mAnimationDurationMove);
rotation.setInterpolator(new AccelerateDecelerateInterpolator());
break;
case ANIMATION_SLIDE_OUT_TO_RIGHT:
directionToLeft = false;
case ANIMATION_SLIDE_OUT_TO_LEFT:
fillFlashcard(false);
rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
rotation.setDuration(mAnimationDurationMove);
rotation.setInterpolator(new AccelerateInterpolator());
switchTopBarVisibility(View.INVISIBLE);
break;
case ANIMATION_SLIDE_IN_FROM_LEFT:
directionToLeft = false;
case ANIMATION_SLIDE_IN_FROM_RIGHT:
fillFlashcard(false);
rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
rotation.setDuration(mAnimationDurationMove);
rotation.setInterpolator(new DecelerateInterpolator());
switchTopBarVisibility(View.VISIBLE);
break;
case ANIMATION_NO_ANIMATION:
default:
return;
}
rotation.reset();
mCardContainer.setDrawingCacheEnabled(true);
mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
mCardContainer.clearAnimation();
mCardContainer.startAnimation(rotation);
}
}
use of android.view.animation.AccelerateDecelerateInterpolator in project AndroidViewAnimations by daimajia.
the class MyActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
mListView = (ListView) findViewById(R.id.list_items);
mTarget = findViewById(R.id.hello_world);
mAdapter = new EffectAdapter(this);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (rope != null) {
rope.stop(true);
}
Techniques technique = (Techniques) view.getTag();
rope = YoYo.with(technique).duration(1200).repeat(YoYo.INFINITE).pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT).interpolate(new AccelerateDecelerateInterpolator()).withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
Toast.makeText(MyActivity.this, "canceled previous animation", Toast.LENGTH_SHORT).show();
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).playOn(mTarget);
}
});
findViewById(R.id.hello_world).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rope != null) {
rope.stop(true);
}
}
});
}
Aggregations