diff --git a/liyandong/sample/DesignPatterns/app/build.gradle b/liyandong/sample/DesignPatterns/app/build.gradle index 9a812b80483d96dca53d142b68bfe68be01eb908..f9a8991bb167c58ffd92120173e7e0c694fd8b6a 100644 --- a/liyandong/sample/DesignPatterns/app/build.gradle +++ b/liyandong/sample/DesignPatterns/app/build.gradle @@ -34,4 +34,5 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation("com.squareup.okhttp3:okhttp:4.8.1") } diff --git a/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/MainActivity.kt b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/MainActivity.kt index 25097cc4758c7067f666bc235c4b51f3f260817a..56829ba4f6ad26b7f5eb51eab67448153e9f3b30 100644 --- a/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/MainActivity.kt +++ b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/MainActivity.kt @@ -1,12 +1,20 @@ package com.example.designpatterns -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.example.designpatterns.test.B +import java.util.* class MainActivity : AppCompatActivity() { + private val list: List> = + ArrayList() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + val tc = B() + Log.e("++++++++++++","main: " + tc.list) + Log.e("++++++++++++","main: " + tc.list) } } diff --git a/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/A.kt b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/A.kt new file mode 100644 index 0000000000000000000000000000000000000000..89ee9b22d9d0fc1b3323cb5cd2cb15de7a536daf --- /dev/null +++ b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/A.kt @@ -0,0 +1,12 @@ +package com.example.designpatterns.test + +/** + * 作者:李艳东 + * + * + * 日期:on 2020/8/13 22:38 + */ +class A { + var a1 = "aaaaaa" + var a2 = "bbbbbb" +} \ No newline at end of file diff --git a/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/B.kt b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/B.kt new file mode 100644 index 0000000000000000000000000000000000000000..5d2a573d47811dcc295a0bf8bcccc70924459fc1 --- /dev/null +++ b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/B.kt @@ -0,0 +1,13 @@ +package com.example.designpatterns.test + +import java.util.* + +/** + * 作者:李艳东 + * + * + * 日期:on 2020/8/13 22:39 + */ +class B { + var list: List = ArrayList() +} \ No newline at end of file diff --git a/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/C.kt b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/C.kt new file mode 100644 index 0000000000000000000000000000000000000000..dbb84ac20ef0127fed02b9e9b6bdcfecaaa26153 --- /dev/null +++ b/liyandong/sample/DesignPatterns/app/src/main/java/com/example/designpatterns/test/C.kt @@ -0,0 +1,14 @@ +package com.example.designpatterns.test + +import java.util.* + +/** + * 作者:李艳东 + * + * + * 日期:on 2020/8/13 22:42 + */ +object C { + private val list: List> = + ArrayList() +} \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.gitignore b/liyandong/sample/MainstreamLibrary/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..603b14077394cd2294ac6922fe619669630ef3ab --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/liyandong/sample/MainstreamLibrary/.idea/codeStyles/Project.xml b/liyandong/sample/MainstreamLibrary/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000000000000000000000000000000000..88ea3aa1e593800a41855fcc6e3cfbff8e41e169 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.idea/codeStyles/codeStyleConfig.xml b/liyandong/sample/MainstreamLibrary/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..79ee123c2b23e069e35ed634d687e17f731cc702 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.idea/gradle.xml b/liyandong/sample/MainstreamLibrary/.idea/gradle.xml new file mode 100644 index 0000000000000000000000000000000000000000..5cd135a064522bbb757161b1eee5a7d65de1989e --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.idea/markdown-doclet.xml b/liyandong/sample/MainstreamLibrary/.idea/markdown-doclet.xml new file mode 100644 index 0000000000000000000000000000000000000000..a0355e912bc11f73681311dd2b624facb26d321e --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/markdown-doclet.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.idea/misc.xml b/liyandong/sample/MainstreamLibrary/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..37a750962da6f2b31810e85c8acae1081de7f58c --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/.idea/runConfigurations.xml b/liyandong/sample/MainstreamLibrary/.idea/runConfigurations.xml new file mode 100644 index 0000000000000000000000000000000000000000..7f68460d8b38ac04e3a3224d7c79ef719b1991a9 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/app/.gitignore b/liyandong/sample/MainstreamLibrary/app/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..796b96d1c402326528b4ba3c12ee9d92d0e212e9 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/liyandong/sample/MainstreamLibrary/app/build.gradle b/liyandong/sample/MainstreamLibrary/app/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..178095671ff1195d4939b8364c3e3a5454ab055f --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "com.example.mainstreamlibrary" + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.core:core-ktx:1.3.1' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation 'com.squareup.retrofit2:converter-gson:2.5.0' + implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' + implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0' + implementation 'com.squareup.retrofit2:retrofit:2.5.0' + implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' +} diff --git a/liyandong/sample/MainstreamLibrary/app/proguard-rules.pro b/liyandong/sample/MainstreamLibrary/app/proguard-rules.pro new file mode 100644 index 0000000000000000000000000000000000000000..f1b424510da51fd82143bc74a0a801ae5a1e2fcd --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/liyandong/sample/MainstreamLibrary/app/src/androidTest/java/com/example/mainstreamlibrary/ExampleInstrumentedTest.kt b/liyandong/sample/MainstreamLibrary/app/src/androidTest/java/com/example/mainstreamlibrary/ExampleInstrumentedTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..2ed462511cc59d289db6504016a4c4b0bed8e162 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/androidTest/java/com/example/mainstreamlibrary/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.mainstreamlibrary + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.mainstreamlibrary", appContext.packageName) + } +} diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/AndroidManifest.xml b/liyandong/sample/MainstreamLibrary/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..8e5707019eedefcdf7342edd2a1fdabb33a368e4 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/MainActivity.kt b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/MainActivity.kt new file mode 100644 index 0000000000000000000000000000000000000000..48e47f94f8157352563ad04d3df4605d776addf5 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/MainActivity.kt @@ -0,0 +1,77 @@ +package com.example.mainstreamlibrary + +import android.accessibilityservice.GestureDescription +import android.os.Bundle +import android.util.Log +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import com.example.mainstreamlibrary.retrofit.inter.GitHubService +import com.example.mainstreamlibrary.retrofit.model.Repo +import kotlinx.android.synthetic.main.activity_main.* +import okhttp3.OkHttpClient +import okhttp3.Request +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.io.IOException + + +class MainActivity : AppCompatActivity(), View.OnClickListener { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + initView() + } + + private fun initView() { + retrofit.setOnClickListener(this) + ok.setOnClickListener(this) + } + + private fun retrofit() { + // 1.Retrofit构建过程 + val retrofit = Retrofit.Builder() + .baseUrl("https://api.github.com/") + .addConverterFactory(GsonConverterFactory.create()) + .build() + // 2.创建网络请求接口类实例过程 + val service = retrofit.create(GitHubService::class.java) + val listRepos = service.listRepos("TLocation") + // 3.生成并执行请求过程 + listRepos?.enqueue(object : Callback { + override fun onFailure(call: Call, t: Throwable) { + + } + + override fun onResponse(call: Call, response: Response) { + val userBean = response.body() + Log.e("++++++++++++++", userBean.toString()) + } + + }) + } + + override fun onClick(v: View?) { + retrofit() + okhttp() + } + + private fun okhttp() { + val client = OkHttpClient() + val request = Request.Builder() + .url("https://www.baidu.com/") + .build() + client.newCall(request).enqueue(object : okhttp3.Callback { + override fun onFailure(call: okhttp3.Call, e: IOException) { + + } + + override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) { + println(response.message()) + } + }) + } +} diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/inter/GitHubService.kt b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/inter/GitHubService.kt new file mode 100644 index 0000000000000000000000000000000000000000..62732d37104e1175652a1f5779d33c81a1894343 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/inter/GitHubService.kt @@ -0,0 +1,20 @@ +package com.example.mainstreamlibrary.retrofit.inter + +import com.example.mainstreamlibrary.retrofit.model.Repo +import okhttp3.ResponseBody +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path + + +/** + + * 作者:李艳东 + + * 日期:on 2020/8/15 17:00 + + */ +interface GitHubService { + @GET("{user}") + fun listRepos(@Path("user") user: String?): Call? +} \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/model/Repo.kt b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/model/Repo.kt new file mode 100644 index 0000000000000000000000000000000000000000..bc18bce7b6694432ec5ee65953f309bdbe2f2e42 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/java/com/example/mainstreamlibrary/retrofit/model/Repo.kt @@ -0,0 +1,12 @@ +package com.example.mainstreamlibrary.retrofit.model + +/** + + * 作者:李艳东 + + * 日期:on 2020/8/21 22:15 + + */ +class Repo { + val url: String = "" +} \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b068d11462a4b96669193de13a711a3a36220a0 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable/ic_launcher_background.xml b/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..07d5da9cbf141911847041df5d7b87f0dd5ef9d4 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liyandong/sample/MainstreamLibrary/app/src/main/res/layout/activity_main.xml b/liyandong/sample/MainstreamLibrary/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000000000000000000000000000000000000..a1b4eeb4f4a97f32bca7c7b0115ee1ca12676245 --- /dev/null +++ b/liyandong/sample/MainstreamLibrary/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + +