use of android.animation.Animator in project MultipleTheme by dersoncheng.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (ColorButton) findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SharedPreferencesMgr.getInt("theme", 0) == 1) {
SharedPreferencesMgr.setInt("theme", 0);
setTheme(R.style.theme_1);
} else {
SharedPreferencesMgr.setInt("theme", 1);
setTheme(R.style.theme_2);
}
final View rootView = getWindow().getDecorView();
if (Build.VERSION.SDK_INT >= 14) {
rootView.setDrawingCacheEnabled(true);
rootView.buildDrawingCache(true);
final Bitmap localBitmap = Bitmap.createBitmap(rootView.getDrawingCache());
rootView.setDrawingCacheEnabled(false);
if (null != localBitmap && rootView instanceof ViewGroup) {
final View localView2 = new View(getApplicationContext());
localView2.setBackgroundDrawable(new BitmapDrawable(getResources(), localBitmap));
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
((ViewGroup) rootView).addView(localView2, params);
localView2.animate().alpha(0).setDuration(400).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
ColorUiUtil.changeTheme(rootView, getTheme());
}
@Override
public void onAnimationEnd(Animator animation) {
((ViewGroup) rootView).removeView(localView2);
localBitmap.recycle();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).start();
}
} else {
ColorUiUtil.changeTheme(rootView, getTheme());
}
}
});
btn_next = (ColorButton) findViewById(R.id.btn_2);
btn_next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
});
}
use of android.animation.Animator in project UltimateRecyclerView by cymcsg.
the class SimpleAnimationAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) {
((ViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position));
// ((ViewHolder) holder).itemView.setActivated(selectedItems.get(position, false));
}
if (!isFirstOnly || position > mLastPosition) {
for (Animator anim : getAdapterAnimations(holder.itemView, AdapterAnimationType.ScaleIn)) {
anim.setDuration(mDuration).start();
anim.setInterpolator(mInterpolator);
}
mLastPosition = position;
} else {
ViewHelper.clear(holder.itemView);
}
}
use of android.animation.Animator in project UltimateRecyclerView by cymcsg.
the class SwipeDismissTouchListener method performDismiss.
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss callback.
// This triggers layout on each animation frame; in the future we may want to do something
// smarter and more performant.
URLogs.d("performDismiss");
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallbacks.onDismiss(mView, mToken);
// Reset view presentation
mView.setAlpha(1f);
mView.setTranslationX(0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
// if (lp.height > 100)
mView.setLayoutParams(lp);
// mView.setVisibility(View.GONE);
}
});
animator.start();
}
use of android.animation.Animator in project UltimateRecyclerView by cymcsg.
the class DragDropTouchListener method reset.
private void reset() {
//Animate mobile view back to original position
final View view = getViewByPosition(mobileViewCurrentPos);
if (view != null && mobileView != null) {
float y = getViewRawCoords(view)[1];
mobileView.animate().y(y).setDuration(MOVE_DURATION).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.VISIBLE);
if (mobileView != null) {
ViewGroup parent = (ViewGroup) mobileView.getParent();
parent.removeView(mobileView);
mobileView = null;
}
}
});
}
dragging = false;
mobileViewStartY = -1;
mobileViewCurrentPos = -1;
}
use of android.animation.Animator in project ActivityAnimationLib by dkmeteor.
the class SplitEffect method animate.
public void animate(final Activity destActivity, final int duration) {
final Interpolator interpolator = new DecelerateInterpolator();
destActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
new Handler().post(new Runnable() {
@Override
public void run() {
mSetAnim = new AnimatorSet();
mTopImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mBottomImage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mSetAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
clean(destActivity);
}
@Override
public void onAnimationCancel(Animator animation) {
clean(destActivity);
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
Animator anim1 = ObjectAnimator.ofFloat(mTopImage, "translationY", mTopImage.getHeight() * -1);
Animator anim2 = ObjectAnimator.ofFloat(mBottomImage, "translationY", mBottomImage.getHeight());
if (interpolator != null) {
anim1.setInterpolator(interpolator);
anim2.setInterpolator(interpolator);
}
mSetAnim.setDuration(duration);
mSetAnim.playTogether(anim1, anim2);
mSetAnim.start();
}
});
}
Aggregations