|
|
|
@ -17,6 +17,8 @@
|
|
|
|
|
package com.google.samples.apps.nowinandroid
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
|
import android.content.pm.ApplicationInfo
|
|
|
|
|
import android.os.StrictMode
|
|
|
|
|
import coil.ImageLoader
|
|
|
|
|
import coil.ImageLoaderFactory
|
|
|
|
|
import com.google.samples.apps.nowinandroid.sync.initializers.Sync
|
|
|
|
@ -37,10 +39,25 @@ class NiaApplication : Application(), ImageLoaderFactory {
|
|
|
|
|
|
|
|
|
|
override fun onCreate() {
|
|
|
|
|
super.onCreate()
|
|
|
|
|
|
|
|
|
|
// Kill NiA if there are main thread policy violations and log the offending call.
|
|
|
|
|
if (isDebuggable()) {
|
|
|
|
|
StrictMode.setThreadPolicy(
|
|
|
|
|
StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build(),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize Sync; the system responsible for keeping data in the app up to date.
|
|
|
|
|
Sync.initialize(context = this)
|
|
|
|
|
profileVerifierLogger()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun newImageLoader(): ImageLoader = imageLoader.get()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the application is debuggable.
|
|
|
|
|
*/
|
|
|
|
|
private fun isDebuggable(): Boolean {
|
|
|
|
|
return 0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|