@Background void cameraChangeTask() { showHideLoading(true); try { valid = ZupApi.validateCityBoundary(getActivity(), latitude, longitude); if (GPSUtils.getFromLocation(getActivity(), latitude, longitude) == null) { return; } Address addr = GPSUtils.getFromLocation(getActivity(), latitude, longitude).get(0); showHideLoading(false); verifyValid(); if (addr == null) { return; } street = addr.getThoroughfare(); if (!TextUtils.isEmpty(addr.getFeatureName()) && StringUtils.isNumeric(addr.getFeatureName().substring(0, 1))) { number = addr.getFeatureName(); } else { number = ""; } updateUiAdapter(addr); } catch (Exception e) { Log.e("ZUP", e.getMessage(), e); Crashlytics.logException(e); } }
@Background void timerEnderecoTask(double lat, double lon) { boolean run = true; while (run) { try { Thread.sleep(1000); if (lat != latitude && lon != longitude) { lat = latitude; lon = longitude; if (ignoreUpdate) { ignoreUpdate = false; continue; } showHideLoading(true); List<Address> addresses = GPSUtils.getFromLocation(getContext(), lat, lon); if (addresses.isEmpty()) { showHideLoading(false); return; } Address address = addresses.get(0); if (address.getThoroughfare() == null) { showHideLoading(false); return; } currentAddress = address; valid = ZupApi.validateCityBoundary(getActivity(), lat, lon); verifyValid(); street = address.getThoroughfare(); number = address.getFeatureName(); updateUi(address, address.getFeatureName()); updateUiAdapter(address); showHideLoading(false); } } catch (Exception e) { Log.e("ZUP", e.getMessage(), e); Crashlytics.logException(e); } } }