From db1ef315a8fe44537fc4d0a578686da77f9ed390 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Sat, 18 Feb 2023 18:28:17 +0800 Subject: [PATCH] update --- app/build.gradle | 19 +++++++++++--- app/src/main/AndroidManifest.xml | 8 +++--- .../main/java/com/yutou/musicplayer/App.kt | 9 +++++++ .../com/yutou/musicplayer/MainActivity.kt | 11 ++++++++ .../com/yutou/musicplayer/net/NetManager.kt | 22 ++++++++++++++++ app/src/main/res/layout/activity_main.xml | 25 ++++++++++--------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 6 +++++ settings.gradle | 2 ++ 9 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 app/src/main/java/com/yutou/musicplayer/App.kt create mode 100644 app/src/main/java/com/yutou/musicplayer/net/NetManager.kt create mode 100644 gradle/wrapper/gradle-wrapper.properties diff --git a/app/build.gradle b/app/build.gradle index 3ff7c31..b311e20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,10 +35,23 @@ android { dependencies { implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.5.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.recyclerview:recyclerview:1.2.1' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + //网络库 https://github.com/liangjingkanji/Net + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0" // 协程(版本自定) + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0' + implementation 'com.squareup.okhttp3:okhttp:4.10.0' // 要求OkHttp4以上 + implementation 'com.github.liangjingkanji:Net:3.5.6' + //媒体库 + implementation "androidx.media:media:1.6.0" + implementation 'androidx.palette:palette-ktx:1.0.0' + + implementation 'com.github.bumptech.glide:glide:4.12.0' + implementation 'com.alibaba:fastjson:1.2.78' + } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e2415e8..f6c4688 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,9 @@ + xmlns:tools="http://schemas.android.com/tools"> + android:usesCleartextTraffic="true" + tools:targetApi="31"> + android:exported="true"> diff --git a/app/src/main/java/com/yutou/musicplayer/App.kt b/app/src/main/java/com/yutou/musicplayer/App.kt new file mode 100644 index 0000000..9f0031e --- /dev/null +++ b/app/src/main/java/com/yutou/musicplayer/App.kt @@ -0,0 +1,9 @@ +package com.yutou.musicplayer + +import android.app.Application + +class App : Application() { + override fun onCreate() { + super.onCreate() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/yutou/musicplayer/MainActivity.kt b/app/src/main/java/com/yutou/musicplayer/MainActivity.kt index c34cf84..0273cc6 100644 --- a/app/src/main/java/com/yutou/musicplayer/MainActivity.kt +++ b/app/src/main/java/com/yutou/musicplayer/MainActivity.kt @@ -2,10 +2,21 @@ package com.yutou.musicplayer import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import android.util.Log +import android.widget.TextView +import android.widget.Toast +import com.yutou.musicplayer.net.NetManager +import com.yutou.musicplayer.net.NetManager.Companion.userLogin class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + findViewById(R.id.textView).setOnClickListener { view -> + userLogin("yutou","34864394"){ + Log.i("登录信息", "onCreate: $it") + (view as TextView).text=it + } + } } } \ No newline at end of file diff --git a/app/src/main/java/com/yutou/musicplayer/net/NetManager.kt b/app/src/main/java/com/yutou/musicplayer/net/NetManager.kt new file mode 100644 index 0000000..418124a --- /dev/null +++ b/app/src/main/java/com/yutou/musicplayer/net/NetManager.kt @@ -0,0 +1,22 @@ +package com.yutou.musicplayer.net + +import com.drake.net.Post +import com.drake.net.utils.scopeNet +import kotlinx.coroutines.launch + +class NetManager { + companion object { + /** + * 用户登录 + */ + inline fun userLogin(uname: String, password: String, crossinline block: (String) -> Unit) { + scopeNet { + val data = Post("http://music.cnmglz.com/auth/login") { + json("{\"username\":\"$uname\",\"password\":\"$password\"}") + }.await() + block(data) + } + + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 59c0484..f52a352 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,19 @@ - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 443cab9..a712e13 100644 --- a/build.gradle +++ b/build.gradle @@ -2,5 +2,5 @@ plugins { id 'com.android.application' version '7.4.1' apply false id 'com.android.library' version '7.4.1' apply false - id 'org.jetbrains.kotlin.android' version '1.8.0' apply false + id 'org.jetbrains.kotlin.android' version '1.8.10' apply false } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..5960668 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Feb 18 11:18:42 CST 2023 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index d40f7b2..90648d4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,6 +3,7 @@ pluginManagement { google() mavenCentral() gradlePluginPortal() + maven { url 'https://jitpack.io' } } } dependencyResolutionManagement { @@ -10,6 +11,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { url 'https://jitpack.io' } } } rootProject.name = "MusicPlayerForSubsonic"