Search in sources :

Example 1 with LocationSingleBuilder

use of com.github.moko256.twitlatte.rx.LocationSingleBuilder in project twicalico by moko256.

the class PostActivity method updateLocation.

private void updateLocation() {
    LocationManager locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
    disposable.add(new LocationSingleBuilder(Objects.requireNonNull(locationManager)).getSingle().subscribe(it -> {
        model.getUpdateStatus().setLocation(new Pair<>(it.getLatitude(), it.getLongitude()));
        locationText.setText(getString(R.string.lat_and_lon, it.getLatitude(), it.getLongitude()));
    }, this::errorNotify));
}
Also used : LocationManager(android.location.LocationManager) Rect(android.graphics.Rect) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Pair(kotlin.Pair) Uri(android.net.Uri) ImageView(android.widget.ImageView) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ActionBar(androidx.appcompat.app.ActionBar) Manifest(android.Manifest) CheckBox(android.widget.CheckBox) RequestManager(com.bumptech.glide.RequestManager) LocationSingleBuilder(com.github.moko256.twitlatte.rx.LocationSingleBuilder) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) ContextCompat(androidx.core.content.ContextCompat) PostStatusModelImpl(com.github.moko256.twitlatte.model.impl.PostStatusModelImpl) NoSpanInputFilterKt(com.github.moko256.twitlatte.text.NoSpanInputFilterKt) Objects(java.util.Objects) DpToPxKt(com.github.moko256.twitlatte.view.DpToPxKt) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Unit(kotlin.Unit) TextView(android.widget.TextView) PostStatusModel(com.github.moko256.twitlatte.model.base.PostStatusModel) ImageKeyboardEditText(com.github.moko256.twitlatte.widget.ImageKeyboardEditText) Emoji(com.github.moko256.latte.client.base.entity.Emoji) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LocationManager(android.location.LocationManager) Snackbar(com.google.android.material.snackbar.Snackbar) TextWatcher(android.text.TextWatcher) Context(android.content.Context) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) ArraysKt(kotlin.collections.ArraysKt) Intent(android.content.Intent) CLIENT_TYPE_TWITTER(com.github.moko256.latte.client.twitter.TwitterApiClientImplKt.CLIENT_TYPE_TWITTER) Single(io.reactivex.Single) Editable(android.text.Editable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) PermissionChecker(androidx.core.content.PermissionChecker) SuppressLint(android.annotation.SuppressLint) Menu(android.view.Menu) Parcelable(android.os.Parcelable) ActivityCompat(androidx.core.app.ActivityCompat) Client(com.github.moko256.twitlatte.entity.Client) VerifyCredentialOnSubscribe(com.github.moko256.twitlatte.rx.VerifyCredentialOnSubscribe) Spinner(android.widget.Spinner) Glide(com.bumptech.glide.Glide) TypedValue(android.util.TypedValue) EditText(android.widget.EditText) CLIENT_TYPE_MASTODON(com.github.moko256.latte.client.mastodon.MastodonApiClientImplKt.CLIENT_TYPE_MASTODON) LocationSingleBuilder(com.github.moko256.twitlatte.rx.LocationSingleBuilder) Pair(kotlin.Pair)

Aggregations

Manifest (android.Manifest)1 SuppressLint (android.annotation.SuppressLint)1 ClipData (android.content.ClipData)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Rect (android.graphics.Rect)1 LocationManager (android.location.LocationManager)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Parcelable (android.os.Parcelable)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 TypedValue (android.util.TypedValue)1 KeyEvent (android.view.KeyEvent)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 CheckBox (android.widget.CheckBox)1 EditText (android.widget.EditText)1