private void updateBill() { Utilities.setAPIContext(manage_bill.this); JSONObject updateBill = getUpdateDetails(); APIConnect.UpdateBillTask updateBillTask = new APIConnect.UpdateBillTask(); updateBillTask.cruBill = this; updateBillTask.execute(updateBill); }
private void loadBills() { String paymentType = AppConfig.PAYABLE; Utilities.setAPIContext(getActivity()); APIConnect.GetBillsTask getBillsTask = new APIConnect.GetBillsTask(); getBillsTask.crdDelegate = this; getBillsTask.execute(paymentType); }
private void addBill() { postDate = Utilities.setDayAsTwoNumbers(postDate); Bill[] billArray = { new Bill(paymentType, postTitle, postAmount, postDate, postNotes, categoryName) }; addBillTask = new APIConnect.AddBillTask(billArray); addBillTask.cruDelegate = this; addBillTask.execute(); }
@Override public void getBillTask(BillTaskResponse billTaskResponse) { HttpStatus code = billTaskResponse.code; if (StatusCode.isOk(code)) { Utilities.showRecycler(recyclerView, layoutNoContent); getBills = billTaskResponse.bills; adapter = new PayableAdapter(getActivity(), getBills); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); } else if (StatusCode.isUnauthorised(code)) { Utilities.setAPIContext(getActivity()); new APIConnect.UpdateTokenTask().execute(); loadBills(); } else if (StatusCode.isNoContent(code)) { Utilities.showNoContentLayout(recyclerView, layoutNoContent); } else if (StatusCode.isBadRequest(code)) { Toast.makeText(getActivity(), billTaskResponse.error, Toast.LENGTH_SHORT).show(); } }
@Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { int month = monthOfYear + 1; String date = "" + dayOfMonth + AppConfig.DATE_SEPARATOR + month + AppConfig.DATE_SEPARATOR + year; date = Utilities.setDayAsTwoNumbers(date); etDate.setText(date); dYear = year; dMonth = monthOfYear; dDay = dayOfMonth; spCategory.setFocusable(true); }
@Override public void deleteBillTask(BillTaskResponse deleteResponse) { HttpStatus code = deleteResponse.code; if (StatusCode.isOk(code)) { loadBills(); } else if (StatusCode.isUnauthorised(code)) { Utilities.setAPIContext(getActivity()); new APIConnect.UpdateTokenTask().execute(); deleteBill(); } else if (StatusCode.isBadRequest(code)) { Toast.makeText(getActivity(), deleteResponse.error, Toast.LENGTH_SHORT).show(); } else if (StatusCode.isForbidden(code)) { Toast.makeText(getActivity(), AppConfig.FORBIDDEN, Toast.LENGTH_SHORT).show(); } }
private JSONObject getUpdateDetails() { JSONObject updateDetails = new JSONObject(); postDate = Utilities.setDayAsTwoNumbers(postDate); try { updateDetails.put(AppConfig.PAYMENT_TYPE, paymentType); updateDetails.put(AppConfig.TITLE, postTitle); updateDetails.put(AppConfig.AMOUNT, postAmount); updateDetails.put(AppConfig.DATE, postDate); updateDetails.put(AppConfig.CATEGORY, categoryName); updateDetails.put(AppConfig.NOTES, postNotes); updateDetails.put(AppConfig.BILL_ID, billId); } catch (Exception e) { e.printStackTrace(); } return updateDetails; }
private void restoreBill() { Utilities.setAPIContext(getActivity()); APIConnect.AddBillTask addBillTask = new APIConnect.AddBillTask(deletedBill); addBillTask.crdDelegate = this; addBillTask.execute(); }
private void deleteBill() { Utilities.setAPIContext(getActivity()); APIConnect.DeleteBillTask deleteTask = new APIConnect.DeleteBillTask(); deleteTask.crdDelegate = this; deleteTask.execute(billId); }
private void getSingleBill() { Utilities.setAPIContext(getActivity()); APIConnect.GetSingleBill getSingleBill = new APIConnect.GetSingleBill(); getSingleBill.crdDelegate = this; getSingleBill.execute(billId); }
private void checkForOverdueBills() { Utilities.setAPIContext(this); APIConnect.UpdatePayableToOverdue toOverdue = new APIConnect.UpdatePayableToOverdue(); toOverdue.delegate = this; toOverdue.execute(); }
public void prepareToModify() { Utilities.setAPIContext(this); APIConnect.GetSingleBill getSingleBill = new APIConnect.GetSingleBill(); getSingleBill.cruDelegate = this; getSingleBill.execute(billId); }