update
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
@@ -10,10 +11,11 @@
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MusicPlayerForSubsonic"
|
||||
tools:targetApi="31" >
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true" >
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
9
app/src/main/java/com/yutou/musicplayer/App.kt
Normal file
9
app/src/main/java/com/yutou/musicplayer/App.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.yutou.musicplayer
|
||||
|
||||
import android.app.Application
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
}
|
||||
}
|
||||
@@ -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<TextView>(R.id.textView).setOnClickListener { view ->
|
||||
userLogin("yutou","34864394"){
|
||||
Log.i("登录信息", "onCreate: $it")
|
||||
(view as TextView).text=it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
app/src/main/java/com/yutou/musicplayer/net/NetManager.kt
Normal file
22
app/src/main/java/com/yutou/musicplayer/net/NetManager.kt
Normal 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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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>
|
||||
Reference in New Issue
Block a user