This commit is contained in:
zlzw 2023-02-18 18:28:17 +08:00
parent c7452c3016
commit db1ef315a8
9 changed files with 85 additions and 19 deletions

View File

@ -35,10 +35,23 @@ android {
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.5.0' implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 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'
} }

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" > xmlns:tools="http://schemas.android.com/tools">
<application <application
android:name=".App"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
@ -10,10 +11,11 @@
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MusicPlayerForSubsonic" android:theme="@style/Theme.MusicPlayerForSubsonic"
tools:targetApi="31" > android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" > android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -0,0 +1,9 @@
package com.yutou.musicplayer
import android.app.Application
class App : Application() {
override fun onCreate() {
super.onCreate()
}
}

View File

@ -2,10 +2,21 @@ package com.yutou.musicplayer
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle 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() { class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
findViewById<TextView>(R.id.textView).setOnClickListener { view ->
userLogin("yutou","34864394"){
Log.i("登录信息", "onCreate: $it")
(view as TextView).text=it
}
}
} }
} }

View File

@ -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<String>("http://music.cnmglz.com/auth/login") {
json("{\"username\":\"$uname\",\"password\":\"$password\"}")
}.await()
block(data)
}
}
}
}

View File

@ -1,18 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> <TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -2,5 +2,5 @@
plugins { plugins {
id 'com.android.application' version '7.4.1' apply false id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' 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
} }

View File

@ -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

View File

@ -3,6 +3,7 @@ pluginManagement {
google() google()
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven { url 'https://jitpack.io' }
} }
} }
dependencyResolutionManagement { dependencyResolutionManagement {
@ -10,6 +11,7 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
maven { url 'https://jitpack.io' }
} }
} }
rootProject.name = "MusicPlayerForSubsonic" rootProject.name = "MusicPlayerForSubsonic"