use of com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter in project EasyRecyclerView by Jude95.
the class StickyHeaderActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loadmore);
top = (FloatingActionButton) findViewById(R.id.top);
recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
itemDecoration.setDrawLastItem(false);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setAdapterWithProgress(adapter = new RecyclerArrayAdapter<Person>(this) {
@Override
public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
return new PersonViewHolder(parent);
}
});
adapter.setMore(R.layout.view_more, this);
adapter.setNoMore(R.layout.view_nomore, new RecyclerArrayAdapter.OnNoMoreListener() {
@Override
public void onNoMoreShow() {
adapter.resumeMore();
}
@Override
public void onNoMoreClick() {
adapter.resumeMore();
}
});
adapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(int position) {
adapter.remove(position);
return true;
}
});
adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {
@Override
public void onErrorShow() {
adapter.resumeMore();
}
@Override
public void onErrorClick() {
adapter.resumeMore();
}
});
// StickyHeader
StickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));
decoration.setIncludeHeader(false);
recyclerView.addItemDecoration(decoration);
top.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
recyclerView.scrollToPosition(0);
}
});
recyclerView.setRefreshListener(this);
onRefresh();
}
use of com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter in project EasyRecyclerView by Jude95.
the class RefreshAndMoreActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loadmore);
top = (FloatingActionButton) findViewById(R.id.top);
recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 16f), Util.dip2px(this, 72), 0);
itemDecoration.setDrawLastItem(false);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setAdapterWithProgress(adapter = new RecyclerArrayAdapter<Person>(this) {
@Override
public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
return new PersonViewHolder(parent);
}
});
adapter.setMore(R.layout.view_more, this);
adapter.setNoMore(R.layout.view_nomore);
adapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(int position) {
adapter.remove(position);
return true;
}
});
adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {
@Override
public void onErrorShow() {
adapter.resumeMore();
}
@Override
public void onErrorClick() {
adapter.resumeMore();
}
});
top.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
recyclerView.scrollToPosition(0);
}
});
recyclerView.setRefreshListener(this);
onRefresh();
}
Aggregations