From 248778471200c66c0108599338f5fee09ddce5ce Mon Sep 17 00:00:00 2001 From: zeropercenthappy Date: Wed, 19 Dec 2018 10:43:00 +0800 Subject: [PATCH] update dependencies lib. add some const and @JvmStatic --- README.md | 2 +- build.gradle | 2 +- retrofitLib/build.gradle | 6 +++--- .../zeropercenthappy/retrofitutil/CookieManager.kt | 11 ++++++++--- .../retrofitutil/RequestBodyBuilder.kt | 4 +++- .../zeropercenthappy/retrofitutil/RetrofitConfig.kt | 2 ++ sample/build.gradle | 4 ++-- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1b0117c..49462bb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Step 2. Add the dependency ``` dependencies { - implementation 'com.github.zeropercenthappy:RetrofitUtils:1.0.2' + implementation 'com.github.zeropercenthappy:RetrofitUtils:1.0.3' } ``` diff --git a/build.gradle b/build.gradle index 5f0107e..729cc45 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext.android_support_version = '28.0.0' - ext.kotlin_version = '1.3.0' + ext.kotlin_version = '1.3.11' ext.anko_version = '0.10.7' ext.glide_version = '4.7.1' ext.retrofit_version = '2.4.0' diff --git a/retrofitLib/build.gradle b/retrofitLib/build.gradle index 95ce86b..2c00b9f 100644 --- a/retrofitLib/build.gradle +++ b/retrofitLib/build.gradle @@ -11,7 +11,7 @@ android { minSdkVersion 19 targetSdkVersion 28 versionCode 3 - versionName "1.0.2" + versionName "1.0.3" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -37,10 +37,10 @@ dependencies { androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.1.2' + implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.1.5' api "com.squareup.retrofit2:retrofit:$retrofit_version" api "com.squareup.retrofit2:converter-gson:$retrofit_version" - api 'com.squareup.okhttp3:logging-interceptor:3.4.1' + api 'com.squareup.okhttp3:logging-interceptor:3.8.0' } task sourcesJar(type: Jar) { diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt index b631e1b..3f96f56 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt @@ -5,15 +5,17 @@ import android.text.TextUtils import retrofit2.Response object CookieManager { - const val CONSTANT_SET_COOKIE = "Set-Cookie" - const val CONSTANT_COOKIE = "Cookie" + const val CONSTANT_SET_COOKIE = "Set-Cookie" + const val CONSTANT_COOKIE = "Cookie" + @JvmStatic fun getCookie(context: Context): String { context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE).run { - return getString(CONSTANT_COOKIE, "") + return getString(CONSTANT_COOKIE, "") ?: "" } } + @JvmStatic private fun setCookie(context: Context, cookie: String) { context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE).edit().run { putString(CONSTANT_COOKIE, cookie) @@ -21,6 +23,7 @@ object CookieManager { } } + @JvmStatic fun updateCookie(context: Context, response: Response<*>) { response.headers()?.get(CONSTANT_SET_COOKIE)?.run { if (!TextUtils.isEmpty(this)) { @@ -29,6 +32,7 @@ object CookieManager { } } + @JvmStatic fun updateCookie(context: Context, response: okhttp3.Response) { response.headers().get(CONSTANT_SET_COOKIE)?.run { if (!TextUtils.isEmpty(this)) { @@ -37,6 +41,7 @@ object CookieManager { } } + @JvmStatic fun updateCookie(context: Context, cookie: String) { if (TextUtils.isEmpty(cookie)) { setCookie(context, cookie) diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt index bedcff6..44a5914 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt @@ -1,16 +1,18 @@ package com.zeropercenthappy.retrofitutil -import com.zeropercenthappy.utilslibrary.FileUtils +import com.zeropercenthappy.utilslibrary.utils.FileUtils import okhttp3.MediaType import okhttp3.MultipartBody import okhttp3.RequestBody import java.io.File object RequestBodyBuilder { + @JvmStatic fun createText(value: String): RequestBody { return RequestBody.create(MediaType.parse(ContentType.TEXT.value), value) } + @JvmStatic fun createMultipartBodyPartList(fileMap: Map): List { val partList = arrayListOf() for (key in fileMap.keys) { diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitConfig.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitConfig.kt index 27d1fdc..ff8492e 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitConfig.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitConfig.kt @@ -6,9 +6,11 @@ object RetrofitConfig { /** * true or false */ + @JvmStatic var DEBUG_MODE = false /** * [HttpLoggingInterceptor.Level] */ + @JvmStatic var LOG_LEVEL = HttpLoggingInterceptor.Level.BODY } \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 11dbafd..0043750 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -28,7 +28,7 @@ dependencies { implementation "com.android.support:design:$android_support_version" implementation "com.android.support:cardview-v7:$android_support_version" - implementation 'com.android.support.constraint:constraint-layout:1.1.2' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' @@ -37,5 +37,5 @@ dependencies { implementation('com.yanzhenjie:album:2.0.2') { exclude group: 'com.android.support' } - implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.1.2' + implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.1.5' }