use of android.support.v7.widget.RecyclerView.LayoutManager in project iNGAGE by davis123123.
the class RecentCommentsFragment method crossFadeRecyler.
private void crossFadeRecyler() {
adapter = new RecentCommentsAdapter(getContext());
recycler = (RecyclerView) rootView.findViewById(R.id.rvRecentComments);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
recycler.setLayoutManager(layoutManager);
recycler.setAdapter(adapter);
for (int i = 0; i < UserProfileActivity.recentComments.size(); i++) {
// Log.i("STATE", "recent comment : " + UserProfileActivity.recentComments.get(i).thread_title + ", " + UserProfileActivity.recentComments.get(i).recent_comment);
adapter.add(UserProfileActivity.recentComments.get(i));
}
adapter.notifyDataSetChanged();
// if no recent activities/comments, then show message
if (adapter.getItemCount() == 0) {
recycler.setVisibility(View.GONE);
RelativeLayout rlMessage = (RelativeLayout) rootView.findViewById(R.id.rlMessage);
rlMessage.setAlpha(0f);
rlMessage.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
rlMessage.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null);
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)
mLoadingView.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mLoadingView.setVisibility(View.GONE);
}
});
// ImageView icon = (ImageView) rootView.findViewById(R.id.ivIcon);
// icon.setColorFilter(getContext().getResources().getColor(R.color.dark_gray));
} else {
recycler.setAlpha(0f);
recycler.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation
// listener set on the view.
recycler.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null);
}
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)
mLoadingView.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mLoadingView.setVisibility(View.GONE);
}
});
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project assertj-android by square.
the class RecyclerViewAssert method hasLayoutManager.
public RecyclerViewAssert hasLayoutManager(LayoutManager layoutManager) {
isNotNull();
LayoutManager actualLayoutManager = actual.getLayoutManager();
//
assertThat(actualLayoutManager).overridingErrorMessage("Expected layout manager <%s> but was <%s>.", layoutManager, //
actualLayoutManager).isEqualTo(layoutManager);
return this;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project apps-android-wikipedia by wikimedia.
the class DrawableItemDecoration method bounds.
private Rect bounds(@NonNull RecyclerView parent, @NonNull View child, boolean top) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
Rect bounds = new Rect();
bounds.right = parent.getWidth() - parent.getPaddingRight();
bounds.left = parent.getPaddingLeft();
int height = drawable.getIntrinsicHeight();
bounds.top = top ? layoutManager.getDecoratedTop(child) : layoutManager.getDecoratedBottom(child) - height;
bounds.bottom = bounds.top + height;
return bounds;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project RecyclerViewSnap by rubensousa.
the class GravityDelegate method findEndView.
@Nullable
private View findEndView(RecyclerView.LayoutManager layoutManager, @NonNull OrientationHelper helper) {
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
boolean reverseLayout = linearLayoutManager.getReverseLayout();
int lastChild = reverseLayout ? linearLayoutManager.findFirstVisibleItemPosition() : linearLayoutManager.findLastVisibleItemPosition();
int offset = 1;
if (layoutManager instanceof GridLayoutManager) {
offset += ((GridLayoutManager) layoutManager).getSpanCount() - 1;
}
if (lastChild == RecyclerView.NO_POSITION) {
return null;
}
View child = layoutManager.findViewByPosition(lastChild);
float visibleWidth;
if (isRtlHorizontal) {
visibleWidth = (float) helper.getDecoratedEnd(child) / helper.getDecoratedMeasurement(child);
} else {
visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child)) / helper.getDecoratedMeasurement(child);
}
// If we're at the start of the list, we shouldn't snap
// to avoid having the first item not completely visible.
boolean startOfList;
if (!reverseLayout) {
startOfList = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition() == 0;
} else {
startOfList = ((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1;
}
if (visibleWidth > 0.5f && !startOfList) {
return child;
} else if (snapLastItem && startOfList) {
return child;
} else if (startOfList) {
return null;
} else {
// If the child wasn't returned, we need to return the previous view
return reverseLayout ? layoutManager.findViewByPosition(lastChild + offset) : layoutManager.findViewByPosition(lastChild - offset);
}
}
return null;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project RecyclerViewSnap by rubensousa.
the class GravityDelegate method findSnapView.
@Nullable
public View findSnapView(RecyclerView.LayoutManager layoutManager) {
View snapView = null;
if (layoutManager instanceof LinearLayoutManager) {
switch(gravity) {
case Gravity.START:
snapView = findStartView(layoutManager, getHorizontalHelper(layoutManager));
break;
case Gravity.END:
snapView = findEndView(layoutManager, getHorizontalHelper(layoutManager));
break;
case Gravity.TOP:
snapView = findStartView(layoutManager, getVerticalHelper(layoutManager));
break;
case Gravity.BOTTOM:
snapView = findEndView(layoutManager, getVerticalHelper(layoutManager));
break;
}
}
snapping = snapView != null;
return snapView;
}
Aggregations