Merge branch 'master' of gitlab.navinfo.com:vivo/navinfovivo
Conflicts: app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageFragment.kt
This commit is contained in:
commit
3dc49ad764
@ -20,6 +20,7 @@ import androidx.fragment.app.viewModels
|
|||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.easytools.tools.DateUtils
|
import com.easytools.tools.DateUtils
|
||||||
@ -509,10 +510,9 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
|
|
||||||
// 开始网络提交数据
|
// 开始网络提交数据
|
||||||
if (obtainMessageViewModel.getMessageLiveData().value?.id==0L) { // 如果网络id为空,则调用更新操作
|
if (obtainMessageViewModel.getMessageLiveData().value?.id==0L) { // 如果网络id为空,则调用更新操作
|
||||||
obtainMessageViewModel.insertCardByApp()
|
obtainMessageViewModel.insertCardByApp(confirmCallback)
|
||||||
} else {
|
} else {
|
||||||
obtainMessageViewModel.updateCardByApp()
|
obtainMessageViewModel.updateCardByApp(confirmCallback)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,6 +533,12 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val confirmCallback = object: ObtainMessageViewModel.MyConfirmCallback {
|
||||||
|
override fun onSucess() {
|
||||||
|
findNavController().navigate(R.id.navi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.navinfo.volvo.ui.fragments.message
|
package com.navinfo.volvo.ui.fragments.message
|
||||||
|
|
||||||
|
import android.security.ConfirmationCallback
|
||||||
import androidx.lifecycle.*
|
import androidx.lifecycle.*
|
||||||
import com.easytools.tools.FileIOUtils
|
import com.easytools.tools.FileIOUtils
|
||||||
import com.easytools.tools.FileUtils
|
import com.easytools.tools.FileUtils
|
||||||
@ -220,7 +221,7 @@ class ObtainMessageViewModel @Inject constructor(): ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun insertCardByApp() {
|
fun insertCardByApp(confirmCallback: MyConfirmCallback) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
// TODO 首先保存数据到本地
|
// TODO 首先保存数据到本地
|
||||||
@ -241,7 +242,7 @@ class ObtainMessageViewModel @Inject constructor(): ViewModel() {
|
|||||||
message?.id = netId!!.toLong()
|
message?.id = netId!!.toLong()
|
||||||
ToastUtils.showToast("保存成功")
|
ToastUtils.showToast("保存成功")
|
||||||
// TODO 尝试更新本地数据
|
// TODO 尝试更新本地数据
|
||||||
|
confirmCallback.onSucess()
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.msg)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
@ -252,7 +253,7 @@ class ObtainMessageViewModel @Inject constructor(): ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateCardByApp() {
|
fun updateCardByApp(confirmCallback: MyConfirmCallback) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val message = msgLiveData.value
|
val message = msgLiveData.value
|
||||||
@ -271,6 +272,7 @@ class ObtainMessageViewModel @Inject constructor(): ViewModel() {
|
|||||||
// 数据更新成功
|
// 数据更新成功
|
||||||
ToastUtils.showToast("更新成功")
|
ToastUtils.showToast("更新成功")
|
||||||
// 尝试保存数据到本地
|
// 尝试保存数据到本地
|
||||||
|
confirmCallback.onSucess()
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.msg)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
@ -300,4 +302,8 @@ class ObtainMessageViewModel @Inject constructor(): ViewModel() {
|
|||||||
return File(url)
|
return File(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MyConfirmCallback {
|
||||||
|
fun onSucess()
|
||||||
|
}
|
||||||
}
|
}
|
@ -103,7 +103,7 @@ class EasyMediaFile {
|
|||||||
fun selectAudio(activity: Activity) {
|
fun selectAudio(activity: Activity) {
|
||||||
isCrop = false
|
isCrop = false
|
||||||
val intent = Intent(Intent.ACTION_PICK, null).apply {
|
val intent = Intent(Intent.ACTION_PICK, null).apply {
|
||||||
setDataAndType(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, "*/*")
|
setDataAndType(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, "audio/*")
|
||||||
}
|
}
|
||||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
selectFileInternal(intent, activity, 1)
|
selectFileInternal(intent, activity, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user