Java 类android.support.v7.widget.RecyclerView 实例源码

项目:GxIconAndroid    文件:SearchActivity.java   
private void init() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    int[] gridNumAndWidth = calculateGridNumAndWidth();
    recyclerView.setLayoutManager(new GridLayoutManager(this, gridNumAndWidth[0]));

    adapter = new IconAdapter(this, gridNumAndWidth[1]);
    adapter.setMode(IconAdapter.MODE_ICON_LABEL);
    adapter.setOnItemClickListener(new IconAdapter.OnItemClickListener() {
        @Override
        public void onClick(int pos, IconBean bean) {
            searchView.clearFocus();
            IconDialog.newInstance(bean, false).show(getSupportFragmentManager(), "iconDialog");
        }
    });
    recyclerView.setAdapter(adapter);
}
项目:minu-poska-android    文件:AssignmentsFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_assignments, container, false);
    vSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer);
    vSwipeRefreshLayout.setOnRefreshListener(this);
    vSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.primary));

    vRecyclerView = (RecyclerView) view.findViewById(R.id.cardList);
    vRecyclerView.setHasFixedSize(false);
    final LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    vRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            // So the user didn't accidentally refresh on pulling up
            vSwipeRefreshLayout.setEnabled(llm.findFirstCompletelyVisibleItemPosition() == 0);
        }
    });
    vRecyclerView.setLayoutManager(llm);
    return view;
}
项目:Paprika    文件:RecipesItemAnimator.java   
@Override
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder,
                             @NonNull RecyclerView.ViewHolder newHolder,
                             @NonNull ItemHolderInfo preInfo,
                             @NonNull ItemHolderInfo postInfo) {

    if (preInfo instanceof RecipesItemHolderInfo) {
        RecipesItemHolderInfo recipesItemHolderInfo = (RecipesItemHolderInfo) preInfo;
        RecipesAdapter.RecipeViewHolder holder = (RecipesAdapter.RecipeViewHolder) newHolder;

        animateHeartButton(holder);
        if (RecipesAdapter.ACTION_LIKE_IMAGE_DOUBLE_CLICKED.equals(recipesItemHolderInfo.updateAction)) {
            animatePhotoLike(holder);
        }

    }

    return false;
}
项目:Tourguideapp    文件:AroundFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.place_list, container, false);

    // Create a list of words
    final ArrayList<Place> places = new ArrayList<Place>();
    places.add(new Place(R.string.name_Paris, R.string.Paris_title,
            R.drawable.paris_france_logo));
    places.add(new Place(R.string.paris_plage, R.string.argu_p_p,
            R.drawable.paris_plage));
    places.add(new Place(R.string.shopping, R.string.argu_shopping,
            R.drawable.shopping_paris));

    PlaceRecyclerViewAdapter adapter = new PlaceRecyclerViewAdapter(places);

    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.list);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    return rootView;
}
项目:GitHub    文件:RecyclerToListViewScrollListener.java   
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
  int listViewState;
  switch (newState) {
    case RecyclerView.SCROLL_STATE_DRAGGING:
      listViewState = ListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL;
      break;
    case RecyclerView.SCROLL_STATE_IDLE:
      listViewState = ListView.OnScrollListener.SCROLL_STATE_IDLE;
      break;
    case RecyclerView.SCROLL_STATE_SETTLING:
      listViewState = ListView.OnScrollListener.SCROLL_STATE_FLING;
      break;
    default:
      listViewState = UNKNOWN_SCROLL_STATE;
  }

  scrollListener.onScrollStateChanged(null /*view*/, listViewState);
}
项目:TPlayer    文件:FeatureAdapter.java   
/**
 * 当RecyclerView在windows活动时获取StaggeredGridLayoutManager布局管理器,修正header和footer显示整行
 *
 * @param holder the RecyclerView.ViewHolder
 */
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
    ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
    if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
        StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
        if (BEHAVIOR_MODE == ONLY_HEADER) {
            p.setFullSpan(holder.getLayoutPosition() == 0);
        } else if (BEHAVIOR_MODE == ONLY_FOOTER) {
            p.setFullSpan(holder.getLayoutPosition() == mItems.size() + 1);
        } else if (BEHAVIOR_MODE == BOTH_HEADER_FOOTER) {
            if (holder.getLayoutPosition() == 0 || holder.getLayoutPosition() == mItems.size() + 1) {
                p.setFullSpan(true);
            }
        }
    }
}
项目:Coin-Tracker    文件:RVDividerItemDecoration.java   
@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    int dividerLeft = parent.getPaddingLeft();
    int dividerRight = parent.getWidth() - parent.getPaddingRight();

    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount - 1; i++) {
        View child = parent.getChildAt(i);

        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        int dividerTop = child.getBottom() + params.bottomMargin;
        int dividerBottom = dividerTop + mDivider.getIntrinsicHeight();

        mDivider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom);
        mDivider.draw(canvas);
    }
}
项目:Android-Wear-Projects    文件:HistoryActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history);
    // Calling the RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setHasFixedSize(true);

    Realm.init(this);
    realm = Realm.getDefaultInstance();
    RealmResults<StepCounts> results = realm.where(StepCounts.class).findAll();
    // The number of Columns
    mLayoutManager = new GridLayoutManager(this, 1);
    mRecyclerView.setLayoutManager(mLayoutManager);

    mAdapter = new HistoryAdapter(results,HistoryActivity.this);
    mRecyclerView.setAdapter(mAdapter);
}
项目:Tusky    文件:AccountListFragment.java   
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    BaseActivity activity = (BaseActivity) getActivity();

    /* MastodonApi on the base activity is only guaranteed to be initialised after the parent
     * activity is created, so everything needing to access the api object has to be delayed
     * until here. */
    api = activity.mastodonApi;
    // Just use the basic scroll listener to load more accounts.
    scrollListener = new EndlessOnScrollListener(layoutManager) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            AccountListFragment.this.onLoadMore(view);
        }
    };

    recyclerView.addOnScrollListener(scrollListener);
}
项目:UltimateRecyclerView    文件:UltimateRecyclerViewAdapter.java   
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if (mSpanSizeLookup == null) {
                    return (isHeader(position) || isFooter(position) || isRefreshHeader(position))
                            ? gridLayoutManager.getSpanCount() : 1;
                } else {
                    return (isHeader(position) || isFooter(position) ||
                            isRefreshHeader(position)) ? gridLayoutManager.getSpanCount() :
                            mSpanSizeLookup.getSpanSize(gridLayoutManager,
                                    (position - (getHeaderViewCount() + 1)));
                }
            }
        });
    }
    mInnerAdapter.onAttachedToRecyclerView(recyclerView);
}
项目:TestChat    文件:MultiFuncRecyclerView.java   
public void setAdapter(final RecyclerView.Adapter adapter) {
                if (adapter != null) {
                        adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
                                @Override
                                public void onChanged() {
                                        LogUtil.e("数据改变了 ");
//                                        当数据插入完成后
                                        isLoading = false;
                                        if (moreLoadView.getVisibility() == VISIBLE) {
                                                moreLoadView.setVisibility(GONE);
                                        }
                                        if (adapter.getItemCount() == 0 && emptyView != null) {
                                                LogUtil.e("数据为空时,显示空view");
                                                emptyView.setVisibility(VISIBLE);
                                        } else if (emptyView != null) {
                                                emptyView.setVisibility(GONE);
                                        }
                                }
                        });
                        display.setAdapter(adapter);
                }
        }
项目:GitHub    文件:FullyGridLayoutManager.java   
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
                               int heightSpec, int[] measuredDimension) {
    if (position < getItemCount()) {
        try {
            View view = recycler.getViewForPosition(position);//fix 动态添加时报IndexOutOfBoundsException
            if (view != null) {
                RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
                int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
                        getPaddingLeft() + getPaddingRight(), p.width);
                int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
                        getPaddingTop() + getPaddingBottom(), p.height);
                view.measure(childWidthSpec, childHeightSpec);
                measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
                measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
                recycler.recycleView(view);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:gmlrva    文件:DecoratorDrawableDividerHelper.java   
/**
 * Procedure meant to handle the drawing of the intended {@link SimpleDividerItemDecoration}'s divider
 * on start / left of the parent's {@link RecyclerView} item.
 * @param canvas the {@link Canvas} object where the divider will be drawn.
 * @param parent the parent {@link RecyclerView} for the applied {@link SimpleDividerItemDecoration}.
 * @param mDivider the divider's target {@link Drawable} value.
 */
protected void drawDrawableDividerPositionStart(@NonNull final Canvas canvas, @NonNull final RecyclerView parent,
                                                @NonNull final Drawable mDivider) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View view = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();
        final int left = view.getLeft() + params.leftMargin;
        final int right = left + mDivider.getIntrinsicWidth();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(canvas);
    }
}
项目:NovelReader    文件:DividerGridItemDecoration.java   
public void drawVertical(Canvas c, RecyclerView parent) {
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);

        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mHeightDivider.getIntrinsicWidth();

        mHeightDivider.setBounds(left, top, right, bottom);
        mHeightDivider.draw(c);
    }
}
项目:VanGogh    文件:VanMediaAdapter.java   
@Override
public void onCheckViewClicked(CheckView checkView, MediaInfo mediaInfo, RecyclerView.ViewHolder holder) {
    if (mSelectionSpec.countable) {
        int checkedNum = mSelectedCollection.checkedNumOf(mediaInfo);
        if (checkedNum == CheckView.UNCHECKED) {
            if (assertAddSelection(holder.itemView.getContext(), mediaInfo)) {
                mSelectedCollection.add(mediaInfo);
                notifyCheckStateChanged();
            }
        } else {
            mSelectedCollection.remove(mediaInfo);
            notifyCheckStateChanged();
        }
    } else {
        if (mSelectedCollection.isSelected(mediaInfo)) {
            mSelectedCollection.remove(mediaInfo);
            notifyCheckStateChanged();
        } else {
            if (assertAddSelection(holder.itemView.getContext(), mediaInfo)) {
                mSelectedCollection.add(mediaInfo);
                notifyCheckStateChanged();
            }
        }
    }
}
项目:SmartChart    文件:WrapperUtils.java   
public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) {
    innerAdapter.onAttachedToRecyclerView(recyclerView);

    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
        final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
            }
        });
        gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
    }
}
项目:baselibrary-master    文件:HeaderAndFooterWrapper.java   
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView)
{
    WrapperUtils.onAttachedToRecyclerView(mInnerAdapter, recyclerView, new WrapperUtils.SpanSizeCallback()
    {
        @Override
        public int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position)
        {
            int viewType = getItemViewType(position);
            if (mHeaderViews.get(viewType) != null)
            {
                return layoutManager.getSpanCount();
            } else if (mFootViews.get(viewType) != null)
            {
                return layoutManager.getSpanCount();
            }
            if (oldLookup != null)
                return oldLookup.getSpanSize(position);
            return 1;
        }
    });
}
项目:RecyclerViewEvent    文件:DividerGridItemDecoration.java   
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        childCount = childCount - childCount % spanCount;
        if (pos >= childCount)// 如果是最后一行,则不需要绘制底部
            return true;
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        // StaggeredGridLayoutManager 且纵向滚动
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            childCount = childCount - childCount % spanCount;
            // 如果是最后一行,则不需要绘制底部
            if (pos >= childCount)
                return true;
        } else
        // StaggeredGridLayoutManager 且横向滚动
        {
            // 如果是最后一行,则不需要绘制底部
            if ((pos + 1) % spanCount == 0) {
                return true;
            }
        }
    }
    return false;
}
项目:AndroidTvDemo    文件:AbsFocusBorder.java   
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState)
{
    if (newState == RecyclerView.SCROLL_STATE_IDLE)
    {
        final AbsFocusBorder border = mFocusBorder.get();
        final View focused = recyclerView.getFocusedChild();
        if (null != border && null != focused)
        {
            if (border.mReAnim || mScrolledX != 0 || mScrolledY != 0)
            {
                border.runBorderAnimation(focused, Options.OptionsHolder.INSTANCE);
            }
        }
        mScrolledX = mScrolledY = 0;
    }
}
项目:MultiTypeRecyclerViewAdapter    文件:MainActivity.java   
private void initView() {

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        mSearchView = (MaterialSearchView) findViewById(R.id.search);
        mTitle = (TextView) findViewById(R.id.title);
        mAppBar = (AppBarLayout) findViewById(R.id.appbar);
    }
项目:NoPaginate    文件:ScrollUtils.java   
static boolean isOnBottom(RecyclerView recyclerView, int loadingTriggerThreshold) {
    final int visibleItemCount = recyclerView.getChildCount();
    final int totalItemCount = recyclerView.getLayoutManager().getItemCount();
    final int firstVisibleItemPosition = getFirstVisibleItemPositionByLayoutManager(recyclerView.getLayoutManager());
    // Check if end of the list is reached (counting threshold) or if there is no items at all
    return (totalItemCount - visibleItemCount) <= (firstVisibleItemPosition + loadingTriggerThreshold)
            || totalItemCount == 0;

}
项目:GitHub    文件:DefaultAdapter.java   
/**
 * 遍历所有hodler,释放他们需要释放的资源
 *
 * @param recyclerView
 */
public static void releaseAllHolder(RecyclerView recyclerView) {
    if (recyclerView == null) return;
    for (int i = recyclerView.getChildCount() - 1; i >= 0; i--) {
        final View view = recyclerView.getChildAt(i);
        RecyclerView.ViewHolder viewHolder = recyclerView.getChildViewHolder(view);
        if (viewHolder != null && viewHolder instanceof BaseHolder) {
            ((BaseHolder) viewHolder).onRelease();
        }
    }
}
项目:CoordinatorLayoutExample-master    文件:LoadMoreWrapper.java   
private void setFullSpan(RecyclerView.ViewHolder holder) {
    ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();

    if (lp != null
            && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
        StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams)
                lp;

        p.setFullSpan(true);
    }
}
项目:BaseAdapterRel    文件:LoadMoreWrapper.java   
private void setFullSpan(RecyclerView.ViewHolder holder)
{
    ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();

    if (lp != null
            && lp instanceof StaggeredGridLayoutManager.LayoutParams)
    {
        StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;

        p.setFullSpan(true);
    }
}
项目:android-study    文件:SimpleItemTouchHelperCallback.java   
/**
 * 当条目停止移动时调用
 */
@Override public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
  super.clearView(recyclerView, viewHolder);
  viewHolder.itemView.setAlpha(1.0f);
  if (viewHolder instanceof ItemTouchHelperViewHolder) {
    ItemTouchHelperViewHolder holder = (ItemTouchHelperViewHolder) viewHolder;
    holder.onItemClear();
  }
}
项目:AndroidDigIn    文件:RecyclerFragment.java   
/**
     * Provide the cursor for the recycler view.
     */
    public void setRecyclerAdapter(RecyclerView.Adapter adapter) {
//        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mRecyclerView != null) {
            mRecyclerView.setAdapter(adapter);
        }
    }
项目:ClassifyView    文件:BaseMainAdapter.java   
@SuppressWarnings("unchecked")
@Override
public void onStartMergeAnimation(RecyclerView parent, int selectedPosition, int targetPosition,int duration) {
    VH selectedViewHolder = (VH) parent.findViewHolderForAdapterPosition(selectedPosition);
    VH targetViewHolder = (VH) parent.findViewHolderForAdapterPosition(targetPosition);
    if(selectedViewHolder == null || targetViewHolder == null) return;
    onStartMergeAnimation(selectedViewHolder, targetViewHolder, selectedPosition, targetPosition,duration);
}
项目:android-study    文件:GravitySnapHelper.java   
@Override public void attachToRecyclerView(@Nullable RecyclerView recyclerView)
    throws IllegalStateException {
  if (recyclerView != null) {
    mIsRtl = false;
  }
  super.attachToRecyclerView(recyclerView);
}
项目:Android-Infrastructure    文件:NotesActivity.java   
private void setup(){
    recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new NotesAdapter(this));
    findViewById(R.id.addbutton).setOnClickListener(this);
    noteET = (EditText) findViewById(R.id.editText);
    progressBar = (ProgressBar)findViewById(R.id.progressBar);
}
项目:ContactsList    文件:FloatingBarItemDecoration.java   
private void drawTitleArea(Canvas c, int left, int right, View child,
                           RecyclerView.LayoutParams params, int position) {
    final int rectBottom = child.getTop() - params.topMargin;
    c.drawRect(left, rectBottom - mTitleHeight, right,
            rectBottom, mBackgroundPaint);
    c.drawText(mList.get(position), child.getPaddingLeft() + mTextStartMargin,
            rectBottom - (mTitleHeight - mTextHeight) / 2 - mTextBaselineOffset, mTextPaint);
}
项目:RvAdapter    文件:StickyRecyclerHeadersTouchListener.java   
@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
    if (this.mOnHeaderClickListener != null) {
        boolean tapDetectorResponse = this.mTapDetector.onTouchEvent(e);
        if (tapDetectorResponse) {
            // Don't return false if a single tap is detected
            return true;
        }
        if (e.getAction() == MotionEvent.ACTION_DOWN) {
            int position = mDecor.findHeaderPositionUnder((int) e.getX(), (int) e.getY());
            return position != -1;
        }
    }
    return false;
}
项目:vlayout    文件:StaggeredGridLayoutHelper.java   
@Override
public void onScrollStateChanged(int state, int startPosition,
                                 int endPosition, LayoutManagerHelper helper) {
    if (startPosition > getRange().getUpper() || endPosition < getRange().getLower()) {
        return;
    }

    if (state == RecyclerView.SCROLL_STATE_IDLE) {
        checkForGaps();
    }
}
项目:SmartChart    文件:EmptyWrapper.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (isEmpty()) {
        return;
    }
    mInnerAdapter.onBindViewHolder(holder, position);
}
项目:Tangram-Android    文件:BaseTangramEngine.java   
/**
 * @return Return the recyclerView binded to Tangram, do not call this method after {@link #destroy()}, since it
 * will recreate a recyclerView instance. Also it is suggested to call {@link #bindView(RecyclerView)} first
 * before call this method, since the recyclerView created in this method is a default one and may not meet up to
 * your case.
 */
public RecyclerView getContentView() {
    if (mContentView == null) {
        RecyclerView recyclerView = new RecyclerView(mContext);
        bindView(recyclerView);
        Preconditions.checkState(mContentView != null, "mContentView is still null after call bindView()");
    }

    return mContentView;
}
项目:popomusic    文件:JKActivity.java   
@Override
public void initView() {
    recyclerView=(RecyclerView)findViewById(R.id.recycler_JK);
    mAdapter=new LocalMusicAdapter(this);
    mLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(mAdapter);
    LogUtils.d("LocalMusicActivity","initView()");
    srfLayout=(SwipeRefreshLayout)findViewById(R.id.swipe);
    mPresenter=new JKPresenter((JKMusicData.View)this);
    mBtnPlay.setImageResource(R.mipmap.bar_play);
}
项目:CoordinatorLayoutExample-master    文件:EmptyWrapper.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (isEmpty()) {
        return;
    }
    mInnerAdapter.onBindViewHolder(holder, position);
}
项目:2017.1-Trezentos    文件:ExamsFragment.java   
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    ExamsFragment.ViewHolder holder = (ExamsFragment.ViewHolder) viewHolder;

    Exam exam  = exams.get(position) ;
    holder.className.setText(exam.getNameExam());
}
项目:androidadvanced    文件:RecipesAdapterTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();
    URL = "http://galileo.edu";
    when(recipe.getSourceURL()).thenReturn(URL);

    adapter = new RecipesAdapter(recipeList, imageLoader, onItemClickListener);
    shadowAdapter = (ShadowRecyclerViewAdapter) ShadowExtractor.extract(adapter);

    Activity activity = Robolectric.setupActivity(Activity.class);
    RecyclerView recyclerView = new RecyclerView(activity);
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));

    recyclerView.setAdapter(adapter);
}
项目:Hands-On-Android-UI-Development    文件:OverviewActivity.java   
@Override
public void onSwiped(
        final RecyclerView.ViewHolder viewHolder,
        final int direction) {

    final DataBoundViewHolder<?, ClaimItem> holder = (DataBoundViewHolder<?, ClaimItem>) viewHolder;
    new DeleteClaimItemCommand(holder.getItem()).exec(null);
}
项目:SuperRecyclerViewAdapter    文件:Btn2LayoutActivity.java   
private void initView() {

        mRv = (RecyclerView) findViewById(R.id.rv);

        mAdapter = new SuperRecyclerAdapter<String>(this, mList) {
            @Override
            public void convert(SuperRecyclerHolder holder, final String s, int layoutType,
                final int position) {
                //只有一种布局,不使用layoutType来区分type了
                holder//
                    .setText(R.id.tv_content, s)
                    .setOnItemClickListenner(new View.OnClickListener() {
                        @Override public void onClick(View v) {
                            Toast.makeText(Btn2LayoutActivity.this, "item被点击", Toast.LENGTH_SHORT)
                                .show();
                        }
                    });
            }

            @Override public int getLayoutAsViewType(String s, int position) {
                return R.layout.recycler_item_btn2;
            }
        };

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mRv.setLayoutManager(layoutManager);
        mRv.setAdapter(mAdapter);
    }