use of android.view.animation.AccelerateDecelerateInterpolator in project Carbon by ZieIony.
the class AnimUtils method brightnessSaturationFadeIn.
public static ValueAnimator brightnessSaturationFadeIn(final ImageView imageView, Animator.AnimatorListener listener) {
final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
final AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
animator.setInterpolator(interpolator);
animator.setDuration(800);
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
ColorMatrix saturationMatrix = new ColorMatrix();
ColorMatrix brightnessMatrix = new ColorMatrix();
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float fraction = animator.getAnimatedFraction();
saturationMatrix.setSaturation((Float) animator.getAnimatedValue());
float scale = 2 - interpolator.getInterpolation(Math.min(fraction * 4 / 3, 1));
brightnessMatrix.setScale(scale, scale, scale, interpolator.getInterpolation(Math.min(fraction * 2, 1)));
saturationMatrix.preConcat(brightnessMatrix);
imageView.setColorFilter(new ColorMatrixColorFilter(saturationMatrix));
if (imageView.getParent() != null)
((View) imageView.getParent()).postInvalidate();
}
});
animator.start();
return animator;
}
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 Android-ObservableScrollView by ksoichiro.
the class FillGapBaseActivity method changeHeaderBackgroundHeightAnimated.
private void changeHeaderBackgroundHeightAnimated(boolean shouldShowGap, boolean animated) {
if (mGapIsChanging) {
return;
}
final int heightOnGapShown = mHeaderBar.getHeight();
final int heightOnGapHidden = mHeaderBar.getHeight() + mActionBarSize;
final float from = mHeaderBackground.getLayoutParams().height;
final float to;
if (shouldShowGap) {
if (!mGapHidden) {
// Already shown
return;
}
to = heightOnGapShown;
} else {
if (mGapHidden) {
// Already hidden
return;
}
to = heightOnGapHidden;
}
if (animated) {
ViewPropertyAnimator.animate(mHeaderBackground).cancel();
ValueAnimator a = ValueAnimator.ofFloat(from, to);
a.setDuration(100);
a.setInterpolator(new AccelerateDecelerateInterpolator());
a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float height = (float) animation.getAnimatedValue();
changeHeaderBackgroundHeight(height, to, heightOnGapHidden);
}
});
a.start();
} else {
changeHeaderBackgroundHeight(to, to, heightOnGapHidden);
}
}
use of android.view.animation.AccelerateDecelerateInterpolator in project qksms by moezbhatti.
the class ComposeView method onFinishInflate.
@Override
public void onFinishInflate() {
super.onFinishInflate();
// Get references to the views
mReplyText = (QKEditText) findViewById(R.id.compose_reply_text);
mButton = (FrameLayout) findViewById(R.id.compose_button);
mProgress = (DonutProgress) findViewById(R.id.progress);
mButtonBackground = (ImageView) findViewById(R.id.compose_button_background);
mComposeIcon = (ImageView) findViewById(R.id.compose_icon);
mAttachmentPanel = findViewById(R.id.attachment_panel);
mAttach = (ImageButton) findViewById(R.id.attach);
mCamera = (ImageButton) findViewById(R.id.camera);
mDelay = (ImageButton) findViewById(R.id.delay);
mLetterCount = (QKTextView) findViewById(R.id.compose_letter_count);
mAttachmentLayout = (FrameLayout) findViewById(R.id.attachment);
mAttachment = (AttachmentImageView) findViewById(R.id.compose_attachment);
mCancel = (ImageButton) findViewById(R.id.cancel);
mButton.setOnClickListener(this);
mAttach.setOnClickListener(this);
mCamera.setOnClickListener(this);
mCancel.setOnClickListener(this);
mDelay.setOnClickListener(this);
LiveViewManager.registerView(QKPreference.THEME, this, key -> {
mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
mComposeIcon.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mAttachmentPanel.setBackgroundColor(ThemeManager.getColor());
mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
updateDelayButton();
mProgress.setUnfinishedStrokeColor(ThemeManager.getTextOnColorSecondary());
mProgress.setFinishedStrokeColor(ThemeManager.getTextOnColorPrimary());
if (ThemeManager.getSentBubbleRes() != 0)
mReplyText.setBackgroundResource(ThemeManager.getSentBubbleRes());
});
LiveViewManager.registerView(QKPreference.BACKGROUND, this, key -> {
mReplyText.getBackground().setColorFilter(ThemeManager.getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP);
getBackground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP);
});
// keyboard; set that up here.
switch(Integer.parseInt(mPrefs.getString(SettingsFragment.ENTER_BUTTON, "0"))) {
case // emoji
0:
break;
case // new line
1:
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
mReplyText.setSingleLine(false);
break;
case // send
2:
mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
mReplyText.setSingleLine(false);
mReplyText.setOnKeyListener(new //Workaround because ACTION_SEND does not support multiline mode
OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == 66) {
sendSms();
return true;
}
return false;
}
});
break;
}
mReplyText.setTextChangedListener(new QKEditText.TextChangedListener() {
@Override
public void onTextChanged(CharSequence s) {
int length = s.length();
updateButtonState(length);
// If the reply exceeds the SMS limit, it will count down until an extra message will have to be sent, and shows how many messages will currently be sent
if (length < 150) {
mLetterCount.setText("");
} else if (150 <= length && length <= 160) {
mLetterCount.setText("" + (160 - length));
} else if (160 < length) {
mLetterCount.setText((160 - length % 160) + "/" + (length / 160 + 1));
}
}
});
mProgressAnimator = new ValueAnimator();
mProgressAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mProgressAnimator.setDuration(mDelayDuration);
mProgressAnimator.setIntValues(0, 360);
mProgressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mProgress.setProgress((int) animation.getAnimatedValue());
}
});
mProgressAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mProgress.setVisibility(INVISIBLE);
mProgress.setProgress(0);
if (!mSendingCancelled) {
sendSms();
// In case they only enabled it for a particular message, let's set it back to the pref value
mDelayedMessagingEnabled = mPrefs.getBoolean(SettingsFragment.DELAYED, false);
updateDelayButton();
} else {
mSendingCancelled = false;
updateButtonState();
}
}
});
}
use of android.view.animation.AccelerateDecelerateInterpolator in project JamsMusicPlayer by psaravan.
the class FilesFoldersFragment method slideUpListView.
/**
* Slides in the ListView.
*/
private void slideUpListView() {
getDir(rootDir, null);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(600);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
listView.setVisibility(View.VISIBLE);
}
});
listView.startAnimation(animation);
}
Aggregations