コード例 #1
0
  /**
   * ###################################################################################
   * ************************************ On Click **************************************
   * ###################################################################################
   */
  public void onClick(View v) {
    Bundle extra = getIntent().getExtras();

    switch (v.getId()) {
      case R.id.btn_customer_tracking_details_order_received:
        cart.setInvoice_ID(extra.getInt("Invoice_ID"));

        Call<Cart> reg = apiService.customerReceivedOrder(cart);

        reg.enqueue(
            new Callback<Cart>() {
              @Override
              public void onResponse(Response<Cart> response, Retrofit retrofit) {
                if (response.message().equalsIgnoreCase("ok")) {
                  Toast.makeText(
                          getBaseContext(), "Your Order is Delivered To You", Toast.LENGTH_LONG)
                      .show();
                  finish();
                }
              }

              @Override
              public void onFailure(Throwable t) {

                Toast.makeText(
                        getBaseContext(),
                        " Oops! An error occurred  + The Throwable is " + t.getMessage().toString(),
                        Toast.LENGTH_LONG)
                    .show();
              }
            });
        break;
    }
  }
コード例 #2
0
  protected void onResume() {
    super.onResume();
    mImageView_customer_tracking_details =
        (ImageView) findViewById(R.id.imageView_customer_tracking_details);

    Bundle extra = getIntent().getExtras();
    cart.setInvoice_ID(extra.getInt("Invoice_ID"));

    Call<Cart> reg = apiService.getInvoiceStatus(cart);

    reg.enqueue(
        new Callback<Cart>() {
          @Override
          public void onResponse(Response<Cart> response, Retrofit retrofit) {
            if (response.message().equalsIgnoreCase("ok")) {

              cart.setStatus(response.body().getStatus());

              // Text showing the current status
              mText_customer_tracking_details_current_status =
                  (TextView) findViewById(R.id.text_customer_tracking_details_current_status);

              switch (cart.getStatus().toString()) {
                case "Confirmed":
                  mImageView_customer_tracking_details.setImageResource(R.drawable.ic_traker_1);
                  mText_customer_tracking_details_current_status.setText("مؤكد");
                  break;

                case "Accepted":
                  mImageView_customer_tracking_details.setImageResource(R.drawable.ic_traker_2);
                  mText_customer_tracking_details_current_status.setText("مقبول");
                  break;

                case "ReadyForDelivery":
                  mImageView_customer_tracking_details.setImageResource(R.drawable.ic_traker_3);
                  mText_customer_tracking_details_current_status.setText("جاهز لتوصيل");
                  break;

                case "Delivering":
                  mImageView_customer_tracking_details.setImageResource(R.drawable.ic_traker_4);
                  mText_customer_tracking_details_current_status.setText("جاري التوصيل");

                  mBtn_customer_tracking_details_order_received =
                      (Button) findViewById(R.id.btn_customer_tracking_details_order_received);
                  mBtn_customer_tracking_details_order_received.setVisibility(View.VISIBLE);
                  mBtn_customer_tracking_details_order_received.setClickable(true);

                  break;

                case "Delivered":
                  mImageView_customer_tracking_details.setImageResource(R.drawable.ic_traker_5);
                  mText_customer_tracking_details_current_status.setText("تم التوصيل");

                  break;
              }
            }
          }

          @Override
          public void onFailure(Throwable t) {
            Toast.makeText(
                    getBaseContext(),
                    " Oops! An error occurred  + The Throwble is " + t.getMessage().toString(),
                    Toast.LENGTH_LONG)
                .show();
          }
        });
  }