From b747bce9f710cb50c4c38e2fa928f29b25178e3c Mon Sep 17 00:00:00 2001 From: Preyea Regmi Date: Thu, 9 May 2019 14:25:27 +0545 Subject: [PATCH] Adding form based progress bar --- .../view/SendMoneyActionListener.java | 2 +- .../view/SendMoneyScreenManager.java | 16 ++++-- .../sendmoneyV2/view/SendMoneyV2Activity.java | 14 ++++-- .../PayoutModeSendMoneyFragment.java | 50 +++++++++---------- app/src/main/res/anim/enter_from_right.xml | 4 +- app/src/main/res/anim/exit_to_left.xml | 4 +- 6 files changed, 55 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyActionListener.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyActionListener.java index 4ea2d18d..6d5ea860 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyActionListener.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyActionListener.java @@ -24,5 +24,5 @@ public interface SendMoneyActionListener { void updateFinalTranstionToDefault(); - + void prepareRemainingFragments(); } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyScreenManager.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyScreenManager.java index b9241308..3dc38918 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyScreenManager.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyScreenManager.java @@ -10,16 +10,26 @@ import com.gmeremit.online.gmeremittance_native.sendmoneyV2.view.verification.Ve public class SendMoneyScreenManager { - public static BaseFragment getSendMoneyScreenFromId(@LayoutRes int layoutID ) + AmountDetailSendMoneyFragment amountDetailSendMoneyFragment; + VerificationSendMoneyFragment verificationSendMoneyFragment; + public SendMoneyScreenManager() { + } + + public void prepareFragmentsLazily() { + amountDetailSendMoneyFragment= new AmountDetailSendMoneyFragment(); + verificationSendMoneyFragment= new VerificationSendMoneyFragment(); + } + + public BaseFragment getSendMoneyScreenFromId(@LayoutRes int layoutID ) { switch(layoutID) { case R.layout.fragment_payout_mode_send_money_v2: return new PayoutModeSendMoneyFragment(); case R.layout.fragment_amount_detail_send_money_v2: - return new AmountDetailSendMoneyFragment(); + return (amountDetailSendMoneyFragment==null)?new AmountDetailSendMoneyFragment():amountDetailSendMoneyFragment; case R.layout.fragment_verification_send_money_v2: - return new VerificationSendMoneyFragment(); + return (verificationSendMoneyFragment==null)?new VerificationSendMoneyFragment():verificationSendMoneyFragment; default: return null; } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java index 0339578c..e4dea929 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java @@ -50,6 +50,7 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction public static String RECIPIENT_DATA = "recipientData"; private PasswordPromptListener passwordPromptListener; + private SendMoneyScreenManager sendMoneyScreenManager; @Override protected void onCreate(Bundle savedInstanceState) { @@ -78,12 +79,12 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction } private void initialize() { - + sendMoneyScreenManager=new SendMoneyScreenManager(); } public boolean addScreenToSendMoney(@LayoutRes int layoutID, boolean addTransitionEffect) { - BaseFragment baseFragment = SendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); + BaseFragment baseFragment = sendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); if (baseFragment != null) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (addTransitionEffect) @@ -98,7 +99,7 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction } public boolean addScreenToSendMoneyOnly(@LayoutRes int layoutID, boolean addTransitionEffect) { - BaseFragment baseFragment = SendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); + BaseFragment baseFragment = sendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); if (baseFragment != null) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (addTransitionEffect) @@ -112,7 +113,7 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction } public boolean replaceCurrentScreen(@LayoutRes int layoutID) { - BaseFragment baseFragment = SendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); + BaseFragment baseFragment = sendMoneyScreenManager.getSendMoneyScreenFromId(layoutID); if (baseFragment != null) { android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); @@ -318,4 +319,9 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction public void updateFinalTranstionToDefault() { setDefaultBg(page3TxtView); } + + @Override + public void prepareRemainingFragments() { + sendMoneyScreenManager.prepareFragmentsLazily(); + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeSendMoneyFragment.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeSendMoneyFragment.java index da25255f..96aed820 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeSendMoneyFragment.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/payoutmode/PayoutModeSendMoneyFragment.java @@ -233,12 +233,11 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon } - private boolean focusOutAndHideKeyboard() { - if(ed_account.hasFocus()) - { + private boolean focusOutAndHideKeyboard() { + if (ed_account.hasFocus()) { - View currentViewWithFocus=rootView.getFocusedChild(); - if(currentViewWithFocus!=null) + View currentViewWithFocus = rootView.getFocusedChild(); + if (currentViewWithFocus != null) currentViewWithFocus.clearFocus(); hideKeyBoard(); @@ -316,8 +315,8 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon paymentModeRvAdapter.setData(data); } - public void setDataToPaymentModeWithDefaultSelected(List data,int selectedItemPosition) { - paymentModeRvAdapter.setDataWithDefaultSelectedValue(data,selectedItemPosition); + public void setDataToPaymentModeWithDefaultSelected(List data, int selectedItemPosition) { + paymentModeRvAdapter.setDataWithDefaultSelectedValue(data, selectedItemPosition); } @Override @@ -404,15 +403,16 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon if (isUIReady()) { showProgressBar(false, ""); if (payoutModeApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { - setDataToPaymentModeWithDefaultSelected(payoutModeApiResponse.getData().getPayoutMode(),0); + setDataToPaymentModeWithDefaultSelected(payoutModeApiResponse.getData().getPayoutMode(), 0); } else { showPopUpMessage(payoutModeApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } + } else { scheduleTaskLater(() -> { showProgressBar(false, ""); if (payoutModeApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { - setDataToPaymentModeWithDefaultSelected(payoutModeApiResponse.getData().getPayoutMode(),0); + setDataToPaymentModeWithDefaultSelected(payoutModeApiResponse.getData().getPayoutMode(), 0); } else { showPopUpMessage(payoutModeApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); @@ -425,12 +425,12 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon public void onFailed(String message) { if (isUIReady()) { showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } else { scheduleTaskLater(() -> { showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); }); } @@ -440,12 +440,12 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon protected void onConnectionNotEstablished(String message) { if (isUIReady()) { showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); } else { scheduleTaskLater(() -> { showProgressBar(false, ""); - showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); }); } @@ -465,20 +465,20 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon @Override protected void onSuccess(AccountValidationApiResponse accountValidationApiResponse) { if (isUIReady()) { - if (accountValidationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) + if (accountValidationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { ((SendMoneyActionListener) getActivity()).showAmountDetailPage(); - else - { - showPopUpMessage(accountValidationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED,null); + ((SendMoneyActionListener) getActivity()).prepareRemainingFragments(); + } else { + showPopUpMessage(accountValidationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } } else { scheduleTaskLater(() -> { - if (accountValidationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) + if (accountValidationApiResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { ((SendMoneyActionListener) getActivity()).showAmountDetailPage(); - else - { - showPopUpMessage(accountValidationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED,null); + ((SendMoneyActionListener) getActivity()).prepareRemainingFragments(); + } else { + showPopUpMessage(accountValidationApiResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } }); @@ -488,10 +488,10 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon @Override public void onFailed(String message) { if (isUIReady()) { - showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } else { scheduleTaskLater(() -> { - showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); }); } } @@ -499,10 +499,10 @@ public class PayoutModeSendMoneyFragment extends BaseFragment implements SendMon @Override protected void onConnectionNotEstablished(String message) { if (isUIReady()) { - showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); } else { scheduleTaskLater(() -> { - showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET,null); + showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null); }); } } diff --git a/app/src/main/res/anim/enter_from_right.xml b/app/src/main/res/anim/enter_from_right.xml index aaed2a84..4f33e2ec 100644 --- a/app/src/main/res/anim/enter_from_right.xml +++ b/app/src/main/res/anim/enter_from_right.xml @@ -4,5 +4,7 @@ + android:duration="300" + android:startOffset="100" + /> \ No newline at end of file diff --git a/app/src/main/res/anim/exit_to_left.xml b/app/src/main/res/anim/exit_to_left.xml index 2533835e..5f6e452f 100644 --- a/app/src/main/res/anim/exit_to_left.xml +++ b/app/src/main/res/anim/exit_to_left.xml @@ -4,5 +4,7 @@ + android:duration="300" + android:startOffset="100" + /> \ No newline at end of file