use of android.view.animation.OvershootInterpolator in project recyclerview-animators by wasabeef.
the class AdapterSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adapter_sample);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
if (getIntent().getBooleanExtra("GRID", true)) {
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
} else {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
for (Type type : Type.values()) {
spinnerAdapter.add(type.name());
}
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
AnimationAdapter adapter = Type.values()[position].get(AdapterSampleActivity.this);
adapter.setFirstOnly(true);
adapter.setDuration(500);
adapter.setInterpolator(new OvershootInterpolator(.5f));
recyclerView.setAdapter(adapter);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
recyclerView.setItemAnimator(new FadeInAnimator());
MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.setFirstOnly(true);
alphaAdapter.setDuration(500);
alphaAdapter.setInterpolator(new OvershootInterpolator(.5f));
recyclerView.setAdapter(alphaAdapter);
}
use of android.view.animation.OvershootInterpolator in project UltimateAndroid by cymcsg.
the class DefaultAnimationHandler method animateMenuOpening.
@Override
public void animateMenuOpening(Point center) {
super.animateMenuOpening(center);
setAnimating(true);
Animator lastAnimation = null;
for (int i = 0; i < menu.getSubActionItems().size(); i++) {
menu.getSubActionItems().get(i).view.setScaleX(0);
menu.getSubActionItems().get(i).view.setScaleY(0);
menu.getSubActionItems().get(i).view.setAlpha(0);
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2);
PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 720);
PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA);
animation.setDuration(DURATION);
animation.setInterpolator(new OvershootInterpolator(0.9f));
animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING));
if (i == 0) {
lastAnimation = animation;
}
// Put a slight lag between each of the menu items to make it asymmetric
animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
animation.start();
}
if (lastAnimation != null) {
lastAnimation.addListener(new LastAnimationListener());
}
}
use of android.view.animation.OvershootInterpolator in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartBarEditor method switchId.
/**
* Switches positions of two views and updates their mButtonViews entry
*
* @param targetView - view to be replaced animate out
* @param view - view being dragged
*/
private void switchId(View replaceView, View dragView) {
final OpaLayout squatter = (OpaLayout) replaceView;
final OpaLayout dragger = (OpaLayout) dragView;
final boolean vertical = mHost.isVertical();
ViewGroup parent = (ViewGroup) replaceView.getParent();
float slideTo = vertical ? mDragOrigin - parent.getTop() : mDragOrigin - parent.getLeft();
replaceView.getLocationOnScreen(sLocation);
mDragOrigin = sLocation[vertical ? 1 : 0];
final int targetIndex = mHost.getCurrentSequence().indexOf(squatter.getButton().getTag());
final int draggedIndex = mHost.getCurrentSequence().indexOf(dragger.getButton().getTag());
Collections.swap(mHost.getCurrentSequence(), draggedIndex, targetIndex);
SmartButtonView hidden1 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(squatter.getButton().getTag());
SmartButtonView hidden2 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(dragger.getButton().getTag());
OpaLayout hidden1Opa = (OpaLayout) hidden1.getParent();
OpaLayout hidden2Opa = (OpaLayout) hidden2.getParent();
swapConfigs(hidden1Opa, hidden2Opa);
Animator anim = getButtonSlideAnimator(squatter, vertical, slideTo);
anim.setInterpolator(new OvershootInterpolator());
anim.setDuration(250);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mSquatters.remove(squatter);
}
});
anim.start();
}
use of android.view.animation.OvershootInterpolator in project android_packages_apps_DUI by DirtyUnicorns.
the class SmartButtonView method checkAndDoFlipAnim.
private void checkAndDoFlipAnim() {
if (mAnimStyle == ANIM_STYLE_FLIP) {
mFlipAnim = ObjectAnimator.ofFloat(this, "rotationY", 0f, 360f);
mFlipAnim.setDuration(1500);
mFlipAnim.setInterpolator(new OvershootInterpolator());
mFlipAnim.start();
}
}
use of android.view.animation.OvershootInterpolator in project android_frameworks_base by ResurrectionRemix.
the class QSPanel method setAnimationTile.
private void setAnimationTile(TileRecord r) {
ObjectAnimator animTile = null;
int animStyle = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT);
int animDuration = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_DURATION, 2000, UserHandle.USER_CURRENT);
int interpolatorType = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_INTERPOLATOR, 0, UserHandle.USER_CURRENT);
if (animStyle == 0) {
//No animation
}
if (animStyle == 1) {
animTile = ObjectAnimator.ofFloat(r.tileView, "rotationY", 0f, 360f);
}
if (animStyle == 2) {
animTile = ObjectAnimator.ofFloat(r.tileView, "rotation", 0f, 360f);
}
if (animTile != null) {
switch(interpolatorType) {
case 0:
animTile.setInterpolator(new LinearInterpolator());
break;
case 1:
animTile.setInterpolator(new AccelerateInterpolator());
break;
case 2:
animTile.setInterpolator(new DecelerateInterpolator());
break;
case 3:
animTile.setInterpolator(new AccelerateDecelerateInterpolator());
break;
case 4:
animTile.setInterpolator(new BounceInterpolator());
break;
case 5:
animTile.setInterpolator(new OvershootInterpolator());
break;
case 6:
animTile.setInterpolator(new AnticipateInterpolator());
break;
case 7:
animTile.setInterpolator(new AnticipateOvershootInterpolator());
break;
default:
break;
}
animTile.setDuration(animDuration);
animTile.start();
}
}
Aggregations