network change - zl

master
zhoulu 5 years ago
parent ce813fffe1
commit 7d4e602e9d

@ -15,7 +15,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.DiaryBottleApp">
android:theme="@style/Theme.DiaryBottleApp"
android:networkSecurityConfig="@xml/network_config">
<activity
android:name=".ui.home.HomeActivity"
android:exported="false" />

@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.diarybottleapp.network.DBNetwork
import kotlinx.coroutines.*
import java.lang.Exception
class HomeViewModel : ViewModel() {
@ -18,9 +19,13 @@ class HomeViewModel : ViewModel() {
*/
fun getTestStr() {
scope.launch {
testStr.postValue(withContext(Dispatchers.Default){
DBNetwork.test().string()
})
try {
testStr.postValue(withContext(Dispatchers.Default){
DBNetwork.test().string()
})
} catch (e: Exception) {
}
}
}

@ -24,8 +24,8 @@ class ReadActivity : BaseActivity() {
override fun initEvents() {
read_save.setOnClickListener(this)
read_back.setOnClickListener(this)
check_msg.setOnClickListener(this)
hide_msg.setOnClickListener(this)
read_check_msg.setOnClickListener(this)
read_hide_msg.setOnClickListener(this)
}
override fun onActivityCreated() {
@ -37,13 +37,13 @@ class ReadActivity : BaseActivity() {
override fun onClick(v: View?) {
when(v?.id) {
R.id.read_back -> finish()
R.id.check_msg -> {
check_msg.visibility = View.GONE
R.id.read_check_msg -> {
read_check_msg.visibility = View.GONE
read_msg_rl.visibility = View.VISIBLE
read_msg_rl.startAnimation(bottomAnimIn)
}
R.id.hide_msg -> {
check_msg.visibility = View.VISIBLE
R.id.read_hide_msg -> {
read_check_msg.visibility = View.VISIBLE
read_msg_rl.visibility = View.GONE
read_msg_rl.startAnimation(bottomAnimOut)
}

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
Loading…
Cancel
Save