use of com.androidstudy.medmanager.ui.adapter.DailyMedicineStatisticsAdapter in project Andela-Med-Manager by jumaallan.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
User user = new User(Long.valueOf("1"), "Data Binding", "User");
binding.setUser(user);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ButterKnife.bind(this);
profileDialog = ProfileDialog.newInstance(((dialog, which) -> logout()));
calendar = Calendar.getInstance();
simpleDateFormat = new SimpleDateFormat("EEEE, MMM d, yyyy");
String currentDate = simpleDateFormat.format(calendar.getTime());
date.setText(currentDate);
menuViewList = getMenuOptions();
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
ItemOffsetDecoration itemDecoration = new ItemOffsetDecoration(this, R.dimen.item_offset);
recyclerView.addItemDecoration(itemDecoration);
MainDashboardAdapter mainDashboardAdapter = new MainDashboardAdapter(this, menuViewList, (v, position) -> {
MenuView role = menuViewList.get(position);
String menuName = role.getName();
switch(menuName) {
case "Add Medicine":
Intent addMedicine = new Intent(getApplicationContext(), AddMedicineActivity.class);
startActivity(addMedicine);
break;
case "Profile":
break;
case "Reminders":
break;
case "Monthly Intake":
break;
default:
Toast.makeText(MainActivity.this, "Sorry, It's Under development", Toast.LENGTH_SHORT).show();
break;
}
});
recyclerView.setAdapter(mainDashboardAdapter);
DailyMedicineStatisticsAdapter dailyMedicineStatisticsAdapter = new DailyMedicineStatisticsAdapter(this, new ArrayList<>());
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);
// MedicineViewModel medicineViewModel = ViewModelProviders.of(this).get(MedicineViewModel.class);
// medicineViewModel.getMedicineList().observe(MainActivity.this, dailyMedicineStatisticsAdapter::addItems);
}
Aggregations