Skip to content

Commit faff799

Browse files
committed
增加中文文檔
Http傳輸紀錄儲存目錄位置更換
1 parent 5186e16 commit faff799

File tree

10 files changed

+520
-11
lines changed

10 files changed

+520
-11
lines changed

EasyHttp/src/main/java/com/jimmyworks/easyhttp/builder/RequestBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ open class RequestBuilder {
4747
private fun initOkHttpClientBuilder() {
4848
okHttpClientBuilder.cache(
4949
Cache(
50-
CommonUtils.getDiskCacheDir(
50+
CommonUtils.getCacheDir(
5151
context, EasyHttpConfig.CACHE_DIR_NAME
5252
),
5353
EasyHttpConfig.MAX_CACHE_SIZE

EasyHttp/src/main/java/com/jimmyworks/easyhttp/database/repository/HttpRecordRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class HttpRecordRepository(context: Context) {
2828
private val httpCookiesDAO: HttpCookiesDAO
2929

3030
private val requestDir: File =
31-
CommonUtils.getDiskCacheDir(context, EasyHttpConfig.REQUEST_DIR_NAME)
31+
CommonUtils.getDataDir(context, EasyHttpConfig.REQUEST_DIR_NAME)
3232
private val responseDir: File =
33-
CommonUtils.getDiskCacheDir(context, EasyHttpConfig.RESPONSE_DIR_NAME)
33+
CommonUtils.getDataDir(context, EasyHttpConfig.RESPONSE_DIR_NAME)
3434

3535
init {
3636
val db: HttpRecordDatabase = HttpRecordDatabase.getDatabase(context)

EasyHttp/src/main/java/com/jimmyworks/easyhttp/fragment/EasyHttpRecordRequestFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class EasyHttpRecordRequestFragment : Fragment() {
4545
private fun initData() {
4646
val httpRecordRepository = HttpRecordRepository(requireContext())
4747
val requestDir: File =
48-
CommonUtils.getDiskCacheDir(requireContext(), EasyHttpConfig.REQUEST_DIR_NAME)
48+
CommonUtils.getDataDir(requireContext(), EasyHttpConfig.REQUEST_DIR_NAME)
4949

5050
httpRecordRepository
5151
.findRequestHeadersByRecordId(recordId)

EasyHttp/src/main/java/com/jimmyworks/easyhttp/fragment/EasyHttpRecordResponseFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EasyHttpRecordResponseFragment : Fragment() {
4747
private fun initData() {
4848
val httpRecordRepository = HttpRecordRepository(requireContext())
4949
val responseDir: File =
50-
CommonUtils.getDiskCacheDir(requireContext(), EasyHttpConfig.RESPONSE_DIR_NAME)
50+
CommonUtils.getDataDir(requireContext(), EasyHttpConfig.RESPONSE_DIR_NAME)
5151
httpRecordRepository
5252
.findResponseHeadersByRecordId(recordId)
5353
.observe(viewLifecycleOwner) { headerList ->

EasyHttp/src/main/java/com/jimmyworks/easyhttp/service/SaveRecordService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class SaveRecordService(
2727
) {
2828
private val httpRecordRepository: HttpRecordRepository = HttpRecordRepository(context)
2929
private val requestDir: File =
30-
CommonUtils.getDiskCacheDir(context, EasyHttpConfig.REQUEST_DIR_NAME)
30+
CommonUtils.getDataDir(context, EasyHttpConfig.REQUEST_DIR_NAME)
3131
private val responseDir: File =
32-
CommonUtils.getDiskCacheDir(context, EasyHttpConfig.RESPONSE_DIR_NAME)
32+
CommonUtils.getDataDir(context, EasyHttpConfig.RESPONSE_DIR_NAME)
3333

3434
init {
3535
if (!requestDir.exists()) {

EasyHttp/src/main/java/com/jimmyworks/easyhttp/utils/CommonUtils.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,18 @@ class CommonUtils {
4242
* @param dirName 目錄名稱
4343
* @return 快取目錄
4444
*/
45-
fun getDiskCacheDir(context: Context, dirName: String): File {
45+
fun getDataDir(context: Context, dirName: String): File {
46+
return File(context.dataDir, dirName)
47+
}
48+
49+
/**
50+
* 取得快取目錄
51+
*
52+
* @param context Context
53+
* @param dirName 目錄名稱
54+
* @return 快取目錄
55+
*/
56+
fun getCacheDir(context: Context, dirName: String): File {
4657
return File(context.cacheDir, dirName)
4758
}
4859

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Android Easy Http Library
22
<img src="images/banner.png" />
33

4+
[繁體中文文檔](README_ZH.md)
5+
46
## About Android Easy Http Library
57

68
* Made on [OkHttp](http://square.github.io/okhttp/).
@@ -21,7 +23,7 @@ android {
2123
}
2224
2325
dependencies {
24-
implementation 'io.github.af19git5:easy-http-android:0.0.2'
26+
implementation 'io.github.af19git5:easy-http-android:0.0.3'
2527
}
2628
```
2729

@@ -491,3 +493,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
491493
See the License for the specific language governing permissions and
492494
limitations under the License.
493495
```
496+

0 commit comments

Comments
 (0)