Java Code Examples for com.zhy.adapter.recyclerview.base.ViewHolder#getView()

The following examples show how to use com.zhy.adapter.recyclerview.base.ViewHolder#getView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OtherStoriesHeaderDelegate.java    From ZhihuDaily with Apache License 2.0 6 votes vote down vote up
@Override
public void convert(ViewHolder holder, BaseItem baseItem, int position) {
    OtherStoriesHeader storiesHeader = (OtherStoriesHeader) baseItem;
    ImageView imageView = holder.getView(R.id.image);
    TextView textView = holder.getView(R.id.title);
    if ((boolean) SharedPreferencesUtils.get(App.getContext(), "NO_IMAGE_MODE", false)
            && !NetWorkUtils.isWifiConnected(App.getContext())) {
        Glide.with(holder.getConvertView().getContext())
                .load(R.drawable.image_top_default)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .centerCrop()
                .into(imageView);
    } else {
        Glide.with(holder.getConvertView().getContext())
                .load(storiesHeader.getUrl())
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .centerCrop()
                .into(imageView);
    }
    textView.setText(storiesHeader.getDescription());
}
 
Example 2
Source File: OtherStoriesSectionDelegate.java    From ZhihuDaily with Apache License 2.0 5 votes vote down vote up
@Override
public void convert(ViewHolder holder, BaseItem baseItem, int position) {
    mContext = holder.getConvertView().getContext();
    final OtherStoriesSection section = (OtherStoriesSection) baseItem;
    LinearLayout editorGroup = holder.getView(R.id.editor_group);
    if (editorGroup.getChildCount() == 0) {
        int defaultMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, holder.getConvertView().getResources().getDisplayMetrics());
        for (Editors editors : section.getEditors()) {
            ImageView imageView = new ImageView(mContext);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(defaultMargin, defaultMargin);
            imageView.setLayoutParams(params);
            if ((boolean) SharedPreferencesUtils.get(App.getContext(), "NO_IMAGE_MODE", false)
                    && !NetWorkUtils.isWifiConnected(App.getContext())) {
                Glide.with(mContext)
                        .load(R.drawable.editor_profile_avatar)
                        .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                        .transform(new CircleTransform(mContext))
                        .into(imageView);
            } else {
                Glide.with(mContext)
                        .load(editors.getAvatar())
                        .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                        .transform(new CircleTransform(mContext))
                        .into(imageView);
            }
            editorGroup.addView(imageView);
        }
    }
    holder.getView(R.id.editors).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mContext, EditorListActivity.class);
            intent.putParcelableArrayListExtra("editorList", section.getEditors());
            mContext.startActivity(intent);
        }
    });
}