use of android.support.v7.widget.SnapHelper in project AndelaMedManager by jumaallan.
the class MainActivity method setListData.
public void setListData(final List<Medicine> medicineList) {
this.medicineList = medicineList;
if (medicineList.isEmpty()) {
emptyFrame.setVisibility(View.VISIBLE);
} else {
cardMedDaily.setVisibility(View.VISIBLE);
DailyMedicineStatisticsAdapter dailyMedicineStatisticsAdapter = new DailyMedicineStatisticsAdapter(this, medicineList, (v, position) -> {
Medicine medicine = medicineList.get(position);
Intent intent = new Intent(getApplicationContext(), MedicineActivity.class);
Bundle b = new Bundle();
b.putString("name", medicine.getName());
b.putString("description", medicine.getDescription());
b.putString("interval", medicine.getInterval());
b.putString("pills", medicine.getPills());
b.putString("pillsTaken", medicine.getPillsTaken());
b.putBoolean("true", medicine.isHasNotification());
b.putString("startDate", medicine.getStartDate());
b.putString("endDate", medicine.getEndDate());
b.putInt("days", medicine.getDays());
intent.putExtras(b);
startActivity(intent);
});
recyclerViewDailyMedicineStatistics.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
// add pager behavior
PagerSnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerViewDailyMedicineStatistics);
// pager indicator
recyclerViewDailyMedicineStatistics.addItemDecoration(new CirclePagerIndicatorDecoration());
recyclerViewDailyMedicineStatistics.setAdapter(dailyMedicineStatisticsAdapter);
DailyMedicineAdapter dailyMedicineAdapter = new DailyMedicineAdapter(this, medicineList, (v, position) -> {
Medicine medicine = medicineList.get(position);
Intent intent = new Intent(MainActivity.this.getApplicationContext(), MedicineActivity.class);
Bundle b = new Bundle();
b.putString("name", medicine.getName());
b.putString("description", medicine.getDescription());
b.putString("interval", medicine.getInterval());
b.putString("pills", medicine.getPills());
b.putString("pillsTaken", medicine.getPillsTaken());
b.putBoolean("true", medicine.isHasNotification());
b.putString("startDate", medicine.getStartDate());
b.putString("endDate", medicine.getEndDate());
b.putInt("days", medicine.getDays());
intent.putExtras(b);
MainActivity.this.startActivity(intent);
});
recyclerViewDailyMedicine.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recyclerViewDailyMedicine.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
recyclerViewDailyMedicine.setAdapter(dailyMedicineAdapter);
}
}
use of android.support.v7.widget.SnapHelper in project PLDroidPlayer by pili-engineering.
the class ShortVideoListFragment method initView.
private void initView(View root) {
mVideoList = root.findViewById(R.id.video_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
mVideoList.setLayoutManager(layoutManager);
mVideoList.setHasFixedSize(true);
PagerSnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(mVideoList);
mVideoView = new PLShortVideoTextureView(getContext());
mVideoView.setOnPreparedListener(new PLOnPreparedListener() {
@Override
public void onPrepared(int preparedTime) {
mVideoView.start();
}
});
mShortVideoListAdapter = new ShortVideoListAdapter(mItemList, mVideoView);
mVideoList.setAdapter(mShortVideoListAdapter);
mVideoList.addOnScrollListener(mOnScrollListener);
if (mShouldPlay) {
mVideoList.post(new Runnable() {
@Override
public void run() {
startCurVideoView();
mShouldPlay = false;
}
});
}
}
Aggregations