use of la.xiong.androidquick.ui.adapter.CommonViewHolder in project AndroidQuick by ddnosh.
the class Network2Fragment method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
DialogUtil.showLoadingDialog(mContext, "加载中...");
mTestBeanList = new ArrayList<>();
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.setHasFixedSize(true);
mCommonAdapter = new CommonAdapter<TestBean>(getActivity(), R.layout.item_common_adapter_2, mTestBeanList) {
@Override
public void convert(CommonViewHolder holder, final TestBean bean) {
holder.setText(R.id.tv_login, bean.getLogin());
holder.setText(R.id.tv_id, bean.getId() + "");
holder.setImageResourceWithGlide(R.id.iv_avatar, bean.getAvatar_url());
holder.setOnClickListener(R.id.ll_rv_common_adapter_item, new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtil.d(TAG, "onItemClick");
ToastUtil.showToast(bean.getLogin() + " clicked!");
bean.setLogin(bean.getLogin() + " clicked!");
notifyDataSetChanged();
}
});
}
};
mRecyclerView.setAdapter(mCommonAdapter);
mCompositeSubscription = new CompositeSubscription();
mRetrofitManager = new RetrofitManager();
Subscription subscription = mRetrofitManager.createApi(MyApplication.getInstance().getApplicationContext(), TestApis.class).getOctocat("https://api.github.com/repos/octocat/Hello-World/contributors").subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new BaseSubscriber<List<TestBean>>() {
@Override
public void onNext(List<TestBean> list) {
DialogUtil.dismissLoadingDialog(mContext);
LogUtil.i(TAG, list.toString());
// 不能这样赋值:mTestBeanList = list;
// 方法一
// mTestBeanList.clear();
// mTestBeanList.addAll(list);
// mCommonAdapter.notifyDataSetChanged();
// 方法二
mCommonAdapter.update(list);
}
@Override
public void onError(Throwable e) {
super.onError(e);
DialogUtil.dismissLoadingDialog(mContext);
}
});
mCompositeSubscription.add(subscription);
}
use of la.xiong.androidquick.ui.adapter.CommonViewHolder in project AndroidQuick by ddnosh.
the class GreenDaoFragment method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
mUserList = new ArrayList<User>();
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.setHasFixedSize(true);
mCommonAdapter = new CommonAdapter<User>(getActivity(), R.layout.item_common_adapter_1, mUserList) {
@Override
public void convert(CommonViewHolder holder, final User user) {
holder.setText(R.id.tv_name, user.getName());
}
};
mRecyclerView.setAdapter(mCommonAdapter);
}
use of la.xiong.androidquick.ui.adapter.CommonViewHolder in project AndroidQuick by ddnosh.
the class CommonAdapterFragment method initViewsAndEvents.
@Override
protected void initViewsAndEvents() {
mABeanList = new ArrayList<ABean>();
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.setHasFixedSize(true);
mCommonAdapter = new CommonAdapter<ABean>(getActivity(), R.layout.item_common_adapter_1, mABeanList) {
@Override
public void convert(CommonViewHolder holder, final ABean bean) {
holder.setText(R.id.tv_name, bean.getName());
holder.setText(R.id.tv_age, bean.getAge() + "");
holder.setOnClickListener(R.id.ll_rv_common_adapter_item, new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtil.d(TAG, "onItemClick");
ToastUtil.showToast(bean.getName() + " clicked!");
notifyDataSetChanged();
}
});
}
};
mRecyclerView.setAdapter(mCommonAdapter);
new Handler().postDelayed(new Runnable() {
public void run() {
mABeanList.add(new ABean("tom", 18));
mABeanList.add(new ABean("jerry", 20));
mCommonAdapter.notifyDataSetChanged();
}
}, 1000);
}
Aggregations