Skip to content

Commit

Permalink
Add kmacros dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
muddassir235 committed Sep 3, 2020
1 parent 6227205 commit 565e89e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
2 changes: 2 additions & 0 deletions connection_checker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 565e89e

Please sign in to comment.