Skip to content

Commit

Permalink
升级 Kotlin 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
twiceyuan committed Jul 18, 2018
1 parent f7cbf14 commit 0711604
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.31'
ext.kotlin_version = '1.2.51'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import kotlin.reflect.jvm.javaType
/**
* 定义传递参数数据 Model 所要继承的类。例如:
* ```
* data class Starter(val name: String) : ActivityArgs {
* override fun targetClass() = SomeActivity::class.java
* }
* data class Starter(val name: String) : ActivityArgs(SomeActivity::class.java)
* ```
*/
abstract class ActivityArgs(@Transient private val targetClass: Class<out Activity>) {
Expand Down Expand Up @@ -176,13 +174,11 @@ fun <Data : ActivityArgs> parseActivityArgs(activity: Activity, dataClass: Class

val constructorMap = hashMapOf<KParameter, Any?>()

val primaryConstructor = dataClass.kotlin.constructors.firstOrNull() ?: throw DataBeanNotLegalException(
"数据类应该有一个主构造器"
)
val primaryConstructor = dataClass.kotlin.constructors.firstOrNull()
?: throw DataBeanNotLegalException("数据类应该有一个主构造器")

if (primaryConstructor.parameters.isEmpty()) throw DataBeanNotLegalException(
"数据类应该至少有一个构造器参数"
)
if (primaryConstructor.parameters.isEmpty())
throw DataBeanNotLegalException("数据类应该至少有一个构造器参数")

primaryConstructor.parameters.forEach {

Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
}
buildTypes {
debug {
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Expand All @@ -32,10 +32,10 @@ dependencies {
implementation project(path: ':library')

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

implementation 'com.android.support:appcompat-v7:27.1.1'

implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.code.gson:gson:2.8.4'
}

0 comments on commit 0711604

Please sign in to comment.