use of com.forcelain.android.awesomerecyclerview.data.FakeDataProvider in project AwesomeRecyclerView by forceLain.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
layoutManager = new AwesomeLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
ArticleAdapter adapter = new ArticleAdapter();
recyclerView.setAdapter(adapter);
dataProvider = new FakeDataProvider(this);
List<Article> articles = dataProvider.getArticles();
adapter.setArticles(articles);
recyclerView.setChildDrawingOrderCallback(new RecyclerView.ChildDrawingOrderCallback() {
@Override
public int onGetChildDrawingOrder(int childCount, int i) {
return childCount - i - 1;
}
});
adapter.setItemClickListener(new ArticleAdapter.OnItemClickListener() {
@Override
public void onItemClicked(int pos) {
layoutManager.openItem(pos);
}
});
findViewById(R.id.test_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
recyclerView.smoothScrollToPosition(4);
}
});
}
Aggregations