├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── freddy │ │ │ │ └── shine │ │ │ │ └── kotlin │ │ │ │ └── example │ │ │ │ ├── History.kt │ │ │ │ ├── Journalism.kt │ │ │ │ ├── CustomResponseModel2.kt │ │ │ │ ├── CustomResponseModel1.kt │ │ │ │ ├── TestRepository.kt │ │ │ │ ├── CustomParser1.kt │ │ │ │ ├── CustomParser2.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ └── BaseRepository.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── freddy │ │ │ └── shine │ │ │ └── kotlin │ │ │ └── example │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── freddy │ │ └── shine │ │ └── kotlin │ │ └── example │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── shine-kotlin ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── freddy │ │ │ └── shine │ │ │ └── kotlin │ │ │ ├── config │ │ │ ├── NetworkConfig.kt │ │ │ ├── ShineConfig.kt │ │ │ ├── RequestMethod.kt │ │ │ ├── ShineOptions.kt │ │ │ └── RequestOptions.kt │ │ │ ├── model │ │ │ ├── IResponseModel.kt │ │ │ └── DefaultResponseModel.kt │ │ │ ├── cipher │ │ │ ├── AbstractCipher.kt │ │ │ ├── ICipher.kt │ │ │ └── DefaultCipher.kt │ │ │ ├── parser │ │ │ ├── IParser.kt │ │ │ ├── AbstractParser.kt │ │ │ └── DefaultParser.kt │ │ │ ├── RequestManagerFactory.kt │ │ │ ├── ShineKit.kt │ │ │ ├── retrofit │ │ │ ├── interceptor │ │ │ │ ├── OkHttpRequestHeaderInterceptor.kt │ │ │ │ ├── OkHttpLoggingInterceptor.kt │ │ │ │ ├── OkHttpResponseDecryptInterceptor.kt │ │ │ │ ├── OkHttpBaseInterceptor.kt │ │ │ │ └── OkHttpRequestEncryptInterceptor.kt │ │ │ ├── converter │ │ │ │ └── StringConverterFactory.kt │ │ │ ├── api │ │ │ │ └── IApiService.kt │ │ │ └── manager │ │ │ │ ├── RetrofitManager.kt │ │ │ │ └── RetrofitRequestManager.kt │ │ │ ├── exception │ │ │ └── RequestException.kt │ │ │ ├── utils │ │ │ └── ShineLog.kt │ │ │ ├── interf │ │ │ └── IRequest.kt │ │ │ └── AbstractRequestManager.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── freddy │ │ │ └── shine │ │ │ └── kotlin │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── freddy │ │ └── shine │ │ └── kotlin │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── misc.xml └── gradle.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /shine-kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /shine-kotlin/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Shine-Kotlin 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreddyChen/Shine-Kotlin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shine-kotlin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 07 13:42:37 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/config/NetworkConfig.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.config 2 | 3 | /** 4 | * 网络配置 5 | * 6 | * @author: FreddyChen 7 | * @date : 2022/01/07 10:19 8 | * @email : freddychencsc@gmail.com 9 | */ 10 | object NetworkConfig { 11 | const val DEFAULT_CONTENT_TYPE = "application/json; charset=utf-8" 12 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "Shine-Kotlin" 10 | include ':app' 11 | include ':shine-kotlin' 12 | -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/config/ShineConfig.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.config 2 | 3 | /** 4 | * Shine配置 5 | * @author: FreddyChen 6 | * @date : 2022/01/09 21:04 7 | * @email : freddychencsc@gmail.com 8 | */ 9 | internal object ShineConfig { 10 | 11 | const val DEFAULT_LOG_TAG = "Shine" 12 | const val DEFAULT_LOG_ENABLE = true 13 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/model/IResponseModel.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.model 2 | 3 | /** 4 | * ResponseModel接口,自定义ResponseModel需继承此接口并实现[isSuccessful]方法 5 | * 6 | * 7 | * @author: FreddyChen 8 | * @date : 2022/01/15 00:51 9 | * @email : freddychencsc@gmail.com 10 | */ 11 | interface IResponseModel { 12 | 13 | fun isSuccessful(): Boolean 14 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/cipher/AbstractCipher.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.cipher 2 | 3 | /** 4 | * 抽象的加解密器 5 | * 6 | * 如果需要自定义加解密器,继承此[AbstractCipher],实现[encrypt]及[decrypt]方法即可 7 | * @see [DefaultCipher] 8 | * @author: FreddyChen 9 | * @date : 2022/01/13 16:10 10 | * @email : freddychencsc@gmail.com 11 | */ 12 | abstract class AbstractCipher : ICipher -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/parser/IParser.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.parser 2 | 3 | import java.lang.reflect.Type 4 | 5 | /** 6 | * 数据解析器抽象接口 7 | * 8 | * @see [DefaultParser] 9 | * @author: FreddyChen 10 | * @date : 2022/01/06 17:53 11 | * @email : freddychencsc@gmail.com 12 | */ 13 | interface IParser { 14 | fun parse(url: String, data: String, type: Type): T 15 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/config/RequestMethod.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.config 2 | 3 | /** 4 | * 请求方式 5 | * 6 | * 支持以下常用请求方法: 7 | * * [GET] 8 | * * [POST] 9 | * * [PUT] 10 | * * [DELETE] 11 | * @author: FreddyChen 12 | * @date : 2022/01/06 17:12 13 | * @email : freddychencsc@gmail.com 14 | */ 15 | enum class RequestMethod { 16 | GET, 17 | POST, 18 | PUT, 19 | DELETE 20 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /shine-kotlin/src/test/java/com/freddy/shine/kotlin/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/test/java/com/freddy/shine/kotlin/example/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/parser/AbstractParser.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.parser 2 | 3 | import com.google.gson.Gson 4 | import java.lang.reflect.Type 5 | import kotlin.reflect.KClass 6 | 7 | /** 8 | * 抽象的数据解析器 9 | * 10 | * 如果需要自定义解析器,继承此[AbstractParser],实现[parse]方法即可 11 | * @see [DefaultParser] 12 | * @author: FreddyChen 13 | * @date : 2022/01/06 17:50 14 | * @email : freddychencsc@gmail.com 15 | */ 16 | abstract class AbstractParser : IParser { 17 | 18 | protected val gson: Gson by lazy { Gson() } 19 | } -------------------------------------------------------------------------------- /app/src/main/java/com/freddy/shine/kotlin/example/History.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | 6 | /** 7 | * 8 | * @author: FreddyChen 9 | * @date : 2022/01/17 16:17 10 | * @email : freddychencsc@gmail.com 11 | */ 12 | data class History( 13 | @SerializedName("date") 14 | val date: String?, 15 | @SerializedName("title") 16 | val title: String? 17 | ) { 18 | override fun toString(): String { 19 | return "History(date=$date, title=$title)" 20 | } 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/freddy/shine/kotlin/example/Journalism.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | import com.google.gson.annotations.SerializedName 3 | 4 | 5 | /** 6 | * 7 | * @author: FreddyChen 8 | * @date : 2022/01/17 16:10 9 | * @email : freddychencsc@gmail.com 10 | */ 11 | data class Journalism( 12 | 13 | @SerializedName("code") 14 | val code: String?, 15 | @SerializedName("content") 16 | val content: String? 17 | ) { 18 | override fun toString(): String { 19 | return "Journalism(code=$code, content=$content)" 20 | } 21 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/cipher/ICipher.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.cipher 2 | 3 | /** 4 | * 加解密器抽象接口 5 | * 6 | * @see [DefaultCipher] 7 | * @author: FreddyChen 8 | * @date : 2022/01/13 16:07 9 | * @email : freddychencsc@gmail.com 10 | */ 11 | interface ICipher { 12 | 13 | /** 14 | * 加密数据 15 | */ 16 | fun encrypt(original: String?): String? 17 | 18 | /** 19 | * 解密数据 20 | */ 21 | fun decrypt(original: String?): String? 22 | 23 | /** 24 | * 获取加解密字段名称 25 | */ 26 | fun getParamName(): String 27 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/RequestManagerFactory.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin 2 | 3 | import com.freddy.shine.kotlin.interf.IRequest 4 | import com.freddy.shine.kotlin.retrofit.manager.RetrofitRequestManager 5 | 6 | /** 7 | * RequestManager工厂,提供获取RequestManager方法,应用层直接调用[getRequestManager]即可,无需关心内部实现逻辑 8 | * @author: FreddyChen 9 | * @date : 2022/01/07 14:08 10 | * @email : freddychencsc@gmail.com 11 | */ 12 | internal object RequestManagerFactory { 13 | 14 | fun getRequestManager(): IRequest { 15 | return RetrofitRequestManager.INSTANCE 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/freddy/shine/kotlin/example/CustomResponseModel2.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import com.freddy.shine.kotlin.model.IResponseModel 4 | import com.google.gson.annotations.SerializedName 5 | 6 | /** 7 | * 8 | * @author: FreddyChen 9 | * @date : 2022/01/17 16:05 10 | * @email : freddychencsc@gmail.com 11 | */ 12 | data class CustomResponseModel2( 13 | @SerializedName("message") 14 | val message: String?, 15 | @SerializedName("data") 16 | val data: T? 17 | ) : IResponseModel { 18 | 19 | override fun isSuccessful() = this.message == "success" 20 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/model/DefaultResponseModel.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.model 2 | 3 | /** 4 | * 默认的ResponseModel 5 | * 6 | * * code 返回码 7 | * * msg 返回信息 8 | * * data 返回数据 9 | * @author: FreddyChen 10 | * @date : 2022/01/06 18:34 11 | * @email : freddychencsc@gmail.com 12 | */ 13 | internal data class DefaultResponseModel(var code: Int?, var msg: String?, val data: T?) : 14 | IResponseModel { 15 | 16 | override fun isSuccessful() = code == 0 17 | 18 | override fun toString(): String { 19 | return "DefaultResponseModel(code=$code, msg=$msg, data=$data)" 20 | } 21 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/cipher/DefaultCipher.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.cipher 2 | 3 | /** 4 | * 默认的加解密器 5 | *

6 | * 示例实现 7 | * * 在[encrypt]中实现加密逻辑 8 | * * 在[decrypt]中实现解密逻辑 9 | * * [getParamName]配置与服务端协商好的加密字段key 10 | * @author: FreddyChen 11 | * @date : 2022/01/13 16:11 12 | * @email : freddychencsc@gmail.com 13 | */ 14 | class DefaultCipher : AbstractCipher() { 15 | 16 | override fun encrypt(original: String?): String? { 17 | return original 18 | } 19 | 20 | override fun decrypt(original: String?): String? { 21 | return original 22 | } 23 | 24 | override fun getParamName(): String { 25 | return "params" 26 | } 27 | } -------------------------------------------------------------------------------- /shine-kotlin/src/main/java/com/freddy/shine/kotlin/ShineKit.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin 2 | 3 | import com.freddy.shine.kotlin.config.ShineOptions 4 | import com.freddy.shine.kotlin.interf.IRequest 5 | 6 | /** 7 | * Shine核心类 8 | * 9 | * * [init] 初始化配置 10 | * * [getRequestManager] 获取请求管理器 11 | * @author: FreddyChen 12 | * @date : 2022/01/07 13:56 13 | * @email : freddychencsc@gmail.com 14 | */ 15 | object ShineKit { 16 | 17 | var options: ShineOptions = ShineOptions.Builder().build() 18 | 19 | fun init(options: ShineOptions) { 20 | this.options = options 21 | } 22 | 23 | fun getRequestManager(): IRequest { 24 | return RequestManagerFactory.getRequestManager() 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/java/com/freddy/shine/kotlin/example/CustomResponseModel1.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import com.freddy.shine.kotlin.model.IResponseModel 4 | import com.google.gson.annotations.SerializedName 5 | 6 | /** 7 | * 8 | * @author: FreddyChen 9 | * @date : 2022/01/17 16:05 10 | * @email : freddychencsc@gmail.com 11 | */ 12 | data class CustomResponseModel1( 13 | @SerializedName("code") 14 | val code: String?, 15 | @SerializedName("day") 16 | val day: String?, 17 | @SerializedName("result") 18 | val result: T? 19 | ) : IResponseModel { 20 | 21 | override fun isSuccessful() = this.code == "1" 22 | 23 | override fun toString(): String { 24 | return "CustomResponseModel1(code=$code, day=$day, result=$result)" 25 | } 26 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /shine-kotlin/src/androidTest/java/com/freddy/shine/kotlin/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.freddy.shine.kotlin.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /shine-kotlin/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/freddy/shine/kotlin/example/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.freddy.shine.kotlin.example", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/freddy/shine/kotlin/example/TestRepository.kt: -------------------------------------------------------------------------------- 1 | package com.freddy.shine.kotlin.example 2 | 3 | import com.freddy.shine.kotlin.config.RequestMethod 4 | 5 | /** 6 | * 7 | * @author: FreddyChen 8 | * @date : 2022/01/08 23:09 9 | * @email : freddychencsc@gmail.com 10 | */ 11 | class TestRepository : BaseRepository() { 12 | 13 | /** 14 | * 获取历史列表数据 15 | * 异步请求 16 | */ 17 | suspend fun fetchHistoryList(): ArrayList { 18 | return request( 19 | requestMethod = RequestMethod.POST, 20 | function = "lishi/api.php", 21 | ) 22 | } 23 | 24 | /** 25 | * 获取新闻列表数据 26 | * 同步请求 27 | */ 28 | fun fetchJournalismList(): ArrayList { 29 | return requestSync( 30 | requestMethod = RequestMethod.GET, 31 | baseUrl = "https://is.snssdk.com/", 32 | function = "api/news/feed/v51/", 33 | parserCls = CustomParser2::class, 34 | ) 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |