From 2d91454343cf8ab17dcb821d0f47834018519d5b Mon Sep 17 00:00:00 2001 From: zeropercenthappy Date: Wed, 9 Oct 2019 14:52:23 +0800 Subject: [PATCH] 1.0.7 --- README.md | 2 +- build.gradle | 8 +- gradlew | 0 retrofitLib/build.gradle | 19 ++- .../retrofitutil/CookieManager.kt | 2 +- .../retrofitutil/DefaultInterceptor.kt | 16 ++- .../retrofitutil/RequestBodyBuilder.kt | 8 +- .../retrofitutil/RetrofitBuilder.kt | 47 ++++++-- sample/build.gradle | 18 ++- .../retrofitutilsample/MainActivity.kt | 109 ++++++++++-------- .../retrofitutilsample/api/IKalleApi.kt | 5 +- .../retrofitutilsample/api/KalleUrl.kt | 2 +- sample/src/main/res/values/strings.xml | 2 +- 13 files changed, 131 insertions(+), 107 deletions(-) mode change 100644 => 100755 gradlew diff --git a/README.md b/README.md index c0b29ad..670047c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Step 2. Add the dependency ``` dependencies { - implementation 'com.github.zeropercenthappy:RetrofitUtils:1.0.6' + implementation 'com.github.zeropercenthappy:RetrofitUtils:1.0.7' } ``` diff --git a/build.gradle b/build.gradle index 802ff82..f3ec2d4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,16 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.android_support_version = '27.1.1' - ext.kotlin_version = '1.3.41' + ext.android_support_version = '28.0.0' + ext.kotlin_version = '1.3.50' ext.anko_version = '0.10.8' - ext.retrofit_version = '2.4.0' + ext.retrofit_version = '2.6.2' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/retrofitLib/build.gradle b/retrofitLib/build.gradle index a8f918e..019f92f 100644 --- a/retrofitLib/build.gradle +++ b/retrofitLib/build.gradle @@ -5,13 +5,13 @@ apply plugin: 'com.github.dcendents.android-maven' group = 'com.github.zeropercenthappy' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { minSdkVersion 14 - targetSdkVersion 27 - versionCode 106 - versionName "1.0.6" + targetSdkVersion 28 + versionCode 107 + versionName "1.0.7" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -30,17 +30,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1" - implementation "org.jetbrains.anko:anko:$anko_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0" - 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' - - implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.2.1' + implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.2.2' api "com.squareup.retrofit2:retrofit:$retrofit_version" api "com.squareup.retrofit2:converter-gson:$retrofit_version" - api 'com.squareup.okhttp3:logging-interceptor:3.8.0' + api 'com.squareup.okhttp3:logging-interceptor:4.2.1' api 'me.jessyan:progressmanager:1.5.0' } diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt index 3f96f56..9436229 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/CookieManager.kt @@ -34,7 +34,7 @@ object CookieManager { @JvmStatic fun updateCookie(context: Context, response: okhttp3.Response) { - response.headers().get(CONSTANT_SET_COOKIE)?.run { + response.headers[CONSTANT_SET_COOKIE]?.run { if (!TextUtils.isEmpty(this)) { setCookie(context, this) } diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/DefaultInterceptor.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/DefaultInterceptor.kt index d1c93d5..228f2f6 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/DefaultInterceptor.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/DefaultInterceptor.kt @@ -38,10 +38,9 @@ class DefaultInterceptor(private var context: Context, private val handleCookie: } private fun addExtraParam(request: Request): Request { - val method = request.method() - when (method) { + when (request.method) { "GET", "get" -> { - val httpUrlBuilder = request.url().newBuilder() + val httpUrlBuilder = request.url.newBuilder() for (key in extraParamMap.keys) { val value = extraParamMap[key] if (value != null && value != "") { @@ -52,13 +51,12 @@ class DefaultInterceptor(private var context: Context, private val handleCookie: return request.newBuilder().url(newHttpUrl).build() } "POST", "post" -> { - val requestBody = request.body() - when (requestBody) { + when (val requestBody = request.body) { is FormBody -> { //FormBody val formBodyBuilder = FormBody.Builder() //原参数 - for (i in 0 until requestBody.size()) { + for (i in 0 until requestBody.size) { formBodyBuilder.addEncoded(requestBody.encodedName(i), requestBody.encodedValue(i)) } //新参数 @@ -70,7 +68,7 @@ class DefaultInterceptor(private var context: Context, private val handleCookie: } val formBody = formBodyBuilder.build() return request.newBuilder() - .method(request.method(), formBody) + .method(request.method, formBody) .build() } is MultipartBody -> { @@ -78,7 +76,7 @@ class DefaultInterceptor(private var context: Context, private val handleCookie: val builder = MultipartBody.Builder() builder.setType(MultipartBody.FORM) //原参数 - for (part in requestBody.parts()) { + for (part in requestBody.parts) { builder.addPart(part) } //新参数 @@ -90,7 +88,7 @@ class DefaultInterceptor(private var context: Context, private val handleCookie: } val multipartBody = builder.build() return request.newBuilder() - .method(request.method(), multipartBody) + .method(request.method, multipartBody) .build() } else -> return request diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt index c33c149..339fc93 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RequestBodyBuilder.kt @@ -1,7 +1,7 @@ package com.zeropercenthappy.retrofitutil import com.zeropercenthappy.utilslibrary.utils.FileUtils -import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody import okhttp3.RequestBody import java.io.File @@ -9,7 +9,7 @@ import java.io.File object RequestBodyBuilder { @JvmStatic fun createText(value: String): RequestBody { - return RequestBody.create(MediaType.parse(ContentType.TEXT.value), value) + return RequestBody.create(ContentType.TEXT.value.toMediaTypeOrNull(), value) } @JvmStatic @@ -20,7 +20,7 @@ object RequestBodyBuilder { file?.apply { val mimeType = FileUtils.getFileMimeType(file) mimeType?.apply { - val requestBody = RequestBody.create(MediaType.parse(mimeType), file) + val requestBody = RequestBody.create(mimeType.toMediaTypeOrNull(), file) val part = MultipartBody.Part.createFormData(key, file.name, requestBody) partList.add(part) } @@ -31,6 +31,6 @@ object RequestBodyBuilder { @JvmStatic fun createJson(value: String): RequestBody { - return RequestBody.create(MediaType.parse(ContentType.JSON.value), value) + return RequestBody.create(ContentType.JSON.value.toMediaTypeOrNull(), value) } } \ No newline at end of file diff --git a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitBuilder.kt b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitBuilder.kt index af6e626..a0bb3b7 100644 --- a/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitBuilder.kt +++ b/retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/RetrofitBuilder.kt @@ -6,6 +6,8 @@ import me.jessyan.progressmanager.ProgressManager import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.CallAdapter +import retrofit2.Converter import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.* @@ -21,6 +23,8 @@ class RetrofitBuilder { private var readTimeoutMs: Long = 10_000 private var writeTimeoutMs: Long = 10_000 private val okHttpClientBuilder = ProgressManager.getInstance().with(OkHttpClient.Builder()) + private val converterFactoryList = arrayListOf() + private val callAdapterFactoryList = arrayListOf() fun baseUrl(baseUrl: String): RetrofitBuilder { this.baseUrl = baseUrl @@ -68,22 +72,22 @@ class RetrofitBuilder { } fun addInterceptors(interceptorList: List): RetrofitBuilder { - this.extraInterceptorList.addAll(interceptorList) + extraInterceptorList.addAll(interceptorList) return this } fun connectTimeout(ms: Long): RetrofitBuilder { - this.connectTimeoutMs = ms + connectTimeoutMs = ms return this } fun readTimeoutMs(ms: Long): RetrofitBuilder { - this.readTimeoutMs = ms + readTimeoutMs = ms return this } fun writeTimeoutSec(ms: Long): RetrofitBuilder { - this.writeTimeoutMs = ms + writeTimeoutMs = ms return this } @@ -92,6 +96,16 @@ class RetrofitBuilder { return this } + fun addConverterFactory(factory: Converter.Factory): RetrofitBuilder { + converterFactoryList.add(factory) + return this + } + + fun addCallAdapterFactory(factory: CallAdapter.Factory): RetrofitBuilder { + callAdapterFactoryList.add(factory) + return this + } + fun build(context: Context): Retrofit { //检测baseUrl if (TextUtils.isEmpty(baseUrl)) { @@ -100,8 +114,8 @@ class RetrofitBuilder { throw Exception("base url must end with /") } // 默认Interceptor - val defaultInterceptor = DefaultInterceptor(context.applicationContext, handleCookie, - extraParamMap, extraHeaderMap) + val defaultInterceptor = + DefaultInterceptor(context.applicationContext, handleCookie, extraParamMap, extraHeaderMap) extraInterceptorList.add(0, defaultInterceptor) // LogInterceptor if (RetrofitConfig.DEBUG_MODE) { @@ -118,11 +132,20 @@ class RetrofitBuilder { readTimeout(readTimeoutMs, TimeUnit.MILLISECONDS) writeTimeout(writeTimeoutMs, TimeUnit.MILLISECONDS) }.build() - - return Retrofit.Builder() - .baseUrl(baseUrl) - .addConverterFactory(GsonConverterFactory.create()) - .client(okHttpClient) - .build() + // 默认ConverterAdapterFactory,使用GsonConverterFactory + converterFactoryList.add(0, GsonConverterFactory.create()) + // 默认CallAdapterFactory,暂不配置 + + // 构造Retrofit + val builder = Retrofit.Builder() + builder.baseUrl(baseUrl) + builder.client(okHttpClient) + for (factory in converterFactoryList) { + builder.addConverterFactory(factory) + } + for (factory in callAdapterFactoryList) { + builder.addCallAdapterFactory(factory) + } + return builder.build() } } \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 2d770e6..3ff5501 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { applicationId "com.zeropercenthappy.retrofitutilsample" minSdkVersion 15 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -24,21 +24,19 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "com.android.support:appcompat-v7:$android_support_version" - 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.3" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1" - implementation "org.jetbrains.anko:anko:$anko_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0" + implementation("org.jetbrains.anko:anko:$anko_version") { + exclude group: "com.android.support" + } 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' implementation project(':retrofitLib') - implementation('com.yanzhenjie:album:2.1.3') { - exclude group: 'com.android.support' - } - implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.2.1' + implementation('com.yanzhenjie:album:2.1.3') + implementation 'com.github.zeropercenthappy:ZPHAndroidUtils:1.2.2' } diff --git a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/MainActivity.kt b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/MainActivity.kt index d33791b..d24ff35 100644 --- a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/MainActivity.kt +++ b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/MainActivity.kt @@ -21,7 +21,6 @@ import me.jessyan.progressmanager.ProgressListener import me.jessyan.progressmanager.ProgressManager import me.jessyan.progressmanager.body.ProgressInfo import okhttp3.FormBody -import okhttp3.RequestBody import okhttp3.ResponseBody import okhttp3.logging.HttpLoggingInterceptor import org.jetbrains.anko.AnkoLogger @@ -37,6 +36,7 @@ import java.util.* class MainActivity : AppCompatActivity(), AnkoLogger { private lateinit var extraTestParamMap: Map + private lateinit var kalleApi: IKalleApi override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -45,17 +45,23 @@ class MainActivity : AppCompatActivity(), AnkoLogger { RetrofitConfig.DEBUG_MODE = true RetrofitConfig.LOG_LEVEL = HttpLoggingInterceptor.Level.BODY - val imageLoaderConfig = ImageLoaderConfiguration.Builder(this) - .build() + extraTestParamMap = mapOf("aTopKey" to "aTopValue", "customKey" to "customValue") + val retrofit = RetrofitBuilder() + .baseUrl(KalleUrl.BASE_URL) + .addParams(extraTestParamMap) + .build(this) + kalleApi = retrofit.create(IKalleApi::class.java) + + val imageLoaderConfig = ImageLoaderConfiguration.Builder(this).build() ImageLoader.getInstance().init(imageLoaderConfig) - Album.initialize(AlbumConfig.newBuilder(this) + Album.initialize( + AlbumConfig.newBuilder(this) .setAlbumLoader(AlbumImageLoader()) - .build()) + .build() + ) ProgressManager.getInstance().setRefreshTime(1000) - extraTestParamMap = mapOf("aTopKey" to "aTopValue", "customKey" to "customValue") - btn_login.setOnClickListener { login() } btn_get.setOnClickListener { get() } btn_post.setOnClickListener { post() } @@ -65,11 +71,6 @@ class MainActivity : AppCompatActivity(), AnkoLogger { } private fun login() { - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .addParams(extraTestParamMap) - .build(this) - val kalleApi = retrofit.create(IKalleApi::class.java) val login = kalleApi.login("guest", "123456") login.enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { @@ -92,11 +93,6 @@ class MainActivity : AppCompatActivity(), AnkoLogger { } private fun get() { - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .addParams(extraTestParamMap) - .build(this) - val kalleApi = retrofit.create(IKalleApi::class.java) val get = kalleApi.get("guest", "25") get.enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { @@ -122,11 +118,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger { val builder = FormBody.Builder() builder.addEncoded("name", "guest") builder.addEncoded("age", "25") - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .build(this) val formBody = builder.build() - val kalleApi = retrofit.create(IKalleApi::class.java) val post = kalleApi.post(formBody) post.enqueue(object : Callback { @@ -151,30 +143,45 @@ class MainActivity : AppCompatActivity(), AnkoLogger { private fun pickImage() { Album.image(this) - .multipleChoice() - .selectCount(3) - .camera(true) - .columnCount(3) - .onResult { result -> - val fileMap = TreeMap() - for ((index, albumFile) in result.withIndex()) { - fileMap["file${index + 1}"] = File(albumFile.path) - } - upload(fileMap) + .multipleChoice() + .selectCount(3) + .camera(true) + .columnCount(3) + .onResult { result -> + val fileMap = TreeMap() + for ((index, albumFile) in result.withIndex()) { + fileMap["file${index + 1}"] = File(albumFile.path) } - .start() + upload(fileMap) + } + .start() } private fun upload(fileMap: TreeMap) { - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .build(this) - val kalleApi = retrofit.create(IKalleApi::class.java) + // 为了避免添加的测试用的公共参数影响ProgressManager获取进度,这里重新构建Retrofit + // 实际业务中根据具体情况,可以对url进行处理、拼接后,将实际的url传给ProgressManager + val tempRetrofit = RetrofitBuilder() + .baseUrl(KalleUrl.BASE_URL) + .build(this@MainActivity) + val tempKalleApi = tempRetrofit.create(IKalleApi::class.java) + //progress + ProgressManager.getInstance() + .addRequestListener(KalleUrl.BASE_URL + KalleUrl.UPLOAD, object : ProgressListener { + override fun onProgress(progressInfo: ProgressInfo) { + info { "progress:${progressInfo.percent}%" } + } + + override fun onError(id: Long, e: Exception?) { + e?.printStackTrace() + error(e?.localizedMessage) + } + }) + // val name = RequestBodyBuilder.createText("guest") val age = RequestBodyBuilder.createText("25") val fileList = RequestBodyBuilder.createMultipartBodyPartList(fileMap) - val uploadFile = kalleApi.uploadFile(name, age, fileList) + val uploadFile = tempKalleApi.uploadFile(name, age, fileList) uploadFile.enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { if (call.isCanceled) { @@ -197,7 +204,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger { // val paramMap = TreeMap() // paramMap["name"] = RequestBodyBuilder.createText("guest") // paramMap["age"] = RequestBodyBuilder.createText("25") -// val uploadFile1 = kalleApi.uploadFile1(paramMap, fileList) +// val uploadFile1 = tempKalleApi.uploadFile1(paramMap, fileList) // uploadFile1.enqueue(object : Callback { // override fun onFailure(call: Call, t: Throwable) { // if (call.isCanceled) { @@ -219,16 +226,19 @@ class MainActivity : AppCompatActivity(), AnkoLogger { } private fun download() { - val fileUrl = "http://cdn.aixifan.com/downloads/AcFun-portal-release-5.7.0.575-575.apk" - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .build(this) - val kalleApi = retrofit.create(IKalleApi::class.java) - val downloadFile = kalleApi.downloadFile(fileUrl) - //progress + // 为了避免添加的测试用的公共参数影响ProgressManager获取进度,这里重新构建Retrofit + // 实际业务中根据具体情况,可以对url进行处理、拼接后,将实际的url传给ProgressManager + val tempRetrofit = RetrofitBuilder() + .baseUrl(KalleUrl.BASE_URL) + .build(this@MainActivity) + val tempKalleApi = tempRetrofit.create(IKalleApi::class.java) + // 实际使用中避免以这种方式定义url,这样字符串会被加入全局字符串常量池, 池中的字符串将不会被回收 + // 在多次下载同一个url时导致ProgressManager的回调多次被触发 + val fileUrl = "https://imgs.aixifan.com/cms/2018_10_16/1539673075965.jpg" + // progress ProgressManager.getInstance().addResponseListener(fileUrl, object : ProgressListener { override fun onProgress(progressInfo: ProgressInfo) { - info("progress:${progressInfo.percent}%") + info { "progress:${progressInfo.percent}%" } } override fun onError(id: Long, e: Exception?) { @@ -237,6 +247,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger { } }) // + val downloadFile = tempKalleApi.downloadFile(fileUrl) downloadFile.enqueue(object : Callback { override fun onFailure(call: Call, t: Throwable) { if (call.isCanceled) { @@ -252,7 +263,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger { // download completely doAsync { if (response.isSuccessful && response.body() != null) { - val cacheFile = CacheUtils.createFormatedCacheFile(this@MainActivity, "apk") + val cacheFile = CacheUtils.createFormatedCacheFile(this@MainActivity, "jpg") if (cacheFile != null) { val result = FileUtils.writeFileByIS(cacheFile, response.body()!!.byteStream(), false) info { if (result) "download success" else "download failed" } @@ -264,10 +275,6 @@ class MainActivity : AppCompatActivity(), AnkoLogger { } private fun postJson() { - val retrofit = RetrofitBuilder() - .baseUrl(KalleUrl.BASE_URL) - .build(this) - val kalleApi = retrofit.create(IKalleApi::class.java) val simpleBean = SimpleBean("guest", "25") val resultBody = RequestBodyBuilder.createJson(Gson().toJson(simpleBean)) val postJson = kalleApi.postJson(resultBody) diff --git a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/IKalleApi.kt b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/IKalleApi.kt index fb3f35b..a2c244c 100644 --- a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/IKalleApi.kt +++ b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/IKalleApi.kt @@ -1,6 +1,9 @@ package com.zeropercenthappy.retrofitutilsample.api -import com.zeropercenthappy.retrofitutilsample.pojo.* +import com.zeropercenthappy.retrofitutilsample.pojo.GetBean +import com.zeropercenthappy.retrofitutilsample.pojo.LoginBean +import com.zeropercenthappy.retrofitutilsample.pojo.PostBean +import com.zeropercenthappy.retrofitutilsample.pojo.UploadBean import okhttp3.FormBody import okhttp3.MultipartBody import okhttp3.RequestBody diff --git a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/KalleUrl.kt b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/KalleUrl.kt index c0751ed..fcfaa4b 100644 --- a/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/KalleUrl.kt +++ b/sample/src/main/java/com/zeropercenthappy/retrofitutilsample/api/KalleUrl.kt @@ -1,7 +1,7 @@ package com.zeropercenthappy.retrofitutilsample.api object KalleUrl { - const val BASE_URL = "http://kalle.nohttp.net/" + const val BASE_URL = "https://kalle.nohttp.net/" const val LOGIN = "login" const val GET = "method/get" diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 9efd68c..946b1fa 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - RetrofitUtilSample + RetrofitSample