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
@Suppress("FunctionName") | |
fun BroadcastReceiverFlow(c: Context, intentFilter: IntentFilter): Flow<Intent> { | |
return callbackFlow { | |
val broadcastReceiver = object : android.content.BroadcastReceiver() { | |
override fun onReceive(context: Context, intent: Intent) { | |
offer(intent) | |
} | |
} | |
c.registerReceiver(broadcastReceiver, intentFilter) | |
awaitClose { c.unregisterReceiver(broadcastReceiver) } |
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
dependencies { | |
implementation project(':core') | |
implementation project(':view') | |
implementation project(':live-edit') | |
} |
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
apply plugin: 'kotlin' | |
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | |
implementation 'com.squareup.okhttp3:okhttp:3.12.3' | |
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.3' | |
implementation 'com.google.code.gson:gson:2.8.5' | |
} |
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
fun Language(jsonObject: JSONObject) = Language( | |
id = jsonObject.getInt("id"), | |
name = jsonObject.getString("name"), | |
locale = Locale(jsonObject.getString("locale")), | |
direction = jsonObject.getString("direction"), | |
isDefault = jsonObject.getBoolean("is_default"), | |
isBestFit = jsonObject.getBoolean("is_best_fit") | |
) |
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
data class Language( | |
val id: Int, | |
val name: String, | |
val locale: Locale, | |
val direction: String, | |
val isDefault: Boolean, | |
val isBestFit: Boolean | |
) { | |
constructor(jsonObject: JSONObject) : this( | |
id = jsonObject.getInt("id"), |
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
apply plugin: 'com.android.library' | |
apply plugin: 'kotlin-android' | |
android { | |
compileSdkVersion 28 | |
buildToolsVersion '28.0.3' | |
defaultConfig { | |
minSdkVersion 19 | |
targetSdkVersion 28 | |
versionCode 230 |
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 androidx.work.ListenableWorker | |
import dagger.MapKey | |
import kotlin.reflect.KClass | |
@MapKey | |
@Retention(AnnotationRetention.RUNTIME) | |
@Target(AnnotationTarget.FUNCTION) | |
annotation class WorkerKey(val value: KClass<out ListenableWorker>) |
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.content.Context | |
import androidx.work.ListenableWorker | |
import androidx.work.WorkerFactory | |
import androidx.work.WorkerParameters | |
import javax.inject.Inject | |
import javax.inject.Provider | |
class DaggerWorkerFactory @Inject constructor( | |
private val creators: Map<Class<out ListenableWorker>, @JvmSuppressWildcards Provider<ChildWorkerFactory>> | |
) : WorkerFactory() { |