Search in sources :

Example 1 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project UltimateRecyclerView by cymcsg.

the class HeaderPositionCalculator method itemIsObscuredByHeader.

/**
     * Determines if an item is obscured by a header
     *
     * @param parent
     * @param item        to determine if obscured by header
     * @param header      that might be obscuring the item
     * @param orientation of the {@link RecyclerView}
     * @return true if the item view is obscured by the header view
     */
private boolean itemIsObscuredByHeader(RecyclerView parent, View item, View header, int orientation) {
    RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) item.getLayoutParams();
    Rect headerMargins = mDimensionCalculator.getMargins(header);
    int adapterPosition = parent.getChildAdapterPosition(item);
    if (adapterPosition == RecyclerView.NO_POSITION || mHeaderProvider.getHeader(parent, adapterPosition) != header) {
        // Handles an edge case where a trailing header is smaller than the current sticky header.
        return false;
    }
    if (orientation == LinearLayoutManager.VERTICAL) {
        int itemTop = item.getTop() - layoutParams.topMargin;
        int headerBottom = header.getBottom() + headerMargins.bottom + headerMargins.top;
        if (itemTop > headerBottom) {
            return false;
        }
    } else {
        int itemLeft = item.getLeft() - layoutParams.leftMargin;
        int headerRight = header.getRight() + headerMargins.right + headerMargins.left;
        if (itemLeft > headerRight) {
            return false;
        }
    }
    return true;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView)

Example 2 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project UltimateAndroid by cymcsg.

the class BaseLayoutManager method generateLayoutParams.

@Override
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
    final LayoutParams lanedLp = new LayoutParams((MarginLayoutParams) lp);
    if (isVertical()) {
        lanedLp.width = LayoutParams.MATCH_PARENT;
        lanedLp.height = lp.height;
    } else {
        lanedLp.width = lp.width;
        lanedLp.height = LayoutParams.MATCH_PARENT;
    }
    return lanedLp;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Example 3 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project VideoPlayerManager by danylovolokh.

the class BaseVideoItem method createView.

public View createView(ViewGroup parent, int screenWidth) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item, parent, false);
    ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    layoutParams.height = screenWidth;
    final VideoViewHolder videoViewHolder = new VideoViewHolder(view);
    view.setTag(videoViewHolder);
    videoViewHolder.mPlayer.addMediaPlayerListener(new MediaPlayerWrapper.MainThreadMediaPlayerListener() {

        @Override
        public void onVideoSizeChangedMainThread(int width, int height) {
        }

        @Override
        public void onVideoPreparedMainThread() {
            // When video is prepared it's about to start playback. So we hide the cover
            videoViewHolder.mCover.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onVideoCompletionMainThread() {
        }

        @Override
        public void onErrorMainThread(int what, int extra) {
        }

        @Override
        public void onBufferingUpdateMainThread(int percent) {
        }

        @Override
        public void onVideoStoppedMainThread() {
            // Show the cover when video stopped
            videoViewHolder.mCover.setVisibility(View.VISIBLE);
        }
    });
    return view;
}
Also used : ViewGroup(android.view.ViewGroup) MediaPlayerWrapper(com.volokh.danylo.video_player_manager.ui.MediaPlayerWrapper) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) VideoViewHolder(com.volokh.danylo.videolist.video_list_demo.adapter.holders.VideoViewHolder)

Example 4 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project HoloEverywhere by Prototik.

the class ActionBarView method setMenu.

public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu) {
        return;
    }
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.FILL_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 5 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project SuperSLiM by TonicArtos.

the class LayoutManager method findFirstVisibleItem.

/**
     * Find the position of the first visible item.
     *
     * @return Position of first visible item.
     */
public View findFirstVisibleItem() {
    SectionData sd = new SectionData(this, getChildAt(0));
    final SectionLayoutManager slm = getSlm(sd);
    View firstVisibleView = slm.getFirstVisibleView(sd.firstPosition, false);
    int position = getPosition(firstVisibleView);
    if (position > sd.firstPosition + 1 || position == sd.firstPosition) {
        return firstVisibleView;
    }
    View first = findAttachedHeaderOrFirstViewForSection(sd.firstPosition, 0, Direction.START);
    if (first == null) {
        return firstVisibleView;
    }
    if (getDecoratedBottom(first) <= getDecoratedTop(firstVisibleView)) {
        return first;
    }
    LayoutParams firstParams = (LayoutParams) first.getLayoutParams();
    if ((!firstParams.isHeaderInline() || firstParams.isHeaderOverlay()) && getDecoratedTop(first) == getDecoratedTop(firstVisibleView)) {
        return first;
    }
    return firstVisibleView;
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

View (android.view.View)77 RecyclerView (android.support.v7.widget.RecyclerView)67 ViewGroup (android.view.ViewGroup)21 TextView (android.widget.TextView)21 ImageView (android.widget.ImageView)13 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)12 Toolbar (android.support.v7.widget.Toolbar)9 FrameLayout (android.widget.FrameLayout)9 Rect (android.graphics.Rect)8 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)8 BindView (butterknife.BindView)8 ActionMenuView (android.support.v7.widget.ActionMenuView)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 LinearLayout (android.widget.LinearLayout)6 CollapsibleActionView (android.support.v7.view.CollapsibleActionView)5 MenuView (android.support.v7.view.menu.MenuView)5 EditText (android.widget.EditText)5 ImageView (carbon.widget.ImageView)5 TextView (carbon.widget.TextView)5 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)5