Commit 220b3111 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add timber, picasso, crashlytics

parent ad2d80ea
......@@ -79,6 +79,17 @@ dependencies {
//Constraint Layout
implementation "androidx.constraintlayout:constraintlayout:$constrainLayoutVersion"
//image loading store and cashe by url: Picasso
implementation "com.squareup.picasso:picasso:$picassoVersion"
//Logger: Timber
implementation "com.jakewharton.timber:timber:$timberVersion"
//Crashlytics
implementation('com.crashlytics.sdk.android:crashlytics:2.10.0@aar') {
transitive = true;
}
//Tests
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
......
package com.biganto.visual.roompark.base
import android.app.Application
import android.util.Log
import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.di.koin.initDI
import com.crashlytics.android.Crashlytics
import com.squareup.picasso.Picasso
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 03.09.2019.
......@@ -11,6 +16,37 @@ class RoomParkApplication : Application() {
override fun onCreate() {
super.onCreate()
initDI()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
else Timber.plant(CrashlyticsTree())
val picassoBuilder = Picasso.Builder(this)
picassoBuilder.listener { _, uri, exception ->
Timber.e(exception)
Timber.e(exception, "PICASSO url = %s", uri.toString())
}
// Picasso.Builder creates the Picasso object to do the actual requests
val picasso = picassoBuilder.build()
try {
Picasso.setSingletonInstance(picasso)
} catch (ignored: IllegalStateException) {
Timber.e(ignored, "PICASSO")
// Picasso instance was already set
// cannot set it after Picasso.with(Context) was already in use
}
}
}
private class CrashlyticsTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, throwable: Throwable?) {
if (priority == Log.VERBOSE || priority == Log.DEBUG) return
Crashlytics.log(priority, tag, message)
throwable?.let { Crashlytics.logException(it) }
}
}
\ No newline at end of file
......@@ -16,4 +16,7 @@ ext {
materialVersion = '1.1.0-alpha09'
gradleVersion = '3.5.0'
koinVersion = '2.0.1'
timberVersion = '4.7.1'
picassoVersion = '2.5.2'
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment