@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    String itemName = null;
    if (extras != null && extras.containsKey(EXTRA_MENUITEM_NAME)) {
      itemName = extras.getString(EXTRA_MENUITEM_NAME);
    } else if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_MENUITEM_NAME)) {
      itemName = extras.getString(EXTRA_MENUITEM_NAME);
    }

    // Ugly way to find the item
    DineOnUser dou = DineOnUserApplication.getDineOnUser();
    DiningSession session = dou.getDiningSession();
    if (session != null) {
      for (Menu menu : session.getRestaurantInfo().getMenuList()) {
        for (MenuItem item : menu.getItems()) {
          if (item.getTitle().equals(itemName)) {
            mItem = item;
          }
        }
      }
    }

    if (mItem == null) {
      Log.e(TAG, "Unable to load menu item to show details");
      return;
    }

    setContentView(R.layout.activity_menuitem_detail);
  }
Exemple #2
0
 /**
  * Returns a fake Dining Session.
  *
  * @param user UserInfo to create session for
  * @param restInfo RestaurantInfo to create session at
  * @return a fake DiningSession
  * @throws ParseException if infos are null
  */
 public static DiningSession createFakeDiningSession(UserInfo user, RestaurantInfo restInfo)
     throws ParseException {
   DiningSession ds = new DiningSession(1, new GregorianCalendar().getTime(), user, restInfo);
   ds.setObjId("session");
   return ds;
 }