BaseRecyclerViewAdapterHelper

1 和databing 的联合使用

/**
 * 作者:水东流 编于 2019/3/20
 * 协助adapter中使用databing
 */
public class MyBaseViewHolder extends BaseViewHolder {
    public MyBaseViewHolder(View view) {
        super(view);
    }
}

 

/**
 * 作者:水东流 编于 2019/3/20
 * 关注适配器
 */
public class FollowAdapter extends BaseQuickAdapter<XinHuaBean, MyBaseViewHolder> {

    public FollowAdapter(@Nullable List<XinHuaBean> data) {
        super(data);
    }

    @Override
    protected MyBaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
        ItemXinHuaFollowBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext),     R.layout.item_xin_hua_follow, parent, false);
        return new MyBaseViewHolder(binding.getRoot());
    }

    @Override
    protected void convert(MyBaseViewHolder helper, XinHuaBean item) {
        ItemXinHuaFollowBinding binding = DataBindingUtil.getBinding(helper.itemView);

        ImageLoaderUtil.getInstance().loadImage(mContext, item.getXinhuaCover(), helper.getView(R.id.cover));
        binding.setXinhuabean(item);
 } 
}

item_xin_hua_follow 布局

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>

        <variable
            name="xinhuabean"
            type="com.broken.molaware.xinhua_android.bean.home.XinHuaBean" />
    </data>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/dp_16"
        android:gravity="center_vertical">

        <ImageView
            android:id="@+id/cover"
            android:layout_width="35dp"
            android:layout_height="35dp" />

        <LinearLayout
            android:layout_width="@dimen/dp_190"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/dp_50"
            android:orientation="vertical">

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{xinhuabean.xinHuaName}"
                android:textColor="@color/title"
                android:textSize="@dimen/text_size_17" />

            <TextView
                android:id="@+id/little_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dp_5"
                android:ellipsize="end"
                android:text="@{xinhuabean.xinhuaDesc}"
                android:textColor="@color/little_title"
                android:textSize="@dimen/text_size_12" />
        </LinearLayout>

    </FrameLayout>
</layout>

2 支持动画

 

followAdapter.isFirstOnly(false);
//慢慢淡进
//adapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
//慢慢放大进入
//adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
//从下滑入
// followAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
//从左滑入
followAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
//从有滑入
//adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值