Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.16 KB

README.md

File metadata and controls

42 lines (33 loc) · 1.16 KB

NetLog

Create a singleton repository instance. Example:

import android.app.Application
import ru.mertsalovda.netlog.interceptor.INetLogRepository
import ru.mertsalovda.netlog.repository.NetLogRepositoryImpl

class App : Application() {

    companion object {
        lateinit var netLogRepository: INetLogRepository
    }

    override fun onCreate() {
        super.onCreate()
        netLogRepository = NetLogRepositoryImpl()
    }
}

Create and add an interceptor to your OkHttpClient

   fun provideOkHttpClient(): OkHttpClient {
        return OkHttpClient.Builder()
                   .addInterceptor(NetLogInterceptor(App.netLogRepository))
                   .build()
    }

Create an instance of a NetLogDialogFragment and pass it a link to the repository with logs. Call the show method.

    NetLogDialogFragment.newInstance(App.netLogRepository).show(supportFragmentManager, "NetLog")