Remove Flipper
This commit is contained in:
@@ -181,12 +181,6 @@ dependencies {
|
||||
|
||||
testImplementation "io.mockk:mockk:$mockk_version"
|
||||
|
||||
debugImplementation "com.facebook.flipper:flipper:$flipper_version"
|
||||
debugImplementation "com.facebook.flipper:flipper-leakcanary2-plugin:$flipper_version"
|
||||
debugImplementation "com.facebook.flipper:flipper-network-plugin:$flipper_version"
|
||||
|
||||
debugImplementation "com.facebook.soloader:soloader:$soloader_version"
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
|
||||
|
||||
// https://github.com/ChuckerTeam/chucker/releases
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
package gq.kirmanak.mealient
|
||||
|
||||
import android.app.Application
|
||||
import com.facebook.flipper.android.AndroidFlipperClient
|
||||
import com.facebook.flipper.android.utils.FlipperUtils
|
||||
import com.facebook.flipper.core.FlipperPlugin
|
||||
import com.facebook.soloader.SoLoader
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltAndroidApp
|
||||
class App : Application() {
|
||||
// Use @JvmSuppressWildcards because otherwise dagger can't inject it (https://stackoverflow.com/a/43149382)
|
||||
@Inject
|
||||
lateinit var flipperPlugins: Set<@JvmSuppressWildcards FlipperPlugin>
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
Timber.plant(Timber.DebugTree())
|
||||
Timber.v("onCreate() called")
|
||||
setupFlipper()
|
||||
}
|
||||
|
||||
private fun setupFlipper() {
|
||||
if (FlipperUtils.shouldEnableFlipper(this)) {
|
||||
SoLoader.init(this, false)
|
||||
val flipperClient = AndroidFlipperClient.getInstance(this)
|
||||
for (flipperPlugin in flipperPlugins) flipperClient.addPlugin(flipperPlugin)
|
||||
flipperClient.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,6 @@ import android.content.Context
|
||||
import com.chuckerteam.chucker.api.ChuckerCollector
|
||||
import com.chuckerteam.chucker.api.ChuckerInterceptor
|
||||
import com.chuckerteam.chucker.api.RetentionManager
|
||||
import com.facebook.flipper.core.FlipperPlugin
|
||||
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin
|
||||
import com.facebook.flipper.plugins.inspector.DescriptorMapping
|
||||
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin
|
||||
import com.facebook.flipper.plugins.leakcanary2.FlipperLeakListener
|
||||
import com.facebook.flipper.plugins.leakcanary2.LeakCanary2FlipperPlugin
|
||||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor
|
||||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin
|
||||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
@@ -20,7 +11,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import dagger.multibindings.IntoSet
|
||||
import gq.kirmanak.mealient.BuildConfig
|
||||
import leakcanary.LeakCanary
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import timber.log.Timber
|
||||
@@ -55,46 +45,4 @@ object DebugModule {
|
||||
.alwaysReadResponseBody(true)
|
||||
.build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun provideFlipperInterceptor(networkFlipperPlugin: NetworkFlipperPlugin): Interceptor {
|
||||
return FlipperOkhttpInterceptor(networkFlipperPlugin)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun networkFlipperPlugin() = NetworkFlipperPlugin()
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun bindNetworkFlipperPlugin(plugin: NetworkFlipperPlugin): FlipperPlugin = plugin
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun sharedPreferencesPlugin(@ApplicationContext context: Context): FlipperPlugin =
|
||||
SharedPreferencesFlipperPlugin(context)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun leakCanaryPlugin(): FlipperPlugin {
|
||||
LeakCanary.config = LeakCanary.config.copy(onHeapAnalyzedListener = FlipperLeakListener())
|
||||
return LeakCanary2FlipperPlugin()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun databasesPlugin(@ApplicationContext context: Context): FlipperPlugin =
|
||||
DatabasesFlipperPlugin(context)
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IntoSet
|
||||
fun inspectorPlugin(@ApplicationContext context: Context): FlipperPlugin =
|
||||
InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user