use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project AndFrameWorks by scwang90.
the class RecycleViewDivider method drawHorizontal.
// 绘制横向 item 分割线
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
final int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + layoutParams.bottomMargin;
final int bottom = top + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project KL2 by jweihao.
the class SpaceItemDecorationUtil method drawLinear.
private void drawLinear(int orientation, Canvas c, RecyclerView parent) {
if (orientation == LinearLayoutManager.VERTICAL) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin + Math.round(ViewCompat.getTranslationY(child));
final int bottom = top + mSpace;
c.drawRect(left, top, right, bottom, mDividerPaint);
}
} else if (orientation == LinearLayoutManager.HORIZONTAL) {
final int top = parent.getPaddingTop();
final int bottom = parent.getHeight() - parent.getPaddingBottom();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
final int right = left + mSpace;
c.drawRect(left, top, right, bottom, mDividerPaint);
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project MusicLake by caiyonglong.
the class DividerItemDecoration method drawVertical.
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project NightSkyGuide by MTBehnke.
the class ItemDivider method onDrawOver.
// draws the list item dividers onto the RecyclerView
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(c, parent, state);
// calculate left/right x-coordinates for all dividers
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
// for every item but the last, draw a line below it
for (int i = 0; i < parent.getChildCount() - 1; ++i) {
// get ith list item
View item = parent.getChildAt(i);
// calculate top/bottom y-coordinates for current divider
int top = item.getBottom() + ((RecyclerView.LayoutParams) item.getLayoutParams()).bottomMargin;
int bottom = top + divider.getIntrinsicHeight();
// draw the divider with the calculated bounds
divider.setBounds(left, top, right, bottom);
divider.draw(c);
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project RecyclerViewPager by lsjwzh.
the class VerticalPagerActivity method initViewPager.
protected void initViewPager() {
mRecyclerView = (RecyclerViewPager) findViewById(R.id.viewpager);
LinearLayoutManager layout = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
mRecyclerView.setTriggerOffset(0.15f);
mRecyclerView.setFlingFactor(0.25f);
mRecyclerView.setLayoutManager(layout);
mRecyclerView.setAdapter(new LayoutAdapter(this, mRecyclerView));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLongClickable(true);
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
// mPositionText.setText("First: " + mRecyclerViewPager.getFirstVisiblePosition());
int childCount = mRecyclerView.getChildCount();
int width = mRecyclerView.getChildAt(0).getWidth();
int padding = (mRecyclerView.getWidth() - width) / 2;
for (int j = 0; j < childCount; j++) {
View v = recyclerView.getChildAt(j);
// 往左 从 padding 到 -(v.getWidth()-padding) 的过程中,由大到小
float rate = 0;
if (v.getTop() <= padding) {
if (v.getTop() >= padding - v.getHeight()) {
rate = (padding - v.getTop()) * 1f / v.getHeight();
} else {
rate = 1;
}
v.setScaleX(1 - rate * 0.1f);
v.setScaleY(1 - rate * 0.1f);
} else {
// 往右 从 padding 到 recyclerView.getHeight()-padding 的过程中,由大到小
if (v.getTop() <= recyclerView.getHeight() - padding) {
rate = (recyclerView.getHeight() - padding - v.getTop()) * 1f / v.getHeight();
}
v.setScaleX(0.9f + rate * 0.1f);
v.setScaleY(0.9f + rate * 0.1f);
}
}
}
});
mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (mRecyclerView.getChildCount() < 3) {
if (mRecyclerView.getChildAt(1) != null) {
View v1 = mRecyclerView.getChildAt(1);
v1.setScaleY(0.9f);
}
} else {
if (mRecyclerView.getChildAt(0) != null) {
View v0 = mRecyclerView.getChildAt(0);
v0.setScaleY(0.9f);
}
if (mRecyclerView.getChildAt(2) != null) {
View v2 = mRecyclerView.getChildAt(2);
v2.setScaleY(0.9f);
}
}
}
});
}
Aggregations