Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41b22c09 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Overriding proper layout params methods for a custom ViewGroup

Change-Id: Ib6176a0da510eaa0992551ab4afa6f73b4763db0
parent 03f50ef3
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -695,15 +695,35 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
            super(width, height);
        }

        public LayoutParams(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public LayoutParams(ViewGroup.LayoutParams source) {
            super(source);
        }
    }

    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new LayoutParams(getContext(), attrs);
    }

    @Override
    protected LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    }

    @Override
    protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
        return new LayoutParams(p);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
    }

    public void addFullScreenPage(View page) {
        LayoutParams lp = generateDefaultLayoutParams();
        lp.isFullScreenPage = true;