-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into 'master'
Development See merge request apphud/android!7
- Loading branch information
Showing
26 changed files
with
249 additions
and
78 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.apphud.sdk.client | ||
|
||
data class NetworkException(val code: Int) : RuntimeException() | ||
|
||
internal fun exception(code: Int): Nothing = throw NetworkException(code) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.apphud.sdk.client | ||
|
||
import com.apphud.sdk.tasks.PriorityComparator | ||
import java.util.concurrent.* | ||
|
||
internal class ThreadsUtils { | ||
|
||
companion object { | ||
private const val capacity = 10 | ||
} | ||
|
||
private var pool = buildExecutor() | ||
private val service: ExecutorService = Executors.newSingleThreadExecutor() | ||
private val unlimited: ExecutorService = Executors.newSingleThreadExecutor() | ||
|
||
fun <T> registration(callable: Callable<T>, block: (T) -> Unit) = | ||
service.execute { | ||
try { | ||
block.invoke(callable.call()) | ||
} catch (e: Exception) { | ||
pool.shutdown() | ||
pool = buildExecutor() | ||
} | ||
} | ||
|
||
fun allProducts(runnable: Runnable) = unlimited.execute(runnable) | ||
fun execute(runnable: Runnable) = pool.execute(runnable) | ||
|
||
private fun buildExecutor() = ThreadPoolExecutor( | ||
1, | ||
1, | ||
0L, | ||
TimeUnit.MILLISECONDS, | ||
PriorityBlockingQueue<Runnable>(capacity, PriorityComparator()), | ||
Executors.defaultThreadFactory(), | ||
ThreadPoolExecutor.CallerRunsPolicy() | ||
) | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.apphud.sdk.domain | ||
|
||
data class AppsflyerInfo( | ||
val id: String?, | ||
val data: Map<String, Any>? | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.apphud.sdk.domain | ||
|
||
data class FacebookInfo( | ||
val data: Map<String, Any>? | ||
) |
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
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
Oops, something went wrong.