Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: flowExt and ViewBindingDelegate #155

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ dependencies {
implementation(deps.coroutines.android)
implementation(deps.koin.android)
implementation(deps.androidx.material)
implementation(deps.androidx.startup)

debugImplementation(deps.squareup.leakCanary)
implementation(deps.timber)
implementation(deps.viewBindingDelegate)

testImplementation(deps.test.junit)
androidTestImplementation(deps.test.androidx.junit)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.hoc.flowmvi">

<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -13,6 +14,20 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data
android:name="com.hoc.flowmvi.initializer.TimberInitializer"
android:value="androidx.startup" />

<meta-data
android:name="com.hoc.flowmvi.initializer.ViewBindingInitializer"
android:value="androidx.startup" />
</provider>

</application>

</manifest>
7 changes: 0 additions & 7 deletions app/src/main/java/com/hoc/flowmvi/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import timber.log.Timber

@FlowPreview
@ExperimentalCoroutinesApi
Expand All @@ -42,12 +41,6 @@ class App : Application() {

DynamicColors.applyToActivitiesIfAvailable(this)

if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
// TODO(Timber): plant release tree
}

startKoin {
androidContext(this@App)

Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/hoc/flowmvi/initializer/TimberInitializer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@file:Suppress("unused")

package com.hoc.flowmvi.initializer

import android.content.Context
import androidx.startup.Initializer
import com.hoc.flowmvi.BuildConfig
import timber.log.Timber

class TimberInitializer : Initializer<Unit> {
override fun create(context: Context) {
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
// TODO(Timber): plant release tree
}
Timber.d("TimberInitializer...")
}

override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@file:Suppress("unused")

package com.hoc.flowmvi.initializer

import android.content.Context
import androidx.startup.Initializer
import com.hoc.flowmvi.ui.add.databinding.ActivityAddBinding
import com.hoc.flowmvi.ui.main.databinding.ActivityMainBinding
import com.hoc081098.viewbindingdelegate.preloadBindMethods
import timber.log.Timber

class ViewBindingInitializer : Initializer<Unit> {
override fun create(context: Context) {
preloadBindMethods(
ActivityMainBinding::class,
ActivityAddBinding::class,
)
Timber.d("ViewBindingInitializer...")
}

override fun dependencies(): List<Class<out Initializer<*>>> =
listOf(TimberInitializer::class.java)
}
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ object deps {
const val recyclerView = "androidx.recyclerview:recyclerview:1.2.1"
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
const val material = "com.google.android.material:material:1.6.1"
const val startup = "androidx.startup:startup-runtime:1.1.1"
}

object lifecycle {
Expand Down Expand Up @@ -69,8 +70,8 @@ object deps {
}

const val coil = "io.coil-kt:coil:2.1.0"
const val viewBindingDelegate = "com.github.hoc081098:ViewBindingDelegate:1.3.1"
const val flowExt = "io.github.hoc081098:FlowExt:0.4.0"
const val viewBindingDelegate = "com.github.hoc081098:ViewBindingDelegate:1.4.0"
const val flowExt = "io.github.hoc081098:FlowExt:0.5.0-SNAPSHOT"
const val timber = "com.jakewharton.timber:timber:5.0.1"

object arrow {
Expand Down