From 565e89eacf749d997d652f2f3badb9d4d7185e33 Mon Sep 17 00:00:00 2001 From: Muddassir Khan Date: Thu, 3 Sep 2020 08:25:25 +0500 Subject: [PATCH] Add kmacros dependency --- build.gradle | 1 + connection_checker/build.gradle | 2 ++ .../com/muddassir/connection_checker/ConnectionChecker.kt | 1 + .../src/main/java/com/muddassir/connection_checker/macros.kt | 5 ----- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 1241d12..1bff2ad 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ allprojects { repositories { google() jcenter() + maven { url 'https://jitpack.io' } } } diff --git a/connection_checker/build.gradle b/connection_checker/build.gradle index 1d11347..2d19301 100644 --- a/connection_checker/build.gradle +++ b/connection_checker/build.gradle @@ -48,4 +48,6 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + implementation 'com.github.muddassir235:kmacros:1.8' } \ No newline at end of file diff --git a/connection_checker/src/main/java/com/muddassir/connection_checker/ConnectionChecker.kt b/connection_checker/src/main/java/com/muddassir/connection_checker/ConnectionChecker.kt index f9459ed..49cebdf 100644 --- a/connection_checker/src/main/java/com/muddassir/connection_checker/ConnectionChecker.kt +++ b/connection_checker/src/main/java/com/muddassir/connection_checker/ConnectionChecker.kt @@ -16,6 +16,7 @@ package com.muddassir.connection_checker import android.content.Context import androidx.lifecycle.Lifecycle +import com.muddassir.kmacros.delay enum class ConnectionState { CONNECTED, SLOW, DISCONNECTED diff --git a/connection_checker/src/main/java/com/muddassir/connection_checker/macros.kt b/connection_checker/src/main/java/com/muddassir/connection_checker/macros.kt index a7f035e..230b833 100644 --- a/connection_checker/src/main/java/com/muddassir/connection_checker/macros.kt +++ b/connection_checker/src/main/java/com/muddassir/connection_checker/macros.kt @@ -1,17 +1,12 @@ package com.muddassir.connection_checker import android.content.Context -import android.os.Handler import com.android.volley.Request import com.android.volley.RequestQueue import com.android.volley.Response import com.android.volley.toolbox.StringRequest import com.android.volley.toolbox.Volley -internal fun delay(millis: Long, task: ((Unit) -> Unit)) { - Handler().postDelayed({ task.invoke(Unit) }, millis) -} - internal fun pingUrl(context: Context, url: String, onResult: ((failed: Boolean, timeTaken: Long) -> Unit)) { val queue: RequestQueue = Volley.newRequestQueue(context)