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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations