use of net.iGap.model.bill.MobileDebit in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListVM method getPhoneDebit.
private void getPhoneDebit(BillList.Bill dataModel) {
BillInfo info = new BillInfo();
info.setBillTypeString(dataModel.getBillType());
info.setPhoneNum(dataModel.getPhoneNumber());
if (dataModel.getBillType().equals("PHONE")) {
info.setAreaCode(dataModel.getAreaCode());
}
new BillsAPIRepository().phoneAndMobileInquiry(info, this, new ResponseCallback<ElectricityResponseModel<MobileDebit>>() {
@Override
public void onSuccess(ElectricityResponseModel<MobileDebit> data) {
Map<BillList.Bill, Debit> tmp = mMapData.getValue();
data.getData().setLoading(false);
tmp.put(dataModel, new Debit<>(data.getData()));
mMapData.setValue(tmp);
}
@Override
public void onError(String error) {
Map<BillList.Bill, Debit> tmp = mMapData.getValue();
Debit<MobileDebit> debitTmp = tmp.get(dataModel);
debitTmp.getData().setLoading(false);
debitTmp.getData().setFail(true);
debitTmp.getData().setLastTerm(new MobileDebit.MobileInquiryObject("0", "0", "0"));
debitTmp.getData().setMidTerm(new MobileDebit.MobileInquiryObject("0", "0", "0"));
tmp.put(dataModel, debitTmp);
mMapData.setValue(tmp);
}
@Override
public void onFailed() {
Map<BillList.Bill, Debit> tmp = mMapData.getValue();
Debit<MobileDebit> debitTmp = tmp.get(dataModel);
debitTmp.getData().setLoading(false);
debitTmp.getData().setFail(true);
debitTmp.getData().setLastTerm(new MobileDebit.MobileInquiryObject("0", "0", "0"));
debitTmp.getData().setMidTerm(new MobileDebit.MobileInquiryObject("0", "0", "0"));
tmp.put(dataModel, debitTmp);
mMapData.setValue(tmp);
}
});
}
use of net.iGap.model.bill.MobileDebit in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListFrag method initRecycler.
private void initRecycler(Map<BillList.Bill, Debit> bills) {
adapter = new ElectricityBillListAdapter(getContext(), bills, (item, btnAction) -> {
// ServiceDebit temp = viewModel.getmMapData().getValue().get(item);
switch(btnAction) {
case PAY:
ServiceDebit tempService = (ServiceDebit) bills.get(item).getData();
viewModel.payServiceBill(tempService.getBillID(), tempService.getPaymentID(), tempService.getTotalElectricityBillDebt() != null ? tempService.getTotalElectricityBillDebt() : tempService.getTotalGasBillDebt(), ProtoMplGetBillToken.MplGetBillToken.Type.NONE_VALUE);
break;
case EDIT:
if (item.getBillTitle() == null) {
showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
return;
}
ElectricityBillAddFrag frag = ElectricityBillAddFrag.newInstance(viewModel.getBillInfo(item), true);
frag.setCompleteListener(new ElectricityBillAddFrag.CompleteListener() {
@Override
public void loadAgain() {
viewModel.getBillsList();
}
});
frag.show(getFragmentManager(), "BillAddEdit");
break;
case DELETE:
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteBill_title).content(R.string.elecBill_deleteBill_desc).positiveText(R.string.elecBill_deleteBill_pos).negativeText(R.string.elecBill_deleteBill_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> {
viewModel.deleteItem(item);
Toast.makeText(getContext(), "Deleted", Toast.LENGTH_SHORT).show();
}).build();
dialog.show();
break;
case SHOW_DETAIL:
if (item.getBillTitle() == null) {
showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
return;
}
BillInfo temp = viewModel.getBillInfo(item);
new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(temp.getBillType(), temp.getBillID(), temp.getTitle(), true)).setReplace(false).load();
break;
case MID_PAY:
MobileDebit tempMid = (MobileDebit) bills.get(item).getData();
viewModel.payServiceBill(tempMid.getMidTerm().getBillID(), tempMid.getMidTerm().getPayID(), tempMid.getMidTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.MID_TERM_VALUE);
break;
case LAST_PAY:
MobileDebit tempLast = (MobileDebit) bills.get(item).getData();
viewModel.payServiceBill(tempLast.getLastTerm().getBillID(), tempLast.getLastTerm().getPayID(), tempLast.getLastTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.LAST_TERM_VALUE);
break;
case RELOAD:
viewModel.reloadData(item);
}
});
binding.billRecycler.setAdapter(adapter);
}
use of net.iGap.model.bill.MobileDebit in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListVM method getBillsList.
public void getBillsList() {
progressVisibility.set(View.VISIBLE);
errorVisibility.set(View.GONE);
showRetryView.set(View.GONE);
new BillsAPIRepository().getBillList(this, new ResponseCallback<BillList>() {
@Override
public void onSuccess(BillList data) {
if (data.getBills() == null || data.getBills().size() == 0) {
errorVisibility.set(View.VISIBLE);
}
Map<BillList.Bill, Debit> tmp = new HashMap<>();
for (BillList.Bill dataModel : data.getBills()) {
switch(dataModel.getBillType()) {
case "ELECTRICITY":
case "GAS":
Debit<ServiceDebit> temp = new Debit<>();
temp.setData(new ServiceDebit());
tmp.put(dataModel, temp);
getServiceDebit(dataModel);
break;
case "MOBILE_MCI":
case "PHONE":
Debit<MobileDebit> temp1 = new Debit<>();
temp1.setData(new MobileDebit());
tmp.put(dataModel, temp1);
getPhoneDebit(dataModel);
break;
}
}
mMapData.setValue(tmp);
progressVisibility.set(View.GONE);
}
@Override
public void onError(String error) {
showRetryView.set(View.VISIBLE);
progressVisibility.set(View.GONE);
errorM.setValue(new ErrorModel("", error));
errorVisibility.set(View.VISIBLE);
}
@Override
public void onFailed() {
showRetryView.set(View.VISIBLE);
progressVisibility.set(View.GONE);
showRequestFailedError.setValue(R.string.connection_error);
}
});
}
use of net.iGap.model.bill.MobileDebit in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListVM method reloadData.
public void reloadData(BillList.Bill data) {
Map<BillList.Bill, Debit> tmp = mMapData.getValue();
switch(data.getBillType()) {
case "ELECTRICITY":
case "GAS":
ServiceDebit temp = (ServiceDebit) tmp.get(data).getData();
temp.setLoading(true);
temp.setFail(false);
tmp.put(data, new Debit(temp));
getServiceDebit(data);
break;
case "MOBILE_MCI":
case "PHONE":
MobileDebit temp1 = (MobileDebit) tmp.get(data).getData();
temp1.setLoading(true);
temp1.setFail(false);
tmp.put(data, new Debit(temp1));
getPhoneDebit(data);
break;
}
}
use of net.iGap.model.bill.MobileDebit in project iGap-Android by KianIranian-STDG.
the class ElectricityBillPayVM method payBtn.
public void payBtn(int buttonID) {
if (debit == null)
return;
if (buttonID == 0) {
// main Btn for pay
progressVisibilityPay.set(View.VISIBLE);
payBtnEnable.set(false);
switch(info.getBillType()) {
case ELECTRICITY:
case GAS:
ServiceDebit temp = (ServiceDebit) debit.getData();
if (info.getBillType() == BillInfo.BillType.ELECTRICITY)
payBill(temp.getBillID(), temp.getPaymentID(), temp.getTotalElectricityBillDebt());
else
payBill(temp.getBillID(), temp.getPaymentID(), temp.getTotalGasBillDebt());
break;
case MOBILE:
case PHONE:
MobileDebit temp2 = (MobileDebit) debit.getData();
payBill(temp2.getLastTerm().getBillID(), temp2.getLastTerm().getPayID(), temp2.getLastTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.LAST_TERM_VALUE);
break;
}
} else {
// secondary Btn for phone pay
progressVisibilityPay.set(View.VISIBLE);
pay2BtnEnable.set(false);
MobileDebit temp2 = (MobileDebit) debit.getData();
payBill(temp2.getMidTerm().getBillID(), temp2.getMidTerm().getPayID(), temp2.getMidTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.MID_TERM_VALUE);
}
switch(info.getBillType()) {
case MOBILE:
HelperTracker.sendTracker(HelperTracker.TRACKER_MOBILE_BILL_PAY);
break;
case PHONE:
HelperTracker.sendTracker(HelperTracker.TRACKER_PHONE_BILL_PAY);
break;
case ELECTRICITY:
HelperTracker.sendTracker(HelperTracker.TRACKER_ELECTRIC_BILL_PAY);
break;
case GAS:
HelperTracker.sendTracker(HelperTracker.TRACKER_GAS_BILL_PAY);
break;
}
}
Aggregations