use of com.androidstudy.andelamedmanager.util.CirclePagerIndicatorDecoration in project Andela-Med-Manager 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", String.valueOf(medicine.getStartDate()));
b.putString("endDate", String.valueOf(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", String.valueOf(medicine.getStartDate()));
b.putString("endDate", String.valueOf(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 com.androidstudy.andelamedmanager.util.CirclePagerIndicatorDecoration 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", String.valueOf(medicine.getStartDate()));
b.putString("endDate", String.valueOf(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", String.valueOf(medicine.getStartDate()));
b.putString("endDate", String.valueOf(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);
}
}
Aggregations