Skip to content

Commit

Permalink
done minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nawinkhatiwada committed Dec 30, 2019
1 parent ee8ad35 commit e8a4681
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions library/src/main/java/com/androidbolts/library/gps/GpsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ internal class GpsManager private constructor() : GpsProvider() {
private var mLocationSettingsRequest: LocationSettingsRequest? = null
private var dialog: AlertDialog? = null
private var mRequestingLocationUpdates: Boolean = false
private var timer: CountDownTimer ?= null
private var timer: CountDownTimer? = null

companion object {
private var gpsManager: GpsManager? = null
fun getGpsManager(): GpsManager {
if (gpsManager == null) {
gpsManager = GpsManager()
}
return gpsManager!!
return GpsManager()
}
}

Expand Down Expand Up @@ -141,13 +137,11 @@ internal class GpsManager private constructor() : GpsProvider() {

@SuppressLint("MissingPermission")
private fun startLocationUpdates() {
stopLocationUpdates()
mCurrentLocation = null
mSettingsClient?.checkLocationSettings(mLocationSettingsRequest)?.addOnCompleteListener {
if (it.isSuccessful) {
val frag = getFragment()
val act = getActivity()
if (mCurrentLocation == null && (act != null ||frag != null)) {
if (mCurrentLocation == null && (act != null || frag != null)) {
showDialog()
}
mFusedLocationClient?.requestLocationUpdates(
Expand Down Expand Up @@ -215,27 +209,27 @@ internal class GpsManager private constructor() : GpsProvider() {
posButton?.visibility = View.GONE
negButton?.visibility = View.GONE
if (getTimeOut() != TIME_OUT_NONE && mCurrentLocation == null) {
timer = object :CountDownTimer(getTimeOut(), 1000){
override fun onFinish() {
if(mCurrentLocation == null) {
posButton?.visibility = View.VISIBLE
negButton?.visibility = View.VISIBLE
updateDialog()
}else {
dismissDialog()
}
}
timer = object : CountDownTimer(getTimeOut(), 1000) {
override fun onFinish() {
if (mCurrentLocation == null) {
posButton?.visibility = View.VISIBLE
negButton?.visibility = View.VISIBLE
updateDialog()
} else {
dismissDialog()
}
}

override fun onTick(running: Long) {
}
}
override fun onTick(running: Long) {
}
}
timer?.start()
}
}
dialog?.let { loadingDialog ->
if (!loadingDialog.isShowing) {
dialog?.show()
}else {
} else {
dialog?.dismiss()
}
}
Expand All @@ -244,8 +238,10 @@ internal class GpsManager private constructor() : GpsProvider() {
}

private fun updateDialog() {
dialog?.findViewById<TextView>(R.id.title)?.text = getContext()?.getString(R.string.gps_problem)
dialog?.findViewById<TextView>(R.id.message)?.text =getContext()?.getString(R.string.gps_problem_desc)
dialog?.findViewById<TextView>(R.id.title)?.text =
getContext()?.getString(R.string.gps_problem)
dialog?.findViewById<TextView>(R.id.message)?.text =
getContext()?.getString(R.string.gps_problem_desc)
dialog?.findViewById<ProgressBar>(R.id.progress_circular)?.visibility = View.GONE
}

Expand Down

0 comments on commit e8a4681

Please sign in to comment.