use of com.jcodecraeer.xrecyclerview.XRecyclerView in project XRecyclerView by jianghejie.
the class AlphaChangeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alpha_change_layout);
mRecyclerView = (XRecyclerView) this.findViewById(R.id.recyclerview);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey);
/**
* ----- alpha change listen test start -----
*/
final RelativeLayout alpha_title = (RelativeLayout) findViewById(R.id.alpha_title);
findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
findViewById(R.id.back_to_top).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mRecyclerView.scrollToPosition(0);
}
});
mRecyclerView.setScrollAlphaChangeListener(new XRecyclerView.ScrollAlphaChangeListener() {
@Override
public void onAlphaChange(int alpha) {
alpha_title.getBackground().setAlpha(alpha);
}
@Override
public int setLimitHeight() {
return 1300;
}
});
/**
* ------ alpha change listen test end -----
*/
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
refreshTime++;
times = 0;
new Handler().postDelayed(new Runnable() {
public void run() {
listData.clear();
for (int i = 0; i < 15; i++) {
listData.add("item" + i + "after " + refreshTime + " times of refresh");
}
mAdapter.notifyDataSetChanged();
mRecyclerView.refreshComplete();
}
}, // refresh data here
1000);
}
@Override
public void onLoadMore() {
if (times < 2) {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 15; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.loadMoreComplete();
mAdapter.notifyDataSetChanged();
}
}, 1000);
} else {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 9; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.setNoMore(true);
mAdapter.notifyDataSetChanged();
}
}, 1000);
}
times++;
}
});
listData = new ArrayList<String>();
mAdapter = new MyAdapter(listData);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.refresh();
}
use of com.jcodecraeer.xrecyclerview.XRecyclerView in project XRecyclerView by jianghejie.
the class ItemDecorationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (XRecyclerView) this.findViewById(R.id.recyclerview);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
Drawable dividerDrawable = ContextCompat.getDrawable(this, R.drawable.divider_sample);
mRecyclerView.addItemDecoration(mRecyclerView.new DividerItemDecoration(dividerDrawable));
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey);
View header = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup) findViewById(android.R.id.content), false);
mRecyclerView.addHeaderView(header);
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
refreshTime++;
times = 0;
new Handler().postDelayed(new Runnable() {
public void run() {
listData.clear();
for (int i = 0; i < 15; i++) {
listData.add("item" + i + "after " + refreshTime + " times of refresh");
}
mAdapter.notifyDataSetChanged();
mRecyclerView.refreshComplete();
}
}, // refresh data here
1000);
}
@Override
public void onLoadMore() {
if (times < 2) {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 15; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.loadMoreComplete();
mAdapter.notifyDataSetChanged();
}
}, 1000);
} else {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 9; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.setNoMore(true);
mAdapter.notifyDataSetChanged();
}
}, 1000);
}
times++;
}
});
listData = new ArrayList<String>();
for (int i = 0; i < 15; i++) {
listData.add("item" + i);
}
mAdapter = new MyAdapter(listData);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.refresh();
}
use of com.jcodecraeer.xrecyclerview.XRecyclerView in project XRecyclerView by jianghejie.
the class LinearStickyScrollActivity method initXR.
private void initXR() {
mRecyclerView = (XRecyclerView) findViewById(R.id.XRecyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
// i suggest you do not open pull refresh in StickyScroll
// it maybe case some new problems
mRecyclerView.setPullRefreshEnabled(false);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
}
@Override
public void onLoadMore() {
if (times < 2) {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 10; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.loadMoreComplete();
mAdapter.notifyDataSetChanged();
}
}, 1000);
} else {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 10; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.setNoMore(true);
mAdapter.notifyDataSetChanged();
}
}, 1000);
}
times++;
}
});
listData = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
listData.add(" data -- " + i);
}
mAdapter = new MyAdapter(listData);
mAdapter.setClickCallBack(new MyAdapter.ItemClickCallBack() {
@Override
public void onItemClick(int pos) {
// a demo for notifyItemRemoved
listData.remove(pos);
mRecyclerView.notifyItemRemoved(listData, pos);
}
});
mRecyclerView.setAdapter(mAdapter);
}
use of com.jcodecraeer.xrecyclerview.XRecyclerView in project XRecyclerView by jianghejie.
the class StaggeredGridActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (XRecyclerView) this.findViewById(R.id.recyclerview);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey);
View header = LayoutInflater.from(this).inflate(R.layout.recyclerview_header, (ViewGroup) findViewById(android.R.id.content), false);
mRecyclerView.addHeaderView(header);
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
refreshTime++;
times = 0;
new Handler().postDelayed(new Runnable() {
public void run() {
listData.clear();
for (int i = 0; i < 25; i++) {
listData.add("item" + i + "after " + refreshTime + " times of refresh");
}
mAdapter.notifyDataSetChanged();
mRecyclerView.refreshComplete();
}
}, // refresh data here
1000);
}
@Override
public void onLoadMore() {
if (times < 2) {
new Handler().postDelayed(new Runnable() {
public void run() {
mRecyclerView.loadMoreComplete();
for (int i = 0; i < 25; i++) {
listData.add("item" + (i + listData.size()));
}
mRecyclerView.loadMoreComplete();
mAdapter.notifyDataSetChanged();
}
}, 1000);
} else {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 9; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.setNoMore(true);
mAdapter.notifyDataSetChanged();
}
}, 1000);
}
times++;
}
});
listData = new ArrayList<String>();
for (int i = 0; i < 25; i++) {
listData.add("item" + i);
}
mAdapter = new MyAdapter(listData);
mRecyclerView.setAdapter(mAdapter);
}
use of com.jcodecraeer.xrecyclerview.XRecyclerView in project XRecyclerView by jianghejie.
the class CollapsingToolbarLayoutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collapsing_toolbar_layout);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRecyclerView = (XRecyclerView) this.findViewById(R.id.recyclerview);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate);
mRecyclerView.setArrowImageView(R.drawable.iconfont_downgrey);
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
refreshTime++;
times = 0;
new Handler().postDelayed(new Runnable() {
public void run() {
listData.clear();
for (int i = 0; i < 15; i++) {
listData.add("item" + i + "after " + refreshTime + " times of refresh");
}
mAdapter.notifyDataSetChanged();
mRecyclerView.refreshComplete();
}
}, // refresh data here
1000);
}
@Override
public void onLoadMore() {
if (times < 2) {
new Handler().postDelayed(new Runnable() {
public void run() {
mRecyclerView.loadMoreComplete();
for (int i = 0; i < 15; i++) {
listData.add("item" + (i + listData.size()));
}
mRecyclerView.loadMoreComplete();
mAdapter.notifyDataSetChanged();
}
}, 1000);
} else {
new Handler().postDelayed(new Runnable() {
public void run() {
for (int i = 0; i < 9; i++) {
listData.add("item" + (1 + listData.size()));
}
mRecyclerView.setNoMore(true);
mAdapter.notifyDataSetChanged();
}
}, 1000);
}
times++;
}
});
listData = new ArrayList<String>();
for (int i = 0; i < 15; i++) {
listData.add("item" + i);
}
mAdapter = new MyAdapter(listData);
mRecyclerView.setAdapter(mAdapter);
}
Aggregations