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

Undo #57

Open
D330 opened this issue Jan 12, 2018 · 1 comment
Open

Undo #57

D330 opened this issue Jan 12, 2018 · 1 comment

Comments

@D330
Copy link

D330 commented Jan 12, 2018

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?

@D330
Copy link
Author

D330 commented Jan 12, 2018

Btw, i can create addFromRight + addFromLeft and make pull request? :3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant