Search in sources :

Example 1 with LayoutParams

use of androidx.recyclerview.widget.RecyclerView.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method addHeaderView.

/**
 * @param header
 * @param index
 * @param orientation
 */
public int addHeaderView(View header, int index, int orientation) {
    if (mHeaderLayout == null) {
        mHeaderLayout = new LinearLayout(header.getContext());
        if (orientation == LinearLayout.VERTICAL) {
            mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        } else {
            mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
        }
    }
    final int childCount = mHeaderLayout.getChildCount();
    if (index < 0 || index > childCount) {
        index = childCount;
    }
    mHeaderLayout.addView(header, index);
    if (mHeaderLayout.getChildCount() == 1) {
        int position = getHeaderViewPosition();
        if (position != -1) {
            notifyItemInserted(position);
        }
    }
    return index;
}
Also used : LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayout(android.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 2 with LayoutParams

use of androidx.recyclerview.widget.RecyclerView.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method setEmptyView.

public void setEmptyView(View emptyView) {
    boolean insert = false;
    if (mEmptyLayout == null) {
        mEmptyLayout = new FrameLayout(emptyView.getContext());
        final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        final ViewGroup.LayoutParams lp = emptyView.getLayoutParams();
        if (lp != null) {
            layoutParams.width = lp.width;
            layoutParams.height = lp.height;
        }
        mEmptyLayout.setLayoutParams(layoutParams);
        insert = true;
    }
    mEmptyLayout.removeAllViews();
    mEmptyLayout.addView(emptyView);
    mIsUseEmpty = true;
    if (insert) {
        if (getEmptyViewCount() == 1) {
            int position = 0;
            if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                position++;
            }
            notifyItemInserted(position);
        }
    }
}
Also used : LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 3 with LayoutParams

use of androidx.recyclerview.widget.RecyclerView.LayoutParams in project BaseProject by feer921.

the class BaseQuickAdapter method addFooterView.

/**
 * Add footer view to mFooterLayout and set footer view position in mFooterLayout.
 * When index = -1 or index >= child count in mFooterLayout,
 * the effect of this method is the same as that of {@link #addFooterView(View)}.
 *
 * @param footer
 * @param index  the position in mFooterLayout of this footer.
 *               When index = -1 or index >= child count in mFooterLayout,
 *               the effect of this method is the same as that of {@link #addFooterView(View)}.
 */
public int addFooterView(View footer, int index, int orientation) {
    if (mFooterLayout == null) {
        mFooterLayout = new LinearLayout(footer.getContext());
        if (orientation == LinearLayout.VERTICAL) {
            mFooterLayout.setOrientation(LinearLayout.VERTICAL);
            mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        } else {
            mFooterLayout.setOrientation(LinearLayout.HORIZONTAL);
            mFooterLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
        }
    }
    final int childCount = mFooterLayout.getChildCount();
    if (index < 0 || index > childCount) {
        index = childCount;
    }
    mFooterLayout.addView(footer, index);
    if (mFooterLayout.getChildCount() == 1) {
        int position = getFooterViewPosition();
        if (position != -1) {
            notifyItemInserted(position);
        }
    }
    return index;
}
Also used : LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayout(android.widget.LinearLayout) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 4 with LayoutParams

use of androidx.recyclerview.widget.RecyclerView.LayoutParams in project C3 by Hi5App.

the class BaseQuickAdapter method setEmptyView.

public void setEmptyView(View emptyView) {
    boolean insert = false;
    if (mEmptyView == null) {
        mEmptyView = new FrameLayout(emptyView.getContext());
        mEmptyView.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
        insert = true;
    }
    mEmptyView.removeAllViews();
    mEmptyView.addView(emptyView);
    mIsUseEmpty = true;
    if (insert) {
        if (getEmptyViewCount() == 1) {
            int position = 0;
            if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                position++;
            }
            notifyItemInserted(position);
        }
    }
}
Also used : LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) FrameLayout(android.widget.FrameLayout)

Example 5 with LayoutParams

use of androidx.recyclerview.widget.RecyclerView.LayoutParams in project NetBook by zhou129311.

the class BaseQuickAdapter method addHeaderView.

/**
 * @param header
 * @param index
 * @param orientation
 */
public int addHeaderView(View header, int index, int orientation) {
    if (mHeaderLayout == null) {
        mHeaderLayout = new LinearLayout(header.getContext());
        if (orientation == LinearLayout.VERTICAL) {
            mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        } else {
            mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
            mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
        }
    }
    final int childCount = mHeaderLayout.getChildCount();
    if (index < 0 || index > childCount) {
        index = childCount;
    }
    mHeaderLayout.addView(header, index);
    if (mHeaderLayout.getChildCount() == 1) {
        int position = getHeaderViewPosition();
        if (position != -1) {
            notifyItemInserted(position);
        }
    }
    return index;
}
Also used : LayoutParams(androidx.recyclerview.widget.RecyclerView.LayoutParams) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutParams (androidx.recyclerview.widget.RecyclerView.LayoutParams)10 LinearLayout (android.widget.LinearLayout)6 FrameLayout (android.widget.FrameLayout)4 SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 ViewGroup (android.view.ViewGroup)2