优化ai对话页面
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,10 @@ object ActionCode {
|
|||||||
//const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
//const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
||||||
//const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
//const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
||||||
// const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
// const val BASE_URL = "https://ragged-parting-unrushed.ngrok-free.dev";
|
||||||
|
|
||||||
|
|
||||||
const val BASE_URL = "https://d.chongdunpet.com"
|
const val BASE_URL = "https://d.chongdunpet.com"
|
||||||
|
// const val BASE_URL = "http://192.168.1.187:8080"
|
||||||
const val CUSTOMER_URL = "wss://d.chongdunpet.com/ws/chat?role=customer&token=";
|
const val CUSTOMER_URL = "wss://d.chongdunpet.com/ws/chat?role=customer&token=";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ck.ckcollar.app.model
|
package com.ck.ckcollar.app.model
|
||||||
|
|
||||||
class BannarModel : CkBaseModel(){
|
class BannarModel : CkBaseModel(){
|
||||||
|
var localImageRes: Int = 0
|
||||||
var bannerStatus: String? = ""
|
var bannerStatus: String? = ""
|
||||||
var bannerUrl: String? = ""
|
var bannerUrl: String? = ""
|
||||||
var createBy: String? = ""
|
var createBy: String? = ""
|
||||||
@@ -11,4 +12,4 @@ class BannarModel : CkBaseModel(){
|
|||||||
var sortOrder: Int = 0
|
var sortOrder: Int = 0
|
||||||
var updateBy: String? = ""
|
var updateBy: String? = ""
|
||||||
var updateTime: String? = ""
|
var updateTime: String? = ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
@@ -68,6 +69,8 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
var data = mutableListOf<CustomerMessageModel.MessageItemModel>()
|
var data = mutableListOf<CustomerMessageModel.MessageItemModel>()
|
||||||
|
|
||||||
var path = ""
|
var path = ""
|
||||||
|
private var isSending = false
|
||||||
|
private var isAiResponding = false
|
||||||
var url = ""
|
var url = ""
|
||||||
|
|
||||||
var lock = true
|
var lock = true
|
||||||
@@ -97,6 +100,24 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
binding.recyclerView.adapter = customerMessageAdapter
|
binding.recyclerView.adapter = customerMessageAdapter
|
||||||
|
|
||||||
binding.editMessage.setHorizontallyScrolling(false);
|
binding.editMessage.setHorizontallyScrolling(false);
|
||||||
|
binding.btnSend.setOnClickListener {
|
||||||
|
if (isAiResponding) {
|
||||||
|
toast("请等待当前问题回答结束")
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
isSending = true
|
||||||
|
// Reset the action controls immediately. The send flow captures the
|
||||||
|
// submitted text and image path before clearing the visible draft.
|
||||||
|
binding.btnSend.visibility = View.GONE
|
||||||
|
binding.btnMore.visibility = View.VISIBLE
|
||||||
|
binding.editMessage.onEditorAction(EditorInfo.IME_ACTION_SEND)
|
||||||
|
}
|
||||||
|
updateSendControls()
|
||||||
|
// Use the traditional multiline keyboard action; sending is handled by the
|
||||||
|
// activity's own message flow rather than the IME action button.
|
||||||
|
binding.editMessage.setSingleLine(false)
|
||||||
|
binding.editMessage.imeOptions = EditorInfo.IME_ACTION_NONE
|
||||||
|
binding.editMessage.setRawInputType(android.text.InputType.TYPE_CLASS_TEXT or android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||||
|
|
||||||
binding.editMessage.setOnEditorActionListener(object : TextView.OnEditorActionListener {
|
binding.editMessage.setOnEditorActionListener(object : TextView.OnEditorActionListener {
|
||||||
override fun onEditorAction(
|
override fun onEditorAction(
|
||||||
@@ -104,21 +125,21 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
actionId: Int,
|
actionId: Int,
|
||||||
ketEvent: KeyEvent?
|
ketEvent: KeyEvent?
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED ||
|
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
actionId == EditorInfo.IME_ACTION_SEND ||
|
|
||||||
(ketEvent != null && ketEvent.keyCode == KeyEvent.KEYCODE_ENTER)
|
|
||||||
) {
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
var text = binding.editMessage.text.toString()
|
// Whitespace-only input is not a message. A selected image may still be sent alone.
|
||||||
var index = text.indexOf("$$$$$") >= 0
|
val text = binding.editMessage.text.toString().trim()
|
||||||
if (!index) {
|
if (text.isNotEmpty() || path.isNotEmpty()) {
|
||||||
path = ""
|
|
||||||
}
|
|
||||||
text = text.replace("$$$$$", "")
|
|
||||||
if (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(path)) {
|
|
||||||
lock = false
|
lock = false
|
||||||
|
KeyboardUtils.hideKeyboard(this@CustomerActivity)
|
||||||
|
binding.editMessage.clearFocus()
|
||||||
handler.post {
|
handler.post {
|
||||||
sendMessage(UUID.randomUUID().toString(),text,false)
|
if (!TextUtils.isEmpty(path)) {
|
||||||
|
uploadImage(text, path)
|
||||||
|
} else {
|
||||||
|
sendMessage(UUID.randomUUID().toString(), text, false, "")
|
||||||
|
}
|
||||||
|
clearInputViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,14 +177,9 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
p2: Int,
|
p2: Int,
|
||||||
p3: Int
|
p3: Int
|
||||||
) {
|
) {
|
||||||
|
if (p0?.toString()?.trim()?.isNotEmpty() == true) isSending = false
|
||||||
|
updateSendControls()
|
||||||
try {
|
try {
|
||||||
var text = binding.editMessage.text.toString()
|
|
||||||
var index = text.indexOf("$$$$$") >= 0
|
|
||||||
// if (!index) {
|
|
||||||
// path = ""
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
val lineCount: Int? = binding.editMessage.getLineCount()
|
val lineCount: Int? = binding.editMessage.getLineCount()
|
||||||
val lineHeight: Int = binding.editMessage.getLineHeight()
|
val lineHeight: Int = binding.editMessage.getLineHeight()
|
||||||
val maxHeight: Int = lineCount!! * lineHeight
|
val maxHeight: Int = lineCount!! * lineHeight
|
||||||
@@ -175,12 +191,13 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
})
|
})
|
||||||
binding.btnMore.setOnClickListener {
|
binding.btnMore.setOnClickListener {
|
||||||
if (binding.contentBottom.visibility == View.GONE) {
|
if (binding.contentBottom.visibility == View.GONE) {
|
||||||
KeyboardUtils.hideKeyboard(this@CustomerActivity)
|
val inputMethodManager =
|
||||||
|
getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(binding.editMessage.windowToken, 0)
|
||||||
|
binding.editMessage.clearFocus()
|
||||||
binding.contentBottom.visibility = View.VISIBLE
|
binding.contentBottom.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.contentBottom.visibility = View.GONE
|
binding.contentBottom.visibility = View.GONE
|
||||||
binding.editMessage.requestFocus()
|
|
||||||
KeyboardUtils.showKeyboard(binding.editMessage)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.btnSmile.setOnClickListener {
|
binding.btnSmile.setOnClickListener {
|
||||||
@@ -188,6 +205,9 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
binding.editMessage.requestFocus()
|
binding.editMessage.requestFocus()
|
||||||
KeyboardUtils.showKeyboard(binding.editMessage)
|
KeyboardUtils.showKeyboard(binding.editMessage)
|
||||||
}
|
}
|
||||||
|
binding.btnDeleteImage.setOnClickListener {
|
||||||
|
clearSelectedImage()
|
||||||
|
}
|
||||||
//拍照
|
//拍照
|
||||||
binding.conetnt1.setOnClickListener {
|
binding.conetnt1.setOnClickListener {
|
||||||
|
|
||||||
@@ -233,7 +253,7 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleMessage()
|
handleMessage()
|
||||||
|
binding.btnSmile.visibility = View.GONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPermissionsGranted(requestCode: Int, permissions: Array<String>) {
|
override fun onPermissionsGranted(requestCode: Int, permissions: Array<String>) {
|
||||||
@@ -295,7 +315,7 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
if (!TextUtils.isEmpty(sendConetnt) || !TextUtils.isEmpty(url)){
|
if (!TextUtils.isEmpty(sendConetnt) || !TextUtils.isEmpty(url)){
|
||||||
handler.post {
|
handler.post {
|
||||||
sendMessage2(UUID.randomUUID().toString(),sendConetnt,true)
|
sendMessage2(UUID.randomUUID().toString(),sendConetnt,true, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,15 +342,17 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}).show()
|
}).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendMessage(uuid :String ,content: String,isResend : Boolean) {
|
fun sendMessage(uuid :String ,content: String,isResend : Boolean, imageUrl: String) {
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(url)) {
|
isAiResponding = true
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(imageUrl)) {
|
||||||
this@CustomerActivity.data.add(CustomerMessageModel.MessageItemModel().apply {
|
this@CustomerActivity.data.add(CustomerMessageModel.MessageItemModel().apply {
|
||||||
senderId = CKApp.app.userInfo?.id!!
|
senderId = CKApp.app.userInfo?.id!!
|
||||||
this.content = content
|
this.content = content
|
||||||
this.senderAvatar = CKApp.app.userInfo?.avatar
|
this.senderAvatar = CKApp.app.userInfo?.avatar
|
||||||
this.senderName = CKApp.app.userInfo?.custName ?: "我"
|
this.senderName = CKApp.app.userInfo?.custName ?: "我"
|
||||||
this.url = this@CustomerActivity.url
|
this.url = imageUrl
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(content) && !isResend) {
|
if (!TextUtils.isEmpty(content) && !isResend) {
|
||||||
@@ -350,14 +372,12 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
|
|
||||||
TTHttpClient.postJsonStream3(this, "发送会话消息stream", TTRequestParam().apply {
|
TTHttpClient.postJsonStream3(this, "发送会话消息stream", TTRequestParam().apply {
|
||||||
add(TTRequestData("imageUrl", url))
|
add(TTRequestData("imageUrl", imageUrl))
|
||||||
|
|
||||||
add(TTRequestData("question", content))
|
add(TTRequestData("question", content))
|
||||||
}, object : ICallback {
|
}, object : ICallback {
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
|
|
||||||
lock = true
|
|
||||||
|
|
||||||
// var model = Gson().fromJson<AIMessageModel>(data, AIMessageModel::class.java)
|
// var model = Gson().fromJson<AIMessageModel>(data, AIMessageModel::class.java)
|
||||||
|
|
||||||
var flag = false
|
var flag = false
|
||||||
@@ -379,9 +399,6 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.editMessage.setText("")
|
|
||||||
path = ""
|
|
||||||
url = ""
|
|
||||||
customerMessageAdapter.data = this@CustomerActivity.data
|
customerMessageAdapter.data = this@CustomerActivity.data
|
||||||
customerMessageAdapter.notifyDataSetChanged()
|
customerMessageAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
@@ -401,13 +418,17 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailed(code: String, msg: String) {
|
override fun onFailed(code: String, msg: String) {
|
||||||
|
isAiResponding = false
|
||||||
lock = true
|
lock = true
|
||||||
// toast(msg)
|
// toast(msg)
|
||||||
//TTLog.e(msg)
|
//TTLog.e(msg)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
binding.editMessage.setText("")
|
override fun onComplete() {
|
||||||
|
isAiResponding = false
|
||||||
|
lock = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
customerMessageAdapter.data = this@CustomerActivity.data
|
customerMessageAdapter.data = this@CustomerActivity.data
|
||||||
customerMessageAdapter.notifyDataSetChanged()
|
customerMessageAdapter.notifyDataSetChanged()
|
||||||
@@ -418,7 +439,8 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun sendMessage2(uuid :String ,content: String,isResend : Boolean) {
|
fun sendMessage2(uuid :String ,content: String,isResend : Boolean, imageUrl: String) {
|
||||||
|
isAiResponding = true
|
||||||
lock = false
|
lock = false
|
||||||
if (!TextUtils.isEmpty(content) && !isResend) {
|
if (!TextUtils.isEmpty(content) && !isResend) {
|
||||||
this@CustomerActivity.data.add(CustomerMessageModel.MessageItemModel().apply {
|
this@CustomerActivity.data.add(CustomerMessageModel.MessageItemModel().apply {
|
||||||
@@ -437,14 +459,12 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
|
|
||||||
TTHttpClient.postJsonStream3(this, "发送会话消息stream", TTRequestParam().apply {
|
TTHttpClient.postJsonStream3(this, "发送会话消息stream", TTRequestParam().apply {
|
||||||
add(TTRequestData("imageUrl", url))
|
add(TTRequestData("imageUrl", imageUrl))
|
||||||
|
|
||||||
add(TTRequestData("question", content))
|
add(TTRequestData("question", content))
|
||||||
}, object : ICallback {
|
}, object : ICallback {
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
|
|
||||||
lock = true
|
|
||||||
|
|
||||||
// var model = Gson().fromJson<AIMessageModel>(data, AIMessageModel::class.java)
|
// var model = Gson().fromJson<AIMessageModel>(data, AIMessageModel::class.java)
|
||||||
|
|
||||||
var flag = false
|
var flag = false
|
||||||
@@ -466,9 +486,6 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.editMessage.setText("")
|
|
||||||
path = ""
|
|
||||||
url = ""
|
|
||||||
customerMessageAdapter.data = this@CustomerActivity.data
|
customerMessageAdapter.data = this@CustomerActivity.data
|
||||||
customerMessageAdapter.notifyDataSetChanged()
|
customerMessageAdapter.notifyDataSetChanged()
|
||||||
|
|
||||||
@@ -488,13 +505,17 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailed(code: String, msg: String) {
|
override fun onFailed(code: String, msg: String) {
|
||||||
|
isAiResponding = false
|
||||||
lock = true
|
lock = true
|
||||||
// toast(msg)
|
// toast(msg)
|
||||||
//TTLog.e(msg)
|
//TTLog.e(msg)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
binding.editMessage.setText("")
|
override fun onComplete() {
|
||||||
|
isAiResponding = false
|
||||||
|
lock = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
customerMessageAdapter.data = this@CustomerActivity.data
|
customerMessageAdapter.data = this@CustomerActivity.data
|
||||||
customerMessageAdapter.notifyDataSetChanged()
|
customerMessageAdapter.notifyDataSetChanged()
|
||||||
@@ -504,10 +525,10 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun uploadImage() {
|
fun uploadImage(content: String, imagePath: String) {
|
||||||
|
|
||||||
var param = TTRequestParam()
|
var param = TTRequestParam()
|
||||||
param.files.add(File(path))
|
param.files.add(File(imagePath))
|
||||||
|
|
||||||
showProgeassDialog()
|
showProgeassDialog()
|
||||||
TTHttpClient.postFile(this, "上传照片s", param, object : ICallback {
|
TTHttpClient.postFile(this, "上传照片s", param, object : ICallback {
|
||||||
@@ -515,9 +536,8 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
hiddenProgeassDialog()
|
hiddenProgeassDialog()
|
||||||
var model = Gson().fromJson<UploadModel>(data, UploadModel::class.java)
|
var model = Gson().fromJson<UploadModel>(data, UploadModel::class.java)
|
||||||
|
|
||||||
url = model.urls
|
|
||||||
handler.post {
|
handler.post {
|
||||||
sendMessage(UUID.randomUUID().toString(), "", false)
|
sendMessage(UUID.randomUUID().toString(), content, false, model.urls)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -525,8 +545,11 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
override fun onFailed(code: String, msg: String) {
|
override fun onFailed(code: String, msg: String) {
|
||||||
hiddenProgeassDialog()
|
hiddenProgeassDialog()
|
||||||
lock = true
|
lock = true
|
||||||
path = ""
|
if (path.isEmpty() && binding.editMessage.text.toString().isEmpty()) {
|
||||||
url = ""
|
path = imagePath
|
||||||
|
showImagePreview(imagePath)
|
||||||
|
binding.editMessage.setText(content)
|
||||||
|
}
|
||||||
toast(msg)
|
toast(msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -561,15 +584,15 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
if (requestCode == 55 && resultCode == RESULT_OK) {
|
if (requestCode == 55 && resultCode == RESULT_OK) {
|
||||||
path = PreferencesUtils.getString(this@CustomerActivity, Const.IMAGE_PATH, "")!!
|
path = PreferencesUtils.getString(this@CustomerActivity, Const.IMAGE_PATH, "")!!
|
||||||
sendSelectedImage()
|
prepareSelectedImage()
|
||||||
} else if (requestCode == 56 && resultCode == RESULT_OK) {
|
} else if (requestCode == 56 && resultCode == RESULT_OK) {
|
||||||
path = TTUtils.getImageUrl(this, data!!.getData());
|
path = TTUtils.getImageUrl(this, data!!.getData());
|
||||||
sendSelectedImage()
|
prepareSelectedImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendSelectedImage() {
|
private fun prepareSelectedImage() {
|
||||||
if (TextUtils.isEmpty(path)) return
|
if (TextUtils.isEmpty(path)) return
|
||||||
|
|
||||||
LubanCompressUtil.getCompressFile(
|
LubanCompressUtil.getCompressFile(
|
||||||
@@ -579,10 +602,17 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
override fun success(file: File) {
|
override fun success(file: File) {
|
||||||
if (isFinishing || isDestroyed) return
|
if (isFinishing || isDestroyed) return
|
||||||
path = file.absolutePath
|
path = file.absolutePath
|
||||||
lock = false
|
lock = true
|
||||||
binding.contentBottom.visibility = View.GONE
|
binding.contentBottom.visibility = View.GONE
|
||||||
binding.editMessage.setText("")
|
showImagePreview(path)
|
||||||
uploadImage()
|
binding.editMessage.requestFocus()
|
||||||
|
KeyboardUtils.showKeyboard(binding.editMessage)
|
||||||
|
// Rebind the IME after selecting an image so its action button is
|
||||||
|
// available even though the text field itself is empty.
|
||||||
|
binding.editMessage.postDelayed({
|
||||||
|
val imm = getSystemService(INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager
|
||||||
|
imm?.restartInput(binding.editMessage)
|
||||||
|
}, 150L)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fail(failMsg: String) {
|
override fun fail(failMsg: String) {
|
||||||
@@ -595,6 +625,48 @@ class CustomerActivity : CKBaseActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showImagePreview(imagePath: String) {
|
||||||
|
isSending = false
|
||||||
|
binding.contentImagePreview.visibility = View.VISIBLE
|
||||||
|
updateSendControls()
|
||||||
|
binding.imagePreview.scaleType = android.widget.ImageView.ScaleType.CENTER_CROP
|
||||||
|
Glide.with(this)
|
||||||
|
.load(imagePath)
|
||||||
|
.into(binding.imagePreview)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearSelectedImage() {
|
||||||
|
path = ""
|
||||||
|
url = ""
|
||||||
|
binding.imagePreview.setImageDrawable(null)
|
||||||
|
binding.contentImagePreview.visibility = View.GONE
|
||||||
|
updateSendControls()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearInputViews() {
|
||||||
|
binding.editMessage.setText("")
|
||||||
|
path = ""
|
||||||
|
url = ""
|
||||||
|
binding.imagePreview.setImageDrawable(null)
|
||||||
|
binding.contentImagePreview.visibility = View.GONE
|
||||||
|
// Sending has already been initiated; keep the controls in their idle state
|
||||||
|
// until the user starts composing the next draft.
|
||||||
|
binding.btnSend.visibility = View.GONE
|
||||||
|
binding.btnMore.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateSendControls() {
|
||||||
|
val hasImage = path.isNotEmpty()
|
||||||
|
val hasText = binding.editMessage.text.toString().trim().isNotEmpty()
|
||||||
|
if (isSending) {
|
||||||
|
binding.btnSend.visibility = View.GONE
|
||||||
|
binding.btnMore.visibility = View.VISIBLE
|
||||||
|
return
|
||||||
|
}
|
||||||
|
binding.btnSend.visibility = if (hasImage || hasText) View.VISIBLE else View.GONE
|
||||||
|
binding.btnMore.visibility = if (hasImage) View.GONE else View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class MineCustomerActivity : CKBaseActivity() {
|
|||||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||||
TTLog.e("onOpen")
|
TTLog.e("onOpen")
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
toast(getString(R.string.connect_customer_success))
|
// toast(getString(R.string.connect_customer_success))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ class PeopleCustomerActivity : CKBaseActivity() {
|
|||||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||||
TTLog.e("onOpen")
|
TTLog.e("onOpen")
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
toast(getString(R.string.connect_customer_success))
|
// toast(getString(R.string.connect_customer_success))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class ShopCustomerActivity : CKBaseActivity() {
|
|||||||
override fun onOpen(webSocket: WebSocket, response: Response) {
|
override fun onOpen(webSocket: WebSocket, response: Response) {
|
||||||
TTLog.e("onOpen")
|
TTLog.e("onOpen")
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
toast(getString(R.string.connect_customer_success))
|
// toast(getString(R.string.connect_customer_success))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.ck.ckcollar.app.CKApp
|
||||||
import com.ck.ckcollar.app.R
|
import com.ck.ckcollar.app.R
|
||||||
import com.ck.ckcollar.app.databinding.FragmentHealthBinding
|
import com.ck.ckcollar.app.databinding.FragmentHealthBinding
|
||||||
import com.ck.ckcollar.app.databinding.LayoutItemNoteBinding
|
import com.ck.ckcollar.app.databinding.LayoutItemNoteBinding
|
||||||
@@ -16,6 +17,7 @@ import com.ck.ckcollar.app.model.CustomerStatusModel
|
|||||||
import com.ck.ckcollar.app.model.HealthNoteModel
|
import com.ck.ckcollar.app.model.HealthNoteModel
|
||||||
import com.ck.ckcollar.app.ui.act.customer.CustomerActivity
|
import com.ck.ckcollar.app.ui.act.customer.CustomerActivity
|
||||||
import com.ck.ckcollar.app.ui.act.customer.PeopleCustomerActivity
|
import com.ck.ckcollar.app.ui.act.customer.PeopleCustomerActivity
|
||||||
|
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
||||||
import com.ck.ckcollar.app.ui.act.note.NoteDetailsActivity
|
import com.ck.ckcollar.app.ui.act.note.NoteDetailsActivity
|
||||||
import com.ck.ckcollar.app.ui.base.CKBaseFragment
|
import com.ck.ckcollar.app.ui.base.CKBaseFragment
|
||||||
import com.ck.ckcollar.app.ui.dialog.CKAlertDialog
|
import com.ck.ckcollar.app.ui.dialog.CKAlertDialog
|
||||||
@@ -64,10 +66,12 @@ class HealthFragment: CKBaseFragment() {
|
|||||||
binding.recyclerView.adapter = noteAdapter
|
binding.recyclerView.adapter = noteAdapter
|
||||||
|
|
||||||
binding.btnAIText.setOnClickListener {
|
binding.btnAIText.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
|
|
||||||
toActivity(CustomerActivity::class.java, DataCollection())
|
toActivity(CustomerActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.btnAIPhoto.setOnClickListener {
|
binding.btnAIPhoto.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(CustomerActivity::class.java, DataCollection())
|
toActivity(CustomerActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.contentCustomer.setOnClickListener {
|
binding.contentCustomer.setOnClickListener {
|
||||||
@@ -75,6 +79,10 @@ class HealthFragment: CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
binding.refreshLayout.setEnableLoadMore(false)
|
binding.refreshLayout.setEnableLoadMore(false)
|
||||||
binding.refreshLayout.setOnRefreshListener {
|
binding.refreshLayout.setOnRefreshListener {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
binding.refreshLayout.finishRefresh()
|
||||||
|
return@setOnRefreshListener
|
||||||
|
}
|
||||||
page = 1
|
page = 1
|
||||||
getData()
|
getData()
|
||||||
getCustomerTime()
|
getCustomerTime()
|
||||||
@@ -84,6 +92,12 @@ class HealthFragment: CKBaseFragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requireLogin(): Boolean {
|
||||||
|
if (CKApp.app.isUserLoggedIn) return true
|
||||||
|
toActivity(LoginActivity::class.java, DataCollection())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
|
|
||||||
|
|
||||||
@@ -93,6 +107,7 @@ class HealthFragment: CKBaseFragment() {
|
|||||||
|
|
||||||
|
|
||||||
fun getCustomerTime(){
|
fun getCustomerTime(){
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
|
|
||||||
TTHttpClient.get(activity as TTBaseActivity,"客服在线状态", TTRequestParam(),object : ICallback{
|
TTHttpClient.get(activity as TTBaseActivity,"客服在线状态", TTRequestParam(),object : ICallback{
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
@@ -128,6 +143,8 @@ class HealthFragment: CKBaseFragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
fun getData(){
|
fun getData(){
|
||||||
|
// if (!CKApp.app.isUserLoggedIn) return
|
||||||
|
|
||||||
TTHttpClient.get(activity as TTBaseActivity,"宠物知识列表", TTRequestParam().apply {
|
TTHttpClient.get(activity as TTBaseActivity,"宠物知识列表", TTRequestParam().apply {
|
||||||
add(
|
add(
|
||||||
TTRequestData("pageNum", page)
|
TTRequestData("pageNum", page)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.ck.ckcollar.app.CKApp
|
||||||
import com.ck.ckcollar.app.R
|
import com.ck.ckcollar.app.R
|
||||||
import com.ck.ckcollar.app.databinding.FragmentHomeBinding
|
import com.ck.ckcollar.app.databinding.FragmentHomeBinding
|
||||||
import com.ck.ckcollar.app.listenner.OnItemClickListenner
|
import com.ck.ckcollar.app.listenner.OnItemClickListenner
|
||||||
@@ -42,6 +43,7 @@ import com.ck.ckcollar.app.ui.act.petmanager.InputInviteCodeActivity
|
|||||||
import com.ck.ckcollar.app.ui.act.petmanager.MapLocationActivity
|
import com.ck.ckcollar.app.ui.act.petmanager.MapLocationActivity
|
||||||
import com.ck.ckcollar.app.ui.act.petmanager.PetManagerActivity
|
import com.ck.ckcollar.app.ui.act.petmanager.PetManagerActivity
|
||||||
import com.ck.ckcollar.app.ui.act.petmanager.ViewPetFileActivity
|
import com.ck.ckcollar.app.ui.act.petmanager.ViewPetFileActivity
|
||||||
|
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
||||||
import com.ck.ckcollar.app.ui.base.CKBaseFragment
|
import com.ck.ckcollar.app.ui.base.CKBaseFragment
|
||||||
import com.ck.ckcollar.app.ui.dialog.CKAlertDialog
|
import com.ck.ckcollar.app.ui.dialog.CKAlertDialog
|
||||||
import com.ck.ckcollar.app.ui.popview.CKCollarTypePopView
|
import com.ck.ckcollar.app.ui.popview.CKCollarTypePopView
|
||||||
@@ -125,10 +127,12 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
|
|
||||||
homeBinding.textName?.setOnClickListener {
|
homeBinding.textName?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
getPetList()
|
getPetList()
|
||||||
}
|
}
|
||||||
//扫一扫
|
//扫一扫
|
||||||
homeBinding.btnScan?.setOnClickListener {
|
homeBinding.btnScan?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
if (dataModel == null) {
|
if (dataModel == null) {
|
||||||
toast(getString(R.string.choose_pet_alert))
|
toast(getString(R.string.choose_pet_alert))
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
@@ -151,6 +155,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
startScan()
|
startScan()
|
||||||
}
|
}
|
||||||
homeBinding.btnCamera?.setOnClickListener {
|
homeBinding.btnCamera?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!checkCameraPermissions()){
|
if (!checkCameraPermissions()){
|
||||||
@@ -170,9 +175,11 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
homeBinding.btnManager?.setOnClickListener {
|
homeBinding.btnManager?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(PetManagerActivity::class.java, DataCollection())
|
toActivity(PetManagerActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
homeBinding.btnAddPet?.setOnClickListener {
|
homeBinding.btnAddPet?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(AddPetActivity::class.java, DataCollection())
|
toActivity(AddPetActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +205,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
homeBinding.btnViewPostion?.setOnClickListener {
|
homeBinding.btnViewPostion?.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
getData(dataModel?.id.toString())
|
getData(dataModel?.id.toString())
|
||||||
|
|
||||||
// toActivity(MapLocationActivity::class.java, DataCollection().apply {
|
// toActivity(MapLocationActivity::class.java, DataCollection().apply {
|
||||||
@@ -216,6 +224,10 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
homeBinding.refreshLayout?.setOnRefreshListener {
|
homeBinding.refreshLayout?.setOnRefreshListener {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
homeBinding.refreshLayout?.finishRefresh()
|
||||||
|
return@setOnRefreshListener
|
||||||
|
}
|
||||||
|
|
||||||
if (dataModel == null) {
|
if (dataModel == null) {
|
||||||
getData("")
|
getData("")
|
||||||
@@ -232,6 +244,12 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requireLogin(): Boolean {
|
||||||
|
if (CKApp.app.isUserLoggedIn) return true
|
||||||
|
toActivity(LoginActivity::class.java, DataCollection())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private fun requestCameraPermission(action: CameraAction) {
|
private fun requestCameraPermission(action: CameraAction) {
|
||||||
pendingCameraAction = action
|
pendingCameraAction = action
|
||||||
showCameraPermissionTopDialog()
|
showCameraPermissionTopDialog()
|
||||||
@@ -278,6 +296,13 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
|
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
setBannerData(listOf(BannarModel().apply {
|
||||||
|
localImageRes = R.mipmap.index_banner1
|
||||||
|
}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var data = PreferencesUtils.getString(activity!!, Const.PET_DATA, "")
|
var data = PreferencesUtils.getString(activity!!, Const.PET_DATA, "")
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(data)) {
|
if (!TextUtils.isEmpty(data)) {
|
||||||
@@ -305,7 +330,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
LiveDataBus.get().with("FIRST", Int::class.java)
|
LiveDataBus.get().with("FIRST", Int::class.java)
|
||||||
.observe(viewLifecycleOwner, object : Observer<Int?> {
|
.observe(viewLifecycleOwner, object : Observer<Int?> {
|
||||||
override fun onChanged(result: Int?) {
|
override fun onChanged(result: Int?) {
|
||||||
getPetList2()
|
if (CKApp.app.isUserLoggedIn) getPetList2()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -350,22 +375,14 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getData(id: String) {
|
fun getData(id: String) {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
TTHttpClient.get(activity as TTBaseActivity, "首页", TTRequestParam().apply {
|
TTHttpClient.get(activity as TTBaseActivity, "首页", TTRequestParam().apply {
|
||||||
add(TTRequestData("patId", id))
|
add(TTRequestData("patId", id))
|
||||||
}, object : ICallback {
|
}, object : ICallback {
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
homeModel = Gson().fromJson<HomeModel>(data, HomeModel::class.java)
|
homeModel = Gson().fromJson<HomeModel>(data, HomeModel::class.java)
|
||||||
|
|
||||||
bannarData = homeModel?.banners!!
|
setBannerData(homeModel?.banners.orEmpty())
|
||||||
|
|
||||||
imageAdapter = ImageAdapter(activity!!, bannarData, object : OnItemClickListenner {
|
|
||||||
override fun onClick(pos: Int, model: Any) {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
homeBinding.banner.addBannerLifecycleObserver(this@HomeFragment)//添加生命周期观察者
|
|
||||||
.setAdapter(imageAdapter)
|
|
||||||
.setIndicator(CircleIndicator(activity));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +487,18 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setBannerData(data: List<BannarModel>) {
|
||||||
|
bannarData = data
|
||||||
|
imageAdapter = ImageAdapter(activity!!, bannarData, object : OnItemClickListenner {
|
||||||
|
override fun onClick(pos: Int, model: Any) = Unit
|
||||||
|
})
|
||||||
|
homeBinding.banner.addBannerLifecycleObserver(this@HomeFragment)
|
||||||
|
.setAdapter(imageAdapter)
|
||||||
|
.setIndicator(CircleIndicator(activity))
|
||||||
|
}
|
||||||
|
|
||||||
fun switchPet() {
|
fun switchPet() {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
|
|
||||||
|
|
||||||
LiveDataBus.get().with("BOUND" + dataModel!!.id, Int::class.java)
|
LiveDataBus.get().with("BOUND" + dataModel!!.id, Int::class.java)
|
||||||
@@ -506,6 +534,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getPetInfo(id: String) {
|
fun getPetInfo(id: String) {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
TTHttpClient.get(activity as TTBaseActivity, "宠物档案", id, object : ICallback {
|
TTHttpClient.get(activity as TTBaseActivity, "宠物档案", id, object : ICallback {
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
var model = Gson().fromJson<CollarTypeModel.TypeDataModel>(
|
var model = Gson().fromJson<CollarTypeModel.TypeDataModel>(
|
||||||
@@ -592,6 +621,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
|
|
||||||
fun getPetList() {
|
fun getPetList() {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
showProgeassDialog(getString(R.string.search))
|
showProgeassDialog(getString(R.string.search))
|
||||||
TTHttpClient.get(activity as TTBaseActivity, "宠物列表", TTRequestParam().apply {
|
TTHttpClient.get(activity as TTBaseActivity, "宠物列表", TTRequestParam().apply {
|
||||||
add(
|
add(
|
||||||
@@ -656,6 +686,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
|
|
||||||
fun getPetList2() {
|
fun getPetList2() {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
showProgeassDialog(getString(R.string.search))
|
showProgeassDialog(getString(R.string.search))
|
||||||
TTHttpClient.get(activity as TTBaseActivity, "宠物列表", TTRequestParam().apply {
|
TTHttpClient.get(activity as TTBaseActivity, "宠物列表", TTRequestParam().apply {
|
||||||
add(
|
add(
|
||||||
@@ -696,6 +727,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun uploadImage(path: String) {
|
fun uploadImage(path: String) {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
|
|
||||||
var param = TTRequestParam()
|
var param = TTRequestParam()
|
||||||
param.files.add(File(path))
|
param.files.add(File(path))
|
||||||
@@ -717,6 +749,7 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun aiPhoto(imageUrl: String) {
|
fun aiPhoto(imageUrl: String) {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) return
|
||||||
|
|
||||||
TTHttpClient.postJson(activity as TTBaseActivity, "AI拍照识别", TTRequestParam().apply {
|
TTHttpClient.postJson(activity as TTBaseActivity, "AI拍照识别", TTRequestParam().apply {
|
||||||
add(TTRequestData("imageUrl", imageUrl))
|
add(TTRequestData("imageUrl", imageUrl))
|
||||||
@@ -824,8 +857,11 @@ class HomeFragment : CKBaseFragment() {
|
|||||||
position: Int,
|
position: Int,
|
||||||
size: Int
|
size: Int
|
||||||
) {
|
) {
|
||||||
|
val imageSource: Any? = data?.localImageRes
|
||||||
|
?.takeIf { it != 0 }
|
||||||
|
?: data?.bannerUrl
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(data?.bannerUrl)
|
.load(imageSource)
|
||||||
.apply(RequestOptions.bitmapTransform(RoundedCorners(12)))
|
.apply(RequestOptions.bitmapTransform(RoundedCorners(12)))
|
||||||
.placeholder(R.mipmap.image_bannar_item)
|
.placeholder(R.mipmap.image_bannar_item)
|
||||||
.into(holder!!.imageView)
|
.into(holder!!.imageView)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.ck.ckcollar.app.ui.act.deposit.DepositActivity
|
|||||||
import com.ck.ckcollar.app.ui.act.deposit.StartDepositActivity
|
import com.ck.ckcollar.app.ui.act.deposit.StartDepositActivity
|
||||||
import com.ck.ckcollar.app.ui.act.member.MemberActivity
|
import com.ck.ckcollar.app.ui.act.member.MemberActivity
|
||||||
import com.ck.ckcollar.app.ui.act.message.MessageCenterActivity
|
import com.ck.ckcollar.app.ui.act.message.MessageCenterActivity
|
||||||
|
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
||||||
import com.ck.ckcollar.app.ui.act.mine.FeedBackActivity
|
import com.ck.ckcollar.app.ui.act.mine.FeedBackActivity
|
||||||
import com.ck.ckcollar.app.ui.act.mine.ReturnDeviceActivity
|
import com.ck.ckcollar.app.ui.act.mine.ReturnDeviceActivity
|
||||||
import com.ck.ckcollar.app.ui.act.points.PointsActivity
|
import com.ck.ckcollar.app.ui.act.points.PointsActivity
|
||||||
@@ -51,15 +52,19 @@ class MineFragment : CKBaseFragment() {
|
|||||||
override fun initView() {
|
override fun initView() {
|
||||||
|
|
||||||
binding.contentBalance.setOnClickListener {
|
binding.contentBalance.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(BalanceActivity::class.java, DataCollection())
|
toActivity(BalanceActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.conetntPoints.setOnClickListener {
|
binding.conetntPoints.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(PointsActivity::class.java, DataCollection())
|
toActivity(PointsActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.imageUser.setOnClickListener {
|
binding.imageUser.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(UserInfoActivity::class.java, DataCollection())
|
toActivity(UserInfoActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.btnUserInfo.setOnClickListener {
|
binding.btnUserInfo.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(UserInfoActivity::class.java, DataCollection())
|
toActivity(UserInfoActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,19 +76,24 @@ class MineFragment : CKBaseFragment() {
|
|||||||
toActivity(SettingActivity::class.java, DataCollection())
|
toActivity(SettingActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.btnOpen.setOnClickListener {
|
binding.btnOpen.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MemberActivity::class.java, DataCollection())
|
toActivity(MemberActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnReturnDevice.setOnClickListener {
|
binding.btnReturnDevice.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(ReturnDeviceActivity::class.java, DataCollection())
|
toActivity(ReturnDeviceActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.btnFeedback.setOnClickListener {
|
binding.btnFeedback.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(FeedBackActivity::class.java, DataCollection())
|
toActivity(FeedBackActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.btnCustomerService.setOnClickListener {
|
binding.btnCustomerService.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(PeopleCustomerActivity::class.java, DataCollection().apply { add(Data("chatType","2")) })
|
toActivity(PeopleCustomerActivity::class.java, DataCollection().apply { add(Data("chatType","2")) })
|
||||||
}
|
}
|
||||||
binding.textDeposit.setOnClickListener {
|
binding.textDeposit.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
if ("0".equals(CKApp.app.userInfo!!.depositStatus)){
|
if ("0".equals(CKApp.app.userInfo!!.depositStatus)){
|
||||||
toActivity(DepositActivity::class.java, DataCollection())
|
toActivity(DepositActivity::class.java, DataCollection())
|
||||||
}else{
|
}else{
|
||||||
@@ -92,18 +102,23 @@ class MineFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.btnAllOrder.setOnClickListener {
|
binding.btnAllOrder.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","0")) })
|
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","0")) })
|
||||||
}
|
}
|
||||||
binding.btnOrderPayment.setOnClickListener {
|
binding.btnOrderPayment.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","1")) })
|
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","1")) })
|
||||||
}
|
}
|
||||||
binding.btnOrderDelivery.setOnClickListener {
|
binding.btnOrderDelivery.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","2")) })
|
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","2")) })
|
||||||
}
|
}
|
||||||
binding.btnOrderReceipt.setOnClickListener {
|
binding.btnOrderReceipt.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","3")) })
|
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","3")) })
|
||||||
}
|
}
|
||||||
binding.btnOrderAfterSales.setOnClickListener {
|
binding.btnOrderAfterSales.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","4")) })
|
toActivity(MyOrderActivity::class.java, DataCollection().apply { add(Data("pos","4")) })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,10 +126,28 @@ class MineFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requireLogin(): Boolean {
|
||||||
|
if (CKApp.app.isUserLoggedIn) return true
|
||||||
|
toActivity(LoginActivity::class.java, DataCollection())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
|
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
binding.textNick.text = getString(R.string.guest)
|
||||||
|
binding.textPhone.text = ""
|
||||||
|
binding.textPhone.visibility = View.GONE
|
||||||
|
binding.textBalance.text = "0"
|
||||||
|
binding.textPoints.text = "0"
|
||||||
|
binding.textCount.visibility = View.INVISIBLE
|
||||||
|
binding.imageUser.setImageResource(R.mipmap.image_user_default)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
binding.textNick.text = CKApp.app.userInfo?.custName
|
binding.textNick.text = CKApp.app.userInfo?.custName
|
||||||
binding.textPhone.text = CKApp.app.userInfo?.phonenumber
|
binding.textPhone.text = CKApp.app.userInfo?.phonenumber
|
||||||
|
binding.textPhone.visibility = View.VISIBLE
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(CKApp.app.userInfo?.avatar)){
|
if (!TextUtils.isEmpty(CKApp.app.userInfo?.avatar)){
|
||||||
Glide.with(this@MineFragment)
|
Glide.with(this@MineFragment)
|
||||||
@@ -123,8 +156,8 @@ class MineFragment : CKBaseFragment() {
|
|||||||
.into(binding.imageUser)
|
.into(binding.imageUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.textBalance.text = CKApp.app.userInfo?.balance.toString()
|
binding.textBalance.text = CKApp.app.userInfo?.balance?.toString() ?: "0"
|
||||||
binding.textPoints.text = CKApp.app.userInfo?.points.toString()
|
binding.textPoints.text = CKApp.app.userInfo?.points?.toString() ?: "0"
|
||||||
|
|
||||||
if (CKApp.app.userInfo?.isMember == true){
|
if (CKApp.app.userInfo?.isMember == true){
|
||||||
binding.btnOpen.setText(getString(R.string.auto_renewal2))
|
binding.btnOpen.setText(getString(R.string.auto_renewal2))
|
||||||
@@ -150,6 +183,11 @@ class MineFragment : CKBaseFragment() {
|
|||||||
getUserInfo()
|
getUserInfo()
|
||||||
}
|
}
|
||||||
fun getUserInfo(){
|
fun getUserInfo(){
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
binding.textCount.visibility = View.INVISIBLE
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
TTHttpClient.get(activity as TTBaseActivity,"个人资料", TTRequestParam(),object : ICallback{
|
TTHttpClient.get(activity as TTBaseActivity,"个人资料", TTRequestParam(),object : ICallback{
|
||||||
override fun onSuccess(data: String) {
|
override fun onSuccess(data: String) {
|
||||||
CKApp.app.userInfo = Gson().fromJson<UserInfoModel>(data, UserInfoModel::class.java)
|
CKApp.app.userInfo = Gson().fromJson<UserInfoModel>(data, UserInfoModel::class.java)
|
||||||
@@ -187,4 +225,4 @@ class MineFragment : CKBaseFragment() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.ck.ckcollar.app.CKApp
|
||||||
import com.ck.ckcollar.app.R
|
import com.ck.ckcollar.app.R
|
||||||
import com.ck.ckcollar.app.action.ActionCode
|
import com.ck.ckcollar.app.action.ActionCode
|
||||||
import com.ck.ckcollar.app.databinding.FragmentShopBinding
|
import com.ck.ckcollar.app.databinding.FragmentShopBinding
|
||||||
@@ -299,6 +300,11 @@ class ShopFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCarCount() {
|
fun getCarCount() {
|
||||||
|
if (!CKApp.app.isUserLoggedIn) {
|
||||||
|
binding.textCount.visibility = View.GONE
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
TTHttpClient.get(
|
TTHttpClient.get(
|
||||||
activity as TTBaseActivity,
|
activity as TTBaseActivity,
|
||||||
"购物车数量和合计",
|
"购物车数量和合计",
|
||||||
@@ -546,4 +552,4 @@ class ShopFragment : CKBaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ck.ckcollar.app.ui.act.petmanager
|
package com.ck.ckcollar.app.ui.act.petmanager
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@@ -97,12 +98,10 @@ class AddPetActivity : CKBaseActivity() {
|
|||||||
try {
|
try {
|
||||||
if (mark == 0){
|
if (mark == 0){
|
||||||
if (!checkCameraPermissions()){
|
if (!checkCameraPermissions()){
|
||||||
CKAlertDialog(this@AddPetActivity,getString(R.string.alert),getString(R.string.camera_alert),object : CKAlertDialog.AlertClickListener{
|
getPermissionRequst(
|
||||||
override fun onBack(isConfirm: Boolean) {
|
Manifest.permission.CAMERA,
|
||||||
TODO("Not yet implemented")
|
REQUEST_CAMERA_PERMISSION
|
||||||
}
|
)
|
||||||
|
|
||||||
}).show()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
takePhoto()
|
takePhoto()
|
||||||
@@ -194,6 +193,12 @@ class AddPetActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onPermissionsGranted(requestCode: Int, permissions: Array<String>) {
|
||||||
|
if (requestCode == REQUEST_CAMERA_PERMISSION) {
|
||||||
|
takePhoto()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
var data = getReceiveParam().get("data")
|
var data = getReceiveParam().get("data")
|
||||||
data?.let {
|
data?.let {
|
||||||
@@ -408,6 +413,10 @@ class AddPetActivity : CKBaseActivity() {
|
|||||||
}).show()
|
}).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val REQUEST_CAMERA_PERMISSION = 1201
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun uploadImage(path: String) {
|
fun uploadImage(path: String) {
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class SettingActivity : CKBaseActivity(), View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
|
binding.btnLogout.visibility = if (CKApp.app.isUserLoggedIn) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
binding.contentLoginPassword.setOnClickListener(this)
|
binding.contentLoginPassword.setOnClickListener(this)
|
||||||
binding.contentPaymentPassword.setOnClickListener(this)
|
binding.contentPaymentPassword.setOnClickListener(this)
|
||||||
binding.contentAboutUs.setOnClickListener(this)
|
binding.contentAboutUs.setOnClickListener(this)
|
||||||
@@ -44,9 +46,11 @@ class SettingActivity : CKBaseActivity(), View.OnClickListener {
|
|||||||
|
|
||||||
when (v?.id){
|
when (v?.id){
|
||||||
R.id.contentLoginPassword->{
|
R.id.contentLoginPassword->{
|
||||||
|
if (!requireLogin()) return
|
||||||
toActivity(PasswordManagerActivity::class.java, DataCollection())
|
toActivity(PasswordManagerActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
R.id.contentPaymentPassword->{
|
R.id.contentPaymentPassword->{
|
||||||
|
if (!requireLogin()) return
|
||||||
toActivity(PayPasswordManagerActivity::class.java, DataCollection())
|
toActivity(PayPasswordManagerActivity::class.java, DataCollection())
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -60,10 +64,12 @@ class SettingActivity : CKBaseActivity(), View.OnClickListener {
|
|||||||
toActivity(AgreementActivity::class.java, DataCollection().apply { add(Data("title","隐私协议")) })
|
toActivity(AgreementActivity::class.java, DataCollection().apply { add(Data("title","隐私协议")) })
|
||||||
}
|
}
|
||||||
R.id.contentShippingAddress->{
|
R.id.contentShippingAddress->{
|
||||||
|
if (!requireLogin()) return
|
||||||
toActivity(AddressActivity::class.java, DataCollection().apply { add(Data("flag","1"))
|
toActivity(AddressActivity::class.java, DataCollection().apply { add(Data("flag","1"))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
R.id.contentCancellation->{
|
R.id.contentCancellation->{
|
||||||
|
if (!requireLogin()) return
|
||||||
toActivity(AccountCancellationActivity::class.java, DataCollection())
|
toActivity(AccountCancellationActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
R.id.btnLogout->{
|
R.id.btnLogout->{
|
||||||
@@ -80,4 +86,10 @@ class SettingActivity : CKBaseActivity(), View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requireLogin(): Boolean {
|
||||||
|
if (CKApp.app.isUserLoggedIn) return true
|
||||||
|
toActivity(LoginActivity::class.java, DataCollection())
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.ck.ckcollar.app.CKApp
|
||||||
import com.ck.ckcollar.app.R
|
import com.ck.ckcollar.app.R
|
||||||
import com.ck.ckcollar.app.action.ActionCode
|
import com.ck.ckcollar.app.action.ActionCode
|
||||||
import com.ck.ckcollar.app.databinding.ActivityProductDetailsBinding
|
import com.ck.ckcollar.app.databinding.ActivityProductDetailsBinding
|
||||||
@@ -23,6 +24,7 @@ import com.ck.ckcollar.app.ui.act.customer.PeopleCustomerActivity
|
|||||||
import com.ck.ckcollar.app.ui.act.customer.ShopCustomerActivity
|
import com.ck.ckcollar.app.ui.act.customer.ShopCustomerActivity
|
||||||
import com.ck.ckcollar.app.ui.act.home.fragment.HomeFragment
|
import com.ck.ckcollar.app.ui.act.home.fragment.HomeFragment
|
||||||
import com.ck.ckcollar.app.ui.act.home.fragment.HomeFragment.ImageAdapter
|
import com.ck.ckcollar.app.ui.act.home.fragment.HomeFragment.ImageAdapter
|
||||||
|
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
||||||
import com.ck.ckcollar.app.ui.act.petmanager.ImageViewActivity
|
import com.ck.ckcollar.app.ui.act.petmanager.ImageViewActivity
|
||||||
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
||||||
import com.ck.ckcollar.app.ui.base.CKLHBaseActionBarActivity
|
import com.ck.ckcollar.app.ui.base.CKLHBaseActionBarActivity
|
||||||
@@ -63,20 +65,30 @@ class ProductDetailsActivity : CKBaseActivity() {
|
|||||||
setupWebView(binding.textContent)
|
setupWebView(binding.textContent)
|
||||||
|
|
||||||
binding.btnAddCar.setOnClickListener {
|
binding.btnAddCar.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
showProductTypeFragment()
|
showProductTypeFragment()
|
||||||
}
|
}
|
||||||
binding.btnBuyNow.setOnClickListener {
|
binding.btnBuyNow.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
showProductTypeFragment()
|
showProductTypeFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.contentShopCar.setOnClickListener {
|
binding.contentShopCar.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(ShopCarActivity::class.java, DataCollection())
|
toActivity(ShopCarActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
binding.contentCustomer.setOnClickListener {
|
binding.contentCustomer.setOnClickListener {
|
||||||
|
if (!requireLogin()) return@setOnClickListener
|
||||||
toActivity(PeopleCustomerActivity::class.java, DataCollection().apply { add(Data("chatType","1")) })
|
toActivity(PeopleCustomerActivity::class.java, DataCollection().apply { add(Data("chatType","1")) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun requireLogin(): Boolean {
|
||||||
|
if (CKApp.app.isUserLoggedIn) return true
|
||||||
|
toActivity(LoginActivity::class.java, DataCollection())
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
model = Gson().fromJson<ShopProductModel.ProductModel>(getReceiveParam().get("data")!!.stringValue,
|
model = Gson().fromJson<ShopProductModel.ProductModel>(getReceiveParam().get("data")!!.stringValue,
|
||||||
ShopProductModel.ProductModel::class.java)
|
ShopProductModel.ProductModel::class.java)
|
||||||
@@ -313,4 +325,4 @@ class ProductDetailsActivity : CKBaseActivity() {
|
|||||||
// 使用 loadDataWithBaseURL 加载
|
// 使用 loadDataWithBaseURL 加载
|
||||||
webView.loadDataWithBaseURL(null, styledHtml, "text/html", "UTF-8", null)
|
webView.loadDataWithBaseURL(null, styledHtml, "text/html", "UTF-8", null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ import com.tt.kit.model.DataCollection
|
|||||||
import com.tt.kit.utils.KeyboardUtils
|
import com.tt.kit.utils.KeyboardUtils
|
||||||
|
|
||||||
class TypeActivity : CKLHBaseActionBarActivity() {
|
class TypeActivity : CKLHBaseActionBarActivity() {
|
||||||
|
override val shouldRequestPermissionsOnCreate: Boolean = false
|
||||||
|
|
||||||
lateinit var binding: ActivityShopTypeBinding
|
lateinit var binding: ActivityShopTypeBinding
|
||||||
lateinit var productAdapter: ProductAdapter
|
lateinit var productAdapter: ProductAdapter
|
||||||
|
|
||||||
@@ -172,4 +174,4 @@ class TypeActivity : CKLHBaseActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.os.Message
|
|||||||
import com.ck.ckcollar.app.CKApp
|
import com.ck.ckcollar.app.CKApp
|
||||||
import com.ck.ckcollar.app.databinding.ActivityIndexBinding
|
import com.ck.ckcollar.app.databinding.ActivityIndexBinding
|
||||||
import com.ck.ckcollar.app.ui.act.home.MainActivity
|
import com.ck.ckcollar.app.ui.act.home.MainActivity
|
||||||
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
|
||||||
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
||||||
import com.ck.ckcollar.app.utils.Const
|
import com.ck.ckcollar.app.utils.Const
|
||||||
import com.cyclone.shadowsocks.utils.PreferencesUtils
|
import com.cyclone.shadowsocks.utils.PreferencesUtils
|
||||||
@@ -29,7 +28,7 @@ class IndexActivity : CKBaseActivity() {
|
|||||||
if (isFirst){
|
if (isFirst){
|
||||||
toActivity(WelcomeActivity::class.java, DataCollection())
|
toActivity(WelcomeActivity::class.java, DataCollection())
|
||||||
}else{
|
}else{
|
||||||
toActivity(LoginActivity::class.java, DataCollection())
|
toActivity(MainActivity::class.java, DataCollection())
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
toActivity(MainActivity::class.java, DataCollection())
|
toActivity(MainActivity::class.java, DataCollection())
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import androidx.viewpager.widget.PagerAdapter
|
|||||||
import com.ck.ckcollar.app.R
|
import com.ck.ckcollar.app.R
|
||||||
import com.ck.ckcollar.app.databinding.ActivityWelcomeBinding
|
import com.ck.ckcollar.app.databinding.ActivityWelcomeBinding
|
||||||
import com.ck.ckcollar.app.databinding.LayoutItemWelcomeBinding
|
import com.ck.ckcollar.app.databinding.LayoutItemWelcomeBinding
|
||||||
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
import com.ck.ckcollar.app.ui.act.home.MainActivity
|
||||||
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
import com.ck.ckcollar.app.ui.base.CKBaseActivity
|
||||||
import com.ck.ckcollar.app.utils.Const
|
import com.ck.ckcollar.app.utils.Const
|
||||||
import com.cyclone.shadowsocks.utils.PreferencesUtils
|
import com.cyclone.shadowsocks.utils.PreferencesUtils
|
||||||
@@ -64,7 +64,7 @@ class WelcomeActivity : CKBaseActivity() {
|
|||||||
// }else{
|
// }else{
|
||||||
// toActivity(LoginActivity::class.java, DataCollection())
|
// toActivity(LoginActivity::class.java, DataCollection())
|
||||||
// }
|
// }
|
||||||
toActivity(LoginActivity::class.java, DataCollection())
|
toActivity(MainActivity::class.java, DataCollection())
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,4 +98,4 @@ class WelcomeActivity : CKBaseActivity() {
|
|||||||
|
|
||||||
PreferencesUtils.putBoolean(this, Const.FIRST, false)
|
PreferencesUtils.putBoolean(this, Const.FIRST, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import pub.devrel.easypermissions.EasyPermissions
|
|||||||
|
|
||||||
open class CKLHBaseActionBarActivity : TTBaseActivity(){
|
open class CKLHBaseActionBarActivity : TTBaseActivity(){
|
||||||
|
|
||||||
|
protected open val shouldRequestPermissionsOnCreate: Boolean = true
|
||||||
|
|
||||||
var perms_= listOf<String>(Manifest.permission.CAMERA, Manifest.permission.READ_MEDIA_IMAGES,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
var perms_= listOf<String>(Manifest.permission.CAMERA, Manifest.permission.READ_MEDIA_IMAGES,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
var perms_tiramisu = listOf<String>(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE)
|
var perms_tiramisu = listOf<String>(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ open class CKLHBaseActionBarActivity : TTBaseActivity(){
|
|||||||
// insets
|
// insets
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!checkPermissions()){
|
if (shouldRequestPermissionsOnCreate && !checkPermissions()){
|
||||||
requstPermissions()
|
requstPermissions()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,4 +204,4 @@ open class CKLHBaseActionBarActivity : TTBaseActivity(){
|
|||||||
// insets
|
// insets
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ package com.ck.ckcollar.app.utils.networkone
|
|||||||
interface ICallback {
|
interface ICallback {
|
||||||
fun onSuccess(data: String)
|
fun onSuccess(data: String)
|
||||||
fun onFailed(code: String, msg: String)
|
fun onFailed(code: String, msg: String)
|
||||||
|
fun onComplete() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -429,10 +429,12 @@ object TTHttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
iCallback.onFailed("500", "网络连接失败,请检查网络")
|
iCallback.onComplete()
|
||||||
}
|
}
|
||||||
}catch (e: Exception){
|
}catch (e: Exception){
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
iCallback.onFailed("500", e.message.orEmpty())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -988,4 +990,4 @@ private fun getMessage(data: JSONObject): String {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.ck.ckcollar.app.widget.CKLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.ck.ckcollar.app.widget.CKLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@@ -7,12 +8,12 @@
|
|||||||
android:background="@color/backgroundColor"
|
android:background="@color/backgroundColor"
|
||||||
>
|
>
|
||||||
<include layout="@layout/action_bar"></include>
|
<include layout="@layout/action_bar"></include>
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
></androidx.recyclerview.widget.RecyclerView>
|
></androidx.recyclerview.widget.RecyclerView>
|
||||||
|
|
||||||
<com.ck.ckcollar.app.widget.CKLinearLayout
|
<com.ck.ckcollar.app.widget.CKLinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -20,7 +21,6 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingHorizontal="20dp"
|
|
||||||
>
|
>
|
||||||
<com.ck.ckcollar.app.widget.CKImageView
|
<com.ck.ckcollar.app.widget.CKImageView
|
||||||
android:id="@+id/btnKeyboard"
|
android:id="@+id/btnKeyboard"
|
||||||
@@ -30,39 +30,86 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
></com.ck.ckcollar.app.widget.CKImageView>
|
></com.ck.ckcollar.app.widget.CKImageView>
|
||||||
|
|
||||||
<com.ck.ckcollar.app.widget.CKEditView
|
<LinearLayout
|
||||||
android:id="@+id/editMessage"
|
android:layout_width="0dp"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="34dp"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textColor="@color/textColor"
|
android:orientation="vertical">
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColorHint="@color/textColor"
|
|
||||||
android:hint="@string/please_input_message"
|
|
||||||
android:paddingHorizontal="16dp"
|
|
||||||
android:paddingVertical="5dp"
|
|
||||||
android:layout_marginVertical="10dp"
|
|
||||||
android:layout_marginHorizontal="12dp"
|
|
||||||
android:background="@drawable/bg_input_message"
|
|
||||||
android:imeOptions="actionSend"
|
|
||||||
android:inputType="text"
|
|
||||||
android:maxLength="100"
|
|
||||||
></com.ck.ckcollar.app.widget.CKEditView>
|
|
||||||
<com.ck.ckcollar.app.widget.CKImageView
|
|
||||||
android:id="@+id/btnSmile"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@mipmap/image_smile"
|
|
||||||
></com.ck.ckcollar.app.widget.CKImageView>
|
|
||||||
|
|
||||||
<com.ck.ckcollar.app.widget.CKImageView
|
<FrameLayout
|
||||||
android:id="@+id/btnMore"
|
android:id="@+id/contentImagePreview"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="80dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="80dp"
|
||||||
android:src="@mipmap/image_more"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginTop="8dp"
|
||||||
></com.ck.ckcollar.app.widget.CKImageView>
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<com.ck.ckcollar.app.widget.CKRoundImageView
|
||||||
|
android:id="@+id/imagePreview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:roundRadius="6dp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnDeleteImage"
|
||||||
|
android:layout_width="18dp"
|
||||||
|
android:layout_height="18dp"
|
||||||
|
android:layout_gravity="end|top"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@mipmap/icon_img_del_red" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<com.ck.ckcollar.app.widget.CKEditView
|
||||||
|
android:id="@+id/editMessage"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:minHeight="34dp"
|
||||||
|
android:textColor="@color/textColor"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColorHint="@color/textColor"
|
||||||
|
android:hint="@string/please_input_message"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:paddingVertical="5dp"
|
||||||
|
android:layout_marginVertical="10dp"
|
||||||
|
android:layout_marginHorizontal="12dp"
|
||||||
|
android:background="@drawable/bg_input_message"
|
||||||
|
android:imeOptions="actionSend"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLength="100" />
|
||||||
|
<com.ck.ckcollar.app.widget.CKImageView
|
||||||
|
android:id="@+id/btnSmile"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@mipmap/image_smile"
|
||||||
|
android:visibility="visible"/>
|
||||||
|
|
||||||
|
<com.ck.ckcollar.app.widget.CKImageView
|
||||||
|
android:id="@+id/btnMore"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@mipmap/image_more"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="15dp"/>
|
||||||
|
|
||||||
|
<com.ck.ckcollar.app.widget.CKImageView
|
||||||
|
android:id="@+id/btnSend"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@mipmap/icon_send_yellow"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
||||||
|
|
||||||
<com.ck.ckcollar.app.widget.CKLinearLayout
|
<com.ck.ckcollar.app.widget.CKLinearLayout
|
||||||
@@ -125,4 +172,4 @@
|
|||||||
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
||||||
|
|
||||||
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
||||||
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
BIN
app/src/main/res/mipmap-xxhdpi/icon_img_del_red.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/icon_img_del_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_send_gray.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/icon_send_gray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_send_yellow.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/icon_send_yellow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/index_banner1.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/index_banner1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/index_banner2.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/index_banner2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
@@ -1,4 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<string name="guest">游客</string>
|
||||||
<string name="app_name">宠盾</string>
|
<string name="app_name">宠盾</string>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user