├── .gitignore
├── MVPAndroid
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── mvpandroid
│ │ │ ├── BaseActivity.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── m
│ │ │ └── User.kt
│ │ │ ├── p
│ │ │ └── IPresenter.kt
│ │ │ └── v
│ │ │ └── IView.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project1
├── .gitignore
└── src
│ └── com
│ └── kymjs
│ └── kotlinprimer
│ ├── A.java
│ ├── AInterface.java
│ └── Test.kt
├── Project10
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
│ └── benchmarks-0.1.0-alpha-2-sources.jar
├── settings.gradle
└── src
│ └── main
│ └── kotlin
│ └── com
│ └── kymjs
│ └── kotlinprimer
│ ├── FileUtils.java
│ └── Main.kt
├── Project11
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── project11
│ │ │ ├── DemoActivity.kt
│ │ │ ├── DemoAdapter.kt
│ │ │ ├── MainActivity.kt
│ │ │ └── RecycleBin.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_demo.xml
│ │ ├── activity_main.xml
│ │ ├── item.xml
│ │ └── list_item.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project12
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── project12
│ │ │ └── MainActivity.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project13
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── project13
│ │ │ ├── MainActivity.kt
│ │ │ ├── unit1
│ │ │ ├── JavaCode.java
│ │ │ ├── KotlinCode.kt
│ │ │ └── KotlinCode2.kt
│ │ │ ├── unit2
│ │ │ ├── ActivityManagerHook.kt
│ │ │ └── JavaCode.java
│ │ │ ├── unit3
│ │ │ ├── CoroutineUtils.kt
│ │ │ └── JavaCode.java
│ │ │ └── unit4
│ │ │ └── KotlinCode.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project2
├── .gitignore
└── src
│ ├── com
│ └── kymjs
│ │ └── project2
│ │ ├── unit0
│ │ └── Main.kt
│ │ ├── unit1
│ │ ├── Main.kt
│ │ └── java
│ │ │ └── Main.java
│ │ ├── unit2
│ │ ├── Java.java
│ │ └── Main.kt
│ │ ├── unit3
│ │ └── LambdaTest.kt
│ │ └── unit4
│ │ └── HighLambda.kt
│ └── kotlin
│ └── Function23.java
├── Project3
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── project3
│ │ │ ├── MainActivity.kt
│ │ │ ├── unit1
│ │ │ └── TestView.kt
│ │ │ ├── unit2
│ │ │ ├── CompTest.java
│ │ │ └── Single.kt
│ │ │ ├── unit3
│ │ │ └── By.kt
│ │ │ ├── unit4
│ │ │ └── User.kt
│ │ │ ├── unit5
│ │ │ ├── Command.kt
│ │ │ ├── Main.java
│ │ │ └── TestEnum.java
│ │ │ └── unit6
│ │ │ ├── KotlinSDK.kt
│ │ │ ├── PlayerView.kt
│ │ │ └── PlayerViewType.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── raw
│ │ └── canon.mp3
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project4
├── .gitignore
└── src
│ └── com
│ └── kymjs
│ └── project4
│ └── unit6
│ ├── BluePlayerView.kt
│ ├── Main.kt
│ ├── PlayerUI.kt
│ ├── PlayerView.kt
│ ├── PlayerViewType.kt
│ ├── User.kt
│ └── VIPPlayer.kt
├── Project5
├── .gitignore
└── src
│ └── com
│ └── kymjs
│ └── project2
│ ├── unit1
│ ├── Main.kt
│ └── java
│ │ ├── ITimePrinter.java
│ │ └── Main.java
│ └── unit2
│ └── Main.kt
├── Project6
├── a.html
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── src
│ └── main
│ │ └── kotlin
│ │ └── com
│ │ └── kymjs
│ │ └── kotlinprimer
│ │ ├── unit1
│ │ ├── KotlinMain.kt
│ │ └── User.kt
│ │ ├── unit2
│ │ ├── JavaRx.java
│ │ ├── Loop.kt
│ │ └── Operator.kt
│ │ ├── unit3
│ │ └── Main.kt
│ │ ├── unit4
│ │ ├── InfixDemo.kt
│ │ └── OperatorOverwrite.kt
│ │ ├── unit5
│ │ ├── Equal.kt
│ │ ├── JavaEqual.java
│ │ └── Main.kt
│ │ ├── unit6
│ │ └── HtmlDSL.kt
│ │ ├── unit7
│ │ ├── HtmlDSL.kt
│ │ └── Main.kt
│ │ └── unit8
│ │ └── KotlinMain.kt
└── test.html
├── Project7
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ └── main
│ └── kotlin
│ └── com
│ └── kymjs
│ └── kotlinprimer
│ ├── unit1
│ └── LambdaReturnDemo.kt
│ ├── unit2
│ ├── FieldDemo.kt
│ ├── Main.kt
│ └── Person.kt
│ ├── unit3
│ ├── GenericDemo.kt
│ └── ReifiedGenericDemo.kt
│ └── unit4
│ ├── JavaMain.kt
│ └── Nullable.kt
├── Project8
├── .gitignore
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── project8
│ │ │ ├── AndroidCommonPool.kt
│ │ │ ├── Dashboard.java
│ │ │ ├── JavaActivity.java
│ │ │ ├── LaunchCoroutine.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ThreadTest.kt
│ │ │ └── eventbus
│ │ │ └── EventBus.kt
│ │ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── Project9
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ └── main
│ └── kotlin
│ └── com
│ └── kymjs
│ └── kotlinprimer
│ ├── BuildSequenceTest.kt
│ ├── ChannelTest1.kt
│ ├── ChannelTest2.kt
│ ├── buildSequence.kt
│ └── launch.kt
├── README.md
├── kotlinjs
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── index.html
├── settings.gradle
└── src
│ └── main
│ └── kotlin
│ └── Main.kt
├── servletdemo
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ └── main
│ └── kotlin
│ └── com
│ └── kymjs
│ └── Main.kt
├── spring-demo
├── .gitignore
├── build.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
│ ├── main
│ ├── kotlin
│ │ └── com
│ │ │ └── kymjs
│ │ │ └── springdemo
│ │ │ └── SpringDemoApplication.kt
│ └── resources
│ │ └── application.properties
│ └── test
│ └── kotlin
│ └── com
│ └── kymjs
│ └── springdemo
│ └── SpringDemoApplicationTests.kt
└── 极客时间kotlin视频PPT.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | tomsuite.xml
2 | **pom.xml.releaseBackup
3 | release.properties
4 | gen
5 | */seed.txt
6 | notes
7 | logs
8 | gen-external-apklibs
9 | .idea
10 | *.iml
11 | .DS_Store
12 | *.swp
13 | out
14 | .gradle
15 | /local.properties
16 | /build
17 |
18 | ###OSX###
19 |
20 | .DS_Store
21 | .AppleDouble
22 | .LSOverride
23 |
24 | # Icon must ends with two \r.
25 | Icon
26 |
27 |
28 | # Thumbnails
29 | ._*
30 |
31 | # Files that might appear on external disk
32 | .Spotlight-V100
33 | .Trashes
34 |
35 |
36 | ###Linux###
37 |
38 | *~
39 |
40 | # KDE directory preferences
41 | .directory
42 |
43 |
44 | ###Android###
45 |
46 | # Built application files
47 | *.apk
48 | *.ap_
49 |
50 | # Files for ART and Dalvik VM
51 | *.dex
52 |
53 | # Java class files
54 | *.class
55 |
56 | # Generated files
57 | gen/
58 |
59 | # Gradle files
60 | .gradle/
61 | .gradletasknamecache
62 | build/
63 |
64 | # Local configuration file (sdk path, etc)
65 | local.properties
66 |
67 | # Proguard folder generated by Eclipse
68 | proguard/
69 |
70 | # Lint
71 | lint-report.html
72 | lint-report_files/
73 | lint_result.txt
74 |
75 | # Mobile Tools for Java (J2ME)
76 | .mtj.tmp/
77 |
78 | # Package Files #
79 | *.war
80 | *.ear
81 |
82 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
83 | hs_err_pid*
84 |
85 |
86 | ###IntelliJ###
87 |
88 | *.iml
89 | *.ipr
90 | *.iws
91 | .idea/
92 |
93 |
94 | ###Eclipse###
95 |
96 | *.pydevproject
97 | .metadata
98 | tmp/
99 | *.tmp
100 | *.bak
101 | *.swp
102 | *~.nib
103 | .settings/
104 | .loadpath
105 |
106 | # External tool builders
107 | .externalToolBuilders/
108 |
109 | # Locally stored "Eclipse launch configurations"
110 | *.launch
111 |
112 | # CDT-specific
113 | .cproject
114 |
115 | # PDT-specific
116 | .buildpath
117 |
118 | # sbteclipse plugin
119 | .target
120 |
121 | # TeXlipse plugin
122 | .texlipseXml version="1.0" encoding="UTF-8"?>captures
123 |
--------------------------------------------------------------------------------
/MVPAndroid/.gitignore:
--------------------------------------------------------------------------------
1 | tomsuite.xml
2 | **pom.xml.releaseBackup
3 | release.properties
4 | gen
5 | */seed.txt
6 | notes
7 | logs
8 | gen-external-apklibs
9 | .idea
10 | *.iml
11 | .DS_Store
12 | *.swp
13 | out
14 | .gradle
15 | /local.properties
16 | /build
17 |
18 | ###OSX###
19 |
20 | .DS_Store
21 | .AppleDouble
22 | .LSOverride
23 |
24 | # Icon must ends with two \r.
25 | Icon
26 |
27 |
28 | # Thumbnails
29 | ._*
30 |
31 | # Files that might appear on external disk
32 | .Spotlight-V100
33 | .Trashes
34 |
35 |
36 | ###Linux###
37 |
38 | *~
39 |
40 | # KDE directory preferences
41 | .directory
42 |
43 |
44 | ###Android###
45 |
46 | # Built application files
47 | *.apk
48 | *.ap_
49 |
50 | # Files for ART and Dalvik VM
51 | *.dex
52 |
53 | # Java class files
54 | *.class
55 |
56 | # Generated files
57 | bin/
58 | gen/
59 |
60 | # Gradle files
61 | .gradle/
62 | .gradletasknamecache
63 | build/
64 |
65 | # Local configuration file (sdk path, etc)
66 | local.properties
67 |
68 | # Proguard folder generated by Eclipse
69 | proguard/
70 |
71 | # Lint
72 | lint-report.html
73 | lint-report_files/
74 | lint_result.txt
75 |
76 | # Mobile Tools for Java (J2ME)
77 | .mtj.tmp/
78 |
79 | # Package Files #
80 | *.war
81 | *.ear
82 |
83 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
84 | hs_err_pid*
85 |
86 |
87 | ###IntelliJ###
88 |
89 | *.iml
90 | *.ipr
91 | *.iws
92 | .idea/
93 |
94 |
95 | ###Eclipse###
96 |
97 | *.pydevproject
98 | .metadata
99 | tmp/
100 | *.tmp
101 | *.bak
102 | *.swp
103 | *~.nib
104 | .settings/
105 | .loadpath
106 |
107 | # External tool builders
108 | .externalToolBuilders/
109 |
110 | # Locally stored "Eclipse launch configurations"
111 | *.launch
112 |
113 | # CDT-specific
114 | .cproject
115 |
116 | # PDT-specific
117 | .buildpath
118 |
119 | # sbteclipse plugin
120 | .target
121 |
122 | # TeXlipse plugin
123 | .texlipseXml version="1.0" encoding="UTF-8"?>captures
124 |
--------------------------------------------------------------------------------
/MVPAndroid/app/.gitignore:
--------------------------------------------------------------------------------
1 | tomsuite.xml
2 | **pom.xml.releaseBackup
3 | release.properties
4 | gen
5 | */seed.txt
6 | notes
7 | logs
8 | gen-external-apklibs
9 | .idea
10 | *.iml
11 | .DS_Store
12 | *.swp
13 | out
14 | .gradle
15 | /local.properties
16 | /build
17 |
18 | ###OSX###
19 |
20 | .DS_Store
21 | .AppleDouble
22 | .LSOverride
23 |
24 | # Icon must ends with two \r.
25 | Icon
26 |
27 |
28 | # Thumbnails
29 | ._*
30 |
31 | # Files that might appear on external disk
32 | .Spotlight-V100
33 | .Trashes
34 |
35 |
36 | ###Linux###
37 |
38 | *~
39 |
40 | # KDE directory preferences
41 | .directory
42 |
43 |
44 | ###Android###
45 |
46 | # Built application files
47 | *.apk
48 | *.ap_
49 |
50 | # Files for ART and Dalvik VM
51 | *.dex
52 |
53 | # Java class files
54 | *.class
55 |
56 | # Generated files
57 | bin/
58 | gen/
59 |
60 | # Gradle files
61 | .gradle/
62 | .gradletasknamecache
63 | build/
64 |
65 | # Local configuration file (sdk path, etc)
66 | local.properties
67 |
68 | # Proguard folder generated by Eclipse
69 | proguard/
70 |
71 | # Lint
72 | lint-report.html
73 | lint-report_files/
74 | lint_result.txt
75 |
76 | # Mobile Tools for Java (J2ME)
77 | .mtj.tmp/
78 |
79 | # Package Files #
80 | *.war
81 | *.ear
82 |
83 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
84 | hs_err_pid*
85 |
86 |
87 | ###IntelliJ###
88 |
89 | *.iml
90 | *.ipr
91 | *.iws
92 | .idea/
93 |
94 |
95 | ###Eclipse###
96 |
97 | *.pydevproject
98 | .metadata
99 | tmp/
100 | *.tmp
101 | *.bak
102 | *.swp
103 | *~.nib
104 | .settings/
105 | .loadpath
106 |
107 | # External tool builders
108 | .externalToolBuilders/
109 |
110 | # Locally stored "Eclipse launch configurations"
111 | *.launch
112 |
113 | # CDT-specific
114 | .cproject
115 |
116 | # PDT-specific
117 | .buildpath
118 |
119 | # sbteclipse plugin
120 | .target
121 |
122 | # TeXlipse plugin
123 | .texlipseXml version="1.0" encoding="UTF-8"?>captures
124 |
--------------------------------------------------------------------------------
/MVPAndroid/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 28
9 | defaultConfig {
10 | applicationId "com.kymjs.mvpandroid"
11 | minSdkVersion 23
12 | targetSdkVersion 28
13 | versionCode 1
14 | versionName "1.0"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation fileTree(dir: 'libs', include: ['*.jar'])
26 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
27 | implementation 'com.android.support:appcompat-v7:28.+'
28 | }
29 |
--------------------------------------------------------------------------------
/MVPAndroid/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
22 |
--------------------------------------------------------------------------------
/MVPAndroid/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/MVPAndroid/app/src/main/java/com/kymjs/mvpandroid/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.mvpandroid
2 |
3 | import android.support.v7.app.AppCompatActivity
4 |
5 | open class BaseActivity(val clazz: Class) : AppCompatActivity() {
6 | val presenter by lazy { clazz.newInstance() }
7 |
8 | companion object {
9 | inline operator fun invoke() = BaseActivity(T::class.java)
10 | }
11 | }
--------------------------------------------------------------------------------
/MVPAndroid/app/src/main/java/com/kymjs/mvpandroid/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.mvpandroid
2 |
3 | import android.support.v7.app.AppCompatActivity
4 | import android.os.Bundle
5 | import android.widget.Button
6 | import com.kymjs.mvpandroid.m.User
7 | import com.kymjs.mvpandroid.p.IPresenter
8 | import com.kymjs.mvpandroid.v.IView
9 |
10 | class MainActivity : AppCompatActivity(), IView by MVPView() {
11 |
12 | inline fun getPresenter(): T {
13 | return T::class.java.newInstance()
14 | }
15 |
16 | //class MainActivity : AppCompatActivity(),
17 | // IView by MVPView(), IPresenter by EmptyPresenter() {
18 |
19 | override fun onCreate(savedInstanceState: Bundle?) {
20 | super.onCreate(savedInstanceState)
21 | setContentView(getLayoutID())
22 |
23 | findViewById
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Project6/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.kymjs'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.2.31'
6 |
7 | repositories {
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 | }
13 | }
14 |
15 | apply plugin: 'java'
16 | apply plugin: 'kotlin'
17 |
18 | sourceCompatibility = 1.8
19 |
20 | repositories {
21 | mavenCentral()
22 | }
23 |
24 | dependencies {
25 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
26 | compile "io.reactivex.rxjava2:rxjava:2.1.16"
27 | testCompile group: 'junit', name: 'junit', version: '4.12'
28 | }
29 |
30 | compileKotlin {
31 | kotlinOptions.jvmTarget = "1.8"
32 | }
33 | compileTestKotlin {
34 | kotlinOptions.jvmTarget = "1.8"
35 | }
--------------------------------------------------------------------------------
/Project6/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Project6/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jul 01 21:18:32 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
7 |
--------------------------------------------------------------------------------
/Project6/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/Project6/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'kotlin'
2 |
3 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit1/KotlinMain.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit1
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/1.
5 | */
6 | fun main(args: Array) {
7 | val user = User(12, "name")
8 | val (age, name, nickname) = user
9 | println(age)
10 | println(name)
11 |
12 | val map = mapOf("key" to "key", "value" to "value")
13 | for ((k, v) in map) {
14 | println("$k---$v")
15 | }
16 | }
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit1/User.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit1
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/1.
5 | */
6 | class User(var age: Int, var name: String) {
7 | operator fun component1() = age
8 | operator fun component2() = name
9 | operator fun component3() = name
10 | }
11 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit2/JavaRx.java:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2;
2 |
3 | import io.reactivex.Observable;
4 | import io.reactivex.ObservableSource;
5 | import io.reactivex.functions.BiFunction;
6 | import io.reactivex.functions.Consumer;
7 | import io.reactivex.functions.Function;
8 | import io.reactivex.functions.Predicate;
9 |
10 | /**
11 | * Created by ZhangTao on 18/7/1.
12 | */
13 | public class JavaRx {
14 | public static void main(String[] args) {
15 | final String[] a = new String[]{"4", "0", "7", "i", "f", "w", "0", "9"};
16 | final Integer[] index = new Integer[]{5, 3, 9, 4, 8, 3, 1, 9, 2, 1, 7};
17 |
18 | Observable.just(index)
19 | .flatMap(new Function>() {
20 | @Override
21 | public ObservableSource apply(Integer[] integers) throws Exception {
22 | return Observable.fromArray(integers);
23 | }
24 | })
25 | .filter(new Predicate() {
26 | @Override
27 | public boolean test(Integer i) throws Exception {
28 | return i < a.length;
29 | }
30 | })
31 | .map(new Function() {
32 | @Override
33 | public String apply(Integer integer) throws Exception {
34 | return a[integer];
35 | }
36 | })
37 | .reduce(new BiFunction() {
38 | @Override
39 | public String apply(String s, String s2) throws Exception {
40 | return s + s2;
41 | }
42 | })
43 | .subscribe(new Consumer() {
44 | @Override
45 | public void accept(String s) throws Exception {
46 | System.out.println("密码是:" + s);
47 | }
48 | });
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit2/Loop.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/1.
5 | */
6 | fun main(args: Array) {
7 | for (i in 1..10) {
8 | println(i)
9 | }
10 | println("---------------")
11 |
12 | for (i in 10..1) {
13 | println(i)
14 | }
15 | println("---------------")
16 |
17 | for (i in 1 until 10) {
18 | println(i)
19 | }
20 | println("---------------")
21 |
22 | for (i in 10 downTo 1) {
23 | println(i)
24 | }
25 | println("---------------")
26 |
27 | for (i in 1..10 step 2) {
28 | println(i)
29 | }
30 | println("---------------")
31 |
32 | val list = arrayListOf("a", "b", "c", "d")
33 | for (str in list) {
34 | println(str)
35 | }
36 |
37 | for ((index, str) in list.withIndex()) {
38 | println("第${index}个元素是$str")
39 | }
40 |
41 | repeat(10) {
42 | println(it)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit2/Operator.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/1.
5 | */
6 |
7 | fun main(args: Array) {
8 | // val a = arrayOf("4", "0", "7", "i", "f", "w", "0", "9")
9 | // val index = arrayOf(5, 3, 9, 4, 8, 3, 1, 9, 2, 1, 7)
10 | //
11 | // index
12 | // .filter {
13 | // it < a.size
14 | // }
15 | // .map {
16 | // a[it]
17 | // }
18 | // .reduce { s, s1 ->
19 | // "$s$s1"
20 | // }
21 | // .also {
22 | // println("密码是:$it")
23 | // }
24 | myOperator()
25 | }
26 |
27 | fun myOperator() {
28 | val list: List = listOf(1, 2, 3, 4, 5)
29 | list.convert {
30 | it + 1
31 | }.forEach {
32 | print(it)
33 | }
34 | }
35 |
36 | inline fun Iterable.convert(action: (T) -> E): Iterable {
37 | val list: MutableList = mutableListOf()
38 | for (item in this) list.add(action(item))
39 | return list
40 | }
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit3/Main.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit3
2 |
3 |
4 | data class User(var name: String)
5 |
6 | fun main(args: Array) {
7 |
8 | val user = User("ZhangTao")
9 |
10 | //let与run都会返回闭包的执行结果,区别在于let有闭包参数,而run没有闭包参数
11 | val letResult = user.let { "let::${it.javaClass}" }
12 | println(letResult)
13 | val runResult = user.run { "run::${this.javaClass}" }
14 | println(runResult)
15 |
16 | //also与apply都不返回闭包的执行结果,区别在于also有闭包参数,而apply没有闭包参数
17 | user.also {
18 | println("also::${it.javaClass}")
19 | }.apply {
20 | println("apply::${this.javaClass}")
21 | }.name = "hello"
22 |
23 | //takeIf 的闭包返回一个判断结果,为false时,takeIf函数会返回空
24 | //takeUnless 与 takeIf 刚好相反, 闭包的判断结果,为true时函数会返回空
25 | user.takeIf { it.name.length > 0 }?.also { println("姓名为${it.name}") } ?: println("姓名为空")
26 | user.takeUnless { it.name.length > 0 }?.also { println("姓名为空") } ?: println("姓名为${user.name}")
27 |
28 | //重复执行当前闭包
29 | repeat(5) {
30 | println(user.name)
31 | print(it)
32 | }
33 |
34 | //with比较特殊,不是以扩展方法的形式存在的,而是一个顶级函数
35 | with(user) {
36 | this.name = "with"
37 | }
38 |
39 | // user.apply{ this.name = "with"}
40 |
41 | }
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit4/InfixDemo.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit4
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/6.
5 | */
6 |
7 | sealed class CompareResult {
8 | object LESS : CompareResult() {
9 | override fun toString(): String {
10 | return "小于"
11 | }
12 | }
13 |
14 | object MORE : CompareResult() {
15 | override fun toString(): String {
16 | return "大于"
17 | }
18 | }
19 |
20 | object EQUAL : CompareResult() {
21 | override fun toString(): String {
22 | return "等于"
23 | }
24 | }
25 | }
26 |
27 | fun Int.a(){
28 |
29 | }
30 |
31 | infix fun Int.vs(num: Int): CompareResult =
32 | if (this - num < 0) {
33 | CompareResult.LESS
34 | } else if (this - num > 0) {
35 | CompareResult.MORE
36 | } else {
37 | CompareResult.EQUAL
38 | }
39 |
40 | infix fun Double.vs(num: Int): CompareResult =
41 | if (this - num < 0) {
42 | CompareResult.MORE
43 | } else if (this - num > 0) {
44 | CompareResult.LESS
45 | } else {
46 | CompareResult.EQUAL
47 | }
48 |
49 | infix fun Long.vs(num: Int): CompareResult =
50 | if (this - num < 0) {
51 | CompareResult.MORE
52 | } else if (this - num > 0) {
53 | CompareResult.LESS
54 | } else {
55 | CompareResult.EQUAL
56 | }
57 |
58 | fun main(args: Array) {
59 | println(5.vs(6))
60 | }
61 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit4/OperatorOverwrite.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit4
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/6.
5 | */
6 |
7 | fun main(args: Array) {
8 | for (i in 1..100 step 20) {
9 | print("$i " + "str")
10 | }
11 |
12 | for (i in 1.rangeTo(100) step 20) {
13 | print("$i ")
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit5/Equal.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit5
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/7.
5 | */
6 |
7 | fun main(s: Array) {
8 |
9 | val string = "string"
10 | // val javaString = String("string")
11 | val newString = StringBuilder("string").toString()
12 | val newString2 = String("string".toByteArray())
13 |
14 | println(string === newString)
15 | println(string == newString)
16 | println(string === newString2)
17 | println(string == newString2)
18 | }
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit5/JavaEqual.java:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit5;
2 |
3 | public class JavaEqual {
4 |
5 | public static void main(String[] s) {
6 | String string = "string";
7 | String newString = new String("string");
8 | System.out.println(string == newString);
9 | System.out.println(string.equals(newString));
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit5/Main.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit5
2 |
3 | import java.io.File
4 |
5 | /**
6 | * Created by ZhangTao on 18/7/7.
7 | */
8 |
9 | fun `1234`() {
10 | println("test1")
11 | }
12 |
13 | fun ` `() {
14 | println("test2")
15 | }
16 |
17 | fun ` `() {
18 | println("test3")
19 | }
20 |
21 | fun main(args: Array) {
22 | val a: File = A("")
23 |
24 | }
25 |
26 |
27 | public typealias A = File
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit7/Main.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit7
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/14.
5 | */
6 |
7 | fun main(args: Array) {
8 | "hello"
9 | }
--------------------------------------------------------------------------------
/Project6/src/main/kotlin/com/kymjs/kotlinprimer/unit8/KotlinMain.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit8
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/14.
5 | */
6 | fun main(args: Array) {
7 | }
8 |
9 |
10 | fun print(msg: String) {
11 |
12 | }
13 |
14 | fun print2(msg: String?) {
15 |
16 | }
--------------------------------------------------------------------------------
/Project6/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | HTML encoding with Kotlin
5 |
6 |
7 |
8 |
9 | HTML encoding with Kotlin
10 |
11 |
12 | this format can be used as an alternative markup to HTML
13 |
14 |
15 | Kotlin
16 |
17 |
18 |
19 | This is some
20 |
21 |
22 |
23 | mixed
24 |
25 |
26 |
27 | text. For more see the
28 |
29 |
30 |
31 | Kotlin
32 |
33 |
34 |
35 | project
36 |
37 |
38 |
39 | some text
40 |
41 |
42 | Command line arguments were:
43 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Project7/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.kymjs.kotlinprimer'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.2.31'
6 |
7 | repositories {
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 | }
13 | }
14 |
15 | apply plugin: 'java'
16 | apply plugin: 'kotlin'
17 |
18 | sourceCompatibility = 1.8
19 |
20 | repositories {
21 | mavenCentral()
22 | }
23 |
24 | dependencies {
25 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
26 | testCompile group: 'junit', name: 'junit', version: '4.12'
27 | compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
28 | }
29 |
30 | compileKotlin {
31 | kotlinOptions.jvmTarget = "1.8"
32 | }
33 | compileTestKotlin {
34 | kotlinOptions.jvmTarget = "1.8"
35 | }
--------------------------------------------------------------------------------
/Project7/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project7/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Project7/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jul 08 15:22:15 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-all.zip
7 |
--------------------------------------------------------------------------------
/Project7/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'kotlin'
2 |
3 |
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit1/LambdaReturnDemo.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit1
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/8.
5 | */
6 |
7 | val runnable = Runnable {
8 | println("runnable")
9 | }
10 |
11 | fun main(args: Array) {
12 | test1 {
13 | println("hello")
14 | return@test1
15 | println("hello1")
16 | }
17 | println("hello2")
18 |
19 | test2({
20 | println("hello")
21 | }, runnable::run)
22 | }
23 |
24 | inline fun test1(crossinline l: () -> Unit) {
25 | l.invoke()
26 | return
27 | }
28 |
29 | inline fun test2(l0: () -> Unit, noinline l1: () -> Unit): () -> Unit {
30 | l0.invoke()
31 | l1.invoke()
32 | println("test2")
33 | return l1
34 | }
35 |
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit2/FieldDemo.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/8.
5 | */
6 |
7 | const val a = 0
8 | const val a1 = ""
9 |
10 | fun main(args: Array) {
11 | val person = Person(1990)
12 | println(person.age)
13 | person.oneYearsLater()
14 | println(person.age)
15 | }
16 |
17 | class A {
18 | companion object {
19 | const val s = 0
20 | }
21 |
22 | var num: Int = 0
23 | set(value) {
24 | field = value + 1
25 | }
26 | }
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit2/Main.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/14.
5 | */
6 | fun main(args: Array) {
7 |
8 | val hello = Hello()
9 | println(hello.string2)
10 | hello.string = "world"
11 | println(hello.string2)
12 | }
13 |
14 | class Hello {
15 | var string: String? = null
16 | get() {
17 | return field + "hello"
18 | }
19 | set(value) {
20 | field = value + "set"
21 | }
22 |
23 | val string2: String? = null
24 | get() {
25 | return field + "hello"
26 | }
27 | }
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit2/Person.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit2
2 |
3 | import java.util.*
4 |
5 | /**
6 | * Created by ZhangTao on 18/7/8.
7 | */
8 | class Person(var birthYear: Int) {
9 | val age: Int
10 | get() {
11 | return Calendar.getInstance().get(Calendar.YEAR) - birthYear
12 | }
13 |
14 | fun oneYearsLater() {
15 | birthYear--
16 | }
17 | }
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit3/GenericDemo.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit3
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/8.
5 | */
6 | class Test where T : Callback, T : Runnable {
7 | fun add(t: T) {
8 | t.run()
9 | t.callback()
10 | }
11 | }
12 |
13 | open class A : Runnable {
14 | override fun run() {
15 | println("run")
16 | }
17 | }
18 |
19 | class B : Callback, A() {
20 | override fun callback() {
21 | println("callback")
22 | }
23 | }
24 |
25 | interface Callback {
26 | fun callback()
27 | }
28 |
29 | fun main(args: Array) {
30 | val test = Test()
31 | test.add(B())
32 | }
33 |
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit3/ReifiedGenericDemo.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit3
2 |
3 | import com.google.gson.Gson
4 |
5 | /**
6 | * Created by ZhangTao on 18/7/8.
7 | */
8 | inline fun Gson.fromJson(json: String): T {
9 | return fromJson(json, T::class.java)
10 | }
11 |
12 | class View(val clazz: Class) {
13 | val presenter by lazy { clazz.newInstance() }
14 |
15 | companion object {
16 | inline operator fun invoke() = View(T::class.java)
17 | }
18 | }
19 |
20 | class Presenter {
21 | override fun toString(): String {
22 | return "presenter"
23 | }
24 | }
25 |
26 | fun main(args: Array) {
27 | val b = View().presenter
28 |
29 | val a = View.Companion.invoke().presenter
30 | println(a)
31 | println(b)
32 | }
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit4/JavaMain.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit4
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/14.
5 | */
6 | object JavaMain {
7 |
8 | @JvmStatic
9 | fun main(args: Array) {
10 | test("")
11 | test2(null)
12 | }
13 |
14 | fun test(str: String) {
15 | println(str)
16 | }
17 |
18 | fun test2(str: String?) {
19 | println(str)
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Project7/src/main/kotlin/com/kymjs/kotlinprimer/unit4/Nullable.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer.unit4
2 |
3 | /**
4 | * Created by ZhangTao on 18/7/8.
5 | */
6 | fun main(args: Array) {
7 | var a: String = ""
8 |
9 | println(getValue(a))
10 | }
11 |
12 | fun getValue(s: String): String {
13 | return "1" + s.length
14 | }
15 |
--------------------------------------------------------------------------------
/Project8/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/Project8/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Project8/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 27
7 | defaultConfig {
8 | applicationId "com.kymjs.project8"
9 | minSdkVersion 15
10 | targetSdkVersion 27
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(include: ['*.jar'], dir: 'libs')
24 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
25 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5'
26 | implementation 'com.android.support:appcompat-v7:27.0.2'
27 | implementation 'com.squareup.okhttp3:okhttp:3.10.0'
28 | }
29 | kotlin {
30 | experimental {
31 | coroutines "enable"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Project8/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
22 |
--------------------------------------------------------------------------------
/Project8/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/AndroidCommonPool.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8
2 |
3 | import android.os.AsyncTask
4 | import kotlinx.coroutines.experimental.CoroutineDispatcher
5 | import kotlinx.coroutines.experimental.Runnable
6 | import kotlin.coroutines.experimental.CoroutineContext
7 |
8 | /**
9 | * Created by ZhangTao on 18/7/11.
10 | */
11 | object AndroidCommonPool : CoroutineDispatcher() {
12 | override fun dispatch(context: CoroutineContext, block: Runnable) {
13 | AsyncTask.THREAD_POOL_EXECUTOR.execute(block)
14 | }
15 | }
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/Dashboard.java:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 | import android.widget.TextView;
6 |
7 | import java.io.IOException;
8 |
9 | import okhttp3.Call;
10 | import okhttp3.Callback;
11 | import okhttp3.OkHttpClient;
12 | import okhttp3.Request;
13 | import okhttp3.Response;
14 |
15 | /**
16 | * Created by ZhangTao on 18/7/8.
17 | */
18 | public class Dashboard {
19 |
20 | private final OkHttpClient mOkHttpClient = new OkHttpClient();
21 | private final Request mRequest = new Request.Builder().url("https://baidu.com").get().build();
22 | private final Handler mHandler = new Handler(Looper.getMainLooper());
23 |
24 | public void display(final TextView textView) {
25 | mOkHttpClient.newCall(mRequest).enqueue(new Callback() {
26 | @Override
27 | public void onFailure(Call call, IOException e) {
28 | }
29 |
30 | @Override
31 | public void onResponse(Call call, Response response) throws IOException {
32 | final String string = response.body().string();
33 | mHandler.post(new Runnable() {
34 | @Override
35 | public void run() {
36 | textView.setText(string);
37 | }
38 | });
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/JavaActivity.java:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.util.Log;
7 |
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | import kotlin.coroutines.experimental.Continuation;
11 | import kotlin.coroutines.experimental.CoroutineContext;
12 | import kotlinx.coroutines.experimental.android.HandlerContextKt;
13 |
14 | /**
15 | * Created by ZhangTao on 18/7/9.
16 | */
17 | public class JavaActivity extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(@Nullable Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 |
23 | LaunchCoroutineKt.getHtml(new Continuation() {
24 | @NotNull
25 | @Override
26 | public CoroutineContext getContext() {
27 | return HandlerContextKt.getUI();
28 | }
29 |
30 | @Override
31 | public void resume(String s) {
32 | Log.d("kymjs", "协程执行成功" + s);
33 | }
34 |
35 | @Override
36 | public void resumeWithException(Throwable throwable) {
37 |
38 | }
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/LaunchCoroutine.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8
2 |
3 | import android.widget.TextView
4 | import kotlinx.coroutines.experimental.android.UI
5 | import kotlinx.coroutines.experimental.async
6 | import kotlinx.coroutines.experimental.launch
7 | import kotlinx.coroutines.experimental.runBlocking
8 | import okhttp3.OkHttpClient
9 | import okhttp3.Request
10 | import java.net.URL
11 |
12 | /**
13 | * Created by ZhangTao on 18/7/8.
14 | */
15 |
16 | // 用于执行协程任务
17 | fun launchCoroutine1() = launch {
18 |
19 | }
20 |
21 | // 用于执行协程任务, 通常只用于启动最外层协程
22 | fun launchCoroutine2() = runBlocking {
23 |
24 | }
25 |
26 | // 用于执行协程任务,并得到执行结果
27 | fun launchCoroutine3() = async {
28 |
29 | }
30 |
31 |
32 | private val mOkHttpClient = OkHttpClient()
33 | private val mRequest = Request.Builder().url("https://baidu.com").get().build()
34 |
35 | fun displayDashboard(textView: TextView) = runBlocking {
36 | launch(UI) {
37 | val job = async(AndroidCommonPool) {
38 | //不考虑异常的情况
39 | mOkHttpClient.newCall(mRequest).execute().body()?.string()
40 | }
41 | textView.text = job.await()
42 | }
43 | }
44 |
45 |
46 | //suspend, 被suspend修饰的函数只能被有 suspend 修饰的函数调用
47 | //因为suspend修饰的函数(或lambda)被编译后会多一个参数类型叫Continuation,
48 | //协程的异步调用本质上就是一次回调
49 | suspend fun getHtml(): String {
50 | return async(AndroidCommonPool) { URL("http://baidu.com").readText() }.await()
51 | }
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.view.View
6 | import com.kymjs.project8.eventbus.onEvent
7 | import com.kymjs.project8.eventbus.post
8 |
9 |
10 | // 1. 启动协程
11 | // 2. 常用的三种方式,参数与返回值
12 | // 3. 协程的轻量性
13 | // 4. 协程的语法糖
14 | // 5. build->intermediates->transforms->dexMerger->dex
15 | // 6. kotlin-android
16 | // 7. suspend / Continuation
17 | // 8. 在java中调用suspend function
18 | // 9. CoroutineImpl
19 | // 10. buildSequence
20 | // 11. channel
21 | // 12. eventbus
22 | class MainActivity : AppCompatActivity() {
23 |
24 | override fun onCreate(savedInstanceState: Bundle?) {
25 | super.onCreate(savedInstanceState)
26 | setContentView(R.layout.activity_main)
27 |
28 | onEvent { str: String ->
29 | println(str)
30 | }
31 | }
32 |
33 | fun test1(v: View) {
34 | "按钮1".post()
35 | }
36 |
37 | fun test2(v: View) {
38 | "点击了按钮2".post()
39 | }
40 |
41 | fun test3(v: View) {
42 | }
43 |
44 |
45 | // kotlin官方提供的利用channel实现view的onclick方法
46 | // fun View.onClick(action: suspend (View) -> Unit) {
47 | // val eventActor = actor(UI) {
48 | // for (event in channel) action(event)
49 | // }
50 | // setOnClickListener {
51 | // eventActor.offer(it)
52 | // }
53 | // }
54 | }
55 |
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/ThreadTest.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8
2 |
3 | import android.util.Log
4 | import kotlinx.coroutines.experimental.android.UI
5 | import kotlinx.coroutines.experimental.launch
6 | import kotlin.concurrent.thread
7 |
8 | /**
9 | * Created by ZhangTao on 18/7/9.
10 | */
11 |
12 | fun makeThread() {
13 | repeat(100000) {
14 | thread {
15 | repeat(10) {
16 | Log.d("thread", "$it")
17 | }
18 | }
19 | }
20 | }
21 |
22 | fun makeCoroutine() {
23 | repeat(100000) {
24 | launch(UI) {
25 | repeat(10) {
26 | Log.d("coroutine", "$it")
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Project8/app/src/main/java/com/kymjs/project8/eventbus/EventBus.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.project8.eventbus
2 |
3 | import kotlinx.coroutines.experimental.CommonPool
4 | import kotlinx.coroutines.experimental.android.UI
5 | import kotlinx.coroutines.experimental.channels.Channel
6 | import kotlinx.coroutines.experimental.launch
7 |
8 | /**
9 | * Created by ZhangTao on 18/7/13.
10 | */
11 |
12 | //时间缓存池
13 | var map = mutableMapOf>()
14 |
15 | inline fun T.post() {
16 | if (!map.containsKey(T::class.java.name)) {
17 | map.put(T::class.java.name, Channel())
18 | }
19 |
20 | launch(CommonPool) {
21 | map[T::class.java.name]?.send(this@post as Any)
22 | }
23 | }
24 |
25 | inline fun T.onEvent(noinline action: suspend (R) -> Unit) {
26 | if (!map.containsKey(R::class.java.name)) {
27 | map.put(R::class.java.name, Channel())
28 | }
29 | launch(CommonPool) {
30 | val receive = map[R::class.java.name]?.receive()
31 | launch(UI) {
32 | action.invoke(receive as R)
33 | }
34 | }
35 | }
36 |
37 |
38 | //发送者.post("event")
39 | //"event".post()
40 |
41 | //接受者 onEvent(event:String)
42 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
16 |
17 |
23 |
24 |
30 |
31 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Project8/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Project8
3 |
4 |
--------------------------------------------------------------------------------
/Project8/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Project8/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.51'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.3'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/Project8/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/Project8/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Project8/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jul 08 20:06:07 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/Project8/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/Project8/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/Project9/build.gradle:
--------------------------------------------------------------------------------
1 | group 'kotlin'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.2.31'
6 |
7 | repositories {
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 | }
13 | }
14 |
15 | apply plugin: 'java'
16 | apply plugin: 'kotlin'
17 |
18 | sourceCompatibility = 1.8
19 |
20 | repositories {
21 | mavenCentral()
22 | }
23 |
24 | dependencies {
25 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
26 | compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.5'
27 | testCompile group: 'junit', name: 'junit', version: '4.12'
28 | }
29 |
30 | compileKotlin {
31 | kotlinOptions.jvmTarget = "1.8"
32 | }
33 | compileTestKotlin {
34 | kotlinOptions.jvmTarget = "1.8"
35 | }
36 | kotlin {
37 | experimental {
38 | coroutines "enable"
39 | }
40 | }
--------------------------------------------------------------------------------
/Project9/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/Project9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Project9/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jul 12 16:47:39 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip
7 |
--------------------------------------------------------------------------------
/Project9/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/Project9/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'com.kymjs.kotlin'
2 |
3 |
--------------------------------------------------------------------------------
/Project9/src/main/kotlin/com/kymjs/kotlinprimer/BuildSequenceTest.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer
2 |
3 | import kotlin.coroutines.experimental.buildSequence
4 |
5 | /**
6 | * Created by ZhangTao on 18/7/12.
7 | */
8 |
9 | // inferred type is Sequence
10 | val fibonacci = buildSequence {
11 | yield(1) // first Fibonacci number
12 | var cur = 1
13 | var next = 1
14 | while (true) {
15 | yield(next) // next Fibonacci number
16 | val tmp = cur + next
17 | cur = next
18 | next = tmp
19 | }
20 | }
21 |
22 | // 1. yield 可以按需调用,无限的返回数据,
23 | // yield 非常适合一些在无法预知终止条件的场景,比如直接读已经写好的本地文本,每次读一条
24 | // 现在很多手机现在都有一种假装打电话的功能,你可以提前编辑好手机里要说的内容和每段内容的间隔,
25 | // 手机自动响起来,你就可以跟手机对话了,这种场景就非常适合。
26 |
27 | fun main(args: Array) {
28 | fibonacci.take(100).iterator().forEach {
29 | print("$it ")
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Project9/src/main/kotlin/com/kymjs/kotlinprimer/ChannelTest1.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer
2 |
3 | import kotlinx.coroutines.experimental.channels.Channel
4 | import kotlinx.coroutines.experimental.launch
5 | import kotlinx.coroutines.experimental.runBlocking
6 |
7 | /**
8 | * Created by ZhangTao on 18/7/13.
9 | */
10 | fun main(args: Array) = runBlocking {
11 | val c = Channel()
12 | launch {
13 | get(c)
14 | }
15 | launch {
16 | put(c)
17 | }
18 | Unit
19 | }
20 |
21 | suspend fun get(channel: Channel) {
22 | while (true) {
23 | println(channel.receive())
24 | }
25 | }
26 |
27 | suspend fun put(channel: Channel) {
28 | var i = 0
29 | while (true) {
30 | channel.send(i++)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Project9/src/main/kotlin/com/kymjs/kotlinprimer/ChannelTest2.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer
2 |
3 | import kotlinx.coroutines.experimental.CommonPool
4 | import kotlinx.coroutines.experimental.channels.ReceiveChannel
5 | import kotlinx.coroutines.experimental.channels.consumeEach
6 | import kotlinx.coroutines.experimental.channels.produce
7 | import kotlinx.coroutines.experimental.channels.take
8 | import kotlinx.coroutines.experimental.launch
9 | import kotlinx.coroutines.experimental.runBlocking
10 |
11 |
12 | // ChannelCoroutine 的动态代理
13 | fun put() = produce(CommonPool) {
14 | var i = 0
15 | while (true) {
16 | send(i++)
17 | }
18 | }
19 |
20 | fun get(channel: ReceiveChannel) = launch(CommonPool) {
21 | channel.take(10).consumeEach {
22 | println("接收到:: $it")
23 | }
24 | }
25 |
26 | fun main(args: Array) = runBlocking {
27 | val producer = put()
28 | get(producer).join()
29 | producer.cancel()
30 | }
31 |
--------------------------------------------------------------------------------
/Project9/src/main/kotlin/com/kymjs/kotlinprimer/buildSequence.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer
2 |
3 | import kotlin.coroutines.experimental.*
4 |
5 | interface SequenceBuilder {
6 | suspend fun yield(value: T)
7 | }
8 |
9 | fun buildSequence(block: suspend SequenceBuilder.() -> Unit): Sequence = Sequence {
10 | MyCoroutine().apply {
11 | nextStep = block.createCoroutine(receiver = this, completion = this)
12 | }
13 | }
14 |
15 | private class MyCoroutine : AbstractIterator(), SequenceBuilder, Continuation {
16 |
17 | lateinit var nextStep: Continuation
18 | override val context: CoroutineContext get() = EmptyCoroutineContext
19 |
20 | override fun computeNext() { nextStep.resume(Unit) }
21 |
22 | override fun resume(value: Unit) { done() }
23 | override fun resumeWithException(exception: Throwable) { throw exception }
24 |
25 | override suspend fun yield(value: T) {
26 | setNext(value)
27 | return suspendCoroutine { cont -> nextStep = cont }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Project9/src/main/kotlin/com/kymjs/kotlinprimer/launch.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.kotlinprimer
2 |
3 | import kotlinx.coroutines.experimental.*
4 |
5 | /**
6 | * Created by ZhangTao on 18/7/15.
7 | */
8 |
9 | fun main(args: Array) = runBlocking {
10 |
11 | val job = launch() {
12 | println("launch..." + Thread.currentThread().name)
13 | }
14 |
15 | val job2 = async(CommonPool) {
16 | delay(500L)
17 | println("async..." + Thread.currentThread().name)
18 | return@async "hello"
19 | }
20 |
21 | println("job2的输出:" + job2.await())
22 | delay(1300L)
23 | }
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 快速上手 Kotlin 开发,极客时间视频课
2 | ---
3 |
4 | 本仓库为极客时间视频课《快速上手 Kotlin 开发》中代码以及PPT存放仓库。
5 |
6 | 视频课中讲的内容面向的是有一定 Java 或 Android 基础的同学,可以帮助你快速的理解 Kotlin 语言的设计思路,各种语法糖背后的实现原理,以及在工作中使用 Kotlin 时经常遇到的坑怎么解决。
7 |
8 | 视频课中没有包含环境搭建等基础内容,你可以在我博客中查看相关基础知识:[https://kymjs.com/code/2017/02/03/01/](https://kymjs.com/code/2017/02/03/01/)
--------------------------------------------------------------------------------
/kotlinjs/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'kotlin2js' version '1.2.60'
3 | }
4 |
5 | group 'com.kymjs'
6 | version '1.0-SNAPSHOT'
7 |
8 | repositories {
9 | mavenCentral()
10 | }
11 |
12 | dependencies {
13 | compile "org.jetbrains.kotlin:kotlin-stdlib-js"
14 | testCompile "org.jetbrains.kotlin:kotlin-test-js"
15 | }
16 |
--------------------------------------------------------------------------------
/kotlinjs/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/kotlinjs/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/kotlinjs/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/kotlinjs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/kotlinjs/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | resolutionStrategy {
3 | eachPlugin {
4 | if (requested.id.id == "kotlin2js") {
5 | useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
6 | }
7 | }
8 | }
9 | }
10 | rootProject.name = 'kotlinjs'
11 |
12 |
--------------------------------------------------------------------------------
/kotlinjs/src/main/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | import kotlin.browser.document
2 | import kotlin.browser.window
3 |
4 | fun main(args: Array) {
5 | println("hello")
6 |
7 | window.onload = {
8 | document.body!!.append(document.createElement("div").apply {
9 | textContent = "Hello, world!"
10 | })
11 | }
12 | }
--------------------------------------------------------------------------------
/servletdemo/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'war'
3 | id 'org.jetbrains.kotlin.jvm' version '1.2.60'
4 | }
5 |
6 | group 'com.kymjs'
7 | version '1.1-SNAPSHOT'
8 |
9 | repositories {
10 | mavenCentral()
11 | }
12 |
13 | dependencies {
14 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
15 | compile group: 'javax', name: 'javaee-api', version: '7.0'
16 | }
17 |
18 | compileKotlin {
19 | kotlinOptions.jvmTarget = "1.8"
20 | }
21 | compileTestKotlin {
22 | kotlinOptions.jvmTarget = "1.8"
23 | }
--------------------------------------------------------------------------------
/servletdemo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/servletdemo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/servletdemo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/servletdemo/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'servletdemo'
2 |
3 |
--------------------------------------------------------------------------------
/servletdemo/src/main/kotlin/com/kymjs/Main.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs
2 |
3 | import javax.servlet.annotation.WebServlet
4 | import javax.servlet.http.HttpServlet
5 | import javax.servlet.http.HttpServletRequest
6 | import javax.servlet.http.HttpServletResponse
7 |
8 | @WebServlet(name = "Hello", value = ["/hello"])
9 | class Main : HttpServlet() {
10 | override fun doGet(req: HttpServletRequest, res: HttpServletResponse) {
11 | res.writer.write("Hello, Kotlin!")
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/spring-demo/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 | /out/
20 |
21 | ### NetBeans ###
22 | /nbproject/private/
23 | /nbbuild/
24 | /dist/
25 | /nbdist/
26 | /.nb-gradle/
--------------------------------------------------------------------------------
/spring-demo/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | kotlinVersion = '1.2.41'
4 | springBootVersion = '2.0.4.RELEASE'
5 | }
6 | repositories {
7 | mavenCentral()
8 | }
9 | dependencies {
10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
13 | }
14 | }
15 |
16 | apply plugin: 'kotlin'
17 | apply plugin: 'kotlin-spring'
18 | apply plugin: 'org.springframework.boot'
19 | apply plugin: 'io.spring.dependency-management'
20 |
21 | group = 'com.kymjs'
22 | version = '0.0.1-SNAPSHOT'
23 | sourceCompatibility = 1.8
24 | compileKotlin {
25 | kotlinOptions {
26 | freeCompilerArgs = ["-Xjsr305=strict"]
27 | jvmTarget = "1.8"
28 | }
29 | }
30 | compileTestKotlin {
31 | kotlinOptions {
32 | freeCompilerArgs = ["-Xjsr305=strict"]
33 | jvmTarget = "1.8"
34 | }
35 | }
36 |
37 | repositories {
38 | mavenCentral()
39 | }
40 |
41 |
42 | dependencies {
43 | compile('org.springframework.boot:spring-boot-starter')
44 | compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
45 | compile("org.jetbrains.kotlin:kotlin-reflect")
46 | compile 'org.springframework.boot:spring-boot-starter-web'
47 | testCompile('org.springframework.boot:spring-boot-starter-test')
48 | }
49 |
--------------------------------------------------------------------------------
/spring-demo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/spring-demo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/spring-demo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Feb 06 12:27:20 CET 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
7 |
--------------------------------------------------------------------------------
/spring-demo/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'spring-demo'
2 |
--------------------------------------------------------------------------------
/spring-demo/src/main/kotlin/com/kymjs/springdemo/SpringDemoApplication.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.springdemo
2 |
3 | import org.springframework.boot.SpringApplication
4 | import org.springframework.boot.autoconfigure.SpringBootApplication
5 |
6 | @SpringBootApplication
7 | class SpringDemoApplication
8 |
9 | fun main(args: Array) {
10 | SpringApplication.run(SpringDemoApplication::class.java, *args)
11 | }
12 |
--------------------------------------------------------------------------------
/spring-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/spring-demo/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-demo/src/test/kotlin/com/kymjs/springdemo/SpringDemoApplicationTests.kt:
--------------------------------------------------------------------------------
1 | package com.kymjs.springdemo
2 |
3 | import org.junit.Test
4 | import org.junit.runner.RunWith
5 | import org.springframework.boot.test.context.SpringBootTest
6 | import org.springframework.test.context.junit4.SpringRunner
7 |
8 | @RunWith(SpringRunner::class)
9 | @SpringBootTest
10 | class SpringDemoApplicationTests {
11 |
12 | @Test
13 | fun contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/极客时间kotlin视频PPT.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kymjs/KotlinPrimer/297d39509d14ab84faada5ba66426eb98cec7960/极客时间kotlin视频PPT.pdf
--------------------------------------------------------------------------------