Ejemplo n.º 1
0
 @GET
 @Path("/testapixml")
 @Produces(MediaType.APPLICATION_XML)
 public List<Shift> getShiftListXML() {
   Shift a = new Shift("Monday", "1AM", "2AM", "PSIB", "Akhil", "Taken", "No Notes");
   a.setId((long) 1001);
   Shift b = new Shift("Monday", "2AM", "3AM", "Library", "Firoze", "Taken", "No Notes");
   b.setId((long) 1002);
   Shift c = new Shift("Monday", "3AM", "4AM", "Bossone", "Varoon", "Taken", "No Notes");
   c.setId((long) 1003);
   Shift d = new Shift("Monday", "4AM", "5AM", "CLC", "Donny", "Taken", "No Notes");
   d.setId((long) 1004);
   List<Shift> shifts = new ArrayList<Shift>();
   shifts.add(a);
   shifts.add(b);
   shifts.add(c);
   shifts.add(d);
   return shifts;
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        // Revert to HomeFragment.
        FragmentCheck.changeFragment(
            getActivity().getSupportFragmentManager(),
            new HomeFragment(),
            FragmentCheck.HOME_FRAGMENT_CALENDAR);
        return true;
      case R.id.accept_button:
        // Set new shifts values and calculate.
        mShift.finalizeShift(
            cashTips,
            creditTips,
            tipOut,
            totalSales,
            mDate,
            (double) mHoursWorkedNumberPicker.getCurrentValue(),
            (double) mMinutesWorkedNumberPicker.getCurrentValue());

        // Add the new shift to the shift register.
        ShiftRegister.get(getActivity()).addShift(mShift);

        // Save the shift to database.
        DatabaseHandler db = new DatabaseHandler(getActivity());
        long shiftId = db.addShift(mShift);
        mShift.setId(shiftId);

        // Revert to the home fragment.
        FragmentCheck.changeFragment(
            getActivity().getSupportFragmentManager(),
            new HomeFragment(),
            FragmentCheck.HOME_FRAGMENT_CALENDAR);
        return true;
      case R.id.cancel_button:
        // Revert to HomeFragment.
        FragmentCheck.changeFragment(
            getActivity().getSupportFragmentManager(),
            new HomeFragment(),
            FragmentCheck.HOME_FRAGMENT_CALENDAR);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }