Ejemplo n.º 1
0
 public static String getPrettyDate(Date date) {
   if (isToday(date)) {
     return MyPlateApplication.getContext().getString(R.string.today);
   } else if (isYesterday(date)) {
     return MyPlateApplication.getContext().getString(R.string.yesterday);
   } else {
     return dateFormatter.format(date);
   }
 }
Ejemplo n.º 2
0
 private void refreshDateLabel() {
   if (dateTextView == null) {
     return;
   }
   if (MyPlateApplication.isToday(this.selectedDate)) {
     this.dateTextView.setText(R.string.today);
   } else if (MyPlateApplication.isYesterday(this.selectedDate)) {
     this.dateTextView.setText(R.string.yesterday);
   } else {
     this.dateTextView.setText(dateFormatter.format(this.selectedDate));
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    // Diary entry item selected
    DiaryEntry clickedEntry = (DiaryEntry) this.adapter.getItem(position);

    MyPlateApplication.setWorkingDateStamp(this.selectedDate);
    int section = this.adapter.getSectionForPosition(position);
    switch (section) {
      case 0:
        MyPlateApplication.setWorkingTimeOfDay(TimeOfDay.BREAKFAST);
        break;
      case 1:
        MyPlateApplication.setWorkingTimeOfDay(TimeOfDay.LUNCH);
        break;
      case 2:
        MyPlateApplication.setWorkingTimeOfDay(TimeOfDay.DINNER);
        break;
      case 3:
        MyPlateApplication.setWorkingTimeOfDay(TimeOfDay.SNACKS);
        break;
    }

    if (clickedEntry instanceof FoodDiaryEntry) {
      FoodDiaryEntry diaryEntry = (FoodDiaryEntry) clickedEntry;
      Intent intent = new Intent(MyPlateApplication.getContext(), AddFoodActivity.class);
      intent.putExtra(FoodDiaryEntry.class.getName(), diaryEntry);
      startActivity(intent);
    } else if (clickedEntry instanceof ExerciseDiaryEntry) {
      ExerciseDiaryEntry diaryEntry = (ExerciseDiaryEntry) clickedEntry;
      Intent intent = new Intent(MyPlateApplication.getContext(), AddExerciseActivity.class);
      intent.putExtra(ExerciseDiaryEntry.class.getName(), diaryEntry);
      startActivity(intent);
    } else if (clickedEntry instanceof WaterDiaryEntry) {
      WaterDiaryEntry diaryEntry = (WaterDiaryEntry) clickedEntry;
      Intent intent = new Intent(MyPlateApplication.getContext(), AddWaterActivity.class);
      intent.putExtra(WaterDiaryEntry.class.getName(), diaryEntry);
      startActivity(intent);
    } else if (clickedEntry instanceof WeightDiaryEntry) {
      WeightDiaryEntry diaryEntry = (WeightDiaryEntry) clickedEntry;
      Intent intent = new Intent(MyPlateApplication.getContext(), AddWeightActivity.class);
      intent.putExtra(WeightDiaryEntry.class.getName(), diaryEntry);
      startActivity(intent);
    }
  }
Ejemplo n.º 4
0
 public static String getPrettyWorkingDate() {
   return MyPlateApplication.getPrettyDate(MyPlateApplication.getWorkingDateStamp());
 }