Skip to content

Commit b1f1a86

Browse files
committed
feat: 新增對 kotlin extention 的支援
1 parent aac2067 commit b1f1a86

File tree

7 files changed

+60
-9
lines changed

7 files changed

+60
-9
lines changed

app/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
24

35
android {
46
compileSdkVersion 28
@@ -27,4 +29,6 @@ dependencies {
2729
implementation 'com.hjq:titlebar:6.0'
2830
// 悬浮窗:https://github.com/getActivity/XToast
2931
implementation 'com.hjq:xtoast:2.6'
30-
}
32+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
33+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34+
}

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.hjq.toast.demo">
44

5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
66

77
<application
88
android:name=".ToastApplication"
99
android:icon="@mipmap/ic_launcher"
1010
android:label="@string/app_name"
1111
android:roundIcon="@mipmap/ic_launcher_round"
1212
android:theme="@style/AppTheme">
13+
<activity android:name=".ToastKotlinActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<action android:name="android.intent.action.VIEW" />
1317

18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter></activity>
1420
<activity android:name=".ToastActivity">
1521
<intent-filter>
1622
<action android:name="android.intent.action.MAIN" />
@@ -19,7 +25,6 @@
1925
<category android:name="android.intent.category.LAUNCHER" />
2026
</intent-filter>
2127
</activity>
22-
2328
</application>
2429

2530
</manifest>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.hjq.toast.demo
2+
3+
import android.support.v7.app.AppCompatActivity
4+
import android.os.Bundle
5+
import com.hjq.toast.toastMe
6+
import kotlinx.android.synthetic.main.activity_toast_kotlin.*
7+
8+
class ToastKotlinActivity : AppCompatActivity() {
9+
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
setContentView(R.layout.activity_toast_kotlin)
13+
14+
btnShow.setOnClickListener {
15+
toastMe("2;obkv8jyu54v8")
16+
}
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".ToastKotlinActivity">
9+
10+
<Button
11+
android:id="@+id/btnShow"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:text="show toast"/>
15+
16+
17+
</LinearLayout>

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

3-
buildscript {
3+
buildscript {
4+
ext.kotlin_version = '1.3.61'
5+
46
repositories {
57
jcenter()
68
google()
79
}
810
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.1.3'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1012
classpath 'com.novoda:bintray-release:0.8.0'
11-
}
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
1214
}
1315

1416
allprojects {
1517
repositories {
1618
jcenter()
1719
google()
18-
maven {url "https://jitpack.io"}
20+
maven {url "https://jitpack.io" }
1921
}
2022

2123
//解决app:mockableAndroidJar错误的问题
@@ -30,4 +32,4 @@ allprojects {
3032

3133
task clean(type: Delete) {
3234
delete rootProject.buildDir
33-
}
35+
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

library/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//文件开头配置
22
apply plugin: 'com.android.library'
33
apply plugin: 'com.novoda.bintray-release'
4+
apply plugin: 'kotlin-android'
45

56
android {
67
compileSdkVersion 26
@@ -16,6 +17,10 @@ android {
1617
}
1718
}
1819

20+
dependencies{
21+
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
22+
}
23+
1924
publish {
2025
userOrg = 'getactivity'//填写bintray用户名,注意大小写
2126
groupId = 'com.hjq'//定义的maven group id最终引用形式

0 commit comments

Comments
 (0)