Android network request framework -- use of Retrofit

stay Android network request framework - Retrofit (dynamic agent mode) This section mainly introduces the use of Retrofit. 1. Advantages of retrofit API is simple, annotation is highly decoupled, multiple parsers are supported, and RxJava is supported. 2. use After introducing these advantages of Retrof ...

Posted on Thu, 06 Feb 2020 08:43:19 -0500 by pkellum

Android network request library RetrofitUtils

RetrofitUtils GitHub address, give Star a hand Project introduction It is a simple encapsulation of Retrofit+Okhttp auxiliary class. vesion 1.0.X implements Get, post form and post JSON There are three forms of network requests, and the subsequent versions will realize file upload and download and various raw requests. function Get Post form P ...

Posted on Fri, 31 Jan 2020 05:10:31 -0500 by lizzardnub

Error/Loading processing when using Retrofit+LiveData

At present, there are many projects that use Retrofit2+LiveData for API requests. Unlike RxJava, LiveData can easily process Error. Therefore, we want to encapsulate a tool class based on LiveData to uniformly process Error/Loading in API requests HttpManager open class HttpManager<T>(context ...

Posted on Wed, 29 Jan 2020 11:12:25 -0500 by burnside

Retrofit quick learning

Content mapping 1. Dependency library import implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' 2. Basic use 2.1 define request interface import hq.demo.net.model.WeatherBeans; import retrofit2.Call; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; ...

Posted on Thu, 02 Jan 2020 07:29:30 -0500 by sonofsam

Interpretation of OKHttp Source Code

Interpretation of OKHttp Source Code Key objectives of this sharing 1. Approximate process interpretation, synchronous process, asynchronous process 2.Interceptor Brief Reading 1. Simple use of OKHttp private String get(String url) throws IOException { Request request = new Request.Builder() .url(url) ...

Posted on Sat, 28 Dec 2019 23:50:20 -0500 by mrmom

android retrofit separately processes the return status code 204 and uniformly processes special return codes such as 401

The return status code, such as 401, generally indicates that the identity is invalid, such as the token is invalid. At this time, you need to call the interface to refresh the token, It's impossible to refresh every interface request callback. If an APP has hundreds of interfaces, wouldn't it be troublesome? How can retrofit ...

Posted on Thu, 26 Dec 2019 16:16:34 -0500 by yapyapayap

Retrofit docking with RxJava and OKhttp

Retrofit is an intermediate link in the whole network request architecture (Rxjava+Retrofit+OKhttp). The asynchronous decoupling layer is Rxjava, and the network request layer is OKhttp. How does Retrofit connect with the two? I'm a rookie. I'd like to write down my understanding here. If there is anything unreasonable, please ...

Posted on Sun, 22 Dec 2019 11:03:33 -0500 by Petrushka

Retrofit source code analysis

## Retrofit source code analysis ###Retrofit is the wrapper class of okhttp. All network requests are processed by okhttp. ####1. Initialize Retrofit #Retrofit public Retrofit build() { if (baseUrl == null) { throw new IllegalStateException("Base URL required."); } //If OkHttpClient is not set, a okhttp3.Ca ...

Posted on Mon, 16 Dec 2019 13:15:56 -0500 by yelvington

Retrofit easy to use

A simple and complete network request processing 0. Pre work: add dependency and permission retrofit github     Official document of retrofit retrofit depends on: implementation 'com.squareup.retrofit2:retrofit:2.4.0' gson github gson relies on: implementation 'com.google.code.gson:gson:2.8.5' Network permissions: ...

Posted on Fri, 13 Dec 2019 10:09:07 -0500 by dansk

Android OkHttp + Retrofit method to cancel the request

Link in this article Preface In a certain interface, the user initiates a network request. For some reason, the user leaves the current interface before the network request is completed. A better way is to cancel the network request. For OkHttp, it is specifically to Call the cancel method of Call. How can I find this network request and ca ...

Posted on Sat, 19 Oct 2019 07:58:05 -0400 by lucerias