feat: 数据新增和修改接口调试
This commit is contained in:
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -7,8 +7,7 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleHome" value="$USER_HOME$/.gradle/wrapper/dists/gradle-7.2-all/260hg96vuh6ex27h9vo47iv4d/gradle-7.2" />
|
<option name="gradleJvm" value="11" />
|
||||||
<option name="gradleJvm" value="JDK" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
<!-- 拍照 -->
|
<!-- 拍照 -->
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.CAMERA"
|
android:name="android.permission.CAMERA"
|
||||||
android:required="false" /> <!-- 网络请求 -->
|
android:required="false" />
|
||||||
|
<!-- 网络请求 -->
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.INTERNET"
|
android:name="android.permission.INTERNET"
|
||||||
android:required="false" /> <!-- 录音 -->
|
android:required="false" />
|
||||||
|
<!-- 录音 -->
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.RECORD_AUDIO"
|
android:name="android.permission.RECORD_AUDIO"
|
||||||
android:required="false" /> <!-- 读写文件 -->
|
android:required="false" /> <!-- 读写文件 -->
|
||||||
@@ -53,5 +55,4 @@
|
|||||||
android:value="" />
|
android:value="" />
|
||||||
<meta-data android:name="ScopedStorage" android:value="true" />
|
<meta-data android:name="ScopedStorage" android:value="true" />
|
||||||
</application>
|
</application>
|
||||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -2,6 +2,6 @@ package com.navinfo.volvo.http
|
|||||||
|
|
||||||
class DefaultResponse<T> {
|
class DefaultResponse<T> {
|
||||||
var code: Int = 0
|
var code: Int = 0
|
||||||
var message: String = ""
|
var msg: String = ""
|
||||||
var data: T? = null
|
var data: T? = null
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.navinfo.volvo.http
|
package com.navinfo.volvo.http
|
||||||
|
|
||||||
import com.navinfo.volvo.db.dao.entity.Attachment
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
import retrofit2.create
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class NavinfoVolvoCall {
|
class NavinfoVolvoCall {
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.navinfo.volvo.ui
|
package com.navinfo.volvo.ui
|
||||||
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -11,10 +9,26 @@ import androidx.navigation.findNavController
|
|||||||
import androidx.navigation.ui.AppBarConfiguration
|
import androidx.navigation.ui.AppBarConfiguration
|
||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
|
import com.easytools.tools.FileUtils
|
||||||
|
import com.elvishew.xlog.LogConfiguration
|
||||||
|
import com.elvishew.xlog.LogLevel
|
||||||
|
import com.elvishew.xlog.XLog
|
||||||
|
import com.elvishew.xlog.interceptor.BlacklistTagsFilterInterceptor
|
||||||
|
import com.elvishew.xlog.printer.AndroidPrinter
|
||||||
|
import com.elvishew.xlog.printer.ConsolePrinter
|
||||||
|
import com.elvishew.xlog.printer.Printer
|
||||||
|
import com.elvishew.xlog.printer.file.FilePrinter
|
||||||
|
import com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
|
||||||
|
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.hjq.permissions.OnPermissionCallback
|
||||||
|
import com.hjq.permissions.Permission
|
||||||
|
import com.hjq.permissions.XXPermissions
|
||||||
|
import com.navinfo.volvo.BuildConfig
|
||||||
import com.navinfo.volvo.R
|
import com.navinfo.volvo.R
|
||||||
import com.navinfo.volvo.databinding.ActivityMainBinding
|
import com.navinfo.volvo.databinding.ActivityMainBinding
|
||||||
|
import com.navinfo.volvo.utils.SystemConstant
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import com.easytools.tools.DateUtils
|
|||||||
import com.easytools.tools.FileUtils
|
import com.easytools.tools.FileUtils
|
||||||
import com.elvishew.xlog.XLog
|
import com.elvishew.xlog.XLog
|
||||||
import com.navinfo.volvo.databinding.FragmentCameraBinding
|
import com.navinfo.volvo.databinding.FragmentCameraBinding
|
||||||
import com.navinfo.volvo.ui.message.ObtainMessageViewModel
|
import com.navinfo.volvo.ui.fragments.message.ObtainMessageViewModel
|
||||||
import com.navinfo.volvo.utils.SystemConstant
|
import com.navinfo.volvo.utils.SystemConstant
|
||||||
import com.otaliastudios.cameraview.CameraListener
|
import com.otaliastudios.cameraview.CameraListener
|
||||||
import com.otaliastudios.cameraview.CameraView
|
import com.otaliastudios.cameraview.CameraView
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import androidx.lifecycle.Observer
|
|||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.easytools.tools.DateUtils
|
import com.easytools.tools.DateUtils
|
||||||
import com.easytools.tools.ToastUtils
|
import com.easytools.tools.ToastUtils
|
||||||
import com.elvishew.xlog.XLog
|
import com.elvishew.xlog.XLog
|
||||||
@@ -28,10 +29,10 @@ import com.hjq.permissions.XXPermissions
|
|||||||
import com.navinfo.volvo.R
|
import com.navinfo.volvo.R
|
||||||
import com.navinfo.volvo.RecorderLifecycleObserver
|
import com.navinfo.volvo.RecorderLifecycleObserver
|
||||||
import com.navinfo.volvo.databinding.FragmentObtainMessageBinding
|
import com.navinfo.volvo.databinding.FragmentObtainMessageBinding
|
||||||
import com.navinfo.volvo.db.dao.entity.Attachment
|
|
||||||
import com.navinfo.volvo.db.dao.entity.AttachmentType
|
|
||||||
import com.navinfo.volvo.db.dao.entity.Message
|
|
||||||
import com.navinfo.volvo.http.NavinfoVolvoCall
|
import com.navinfo.volvo.http.NavinfoVolvoCall
|
||||||
|
import com.navinfo.volvo.model.Attachment
|
||||||
|
import com.navinfo.volvo.model.AttachmentType
|
||||||
|
import com.navinfo.volvo.model.Message
|
||||||
import com.navinfo.volvo.ui.markRequiredInRed
|
import com.navinfo.volvo.ui.markRequiredInRed
|
||||||
import com.navinfo.volvo.utils.EasyMediaFile
|
import com.navinfo.volvo.utils.EasyMediaFile
|
||||||
import com.navinfo.volvo.utils.SystemConstant
|
import com.navinfo.volvo.utils.SystemConstant
|
||||||
@@ -75,7 +76,13 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
if(it.title?.isNotEmpty() == true)
|
if(it.title?.isNotEmpty() == true)
|
||||||
binding.tvMessageTitle?.setText(it.title)
|
binding.tvMessageTitle?.setText(it.title)
|
||||||
if (it.sendDate?.isNotEmpty() == true) {
|
if (it.sendDate?.isNotEmpty() == true) {
|
||||||
binding.btnSendTime.text = it.sendDate
|
// 获取当前发送时间,如果早于当前时间,则显示现在
|
||||||
|
val sendDate = DateUtils.str2Date(it.sendDate, "yyyy-MM-dd HH:mm:ss")
|
||||||
|
if (sendDate<=Date()) {
|
||||||
|
binding.btnSendTime.text = "现在"
|
||||||
|
} else {
|
||||||
|
binding.btnSendTime.text = it.sendDate
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var hasPhoto = false
|
var hasPhoto = false
|
||||||
var hasAudio = false
|
var hasAudio = false
|
||||||
@@ -86,6 +93,7 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
Glide.with(context!!)
|
Glide.with(context!!)
|
||||||
.asBitmap().fitCenter()
|
.asBitmap().fitCenter()
|
||||||
.load(attachment.pathUrl)
|
.load(attachment.pathUrl)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.into(binding.imgMessageAttachment)
|
.into(binding.imgMessageAttachment)
|
||||||
// 显示名称
|
// 显示名称
|
||||||
hasPhoto = true
|
hasPhoto = true
|
||||||
@@ -130,14 +138,20 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
|
|
||||||
fun initView() {
|
fun initView() {
|
||||||
// 设置问候信息提示的红色星号
|
// 设置问候信息提示的红色星号
|
||||||
binding.tiLayoutTitle.markRequiredInRed()
|
// binding.tiLayoutTitle.markRequiredInRed()
|
||||||
binding.tvMessageTitle.addTextChangedListener {
|
// binding.tvMessageTitle.addTextChangedListener(afterTextChanged = {
|
||||||
obtainMessageViewModel.updateMessageTitle(it.toString())
|
// obtainMessageViewModel.updateMessageTitle(it.toString())
|
||||||
|
// })
|
||||||
|
|
||||||
|
binding.tvMessageTitle.setOnFocusChangeListener { view, b ->
|
||||||
|
if (!b) {
|
||||||
|
obtainMessageViewModel.updateMessageTitle(binding.tvMessageTitle.text.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.edtSendFrom.addTextChangedListener {
|
binding.edtSendFrom.addTextChangedListener (afterTextChanged = {
|
||||||
obtainMessageViewModel.updateMessageSendFrom(it.toString())
|
obtainMessageViewModel.updateMessageSendFrom(it.toString())
|
||||||
}
|
})
|
||||||
|
|
||||||
binding.imgPhotoDelete.setOnClickListener {
|
binding.imgPhotoDelete.setOnClickListener {
|
||||||
obtainMessageViewModel.updateMessagePic(null)
|
obtainMessageViewModel.updateMessagePic(null)
|
||||||
@@ -167,9 +181,9 @@ class ObtainMessageFragment: Fragment() {
|
|||||||
override fun onClickListener(selectTime: String) {
|
override fun onClickListener(selectTime: String) {
|
||||||
val sendDate = DateUtils.str2Date(selectTime, "yyyy-MM-dd HH:mm")
|
val sendDate = DateUtils.str2Date(selectTime, "yyyy-MM-dd HH:mm")
|
||||||
if (sendDate <= Date()) {
|
if (sendDate <= Date()) {
|
||||||
obtainMessageViewModel.updateMessageSendTime("现在")
|
obtainMessageViewModel.updateMessageSendTime(DateUtils.date2Str(Date(), "yyyy-MM-dd HH:mm:ss"))
|
||||||
} else {
|
} else {
|
||||||
obtainMessageViewModel.updateMessageSendTime(selectTime)
|
obtainMessageViewModel.updateMessageSendTime(DateUtils.date2Str(sendDate, "yyyy-MM-dd HH:mm:ss"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package com.navinfo.volvo.ui.fragments.message
|
|||||||
import androidx.lifecycle.*
|
import androidx.lifecycle.*
|
||||||
import com.easytools.tools.ToastUtils
|
import com.easytools.tools.ToastUtils
|
||||||
import com.elvishew.xlog.XLog
|
import com.elvishew.xlog.XLog
|
||||||
import com.navinfo.volvo.db.dao.entity.Attachment
|
|
||||||
import com.navinfo.volvo.db.dao.entity.AttachmentType
|
|
||||||
import com.navinfo.volvo.db.dao.entity.Message
|
|
||||||
import com.navinfo.volvo.http.NavinfoVolvoCall
|
import com.navinfo.volvo.http.NavinfoVolvoCall
|
||||||
|
import com.navinfo.volvo.model.Attachment
|
||||||
|
import com.navinfo.volvo.model.AttachmentType
|
||||||
|
import com.navinfo.volvo.model.Message
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType
|
import okhttp3.MediaType
|
||||||
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -122,7 +123,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val requestFile: RequestBody =
|
val requestFile: RequestBody =
|
||||||
RequestBody.create(MediaType.parse("multipart/form-data"), attachmentFile)
|
RequestBody.create("multipart/form-data".toMediaTypeOrNull(), attachmentFile)
|
||||||
val body = MultipartBody.Part.createFormData("picture", attachmentFile.getName(), requestFile)
|
val body = MultipartBody.Part.createFormData("picture", attachmentFile.getName(), requestFile)
|
||||||
val result = NavinfoVolvoCall.getApi().uploadAttachment(body)
|
val result = NavinfoVolvoCall.getApi().uploadAttachment(body)
|
||||||
XLog.d(result.code)
|
XLog.d(result.code)
|
||||||
@@ -133,7 +134,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
downloadAttachment(fileKey, attachmentType)
|
downloadAttachment(fileKey, attachmentType)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.message)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ToastUtils.showToast(e.message)
|
ToastUtils.showToast(e.message)
|
||||||
@@ -163,7 +164,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.message)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ToastUtils.showToast(e.message)
|
ToastUtils.showToast(e.message)
|
||||||
@@ -192,7 +193,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
message.netId = netId!!
|
message.netId = netId!!
|
||||||
// 尝试保存数据到本地
|
// 尝试保存数据到本地
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.message)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ToastUtils.showToast(e.message)
|
ToastUtils.showToast(e.message)
|
||||||
@@ -206,6 +207,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
try {
|
try {
|
||||||
val message = msgLiveData.value
|
val message = msgLiveData.value
|
||||||
val insertData = mapOf(
|
val insertData = mapOf(
|
||||||
|
"id" to message?.netId,
|
||||||
"name" to message?.title,
|
"name" to message?.title,
|
||||||
"imageUrl" to getImageAttachment(message?.attachment!!)?.pathUrl,
|
"imageUrl" to getImageAttachment(message?.attachment!!)?.pathUrl,
|
||||||
"mediaUrl" to getAudioAttachment(message?.attachment!!)?.pathUrl,
|
"mediaUrl" to getAudioAttachment(message?.attachment!!)?.pathUrl,
|
||||||
@@ -221,7 +223,7 @@ class ObtainMessageViewModel: ViewModel() {
|
|||||||
message.netId = netId!!
|
message.netId = netId!!
|
||||||
// 尝试保存数据到本地
|
// 尝试保存数据到本地
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(result.message)
|
ToastUtils.showToast(result.msg)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ToastUtils.showToast(e.message)
|
ToastUtils.showToast(e.message)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
app:counterEnabled="true"
|
app:counterEnabled="true"
|
||||||
app:counterMaxLength="10"
|
app:counterMaxLength="10"
|
||||||
app:errorEnabled="true"
|
app:errorEnabled="true"
|
||||||
android:hint="请输入问候信息"
|
android:hint="问候信息"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user