Beispiel #1
0
 public static String formatTimesForAdapter(MedicineObject medicineObject) {
   ArrayList<Calendar> timeObjects =
       MedicineHelper.formatTimesForObject(MedicineHelper.formatTimesForDatabase(medicineObject));
   StringBuilder stringBuilder = new StringBuilder();
   for (Calendar timeObject : timeObjects) {
     DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
     stringBuilder.append(String.format("%s ", dateFormat.format(timeObject.getTime())));
   }
   return stringBuilder.toString().trim();
 }
 public void populateMedicineList() {
   if (extras != null) {
     Date date = (Date) extras.get("date");
     DateFormat dateFormat = DateFormat.getDateInstance();
     setTitle(String.format("Medicine on %s", dateFormat.format(date)));
     populateListView(
         MedicineHelper.getAllMedicineFromDateObjects(
             getBaseContext(), DateHelper.getDatesFromDateOnly(getBaseContext(), date)));
   } else {
     populateListView(MedicineHelper.getAllMedicines(getBaseContext()));
   }
 }
Beispiel #3
0
 public static ArrayList<MedicineObject> getAllMedicineFromDateObjects(
     Context context, ArrayList<DateObject> dateObjects) {
   ArrayList<MedicineObject> medicineObjects = new ArrayList<>();
   ArrayList<Integer> medicineIds = new ArrayList<>();
   for (DateObject dateObject : dateObjects) {
     MedicineObject medicineObject =
         MedicineHelper.getMedicine(context, dateObject.getMedicineId());
     if (!medicineIds.contains(medicineObject.getId())) {
       medicineObjects.add(medicineObject);
       medicineIds.add(medicineObject.getId());
     }
   }
   return medicineObjects;
 }