This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Class | |
import io.reactivex.Flowable | |
import io.reactivex.functions.Function | |
import java.util.concurrent.TimeUnit | |
class RetryWithDelay(private val maxRetries: Int, private val retryDelayMillis: Int, private val retryIf: Function<Throwable, Boolean>, private val unit: TimeUnit = TimeUnit.MILLISECONDS) : Function<Flowable<out Throwable>, Flowable<*>> { | |
private var retryCount: Int = 0 | |
override fun apply(attempts: Flowable<out Throwable>): Flowable<*> { | |
return attempts.doOnNext { println("RetryWithDelay $it") }.flatMap { throwable -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NetworkHandler(private val context: Context) { | |
val isConnected get() = checkInternet() | |
private fun checkInternet(): Boolean { | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager | |
var result = false | |
if (connectivityManager != null) { | |
result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
connectivityManager.activeNetwork != null | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Canvas | |
import android.graphics.Paint | |
import android.graphics.Rect | |
import android.view.View | |
import androidx.core.graphics.withTranslation | |
import androidx.core.view.children | |
import androidx.recyclerview.widget.RecyclerView | |
class DividerItemDecoration( | |
private val strokeColor: Int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.InputFilter | |
import android.text.Spanned | |
class InputFilterMinMax : InputFilter { | |
private var min: Int = 0 | |
private var max: Int = 0 | |
constructor(min: Int, max: Int) { | |
this.min = min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Definition of geolocation - latitude, longitude in Fragment | |
private lateinit var fusedLocationClient: FusedLocationProviderClient | |
private lateinit var locationRequest: LocationRequest | |
private lateinit var locationCallback: LocationCallback | |
private lateinit var rxPermissions: RxPermissions | |
private var latitude: Double? = 0.0 | |
private var longitude: Double? = 0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usages | |
private lateinit var updateApp: UpdateApp | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
updateApp = UpdateApp(this) | |
} | |
override fun onResume() { | |
super.onResume() |