Search in sources :

Example 1 with CirclePagerIndicatorDecoration

use of com.androidstudy.medmanager.util.CirclePagerIndicatorDecoration 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);
}
Also used : User(com.androidstudy.medmanager.data.model.User) DailyMedicineStatisticsAdapter(com.androidstudy.medmanager.ui.adapter.DailyMedicineStatisticsAdapter) Intent(android.content.Intent) ItemOffsetDecoration(com.androidstudy.medmanager.util.ItemOffsetDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GridLayoutManager(android.support.v7.widget.GridLayoutManager) MainDashboardAdapter(com.androidstudy.medmanager.ui.adapter.MainDashboardAdapter) PagerSnapHelper(android.support.v7.widget.PagerSnapHelper) MenuView(com.androidstudy.medmanager.data.model.MenuView) CirclePagerIndicatorDecoration(com.androidstudy.medmanager.util.CirclePagerIndicatorDecoration) ActivityMainBinding(com.androidstudy.medmanager.databinding.ActivityMainBinding) SimpleDateFormat(java.text.SimpleDateFormat) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Intent (android.content.Intent)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 PagerSnapHelper (android.support.v7.widget.PagerSnapHelper)1 Toolbar (android.support.v7.widget.Toolbar)1 MenuView (com.androidstudy.medmanager.data.model.MenuView)1 User (com.androidstudy.medmanager.data.model.User)1 ActivityMainBinding (com.androidstudy.medmanager.databinding.ActivityMainBinding)1 DailyMedicineStatisticsAdapter (com.androidstudy.medmanager.ui.adapter.DailyMedicineStatisticsAdapter)1 MainDashboardAdapter (com.androidstudy.medmanager.ui.adapter.MainDashboardAdapter)1 CirclePagerIndicatorDecoration (com.androidstudy.medmanager.util.CirclePagerIndicatorDecoration)1 ItemOffsetDecoration (com.androidstudy.medmanager.util.ItemOffsetDecoration)1 SimpleDateFormat (java.text.SimpleDateFormat)1