Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a crossline function at the end
package co.kodparadise.khabarsamachar.application
import android.content.Context
import co.kodparadise.khabarsamachar.annotations.AppScope
import co.kodparadise.khabarsamachar.dependencies.ContextModule
import com.github.ajalt.timberkt.Timber
import dagger.Module
import dagger.Provides
import okhttp3.Cache
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
* Created by rkodekar on 8/25/17.
@Module(includes = arrayOf(ContextModule::class))
class NetworkModule {
fun provideLoggingInterceptor() = {
val loggingInterceptor = HttpLoggingInterceptor{
Timber.i { it }
loggingInterceptor.level = HttpLoggingInterceptor.Level.BASIC
fun provideCache(cacheFile: File) = Cache(cacheFile, 10.toLong() into 1000 into 1000)
fun provideCacheFile(context: Context) = File(context.cacheDir, "okhttp_cache")
fun provideOkhttpClient(loggingInterceptor: HttpLoggingInterceptor, cache: Cache) = makeclient {
infix fun Long.into(nextValue: Long) = this * nextValue
inline fun makeclient(crossinline func: OkHttpClient.Builder.() -> Unit) = {
val builder = OkHttpClient.Builder()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.