Skip to content

Instantly share code, notes, and snippets.

View sanogueralorenzo's full-sized avatar
👋
Hey there

mario sanogueralorenzo

👋
Hey there
View GitHub Profile
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion Versions.compileSdk
defaultConfig {
minSdkVersion Versions.minSdk
targetSdkVersion Versions.targetSdk
apply from: "$rootDir/common-android-library.gradle"
dependencies {
implementation project(Modules.cache)
implementation project(Modules.network)
implementation project(Modules.presentation)
implementation Libraries.koin
implementation Libraries.rxkotlin
implementation SupportLibraries.appcompat
repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.github.shyiko:ktlint:0.29.0"
allprojects {
apply from: "$rootDir/ktlint.gradle"
}
val viewModelModule: Module = module {
viewModel { PostListViewModel(usersPostsUseCase = get()) }
viewModel { PostDetailsViewModel(userPostUseCase = get(), commentsUseCase = get()) }
}
val useCaseModule: Module = module {
factory { UsersPostsUseCase(userRepository = get(), postRepository = get()) }
factory { UserPostUseCase(userRepository = get(), postRepository = get()) }
factory { CommentsUseCase(commentRepository = get()) }
}
object Posts {
fun init() = loadKoinModules(
viewModelModule,
useCaseModule,
repositoryModule,
networkModule,
cacheModule
)
}
class App : Application() {
override fun onCreate() {
super.onCreate()
Posts.init()
}
}
apply plugin: 'io.gitlab.arturbosch.detekt'
detekt {
config = files("$rootDir/default-detekt-config.yml")
filters = ".*build.*,.*/resources/.*,.*/tmp/.*"
//Optional baseline, uncomment & run gradle command detektBaseline to exclude existing issues
//baseline = file("detekt-baseline.xml")
}
buildscript {
repositories {
jcenter()
}
}
plugins {
id "io.gitlab.arturbosch.detekt" version "1.0.0-RC10"
}
private const val PACKAGE_NAME = "com.sanogueralorenzo.namingishard"
private fun intentTo(className: String): Intent =
Intent(Intent.ACTION_VIEW).setClassName(PACKAGE_NAME, className)
internal fun loadIntentOrNull(className: String): Intent? =
try {
Class.forName(className).run { intentTo(className) }
} catch (e: ClassNotFoundException) {
null