Network.API.calls.Demo.webm
Pluto Network is distributed through mavenCentral. To use it, you need to add the following Gradle dependency to your build.gradle file of you android app module.
Note: add the
no-opvariant to isolate the plugin from release builds.
dependencies {
debugImplementation "com.androidpluto.plugins:network:$plutoVersion"
releaseImplementation "com.androidpluto.plugins:network-no-op:$plutoVersion"
}Now to start using the plugin, add it to Pluto
Pluto.Installer(this)
.addPlugin(PlutoNetworkPlugin())
.install()Add interceptor in your OkHttp Client Builder
val client = OkHttpClient.Builder()
.addInterceptor(PlutoOkhttpInterceptor)
.build()Add interceptor in your HttpClient
val client = HttpClient {
install(PlutoKtorInterceptor)
}If you wish to use any interceptor, other than Okhttp or Ktor, Pluto provides way to capture network logs.
/* create interceptor */
val networkInterceptor = NetworkInterceptor.intercept(
NetworkData.Request(....),
NetworkInterceptor.Option()
)
/**
* wait for the network call to complete
**/
/* if error */
networkInterceptor.onError(exception)
/* if success */
networkInterceptor.onResponse(
NetworkData.Response(....)
)🎉 You are all done!
Now re-build and run your app and open Pluto, you will see the Network plugin installed.
To open Network plugin screen via code, use this
Pluto.open(PlutoNetworkPlugin.ID)