Skip to content

Commit

Permalink
Do not auto retry when location fails
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Chagas <[email protected]>
  • Loading branch information
rtchagas committed Sep 22, 2023
1 parent acaea94 commit 71176eb
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.doOnLayout
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationServices
Expand Down Expand Up @@ -49,8 +48,6 @@ import com.rtchagas.pingplacepicker.ui.toast
import com.rtchagas.pingplacepicker.viewmodel.PlacePickerViewModel
import com.rtchagas.pingplacepicker.viewmodel.Resource
import io.reactivex.disposables.CompositeDisposable
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
import kotlin.math.abs

Expand Down Expand Up @@ -90,8 +87,6 @@ internal class PlacePickerActivity :

private var lastKnownLocation: LatLng? = null

private var maxLocationRetries: Int = 3

private var placeAdapter: PlacePickerAdapter? = null

private val viewModel: PlacePickerViewModel by viewModel()
Expand Down Expand Up @@ -533,17 +528,7 @@ internal class PlacePickerActivity :
}

private fun retryWhenLocationIsNotAvailable(animate: Boolean) {

if (maxLocationRetries > 0) {
maxLocationRetries--
lifecycleScope.launch {
delay(1000)
getDeviceLocation(animate)
}
return
}

// Location is not available. Give up...
// Location is not available. Ask the user to retry.
setDefaultLocation()
Snackbar
.make(binding.root, R.string.picker_location_unavailable, Snackbar.LENGTH_INDEFINITE)
Expand Down

0 comments on commit 71176eb

Please sign in to comment.