Commit cbe26dab authored by gaodapeng's avatar gaodapeng

Merge branch 'feature_v2.1_converse' into 'master'

Feature v2.1 converse

See merge request !1
parents 33bca812 8110e192
...@@ -3,6 +3,7 @@ package com.miya.fastcashier.ui ...@@ -3,6 +3,7 @@ package com.miya.fastcashier.ui
import android.content.Intent import android.content.Intent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import android.view.Gravity
import android.widget.Toast import android.widget.Toast
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
...@@ -11,6 +12,7 @@ import com.miya.fastcashier.databinding.ActivityLoginBinding ...@@ -11,6 +12,7 @@ import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.databinding.ActivityMainBinding import com.miya.fastcashier.databinding.ActivityMainBinding
import com.miya.fastcashier.service.AccountService import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.PrintService import com.miya.fastcashier.service.PrintService
import com.miya.fastcashier.ui.dialog.CommonDialog
import com.miya.fastcashier.ui.dialog.MessageDialog import com.miya.fastcashier.ui.dialog.MessageDialog
import com.miya.fastcashier.utils.CenterToasty import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.DateSelectHelper import com.miya.fastcashier.utils.DateSelectHelper
...@@ -24,7 +26,7 @@ import java.util.* ...@@ -24,7 +26,7 @@ import java.util.*
class MainActivity : BaseActivity() { class MainActivity : BaseActivity() {
//退出登录 二次确认弹窗 //退出登录 二次确认弹窗
private var alertDialog: MessageDialog? = null private var alertDialog: CommonDialog? = null
private lateinit var binding: ActivityMainBinding private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainViewModel private lateinit var viewModel: MainViewModel
private var dateSelectHelper: DateSelectHelper? = null private var dateSelectHelper: DateSelectHelper? = null
...@@ -123,25 +125,35 @@ class MainActivity : BaseActivity() { ...@@ -123,25 +125,35 @@ class MainActivity : BaseActivity() {
}) })
} }
private fun loginOut() { private fun loginOut() {
if (null == alertDialog) { if (alertDialog == null || !alertDialog!!.isShowing) {
alertDialog = MessageDialog(this) alertDialog = CommonDialog(this)
.setCustomMessage("是否确认退出登录账号") alertDialog!!.setCustomMessage(getString(R.string.app_text_login_out))
.setPositiveButton("确认退出") { _, _ -> .setNegativeStr(getString(R.string.cancel))
.setPositiveStr(getString(R.string.text_login_out_sure))
.setMessageGravity(Gravity.CENTER_HORIZONTAL)
.setOnClickListener(object : CommonDialog.OnDialogClickListener {
override fun onNegativeClick() {
alertDialog!!.dismiss()
alertDialog = null
}
override fun onPositiveClick() {
alertDialog!!.dismiss()
alertDialog = null
run { run {
MMKV.defaultMMKV().clearAll() MMKV.defaultMMKV().clearAll()
AccountService.setAccountInfo(null) AccountService.setAccountInfo(null)
val intent = Intent() val intent = Intent()
intent.setClass(this@MainActivity, LoginActivity::class.java) intent.setClass(this@MainActivity,
LoginActivity::class.java)
startActivity(intent) startActivity(intent)
finish() finish()
} }
} }
})
.show()
} }
alertDialog?.show()
} }
override fun onDestroy() { override fun onDestroy() {
......
...@@ -151,6 +151,12 @@ class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : ...@@ -151,6 +151,12 @@ class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) :
} }
it.onSuccess { list -> it.onSuccess { list ->
val oldSize = adapter.getDataSource().size val oldSize = adapter.getDataSource().size
if (oldSize == 0 && list.size == 0)
binding!!.cpEmptyView.visibility = View.VISIBLE
else
binding!!.cpEmptyView.visibility = View.GONE
adapter.getDataSource().addAll(list) adapter.getDataSource().addAll(list)
if (oldSize == 0) { if (oldSize == 0) {
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
...@@ -162,9 +168,17 @@ class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : ...@@ -162,9 +168,17 @@ class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) :
} }
} }
} }
initEmptyView()
loadMore(0) loadMore(0)
} }
private fun initEmptyView() {
binding!!.cpEmptyView.visibility = View.GONE
binding!!.cpEmptyView.setPromptText(getString(R.string.search_order_prompt_text))
binding!!.cpEmptyView.setPromptImage(R.mipmap.app_bg_common_empty)
}
private fun loadMore(loadIndex: Int) { private fun loadMore(loadIndex: Int) {
//加载更多 //加载更多
vm.getPayData(payType, loadIndex) vm.getPayData(payType, loadIndex)
......
package com.miya.fastcashier.ui.dialog
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.widget.TextView
import android.text.SpannableString
import android.view.Gravity
import com.miya.fastcashier.R
import android.os.Bundle
import android.text.TextUtils
import android.view.ViewGroup.MarginLayoutParams
import android.text.method.LinkMovementMethod
import android.view.View
import com.miya.fastcashier.utils.clickWithTrigger
class CommonDialog : Dialog {
protected var tvMessage: TextView? = null
protected var tvNegative: TextView? = null
protected var tvPositive: TextView? = null
protected var onClickListener: OnDialogClickListener? = null
protected var mContext: Context
private var mCustomMessage = ""
private var mContentSpanStr: SpannableString? = null
private var mPositiveStr = ""
private var mNegativeStr = ""
private var mMessageGravity = Gravity.LEFT
private var contentLeftMargin = 0
private var contentRightMargin = 0
private var contentTopMargin = 0
private var contentBottomMargin = 0
interface OnDialogClickListener {
fun onNegativeClick()
fun onPositiveClick()
}
fun setOnClickListener(onClickListener: OnDialogClickListener?): CommonDialog {
this.onClickListener = onClickListener
return this
}
constructor(ctx: Context, theme: Int) : super(ctx, theme) {
setCanceledOnTouchOutside(false)
setCancelable(false)
mContext = ctx
}
constructor(ctx: Context) : super(ctx, R.style.CommonDialog) {
setCanceledOnTouchOutside(false)
setCancelable(false)
mContext = ctx
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.setContentView(R.layout.dialog_common)
tvMessage = findViewById(R.id.tvMessage)
tvNegative = findViewById(R.id.tvNegative)
tvPositive = findViewById(R.id.tvPositive)
var vNegative: View = findViewById(R.id.vNegative)
var vPositive: View = findViewById(R.id.vPositive)
vNegative?.clickWithTrigger {
if (onClickListener != null) {
onClickListener!!.onNegativeClick()
}
}
vPositive?.clickWithTrigger {
if (onClickListener != null) {
onClickListener!!.onPositiveClick()
}
}
if (!TextUtils.isEmpty(mCustomMessage)) {
tvMessage?.setText(mCustomMessage)
val marginLayoutParams = tvMessage?.getLayoutParams() as MarginLayoutParams
if (contentTopMargin != 0) {
marginLayoutParams.topMargin = contentTopMargin
}
if (contentBottomMargin != 0) {
marginLayoutParams.bottomMargin = contentBottomMargin
}
if (contentLeftMargin != 0) {
marginLayoutParams.leftMargin = contentLeftMargin
}
if (contentRightMargin != 0) {
marginLayoutParams.rightMargin = contentRightMargin
}
tvMessage?.getViewTreeObserver()?.addOnGlobalLayoutListener {
val textPaint = tvMessage?.getPaint()
textPaint?.textSize = tvMessage!!.getTextSize()
val textViewWidth = textPaint!!.measureText(mCustomMessage).toInt()
tvMessage?.setText(mCustomMessage)
if (textViewWidth > tvMessage!!.getWidth()) {
tvMessage?.setGravity(Gravity.LEFT)
} else {
tvMessage?.setGravity(Gravity.CENTER)
}
}
} else {
if (mContentSpanStr != null) {
tvMessage?.setText(mContentSpanStr)
tvMessage?.setMovementMethod(LinkMovementMethod.getInstance())
tvMessage?.setHighlightColor(Color.TRANSPARENT)
val marginLayoutParams = tvMessage?.getLayoutParams() as MarginLayoutParams
if (contentTopMargin != 0) {
marginLayoutParams.topMargin = contentTopMargin
}
if (contentBottomMargin != 0) {
marginLayoutParams.bottomMargin = contentBottomMargin
}
if (contentLeftMargin != 0) {
marginLayoutParams.leftMargin = contentLeftMargin
}
if (contentRightMargin != 0) {
marginLayoutParams.rightMargin = contentRightMargin
}
}
tvMessage?.setGravity(mMessageGravity)
}
if (!TextUtils.isEmpty(mPositiveStr)) {
tvPositive?.setText(mPositiveStr)
}
if (!TextUtils.isEmpty(mNegativeStr)) {
tvNegative?.setText(mNegativeStr)
}
resize()
}
fun setCustomMessage(message: String): CommonDialog {
mCustomMessage = message
return this
}
fun setMessageGravity(gravity: Int): CommonDialog {
mMessageGravity = gravity
return this
}
fun setPositiveStr(positiveStr: String): CommonDialog {
mPositiveStr = positiveStr
return this
}
fun setNegativeStr(negativeStr: String): CommonDialog {
mNegativeStr = negativeStr
return this
}
fun setTvMessageMargin(
leftMargin: Int,
rightMargin: Int,
topMargin: Int,
bottomMargin: Int
): CommonDialog {
contentLeftMargin = leftMargin
contentRightMargin = rightMargin
contentTopMargin = topMargin
contentBottomMargin = bottomMargin
return this
}
fun show(gravity: Int) {
this.window!!.setGravity(gravity)
this.show()
}
fun resize() {
this.window!!.setLayout(-1, -2)
}
}
\ No newline at end of file
...@@ -60,6 +60,7 @@ class DateSelectHelper(val act: Activity, val callback: (Date) -> Unit) { ...@@ -60,6 +60,7 @@ class DateSelectHelper(val act: Activity, val callback: (Date) -> Unit) {
.setContentTextSize(30) .setContentTextSize(30)
.setTitleSize(30) .setTitleSize(30)
.setSubCalSize(30) .setSubCalSize(30)
.setLineSpacingMultiplier(1.9f)
.setRangDate(startDate, endDate) .setRangDate(startDate, endDate)
.setOutSideCancelable(false) .setOutSideCancelable(false)
.setDecorView(act.findViewById(android.R.id.content)) .setDecorView(act.findViewById(android.R.id.content))
......
package com.miya.fastcashier.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import com.miya.fastcashier.R;
import com.miya.fastcashier.databinding.LayoutCommonPromptViewBinding;
import org.jetbrains.annotations.NotNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
public class CommonPromptView extends ConstraintLayout {
private LayoutCommonPromptViewBinding viewBinding;
public CommonPromptView(@NonNull @NotNull Context context) {
this(context, null);
}
public CommonPromptView(@NonNull @NotNull Context context,
@Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public CommonPromptView(@NonNull @NotNull Context context,
@Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
View inflate = LayoutInflater.from(getContext()).inflate(R.layout.layout_common_prompt_view, this);
viewBinding = LayoutCommonPromptViewBinding.bind(inflate);
}
public void setPromptImage(int imageResId) {
viewBinding.ivPrompt.setImageResource(imageResId);
}
public void setPromptText(String text) {
viewBinding.tvPrompt.setText(text);
}
}
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textColorHint="#89889A" android:textColorHint="#89889A"
android:textAlignment="textEnd" android:textAlignment="textEnd"
android:textSize="47sp" android:textSize="64sp"
android:paddingTop="5dp" android:paddingTop="5dp"
android:layout_marginEnd="32dp" android:layout_marginEnd="32dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:background="@drawable/app_center_dialog_bg"
android:layout_width="match_parent"
android:layout_marginStart="85dp"
android:layout_marginEnd="85dp"
android:layout_marginRight="85dp"
android:layout_height="264dp"
android:layout_marginLeft="85dp">
<TextView
android:id="@+id/tvMessage"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textColor="#323233"
android:textSize="28sp"
tools:text="是否确认退款"
android:layout_marginTop="61dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:id="@+id/vHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="164dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#E8E8E8" />
<View
android:id="@+id/vVerticalLine"
android:layout_width="1dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vHorizontalLine"
android:background="#E8E8E8" />
<View
android:id="@+id/vNegative"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/vVerticalLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vHorizontalLine" />
<TextView
android:id="@+id/tvNegative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:textColor="#969799"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/vVerticalLine"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vHorizontalLine" />
<View
android:id="@+id/vPositive"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/vVerticalLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vHorizontalLine" />
<TextView
android:id="@+id/tvPositive"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/vVerticalLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vHorizontalLine"
android:textColor="#111235"
android:textSize="28sp"
android:text="确定"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvContent" android:id="@+id/rvContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:background="@color/color_F8F8F8" android:background="@color/color_F8F8F8"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<com.miya.fastcashier.widget.CommonPromptView
android:id="@+id/cpEmptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_E5E5E5"
app:layout_constraintStart_toStartOf="parent"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_prompt"
android:layout_width="426dp"
android:layout_height="320dp"
android:layout_marginTop="123dp"
android:scaleType="centerCrop"
android:src="@mipmap/app_bg_common_empty"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:textColor="@color/color_333333"
android:textSize="32sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_prompt" />
</merge>
...@@ -15,4 +15,5 @@ ...@@ -15,4 +15,5 @@
<color name="color_FF4E33">#FF4E33</color> <color name="color_FF4E33">#FF4E33</color>
<color name="color_ECECEC">#ECECEC</color> <color name="color_ECECEC">#ECECEC</color>
<color name="color_F8F8F8">#F8F8F8</color> <color name="color_F8F8F8">#F8F8F8</color>
<color name="color_E5E5E5">#E5E5E5</color>
</resources> </resources>
\ No newline at end of file
...@@ -15,10 +15,13 @@ ...@@ -15,10 +15,13 @@
<string name="username_not_empty">用户名不能为空</string> <string name="username_not_empty">用户名不能为空</string>
<string name="password_not_empty">密码不能为空</string> <string name="password_not_empty">密码不能为空</string>
<string name="invalid_password">密码位数必须得是6位以上</string> <string name="invalid_password">密码位数必须得是6位以上</string>
<string name="search">查询</string> <string name="search">查询账单</string>
<string name="statistic">统计</string> <string name="statistic">统计打印</string>
<string name="balance">结算</string> <string name="balance">结算打印</string>
<string name="cancel">取消</string> <string name="cancel">取消</string>
<string name="sure">确定</string> <string name="sure">确定</string>
<string name="search_order_prompt_text">还没有明细哦~</string>
<string name="app_text_login_out">是否确认退出登录账号</string>
<string name="text_login_out_sure">确认退出</string>
</resources> </resources>
\ No newline at end of file
...@@ -23,4 +23,14 @@ ...@@ -23,4 +23,14 @@
<item name="android:lines">1</item> <item name="android:lines">1</item>
<item name="android:maxLines">1</item> <item name="android:maxLines">1</item>
</style> </style>
<style name="CommonDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.7</item>
</style>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment