This repository was archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
This repository was archived by the owner on Nov 8, 2018. It is now read-only.
Cancel request in java #10
Copy link
Copy link
Open
Description
@jaychang0917 Hi, thanks your library, I am using java in SimpleApiClient
, if I want to manually cancel network request or enable autoCancel, using java, How should I modify it? Thank you.
Activity(java)
GoogleApi.Companion.create().getWebFonts()
.subscribe(new Observer<WebFonts>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(WebFonts webFonts) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
Api(kotlin)
class GoogleApiResult<T : Any> : SimpleApiResult<T> {
@SerializedName("items")
override lateinit var result: T
}
class GoogleApiError : SimpleApiError {
@SerializedName("message")
override lateinit var message: String
}
interface GoogleApi {
companion object {
private val parameters: MutableMap<String, String> = mutableMapOf()
fun create(): GoogleApi = SimpleApiClient.create {
parameters["key"] = ""
baseUrl = "https://www.googleapis.com"
errorMessageKeyPath = "error.message"
defaultParameters = parameters
defaultHeaders = mapOf()
connectTimeout = TimeUnit.MINUTES.toMillis(1)
readTimeout = TimeUnit.MINUTES.toMillis(1)
writeTimeout = TimeUnit.MINUTES.toMillis(1)
isStethoEnabled = true // default: true
logLevel = LogLevel.BASIC // default: NONE
isMockResponseEnabled = true // default: false
jsonParser = GsonParser() // default: GsonParser
errorHandler = { error ->
when (error) {
is AuthenticationError -> {
}
is ClientError -> {
}
is ServerError -> {
}
is NetworkError -> {
}
is SSLError -> {
}
}
}
}
}
@GET("/webfonts/v1/webfonts")
fun getWebFonts(): Observable<WebFonts>
}
Metadata
Metadata
Assignees
Labels
No labels