X Tutup
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Integrate Network Plugin in your application

Network.API.calls.Demo.webm

Add Gradle Dependencies

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-op variant to isolate the plugin from release builds.

dependencies {
  debugImplementation "com.androidpluto.plugins:network:$plutoVersion"
  releaseImplementation "com.androidpluto.plugins:network-no-op:$plutoVersion"
}

Install plugin to Pluto

Now to start using the plugin, add it to Pluto

Pluto.Installer(this)
  .addPlugin(PlutoNetworkPlugin())
  .install()


Add interceptors

1. Okhttp Interceptor

Add interceptor in your OkHttp Client Builder

val client = OkHttpClient.Builder()
  .addInterceptor(PlutoOkhttpInterceptor)
  .build()

2. Ktor Interceptor

Add interceptor in your HttpClient

val client = HttpClient {
    install(PlutoKtorInterceptor)
}

3. Custom Interceptor

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.


Open Plugin view programmatically

To open Network plugin screen via code, use this

Pluto.open(PlutoNetworkPlugin.ID)

X Tutup