From 07116044ad90535949a22dadd58f5cc15adf7074 Mon Sep 17 00:00:00 2001 From: twiceYuan Date: Wed, 18 Jul 2018 16:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=20Kotlin=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../twiceyuan/activityargs/library/ActivityArgs.kt | 14 +++++--------- sample/build.gradle | 6 +++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index c11576c..a16604e 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/library/src/main/java/com/twiceyuan/activityargs/library/ActivityArgs.kt b/library/src/main/java/com/twiceyuan/activityargs/library/ActivityArgs.kt index b63c8f8..aefd1b4 100644 --- a/library/src/main/java/com/twiceyuan/activityargs/library/ActivityArgs.kt +++ b/library/src/main/java/com/twiceyuan/activityargs/library/ActivityArgs.kt @@ -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) { @@ -176,13 +174,11 @@ fun parseActivityArgs(activity: Activity, dataClass: Class val constructorMap = hashMapOf() - 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 { diff --git a/sample/build.gradle b/sample/build.gradle index 15f16e1..ca2b772 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -13,7 +13,7 @@ android { } buildTypes { debug { - minifyEnabled true + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } @@ -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' }