Search in sources :

Example 1 with CirclePagerIndicatorDecoration

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);
    }
}
Also used : Medicine(com.androidstudy.andelamedmanager.data.model.Medicine) DailyMedicineAdapter(com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineAdapter) Bundle(android.os.Bundle) DailyMedicineStatisticsAdapter(com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineStatisticsAdapter) PagerSnapHelper(android.support.v7.widget.PagerSnapHelper) Intent(android.content.Intent) CirclePagerIndicatorDecoration(com.androidstudy.andelamedmanager.util.CirclePagerIndicatorDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Example 2 with CirclePagerIndicatorDecoration

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);
    }
}
Also used : Medicine(com.androidstudy.andelamedmanager.data.model.Medicine) DailyMedicineAdapter(com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineAdapter) Bundle(android.os.Bundle) DailyMedicineStatisticsAdapter(com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineStatisticsAdapter) PagerSnapHelper(android.support.v7.widget.PagerSnapHelper) Intent(android.content.Intent) CirclePagerIndicatorDecoration(com.androidstudy.andelamedmanager.util.CirclePagerIndicatorDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Aggregations

Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 PagerSnapHelper (android.support.v7.widget.PagerSnapHelper)2 Medicine (com.androidstudy.andelamedmanager.data.model.Medicine)2 DailyMedicineAdapter (com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineAdapter)2 DailyMedicineStatisticsAdapter (com.androidstudy.andelamedmanager.ui.medicine.adapter.DailyMedicineStatisticsAdapter)2 CirclePagerIndicatorDecoration (com.androidstudy.andelamedmanager.util.CirclePagerIndicatorDecoration)2