コード例 #1
0
 private void updateBill() {
   Utilities.setAPIContext(manage_bill.this);
   JSONObject updateBill = getUpdateDetails();
   APIConnect.UpdateBillTask updateBillTask = new APIConnect.UpdateBillTask();
   updateBillTask.cruBill = this;
   updateBillTask.execute(updateBill);
 }
コード例 #2
0
 private void loadBills() {
   String paymentType = AppConfig.PAYABLE;
   Utilities.setAPIContext(getActivity());
   APIConnect.GetBillsTask getBillsTask = new APIConnect.GetBillsTask();
   getBillsTask.crdDelegate = this;
   getBillsTask.execute(paymentType);
 }
コード例 #3
0
  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();
  }
コード例 #4
0
  @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();
    }
  }
コード例 #5
0
        @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);
        }
コード例 #6
0
  @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();
    }
  }
コード例 #7
0
 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;
 }
コード例 #8
0
 private void restoreBill() {
   Utilities.setAPIContext(getActivity());
   APIConnect.AddBillTask addBillTask = new APIConnect.AddBillTask(deletedBill);
   addBillTask.crdDelegate = this;
   addBillTask.execute();
 }
コード例 #9
0
 private void deleteBill() {
   Utilities.setAPIContext(getActivity());
   APIConnect.DeleteBillTask deleteTask = new APIConnect.DeleteBillTask();
   deleteTask.crdDelegate = this;
   deleteTask.execute(billId);
 }
コード例 #10
0
 private void getSingleBill() {
   Utilities.setAPIContext(getActivity());
   APIConnect.GetSingleBill getSingleBill = new APIConnect.GetSingleBill();
   getSingleBill.crdDelegate = this;
   getSingleBill.execute(billId);
 }
コード例 #11
0
 private void checkForOverdueBills() {
   Utilities.setAPIContext(this);
   APIConnect.UpdatePayableToOverdue toOverdue = new APIConnect.UpdatePayableToOverdue();
   toOverdue.delegate = this;
   toOverdue.execute();
 }
コード例 #12
0
 public void prepareToModify() {
   Utilities.setAPIContext(this);
   APIConnect.GetSingleBill getSingleBill = new APIConnect.GetSingleBill();
   getSingleBill.cruDelegate = this;
   getSingleBill.execute(billId);
 }