Search in sources :

Example 1 with Article

use of me.yokeyword.sample.demo_wechat.entity.Article in project Fragmentation by YoKeyword.

the class HomeAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    Article item = mItems.get(position);
    holder.tvTitle.setText(item.getTitle());
    holder.tvContent.setText(item.getContent());
}
Also used : Article(me.yokeyword.sample.demo_wechat.entity.Article)

Example 2 with Article

use of me.yokeyword.sample.demo_wechat.entity.Article in project Fragmentation by YoKeyword.

the class WechatThirdTabFragment method onLazyInitView.

@Override
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
    super.onLazyInitView(savedInstanceState);
    mAdapter = new HomeAdapter(_mActivity);
    LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
    mRecy.setLayoutManager(manager);
    mRecy.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view, RecyclerView.ViewHolder vh) {
            // 通知MainActivity跳转至DetailFragment
            EventBus.getDefault().post(new StartBrotherEvent(DetailFragment.newInstance(mAdapter.getItem(position).getTitle())));
        }
    });
    // Init Datas
    List<Article> articleList = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        Article article = new Article(mTitles[i], mContents[i]);
        articleList.add(article);
    }
    mAdapter.setDatas(articleList);
    mRecy.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mScrollTotal += dy;
            if (mScrollTotal <= 0) {
                mAtTop = true;
            } else {
                mAtTop = false;
            }
        }
    });
}
Also used : OnItemClickListener(me.yokeyword.sample.demo_wechat.listener.OnItemClickListener) Article(me.yokeyword.sample.demo_wechat.entity.Article) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) StartBrotherEvent(me.yokeyword.sample.demo_wechat.event.StartBrotherEvent) HomeAdapter(me.yokeyword.sample.demo_wechat.adapter.HomeAdapter) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Article (me.yokeyword.sample.demo_wechat.entity.Article)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ArrayList (java.util.ArrayList)1 HomeAdapter (me.yokeyword.sample.demo_wechat.adapter.HomeAdapter)1 StartBrotherEvent (me.yokeyword.sample.demo_wechat.event.StartBrotherEvent)1 OnItemClickListener (me.yokeyword.sample.demo_wechat.listener.OnItemClickListener)1