RetrofitUrlManager Versions Save

🔮 Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).

v1.4.0

5 years ago

新增超级模式 (高级模式的加强版, 优先级高于高级模式), 让每一个 Url 都可以随意指定不同的 BaseUrl (PathSize 自己定) 作为被替换的基准, 使 RetrofitUrlManager 可以从容应对各种复杂的需求

超级模式也需要手动开启, 但与高级模式不同的是, 开启超级模式并不需要调用 API, 只需要在 Url 中加入 RetrofitUrlManager#IDENTIFICATION_PATH_SIZE + PathSize

  • 至此三种模式替换 BaseUrl 的自由程度 (可扩展性) 排名, 从小到大依次是: 普通模式 (只能替换域名) < 高级模式 (只能替换 RetrofitUrlManager#startAdvancedModel(String) 中传入的 BaseUrl) < 超级模式 (每个 Url 都可以随意指定可被替换的 BaseUrl, pathSize 随意变换)

  • 三种模式在使用上的复杂程度排名, 从小到大依次是: 普通模式 (无需做过多配置) < 高级模式 (App 初始化时调用一次 RetrofitUrlManager#startAdvancedModel(String) 即可) < 超级模式 (每个需要被替换 BaseUrl 的 Url 中都需要加入 RetrofitUrlManager#IDENTIFICATION_PATH_SIZE + PathSize)

  • 由此可见,自由度越强, 操作也越复杂, 所以可以根据自己的需求选择不同的模式, 并且也可以在需求变化时随意升级或降级这三种模式

  • 替换规则如下:

  1. 旧 URL 地址为 https://www.github.com/wiki/part#baseurl_path_size=1, #baseurl_path_size=1 表示其中 BaseUrl 为 https://www.github.com/wiki, 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com/api, 经过本解析器解析后生成的新 URL 地址为 http://www.google.com/api/part

  2. 旧 URL 地址为 https://www.github.com/wiki/part#baseurl_path_size=1, #baseurl_path_size=1 表示其中 BaseUrl 为 https://www.github.com/wiki, 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com, 经过本解析器解析后生成的新 URL 地址为 http://www.google.com/part

  3. 旧 URL 地址为 https://www.github.com/wiki/part#baseurl_path_size=0, #baseurl_path_size=0 表示其中 BaseUrl 为 https://www.github.com, 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com/api, 经过本解析器解析后生成的新 URL 地址为 http://www.google.com/api/wiki/part

  4. 旧 URL 地址为 https://www.github.com/wiki/part/issues/1#baseurl_path_size=3, #baseurl_path_size=3 表示其中 BaseUrl 为 https://www.github.com/wiki/part/issues, 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com/api, 经过本解析器解析后生成的新 URL 地址为 http://www.google.com/api/1

v1.3.0

5 years ago
  1. 优化框架健壮性
  2. 新增高级模式 (RetrofitUrlManager#startAdvancedModel(baseUrl) 开启高级模式) 以支持更复杂的 多级 BaseUrl 的替换
  • 应用场景如下:
  1. 旧 URL 地址为 https://www.github.com/wiki/part, 其中 BaseUrl 为 https://www.github.com/wiki 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com/api 经过本框架替换后生成的新 URL 地址为 http://www.google.com/api/part

  2. 旧 URL 地址为 https://www.github.com/wiki/part, 其中 BaseUrl 为 https://www.github.com/wiki 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com 经过本框架替换后生成的新 URL 地址为 http://www.google.com/part

  3. 旧 URL 地址为 https://www.github.com/wiki/part, 其中 BaseUrl 为 https://www.github.com 您调用 RetrofitUrlManager#putDomain(String, String) 方法传入的 URL 地址是 https://www.google.com/api 经过本框架替换后生成的新 URL 地址为 http://www.google.com/api/wiki/part

v1.2.5

6 years ago
  1. Add debug model
  2. Upgrade build-gradle to v3.1.0
  3. Upgrade some libraries
  4. Create setUrlNotChange(url)

v1.2.0

6 years ago

1.Upgrade AndroidSDK version to 27 and upgrade Okhttp version 2.Add IDENTIFICATION_IGNORE, Url add this identifier will not be changed BaseUrl

v1.1.0

6 years ago

1.Add onUrlChangeListener#onUrlChangeBefore(HttpUrl, String) 2.Upgrade AndroidSDK version to 26 and upgrade Okhttp version

v1.0.5

6 years ago

1.Make GlobalDomain