Search in sources :

Example 36 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project photo-picker-plus-android by chute.

the class GridAdapter method onCreateViewHolder.

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = null;
    LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
    itemView = layoutInflater.inflate(R.layout.gc_grid_adapter_item, parent, false);
    return new ViewHolder(itemView);
}
Also used : LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 37 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project GeekNews by codeestX.

the class NodeListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof TopViewHolder) {
        TopViewHolder topHolder = ((TopViewHolder) holder);
        if (mTopBean == null)
            return;
        ImageLoader.load(mContext, VtexPresenter.parseImg(mTopBean.getavatar_normal()), topHolder.ivNodeFace);
        topHolder.tvNodeContent.setText(mTopBean.getHeader());
        topHolder.tvNodesTips.setText(String.format("%d个主题\n%d次收藏", mTopBean.getTopics(), mTopBean.getStars()));
        topHolder.tvNodeName.setText(mTopBean.getTitle());
    } else {
        ViewHolder contentHolder = ((ViewHolder) holder);
        NodeListBean bean = mList.get(position - 1);
        if (bean == null)
            return;
        ImageLoader.load(mContext, VtexPresenter.parseImg(bean.getMember().getavatar_normal()), contentHolder.ivTopicFace);
        contentHolder.tvTopicName.setText(bean.getMember().getUsername());
        contentHolder.tvTopicTips.setText(DateUtil.formatTime2String(bean.getCreated()));
        contentHolder.tvTopicComment.setText(String.valueOf(bean.getReplies()));
        contentHolder.tvTopicTitle.setText(bean.getTitle());
        contentHolder.tvTopicNode.setText(bean.getNode().getTitle());
        contentHolder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(mContext, RepliesActivity.class);
                if (holder.getAdapterPosition() - 1 < 0 || mList.get(holder.getAdapterPosition() - 1) == null)
                    return;
                intent.putExtra(Constants.IT_VTEX_TOPIC_ID, mList.get(holder.getAdapterPosition() - 1).getId());
                intent.putExtra(Constants.IT_VTEX_REPLIES_TOP, mList.get(holder.getAdapterPosition() - 1));
                mContext.startActivity(intent);
            }
        });
    }
}
Also used : NodeListBean(com.codeest.geeknews.model.bean.NodeListBean) Intent(android.content.Intent) SquareImageView(com.codeest.geeknews.widget.SquareImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) CircleImageView(com.codeest.geeknews.widget.CircleImageView) RepliesActivity(com.codeest.geeknews.ui.vtex.activity.RepliesActivity)

Example 38 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project GeekNews by codeestX.

the class TopicAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    TopicListBean bean = mList.get(position);
    ImageLoader.load(mContext, bean.getImgUrl(), holder.ivTopicFace);
    holder.tvTopicName.setText(bean.getName());
    holder.tvTopicTips.setText(bean.getUpdateTime() + " • 最后回复 " + bean.getLastUser());
    holder.tvTopicComment.setText(String.valueOf(bean.getCommentNum()));
    holder.tvTopicNode.setText(bean.getNode());
    holder.tvTopicTitle.setText(bean.getTitle());
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setClass(mContext, RepliesActivity.class);
            intent.putExtra(Constants.IT_VTEX_TOPIC_ID, mList.get(holder.getAdapterPosition()).getTopicId());
            mContext.startActivity(intent);
        }
    });
}
Also used : Intent(android.content.Intent) TopicListBean(com.codeest.geeknews.model.bean.TopicListBean) SquareImageView(com.codeest.geeknews.widget.SquareImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) RepliesActivity(com.codeest.geeknews.ui.vtex.activity.RepliesActivity)

Example 39 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project materialistic by hidroh.

the class ItemFragmentMultiPageTest method testBindLocalKidData.

@Test
public void testBindLocalKidData() {
    Item story = new TestHnItem(0L);
    story.populate(new TestItem() {

        @Override
        public int getDescendants() {
            return 1;
        }

        @Override
        public long[] getKids() {
            return new long[] { 1L };
        }
    });
    story.getKidItems()[0].populate(new TestItem() {

        @Override
        public String getText() {
            return "text";
        }

        @Override
        public long[] getKids() {
            return new long[] { 2L };
        }

        @Override
        public int getDescendants() {
            return 1;
        }
    });
    Bundle args = new Bundle();
    args.putParcelable(ItemFragment.EXTRA_ITEM, story);
    Fragment fragment = Fragment.instantiate(RuntimeEnvironment.application, ItemFragment.class.getName(), args);
    makeVisible(fragment);
    assertThat(fragment.getView().findViewById(R.id.empty)).isNotVisible();
    RecyclerView recyclerView = (RecyclerView) fragment.getView().findViewById(R.id.recycler_view);
    RecyclerView.ViewHolder viewHolder = CustomShadows.customShadowOf(recyclerView.getAdapter()).getViewHolder(0);
    assertThat((TextView) viewHolder.itemView.findViewById(R.id.text)).hasTextString("text");
    assertThat(viewHolder.itemView.findViewById(R.id.comment)).isVisible();
    viewHolder.itemView.findViewById(R.id.comment).performClick();
    Intent actual = shadowOf(fragment.getActivity()).getNextStartedActivity();
    assertEquals(ItemActivity.class.getName(), actual.getComponent().getClassName());
    assertThat(actual).hasExtra(ItemActivity.EXTRA_OPEN_COMMENTS, true);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) Fragment(android.support.v4.app.Fragment) TestItem(io.github.hidroh.materialistic.test.TestItem) WebItem(io.github.hidroh.materialistic.data.WebItem) Item(io.github.hidroh.materialistic.data.Item) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) TestItem(io.github.hidroh.materialistic.test.TestItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 40 with ViewHolder

use of android.support.v7.widget.RecyclerView.ViewHolder in project materialistic by hidroh.

the class UserActivityTest method testCommentBinding.

@Test
public void testCommentBinding() {
    verify(userManager).getUser(eq("username"), userCaptor.capture());
    userCaptor.getValue().onResponse(user);
    RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
    verify(itemManager).getItem(eq("1"), eq(ItemManager.MODE_DEFAULT), itemCaptor.capture());
    itemCaptor.getValue().onResponse(new TestHnItem(1L) {

        @Override
        public String getText() {
            return "content";
        }

        @Override
        public String getParent() {
            return "2";
        }
    });
    RecyclerView.ViewHolder viewHolder = customShadowOf(recyclerView.getAdapter()).getViewHolder(0);
    assertThat(viewHolder.itemView.findViewById(R.id.title)).isNotVisible();
    assertThat((TextView) viewHolder.itemView.findViewById(R.id.text)).isVisible().hasTextString("content");
    viewHolder.itemView.findViewById(R.id.comment).performClick();
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ThreadPreviewActivity.class).hasExtra(ThreadPreviewActivity.EXTRA_ITEM);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerView(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) Test(org.junit.Test)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)265 View (android.view.View)248 TextView (android.widget.TextView)129 ImageView (android.widget.ImageView)95 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)47 LayoutInflater (android.view.LayoutInflater)34 ViewGroup (android.view.ViewGroup)32 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)28 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 Intent (android.content.Intent)26 ArrayList (java.util.ArrayList)25 Context (android.content.Context)21 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)17 BindView (butterknife.BindView)17 CardView (android.support.v7.widget.CardView)15 Paint (android.graphics.Paint)11 ParallaxRecyclerAdapter (com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter)8 ExampleData (de.madcyph3r.example.data.ExampleData)8 Drawable (android.graphics.drawable.Drawable)7 Test (org.junit.Test)7