示例#1
0
文件: Cook.java 项目: jps/Restaurant
  public synchronized void run() {
    CookMessage("been started");
    while (getLoggedIn()) {

      Order order = WaitingOrders.poll();

      if (order == null) {
        // request a new order
        cookClient.outQueue.OutQueue.add("CookOrderRequest");
        try {
          cookClient.cookGUI.setCurrentlyCooking("Awaiting new order");
          wait();
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      } else {
        try {
          // update the gui
          cookClient.cookGUI.setCurrentlyCooking(order.getOrderNumber().toString());
          wait(GetRandomWaitTime());
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        order.setCookedAtNow();
        order.setOrderStatus(OrderStatus.cooked);
        cookClient.outQueue.OutQueue.add(order); // pass back to server
      }
    }
    // TODO: if they still have incomplete orders do something
  }
示例#2
0
  private void getOrders() {
    try {
      m_orders = new ArrayList<Order>();
      Order o1 = new Order();
      o1.setOrderName("Order Name");
      o1.setOrderStatus("Pending");
      Order o2 = new Order();
      o2.setOrderName("Oder Discription");
      o2.setOrderStatus("Completed");
      m_orders.add(o1);
      m_orders.add(o2);
      Thread.sleep(5000);
      Log.i("ARRAY", "" + m_orders.size());
      for (int i = 0; i < m_orders.size(); i++) {
        m_adapter.add(m_orders.get(i));
        m_adapter.notifyDataSetChanged();
      }

    } catch (Exception e) {
      Log.i("BACKGROUND_PROC", e.getMessage());
    }
    runOnUiThread(returnRes);
  }