Изучаю RxJava, кто-нибудь может подсказать , как сделать так, чтобы информация обновлялась каждую минуту и изменяла TextView?
public class ConccurencyLocation {
private FusedLocationProviderClient fusedLocationProviderClient;
String amount;
public void rxjava(Context context) {
TextView textView = (TextView) ((Activity) context).findViewById(R.id.text);
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
Disposable s = Observable.interval(1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.io())
.map((x) -> {
String amount = this.amount;
fusedLocationProviderClient.getLastLocation().addOnSuccessListener((Activity) context, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {
String l = String.valueOf(location.getLongitude());
String a = String.valueOf(location.getLatitude());
Toast.makeText(context, "Success", Toast.LENGTH_LONG).show();
ConccurencyLocation.this.amount = "longtitude: " + l + " " + " latitude: " + a + " "+x;
;
}
}
});
return amount;
}). observeOn(AndroidSchedulers.mainThread())
.subscribe(textView::setText);
}
}