SwipeStack
SwipeStack copied to clipboard
Undo
Hi. I create undoView method in library
public void undoView() {
RecyclerView.ViewHolder viewHolder = mAdapter.onCreateViewHolder(this, 0);
mAdapter.onBindViewHolder(viewHolder, getCurrentPosition() - 1);
View topView = viewHolder.itemView;
topView.setTag(R.id.new_view, true);
if (!mDisableHwAcceleration) {
topView.setLayerType(LAYER_TYPE_HARDWARE, null);
}
if (mViewRotation > 0) {
topView.setRotation(mRandom.nextInt(mViewRotation) - (mViewRotation / 2));
}
int width = getWidth() - (getPaddingLeft() + getPaddingRight());
int height = getHeight() - (getPaddingTop() + getPaddingBottom());
LayoutParams params = topView.getLayoutParams();
if (params == null) {
params = new LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
}
int measureSpecWidth = MeasureSpec.AT_MOST;
int measureSpecHeight = MeasureSpec.AT_MOST;
if (params.width == LayoutParams.MATCH_PARENT) {
measureSpecWidth = MeasureSpec.EXACTLY;
}
if (params.height == LayoutParams.MATCH_PARENT) {
measureSpecHeight = MeasureSpec.EXACTLY;
}
topView.measure(measureSpecWidth | width, measureSpecHeight | height);
addViewInLayout(topView, getChildCount(), params, true);
}
But i can't solve one problem: If I make undo button under SwipeStack (by Z) with FrameLayout - click on him works but undoView() not works. If i make undo button below/top/left/right of SwipeStack with LinearLayout - undoView() works fine. Why?
Btw, i can create addFromRight + addFromLeft and make pull request? :3