Beispiel #1
0
  private void SetAction(LinearLayout view, final Order order) {

    Button btnAction = (Button) view.findViewById(R.id.btnAction);

    // 根据不同的订单页面动作按钮显示不同的文字信息:
    switch (order.status) {
      case OrderActivity.ORDER_TYPE_NEW: // 接受订单:
        btnAction.setText(orderActivity.getString(R.string.btn_action_new));
        break;
      case OrderActivity.ORDER_TYPE_ACCEPT: // 开始配送:
        btnAction.setText(orderActivity.getString(R.string.btn_action_accept));
        break;
      case OrderActivity.ORDER_TYPE_EXPRESS: // 配送完成:
        btnAction.setText(orderActivity.getString(R.string.btn_action_express));
        break;
      default:
    }

    // 开始/完成配送的按键事件:
    btnAction.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            orderActivity.updateOrder(order.orderID, order.status + 1);
          }
        });
  }
Beispiel #2
0
  private void SetPayment(LinearLayout view, Order order) {

    TextView txtPayment = (TextView) view.findViewById(R.id.txtPayment);
    // 订单金额信息:
    String strPayment = String.valueOf(order.payment) + orderActivity.getString(R.string.pay_unit);
    // 在线支付类文字颜色:
    if (order.payType == Order.PAY_TYPE_ONLINE) {
      strPayment += orderActivity.getString(R.string.pay_type_online);
      txtPayment.setTextColor(orderActivity.getResources().getColor(R.color.pay_type_online));
    }
    // 货到付款类文字颜色:
    else if (order.payType == Order.PAY_TYPE_OFFLINE) {
      strPayment += orderActivity.getString(R.string.pay_type_offline);
      txtPayment.setTextColor(orderActivity.getResources().getColor(R.color.pay_type_offline));
    }
    txtPayment.setText(strPayment);
  }
Beispiel #3
0
  public final void handleMessage(Message message) {
    if (OrderActivity.a(a) != null) OrderActivity.a(a).dismiss();
    switch (message.what) {
      case 2: // '\002'
        Toast.makeText(a, "没有获取到信息", 1).show();
        break;

      case 21: // '\025'
        Toast.makeText(a, "请进入订单管理,检查订单是否生成", 1).show();
        break;

      case 101: // 'e'
        Toast.makeText(a, "登录成功", 1).show();
        break;

      case 102: // 'f'
        OrderActivity.b(a);
        break;
    }
  }
Beispiel #4
0
  private void SetExpressTime(LinearLayout view, Order order) {

    TextView txtExpressTimeTitle = (TextView) view.findViewById(R.id.txtExpressTimeTitle);
    TextView txtExpressTime = (TextView) view.findViewById(R.id.txtExpressTime);

    int nColor = 0;

    // 对配送时间进行检查(未结算页面无须检查):
    if (order.status != OrderActivity.ORDER_TYPE_BALANCE) {

      Date now = new Date();
      long oneHour = 60 * 60 * 1000;
      long oneDay = oneHour * 24;
      long timeSpan = order.expressTime.getTime() + oneHour - now.getTime();

      // 超时:
      if (timeSpan < 0)
        nColor = orderActivity.getResources().getColor(R.color.express_overtime_background);
      else {
        long days = timeSpan / oneDay;
        long hours = (timeSpan - days * oneDay) / oneHour;
        // 在一小时内:
        if (days == 0 && hours == 0)
          nColor = orderActivity.getResources().getColor(R.color.express_intime_background);

        // 还没到时间:
        else nColor = orderActivity.getResources().getColor(R.color.express_normal_background);
      }
    } else {
      nColor = orderActivity.getResources().getColor(R.color.title_balance);
    }

    // 设置时间框背景颜色:
    txtExpressTimeTitle.setBackgroundColor(nColor);
    txtExpressTime.setBackgroundColor(nColor);

    // 为控件设定显示内容:
    txtExpressTime.setText(order.timeString);
  }
Beispiel #5
0
  private void SetSelected(int position, LinearLayout view, Order order) {

    LinearLayout orderExtendLayout = (LinearLayout) view.findViewById(R.id.orderExtendLayout);
    LinearLayout orderCommandLayout = (LinearLayout) view.findViewById(R.id.orderCommandLayout);
    LinearLayout orderDetailLayout = (LinearLayout) view.findViewById(R.id.orderDetailLayout);

    // 选中项展示详情和命令列表:
    if (position == orderActivity.mCurrentPostion
        && orderExtendLayout.getVisibility() == View.GONE) {

      // 显示扩展信息区:
      orderExtendLayout.setVisibility(View.VISIBLE);

      // 清除原有控件:
      orderDetailLayout.removeAllViews();

      // 设定订单详情文本框格式:
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      lp.leftMargin = 50;

      // 逐条加载详情信息:
      OrderItem item;
      for (int i = 0; i < order.items.size(); i++) {

        item = order.items.get(i);

        TextView detailText = new TextView(orderActivity);
        detailText.setTextColor(orderActivity.getResources().getColor(R.color.detail_content));
        detailText.setText(
            orderActivity.getString(R.string.content_detail_header)
                + item.itemName
                + " ( "
                + item.itemCount
                + " ) :  "
                + item.itemAmount
                + orderActivity.getString(R.string.pay_unit));

        orderDetailLayout.addView(detailText, lp);
      }

      // 添加配送信息文本框:
      TextView expressText = new TextView(orderActivity);
      expressText.setText(
          orderActivity.getString(R.string.content_detail_header)
              + orderActivity.getString(R.string.content_express_price)
              + " : "
              + order.expressPrice
              + orderActivity.getString(R.string.pay_unit));
      expressText.setTextColor(orderActivity.getResources().getColor(R.color.detail_content));
      orderDetailLayout.addView(expressText, lp);

      // 结算页不显示操作命令列表:
      if (order.status == OrderActivity.ORDER_TYPE_BALANCE)
        orderCommandLayout.setVisibility(view.GONE);
      else orderCommandLayout.setVisibility(view.VISIBLE);

    } else {
      // 自动隐藏之前选择项扩展信息区:
      if (orderExtendLayout.getVisibility() == View.VISIBLE)
        orderExtendLayout.setVisibility(View.GONE);
    }
  }