Search in sources :

Example 86 with LayoutManager

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);
        }
    });
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) RelativeLayout(android.widget.RelativeLayout) RecentCommentsAdapter(ingage.ingage20.adapters.RecentCommentsAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 87 with LayoutManager

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;
}
Also used : LayoutManager(android.support.v7.widget.RecyclerView.LayoutManager)

Example 88 with LayoutManager

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;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView)

Example 89 with LayoutManager

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;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 90 with LayoutManager

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;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)430 RecyclerView (android.support.v7.widget.RecyclerView)371 View (android.view.View)261 GridLayoutManager (android.support.v7.widget.GridLayoutManager)128 TextView (android.widget.TextView)113 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)79 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)73 ImageView (android.widget.ImageView)71 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)47 Intent (android.content.Intent)46 ArrayList (java.util.ArrayList)43 Bundle (android.os.Bundle)37 Nullable (android.support.annotation.Nullable)33 Context (android.content.Context)29 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)28 BindView (butterknife.BindView)28 Toolbar (android.support.v7.widget.Toolbar)25 ViewGroup (android.view.ViewGroup)25 Handler (android.os.Handler)22 FloatingActionButton (android.support.design.widget.FloatingActionButton)21