-
Notifications
You must be signed in to change notification settings - Fork 0
/
Address.java
35 lines (32 loc) · 2.26 KB
/
Address.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
SmartLocation.with(this).location()
.oneFix()
.start(new OnLocationUpdatedListener() {
@Override
public void onLocationUpdated(Location location) {
SmartLocation.with(MainDashboard.this).geocoding()
.reverse(location, new OnReverseGeocodingListener() {
@Override
public void onAddressResolved(Location location, List<Address> list) {
if (BuildConfig.DEBUG) {
Toast.makeText(MainDashboard.this, "Total Location : "+list.size(), Toast.LENGTH_SHORT).show();
}
if (list.size() > 0) {
Address result = list.get(0);
StringBuilder builder = new StringBuilder();
builder.append(text);
List<String> addressElements = new ArrayList<>();
for (int i = 0; i <= result.getMaxAddressLineIndex(); i++) {
addressElements.add(result.getAddressLine(i));
}
if (BuildConfig.DEBUG) {
Toast.makeText(MainDashboard.this, "Total AddressLine : "+result.getMaxAddressLineIndex(), Toast.LENGTH_SHORT).show();
}
builder.append(TextUtils.join(", ", addressElements));
txtUserAddress.setText(builder.toString());
}else{
txtUserAddress.setText("No Address Found");
}
}
});
}
});