0
我想檢查通過改造在我的排隊調用中發送的原始json。這裏不用我的單擊事件的代碼:檢查通過改造發送的json
public void onClick(View v) {
ArrayList<Product> products = ((MenuAdapter)rvMenuProducts.getAdapter()).getOrderItens();
ArrayList<Item> orderItemList = new ArrayList<Item>();
for(Product p: products){
orderItemList.add(new Item(p));
}
EditText etCardNumber = (EditText) findViewById(R.id.et_card_number);
String cardNumber = etCardNumber.getText().toString();
if(GenericUtils.stringIsNotNullAndNotEmpty(cardNumber)){
NewOrder newOrder = new NewOrder(waiterId, establishmentId, cardNumber, orderItemList);
WaiterRequester.addOrder(newOrder, new Callback<AddOrderResultInfo>() {
@Override
public void onResponse(Call<AddOrderResultInfo> call, Response<AddOrderResultInfo> response) {
int a = 5;
Toast.makeText(context, "Pedido realizado com sucesso", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<AddOrderResultInfo> call, Throwable t) {
int b = 5;
Toast.makeText(context, "VISH", Toast.LENGTH_SHORT).show();
}
});
}
else{
etCardNumber.setError("ERROOOOOOO");
}
}
就是這樣,但是我怎麼稱呼我的API,我讓我的API一些例外,那我不知道,因爲我的回報是一個布爾值,當我使用郵遞員發送請求時,它可以工作!
這裏是郵遞員送來的JSON:
{
"newOrder":
{
"idWaiter" : 1,
"idEstablishment": 6,
"cardNumber": "123",
"listItem": [{ "idProduct": 1, "quantity": 1 }]
}
}
那裏是我班NewOrder:
public class NewOrder {
public int idWaiter;
public long idEstablishment;
public String cardNumber;
public ArrayList<Item> listItem;
public NewOrder() {
}
public NewOrder(int idWaiter, long idEstablishment, String cardNumber, ArrayList<Item> listItem) {
this.idWaiter = idWaiter;
this.idEstablishment = idEstablishment;
this.cardNumber = cardNumber;
this.listItem = listItem;
}
public int getIdWaiter() {
return idWaiter;
}
public void setIdWaiter(int idWaiter) {
this.idWaiter = idWaiter;
}
public long getIdEstablishment() {
return idEstablishment;
}
public void setIdEstablishment(long idEstablishment) {
this.idEstablishment = idEstablishment;
}
public String getCardNumber() {
return cardNumber;
}
public void setCardNumber(String cardNumber) {
this.cardNumber = cardNumber;
}
public ArrayList<Item> getListItem() {
return listItem;
}
public void setListItem(ArrayList<Item> listItem) {
this.listItem = listItem;
}
}
和項目:
public class Item {
public long idProduct;
public int quantity;
public Item() {
}
public Item(Product p) {
this.setQuantity(p.getQuantity());
this.setIdProduct(p.getIdProduct());
}
public Item(int idProduct, int quantity) {
this.idProduct = idProduct;
this.quantity = quantity;
}
public long getIdProduct() {
return idProduct;
}
public void setIdProduct(long idProduct) {
this.idProduct = idProduct;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
編輯:
它可能是有用的,By Object是arr iving作爲後端空值。
如何exaclty可以打印這些日誌? – guisantogui
如果您使用上述代碼,日誌會自動打印在您的logcat中 – 2016-04-14 14:26:56
未打印此處:/ – guisantogui