use of com.github.ybq.android.spinkit.sprite.Sprite in project Android-SpinKit by ybq.
the class FoldingCube method onBoundsChange.
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
bounds = clipSquare(bounds);
int size = Math.min(bounds.width(), bounds.height());
if (wrapContent) {
size = (int) Math.sqrt((size * size) / 2);
int oW = (bounds.width() - size) / 2;
int oH = (bounds.height() - size) / 2;
bounds = new Rect(bounds.left + oW, bounds.top + oH, bounds.right - oW, bounds.bottom - oH);
}
int px = bounds.left + size / 2 + 1;
int py = bounds.top + size / 2 + 1;
for (int i = 0; i < getChildCount(); i++) {
Sprite sprite = getChildAt(i);
sprite.setDrawBounds(bounds.left, bounds.top, px, py);
sprite.setPivotX(sprite.getDrawBounds().right);
sprite.setPivotY(sprite.getDrawBounds().bottom);
}
}
use of com.github.ybq.android.spinkit.sprite.Sprite in project Android-SpinKit by ybq.
the class WanderingCubes method onBoundsChange.
@Override
protected void onBoundsChange(Rect bounds) {
bounds = clipSquare(bounds);
super.onBoundsChange(bounds);
for (int i = 0; i < getChildCount(); i++) {
Sprite sprite = getChildAt(i);
sprite.setDrawBounds(bounds.left, bounds.top, bounds.left + bounds.width() / 4, bounds.top + bounds.height() / 4);
}
}
use of com.github.ybq.android.spinkit.sprite.Sprite in project Android-SpinKit by ybq.
the class DetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPager.setOffscreenPageLimit(0);
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return Style.values().length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_pager, null);
SpinKitView spinKitView = (SpinKitView) view.findViewById(R.id.spin_kit);
TextView name = (TextView) view.findViewById(R.id.name);
Style style = Style.values()[position];
name.setText(style.name());
Sprite drawable = SpriteFactory.create(style);
spinKitView.setIndeterminateDrawable(drawable);
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
int color = (int) ArgbEvaluator.getInstance().evaluate(positionOffset, colors[position % colors.length], colors[(position + 1) % colors.length]);
getWindow().getDecorView().setBackgroundColor(color);
}
@Override
public void onPageSelected(int position) {
getWindow().getDecorView().setBackgroundColor(colors[position % colors.length]);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewPager.setCurrentItem(getIntent().getIntExtra("position", 0));
}
use of com.github.ybq.android.spinkit.sprite.Sprite in project Android-SpinKit by ybq.
the class FoldingCube method drawChild.
@Override
public void drawChild(Canvas canvas) {
Rect bounds = clipSquare(getBounds());
for (int i = 0; i < getChildCount(); i++) {
int count = canvas.save();
canvas.rotate(45 + i * 90, bounds.centerX(), bounds.centerY());
Sprite sprite = getChildAt(i);
sprite.draw(canvas);
canvas.restoreToCount(count);
}
}
use of com.github.ybq.android.spinkit.sprite.Sprite in project Android-SpinKit by ybq.
the class SpinKitView method init.
private void init() {
Sprite sprite = SpriteFactory.create(mStyle);
setIndeterminateDrawable(sprite);
}
Aggregations