Search in sources :

Example 1 with OnInfoCountryResponse

use of net.iGap.observers.interfaces.OnInfoCountryResponse in project iGap-Android by KianIranian-STDG.

the class UserProfileViewModel method setCountry.

public void setCountry(StructCountry country) {
    new RequestInfoCountry().infoCountry(country.getAbbreviation(), new OnInfoCountryResponse() {

        @Override
        public void onInfoCountryResponse(final int callingCode, final String name, final String pattern, final String regexR) {
            G.handler.post(() -> {
                referralCountryCodeObservableField.set("+" + callingCode);
            });
        }

        @Override
        public void onError(int majorCode, int minorCode) {
        }
    });
    referralNumberObservableField.set("");
}
Also used : OnInfoCountryResponse(net.iGap.observers.interfaces.OnInfoCountryResponse) RequestInfoCountry(net.iGap.request.RequestInfoCountry) HelperString(net.iGap.helper.HelperString)

Example 2 with OnInfoCountryResponse

use of net.iGap.observers.interfaces.OnInfoCountryResponse in project iGap-Android by KianIranian-STDG.

the class FragmentAddContactViewModel method setCountry.

public void setCountry(@NotNull StructCountry country) {
    showProgress.set(View.VISIBLE);
    new RequestInfoCountry().infoCountry(country.getAbbreviation(), new OnInfoCountryResponse() {

        @Override
        public void onInfoCountryResponse(final int callingCode, final String name, final String pattern, final String regexR) {
            G.runOnUiThread(() -> {
                showProgress.set(View.GONE);
                hasError.setValue(false);
                countryCode.setValue("+" + callingCode);
                if (pattern.equals("")) {
                    phoneNumberMask.setValue("##################");
                } else {
                    phoneNumberMask.setValue(pattern.replace("X", "#").replace(" ", "-"));
                }
            });
        }

        @Override
        public void onError(int majorCode, int minorCode) {
            G.handler.post(() -> {
                showProgress.set(View.GONE);
                hasError.setValue(true);
            });
        }
    });
}
Also used : OnInfoCountryResponse(net.iGap.observers.interfaces.OnInfoCountryResponse) RequestInfoCountry(net.iGap.request.RequestInfoCountry)

Aggregations

OnInfoCountryResponse (net.iGap.observers.interfaces.OnInfoCountryResponse)2 RequestInfoCountry (net.iGap.request.RequestInfoCountry)2 HelperString (net.iGap.helper.HelperString)1