This file contains hidden or 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 java.io.IOException; | |
import okhttp3.HttpUrl; | |
import okhttp3.Interceptor; | |
import okhttp3.OkHttpClient; | |
import okhttp3.Request; | |
/** An interceptor that allows runtime changes to the URL hostname. */ | |
public final class HostSelectionInterceptor implements Interceptor { | |
private volatile String host; |
This file contains hidden or 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 CrashTree extends Timber.Tree { | |
@Override | |
protected void log(int priority, String tag, String message, Throwable t) { | |
if (t != null && priority == Log.ERROR) { | |
throw new RuntimeException(t); | |
} | |
} | |
} |
This file contains hidden or 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
/* | |
* Copyright (C) 2017 Josh Feinberg | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
/* | |
* Copyright (C) 2017 Josh Feinberg | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
interface OreoTrackerNetwork : SicknessService, WeightService, StatsService | |
interface SicknessService { | |
@GET("throwup") | |
suspend fun getThrowUps(): List<ThrowUp> | |
@POST("throwup") | |
suspend fun postThrowUp(@Body body: ThrowUp) | |
} |
This file contains hidden or 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 WeightController(kodein: Kodein) : KodeinController(kodein), WeightService { | |
private val repository: WeightRepository by instance() | |
override suspend fun getWeights(): List<Weight> { | |
return repository.list() | |
} | |
override suspend fun postWeight(body: Weight) { | |
repository.addWeight(body) |
This file contains hidden or 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 Services( | |
sicknessService: SicknessService, | |
weightService: WeightService, | |
statsService: StatsService | |
) : OreoTrackerNetwork, | |
SicknessService by sicknessService, | |
WeightService by weightService, | |
StatsService by statsService |
This file contains hidden or 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 Application.kodeinApplication( | |
kodeinMapper: Kodein.MainBuilder.(Application) -> Unit = {} | |
) { | |
val application = this | |
val kodein = Kodein { | |
bind<Application>() with instance(application) | |
kodeinMapper(this, application) | |
} |
This file contains hidden or 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
ext.reversedMap = [:] as Map<String, String> | |
void buildReversedMap(String versionCatalogName) { | |
def versionCatalog = rootProject.extensions | |
.getByType(VersionCatalogsExtension).named(versionCatalogName) | |
reversedMap = versionCatalog.getDependencyAliases() | |
.collectEntries { alias -> | |
def versionCatalogAlias = "${versionCatalogName}.${alias}" | |
def module = versionCatalog.findDependency(alias).get().get() | |
def fullModuleName = "${module.getModule()}:${module.getVersionConstraint()}" |