-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor OkHttpUtil #6
Comments
In GitLab by @in_in_mm on Nov 5, 2020, 00:35 changed the description |
In GitLab by @in_in_mm on Nov 5, 2020, 00:39 大家如果有想到什麼問題或是必須要確保的功能在幫我補充上去,感謝! |
In GitLab by @in_in_mm on Nov 5, 2020, 00:40 marked this issue as related to #1 |
In GitLab by @wesely.ong on Nov 5, 2020, 10:34 認同,使用 new Cache(
new File(MyApplication.application.cacheDir, "normal_cache_name"),
NORMAL_CACHE_SIZE
) |
In GitLab by @TakumaLee on Nov 5, 2020, 13:33 基本上同意直接 Application 建立 client,不過如果沒有切換或多個 custom client 的必要的話其實就一個全域 client 也行 |
In GitLab by @HsuHsiaoHsuan on Nov 5, 2020, 13:48 @in_in_mm 根據不同 api 改變 timeout 也許可以放在 interceptor。 https://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html |
In GitLab by @kenhuang1120 on Nov 5, 2020, 15:27 有在考慮使用Retrofit |
In GitLab by @HsuHsiaoHsuan on Nov 5, 2020, 17:12 感覺現在就可以去掉 context:
|
In GitLab by @in_in_mm on Nov 5, 2020, 17:39 我分成兩段:
|
In GitLab by @HsuHsiaoHsuan on Nov 5, 2020, 23:55
|
In GitLab by @PichuChen on Nov 6, 2020, 00:58 Websocket 的部分可以另外使用其他 library, 雖然我現在習慣是用MQTT or Event-Stream |
In GitLab by @in_in_mm on Nov 6, 2020, 09:22 那這樣看用 Retrofit 應該不會有什麼問題 |
In GitLab by @in_in_mm on Nov 16, 2020, 00:02 mentioned in merge request !17 |
現在先簡單實作一個 Client 在 DI module 裡面 |
In GitLab by @in_in_mm on Nov 5, 2020, 00:33
OkhttpClient 連結在這
可能需要重新設計一下取得
OkhttpClient
的方式,下面列出需求及目前遇到的問題。需求
檢查不合法的 URL
每個 link 可能有不同 timeout 跟 cache cookie
以後要有的 check/refresh AccessToken 機制
可能會有的 Link Preview 功能
問題
OkhttpClient
還是會有反覆創建的問題 (基本上 api instance 保留在 Fragment),這樣做有 leak 的風險,我自己之前的做法是讓OkhttpClient
保持單例,原因:docOkhttpClient
的方法有使用到context
,這邊要解耦一下OkhttpClient
的設定,ex:根據不同的 request 改 timeout、interceptor 等等,這邊提出可能的作法The text was updated successfully, but these errors were encountered: