Skip to content
This repository was archived by the owner on Jul 22, 2019. It is now read-only.
This repository was archived by the owner on Jul 22, 2019. It is now read-only.

Undo #57

@D330

Description

@D330

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions