Commit a10ed4c4 by 宁斌

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
#	user-login/src/main/debug/AndroidManifest.xml
parents 1e1dee0d fd2e5345
......@@ -216,12 +216,12 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
// functions.add(new Function((long) 142, 151, 5, "餐牌管理", R.drawable.ic_meals_menu_management));
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "訂單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "外賣接單", R.drawable.ic_takeaway_orders, 0));
functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management_close, 1));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1));
functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.Function.class, ComponentMain.Function.employee,"employee"));
functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
......@@ -287,7 +287,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
.setActionName("showOrderCenterActivity")
.build()
.call();
} else if (name.equals("訂單管理")) {
} else if (name.equals("外賣接單")) {
CC.obtainBuilder("Component.OtherOrder")
.setActionName("orderActivity")
.build()
......
package com.gingersoft.gsa.other_order_mode.data
import com.gingersoft.gsa.other_order_mode.data.model.bean.ThirdItem
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
......@@ -21,7 +23,7 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
heWeather
}
suspend fun updateRestOpenStatus(state: Boolean,restaurantId: String) = withContext(Dispatchers.IO) {
suspend fun updateRestOpenStatus(state: Boolean, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restId", restaurantId)
.add("openStatus", if (state) "1" else "2")
......@@ -30,7 +32,6 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data
}
suspend fun getOrderInfo(orderId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
......@@ -53,6 +54,14 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data
}
suspend fun thirdDelivery(orderId: String, thirdItem: ThirdItem) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.add("items", Gson().toJson(thirdItem))
.build()
network.thirdDelivery(requestBody)
}
suspend fun updateSelfOrderStatus(ids: String, status: String, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("ids", ids)
......@@ -64,7 +73,7 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
}
suspend fun getDeliveryInfo(restId: String, userId: String) = withContext(Dispatchers.IO){
suspend fun getDeliveryInfo(restId: String, userId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restId", restId)
.add("userId", userId)
......@@ -73,6 +82,13 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data
}
suspend fun getDeliveryConfigDTO(restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.build()
network.getDeliveryConfigDTO(requestBody)
}
companion object {
private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class DeliveryConfig(
val `data`: Data,
val success: Boolean,
val sysTime: Long) {
data class Data(val list: List<DeliveryInfo>) {
data class DeliveryInfo(
val addressDetail: String,
val deliveryCost: Double,
val desc: String,
val distributionFee: Double,
val distributionFeeMax: Double,
val distributionFeeMin: Double,
val distributionType: String,//區分當前是什麼類型的配送方式
val id: Int,
val mapX: String,
val mapY: String,
val restaurantId: Int,
val restaurantName: String,
val restaurantPhone: String,
val type: Int//為1時是第三方配送
)
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
class OrderList {
/**
* success : true
* sysTime : 1585282096866
* data : {"data":[{"STATUS":0,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港荔枝角青山道479號麗昌工廠大廈2樓201L室Innovation Design Consultant Ltd.1111","PAY_AMOUNT":89,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200411316057124","Id":48883,"CREATE_TIME":"Mar 27, 2020 12:07:49 PM","takeFoodCode":"0","order_type":2,"RECEIVER":"有 女士"},{"STATUS":3,"MEMBER_NAME":"你好哦","ADDRESS_DETAIL":"香港長沙灣青山道479號麗昌工業大廈303","PAY_AMOUNT":128,"PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26202501369354194","Id":48880,"CREATE_TIME":"Mar 27, 2020 11:43:53 AM","takeFoodCode":"0055","order_type":2,"RECEIVER":"劉先生 先生"},{"STATUS":2,"MEMBER_NAME":"你好哦","ADDRESS_DETAIL":"美國紐約州紐約123123","PAY_AMOUNT":128,"PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200341332451819","Id":48879,"CREATE_TIME":"Mar 27, 2020 11:39:08 AM","takeFoodCode":"0","order_type":2,"RECEIVER":"asdfasdf 先生"},{"STATUS":3,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港禮頓山禮頓道8號8號 59864香港銅鑼灣皇冠假日酒店一","PAY_AMOUNT":384,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200681397655588","Id":48875,"CREATE_TIME":"Mar 27, 2020 11:33:19 AM","takeFoodCode":"0052","order_type":2,"RECEIVER":"說 先生"},{"STATUS":2,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港半山堅尼地道28號香港特別行政區前任行政長官辦公室111","PAY_AMOUNT":228,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200031363851774","Id":48874,"CREATE_TIME":"Mar 27, 2020 11:33:01 AM","takeFoodCode":"0051","order_type":2,"RECEIVER":"特別 女士"},{"STATUS":3,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港鵝頸駱克道463-464號銅鑼灣廣場二期123","PAY_AMOUNT":128,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26201261317059894","Id":48873,"CREATE_TIME":"Mar 27, 2020 11:31:37 AM","takeFoodCode":"0050","order_type":2,"RECEIVER":"杜 先生"},{"STATUS":2,"MEMBER_NAME":"許立燦","ADDRESS_DETAIL":"香港島大坑電腦大廈","PAY_AMOUNT":78,"PHONE":"18938995556","orderPayType":2,"ORDER_NO":"26202381350555250","Id":48866,"CREATE_TIME":"Mar 27, 2020 10:53:45 AM","takeFoodCode":"0046","order_type":2,"RECEIVER":"許 先生"},{"STATUS":2,"MEMBER_NAME":"許立燦","ADDRESS_DETAIL":"香港島中環餐飲服務公司","PAY_AMOUNT":88,"PHONE":"18938995556","orderPayType":2,"ORDER_NO":"26201801340350065","Id":48854,"CREATE_TIME":"Mar 27, 2020 10:44:41 AM","takeFoodCode":"0045","order_type":2,"RECEIVER":"12345 先生"},{"MaxOrder":200,"selflNum":35,"totalAmount":78,"maxOrderSelf":100,"num":111,"dayOrderNum":1,"Open_Status":"1"}],"count":0,"page":{"pageIndex":1,"pageSize":10,"pageCount":0,"totalCount":8}}
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: DataBeanX? = null
class DataBeanX {
/**
* data : [{"STATUS":0,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港荔枝角青山道479號麗昌工廠大廈2樓201L室Innovation Design Consultant Ltd.1111","PAY_AMOUNT":89,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200411316057124","Id":48883,"CREATE_TIME":"Mar 27, 2020 12:07:49 PM","takeFoodCode":"0","order_type":2,"RECEIVER":"有 女士"},{"STATUS":3,"MEMBER_NAME":"你好哦","ADDRESS_DETAIL":"香港長沙灣青山道479號麗昌工業大廈303","PAY_AMOUNT":128,"PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26202501369354194","Id":48880,"CREATE_TIME":"Mar 27, 2020 11:43:53 AM","takeFoodCode":"0055","order_type":2,"RECEIVER":"劉先生 先生"},{"STATUS":2,"MEMBER_NAME":"你好哦","ADDRESS_DETAIL":"美國紐約州紐約123123","PAY_AMOUNT":128,"PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200341332451819","Id":48879,"CREATE_TIME":"Mar 27, 2020 11:39:08 AM","takeFoodCode":"0","order_type":2,"RECEIVER":"asdfasdf 先生"},{"STATUS":3,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港禮頓山禮頓道8號8號 59864香港銅鑼灣皇冠假日酒店一","PAY_AMOUNT":384,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200681397655588","Id":48875,"CREATE_TIME":"Mar 27, 2020 11:33:19 AM","takeFoodCode":"0052","order_type":2,"RECEIVER":"說 先生"},{"STATUS":2,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港半山堅尼地道28號香港特別行政區前任行政長官辦公室111","PAY_AMOUNT":228,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26200031363851774","Id":48874,"CREATE_TIME":"Mar 27, 2020 11:33:01 AM","takeFoodCode":"0051","order_type":2,"RECEIVER":"特別 女士"},{"STATUS":3,"MEMBER_NAME":"觉得很多很多","ADDRESS_DETAIL":"香港鵝頸駱克道463-464號銅鑼灣廣場二期123","PAY_AMOUNT":128,"PHONE":"15899876018","orderPayType":1,"ORDER_NO":"26201261317059894","Id":48873,"CREATE_TIME":"Mar 27, 2020 11:31:37 AM","takeFoodCode":"0050","order_type":2,"RECEIVER":"杜 先生"},{"STATUS":2,"MEMBER_NAME":"許立燦","ADDRESS_DETAIL":"香港島大坑電腦大廈","PAY_AMOUNT":78,"PHONE":"18938995556","orderPayType":2,"ORDER_NO":"26202381350555250","Id":48866,"CREATE_TIME":"Mar 27, 2020 10:53:45 AM","takeFoodCode":"0046","order_type":2,"RECEIVER":"許 先生"},{"STATUS":2,"MEMBER_NAME":"許立燦","ADDRESS_DETAIL":"香港島中環餐飲服務公司","PAY_AMOUNT":88,"PHONE":"18938995556","orderPayType":2,"ORDER_NO":"26201801340350065","Id":48854,"CREATE_TIME":"Mar 27, 2020 10:44:41 AM","takeFoodCode":"0045","order_type":2,"RECEIVER":"12345 先生"},{"MaxOrder":200,"selflNum":35,"totalAmount":78,"maxOrderSelf":100,"num":111,"dayOrderNum":1,"Open_Status":"1"}]
* count : 0
* page : {"pageIndex":1,"pageSize":10,"pageCount":0,"totalCount":8}
*/
var count: Int = 0
var page: PageBean? = null
......@@ -58,7 +49,21 @@ class OrderList {
* dayOrderNum : 1
* Open_Status : 1
*/
var delivery_man_phone_num: String? = null
var delivery_man_name: String? = null
var curStat: Int = 0//訂單已創建 1
// * * Order Assigned To Delivery Man - 配送員已接單 2
// * * Delivery Man Reached Pickup Point Nearby - 配送員已到達店鋪附近 3
// * * Delivery Man Reached Pickup Point - 配送员已到店 4
// * * Delivery In Progress - 訂單正在配送中 5
// * * Delivery Man Reached Destination Nearby - 配送員已到達目的地附近 6
// * * Order Delivered - 訂單已完成 7
// * * Order Cancelled Before Collection - 訂單已取消 - 取餐前 8
// * * Order Cancelled After Collection - 訂單已取消 - 取餐后 9
// * * Order Assigned To Another Delivery Man - 已指派另一位配送員 10
var deliveryMode: String? = null
var trkNo: String? = null
var isDelete: Int = 0
var STATUS: Int = 0//0,1為待確認,2為製作中,3待取餐或送貨中
var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class ThirdItem : ArrayList<ThirdItem.ThirdItemItem>() {
data class ThirdItemItem(val descr: String = "",
val dim: Dim = Dim(),
val name: String,
val ori: String = "",
val qty: Int,
val sku: String = "",
val stg: String = "Normal",
val typ: String = "",
val unt_price: UntPrice,
val wt: Wt = Wt()) {
data class Dim(
val hgt: Int = 1,
val len: Int = 1,
val unt: String = "cm", //尺寸單位
val wid: Int = 1
)
data class UntPrice(
val ccy: String = "HKD",//金額單位
val `val`: Double
)
data class Wt(
val unt: String = "kg", //重量單位
val `val`: Int = 1
)
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class ThirdSend(
val `data`: Data,
val success: Boolean,
val errCode: String,
val errMsg: String,
val sysTime: Long
) {
data class Data(
val createTime: Long,
val ctime: Long,
val curStat: String,
val delivery_man_name: String,
val delivery_man_phone_num: String,
val isDelete: Int,
val lUpd: Long,
val mchShipanyCommn: Double,
val mchUid: String,
val orderId: Int,
val restaurantId: Int,
val takeFoodCode: String,
val uid: String,
val updateTime: Long
)
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody
import retrofit2.Call
......@@ -16,6 +15,8 @@ class CoolWeatherNetwork {
private val service = ServiceCreator.create2(WeatherService::class.java)
private val gsposService = ServiceCreator.create3(WeatherService::class.java)
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
......@@ -24,10 +25,14 @@ class CoolWeatherNetwork {
suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await()
suspend fun thirdDelivery(requestBody: RequestBody) = gsposService.thirdDelivery(requestBody).await()
suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await()
suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await()
suspend fun getDeliveryConfigDTO(requestBody: RequestBody) = gsposService.getDeliveryConfigDTO(requestBody).await()
suspend fun getHistoryOrderList(requestBody: RequestBody) = orderService.getHistoryOrderList(requestBody).await()
private suspend fun <T> Call<T>.await(): T {
......@@ -40,7 +45,6 @@ class CoolWeatherNetwork {
override fun onResponse(call: Call<T>, response: Response<T>) {
val body = response.body()
Log.e("eee", "請求地址:" + response.raw().request().url())
if (body != null) {
continuation.resume(body)
} else continuation.resumeWithException(RuntimeException("response body is null") as Throwable)
......
package com.gingersoft.gsa.other_order_mode.data.network
import com.gingersoft.gsa.cloud.globalconfig.applyOptions.intercept.LoggingInterceptor
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import java.util.concurrent.TimeUnit
object ServiceCreator {
private val httpClient = OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS).addInterceptor(LoggingInterceptor())
private const val ROOT_SZ_URL = "http://192.168.1.74:6060"
private const val ROOT_HK_TEST_URL = "https://hktest.ricepon.com:64377"
private const val ROOT_FORMAL_URL = "https://m.ricepon.com"
const val ROOT_URL = ROOT_HK_TEST_URL
private const val BASE_URL = "$ROOT_URL/ricepon-wechat/api/"
private const val BASE_URL2 = "$ROOT_URL/member-web/api/"
private const val BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/"
private const val BASE_URL = "https://hktest.ricepon.com:64377/ricepon-wechat/api/"
private const val BASE_URL2 = "https://hktest.ricepon.com:64377/member-web/api/"
//https://hktest.ricepon.com:64377/member-web/api/wx/updateRestOpenStatus
private val httpClient = OkHttpClient.Builder()
private val builder = Retrofit.Builder()
.baseUrl(BASE_URL)
......@@ -24,13 +33,15 @@ object ServiceCreator {
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
private val retrofit = builder.build()
private val retrofit2 = builder2.build()
fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)
private val builder3 = Retrofit.Builder()
.baseUrl(BASE_URL3)
.client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
fun <T> create2(serviceClass: Class<T>): T = retrofit2.create(serviceClass)
fun <T> create(serviceClass: Class<T>): T = builder.build().create(serviceClass)
fun <T> create2(serviceClass: Class<T>): T = builder2.build().create(serviceClass)
fun <T> create3(serviceClass: Class<T>): T = builder3.build().create(serviceClass)
}
\ No newline at end of file
......@@ -21,12 +21,18 @@ interface WeatherService {
@POST("wechat/updateOrderStatus")
fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("gsa/shipAnyOrdersNew")
fun thirdDelivery(@Body requestBody: RequestBody): Call<ThirdSend>
@POST("wechat/updateSelfOrderStatus")
fun updateSelfOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("wechat/findRestDelivery")
fun getDeliveryInfo(@Body requestBody: RequestBody): Call<DeliveryBean>
@POST("gsa/getDeliveryConfigDTO")
fun getDeliveryConfigDTO(@Body requestBody: RequestBody): Call<DeliveryConfig>
@POST("wechat/findHistoryOrderList")
fun getHistoryOrderList(@Body requestBody: RequestBody): Call<HistoryOrderBean>
}
\ No newline at end of file
......@@ -17,18 +17,29 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.DeliveryBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.data.model.bean.UpdateOrderBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.*
import com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryAdapter
import com.jess.arms.utils.ArmsUtils
import com.zhy.autolayout.utils.ScreenUtils
import kotlinx.coroutines.launch
class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
private fun showLoading(context: Context, message: String? = null) {
if (message != null)
LoadingDialog.showDialogForLoading(context, message, true)
else
LoadingDialog.showDialogForLoading(context)
}
fun cancelDialogForLoading() {
LoadingDialog.cancelDialogForLoading()
}
companion object {
var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var fragmentType = arrayOf("0", "0", "0", "2", "7")
......@@ -48,8 +59,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//派送員信息
var deliveryBean: DeliveryBean? = null
var deliveryConfig: DeliveryConfig? = null
/**
* 獲取訂單信息
* 獲取訂單
*/
fun getOrderList(context: Context, position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) {
launch({
......@@ -209,35 +223,23 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}.createDialogView().show()
} else {
//確認訂單
updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
if (status == 0 || status == 1 || status == 2) {
//確認送單
if (this.success) {
//打印
//初始化用於打印的view
if (orderDetails.data != null) {
//訂單信息和廚房單
orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType
MyOrderManage.setDataBean(orderDetails.data!![0])
CC.obtainBuilder("Component.Print")
.addParam("type", 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
Log.e("error", "是否成功打印:" + result.isSuccess)
MyOrderManage.setDataBean(null)
}
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
}
listener.invoke(true)
} else {
ToastUtils.show(context, "送單失敗")
showLoading(context)
// 確認訂單
var third = false
if (deliveryConfig != null) {
for (i in 0 until deliveryConfig!!.data.list.size) {
third = deliveryConfig!!.data.list[i].let {
(it.distributionType == data.deliveryMode && deliveryConfig!!.data.list[i].type == 1)
}
}
}
Log.e("eee", "是否是第三方配送:$third")
if (third) {
// 如果是第三方物流,調用第三方接口
thirdSend(data, orderDetails, status, isPush, data.order_type, context, listener)
} else {
updateOrderAndPrint(data, status, isPush, orderDetails, context, listener)
}
}
} else {
// 自取的確認訂單
......@@ -250,12 +252,68 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
private suspend fun updateOrderAndPrint(data: OrderList.DataBeanX.DataBean, status: Int, isPush: Int, orderDetails: OrderDetails, context: Context, listener: (Boolean) -> Unit) {
updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
if (status == 0 || status == 1 || status == 2) {
//確認送單
if (this.success) {
//打印
//初始化用於打印的view
if (orderDetails.data != null) {
//訂單信息和廚房單
orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType
MyOrderManage.setDataBean(orderDetails.data!![0])
CC.obtainBuilder("Component.Print")
.addParam("type", 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
Log.e("error", "是否成功打印:" + result.isSuccess)
MyOrderManage.setDataBean(null)
}
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
}
listener.invoke(true)
} else {
ToastUtils.show(context, "送單失敗")
}
}
}
}
/**
* 第三方派送
*/
private suspend fun thirdSend(data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, status: Int, isPush: Int, orderType: Int, context: Context, listener: (Boolean) -> Unit) {
val third = ThirdItem()
orderDetails.data?.get(0)?.PRODUCT_NAME?.let {
for (i in it) {
val price = ThirdItem.ThirdItemItem.UntPrice(`val` = i.PRICE!!.toDouble())
val thirdItem = if (i.PRODUCT_NAME != null) {
ThirdItem.ThirdItemItem(name = i.PRODUCT_NAME!!, qty = 1, unt_price = price)
} else {
ThirdItem.ThirdItemItem(name = "", qty = 1, unt_price = price)
}
third.add(thirdItem)
}
}
repository.thirdDelivery(data.Id.toString(), third).apply {
cancelDialogForLoading()
if (success) {
ToastUtils.show(context, "訂單派送成功")
updateOrderAndPrint(data, status, isPush, orderDetails, context, listener)
} else {
ToastUtils.show(context, "訂單派送失敗")
}
}
}
suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int): UpdateOrderBean {
return repository.updateOrderStatus(orderId, selfOrderId, status, mobile, sender, isPush, orderType)
}
/**
* 選擇派送員
*/
......@@ -324,6 +382,17 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
fun getDeliveryConfigDTO(context: Context) {
launch({
repository.getDeliveryConfigDTO(GsaCloudApplication.getRestaurantId(context).toString()).apply {
deliveryConfig = this
}
}, {
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
......
......@@ -7,6 +7,7 @@ import android.os.Handler
import android.os.IBinder
import android.util.Log
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import com.google.gson.Gson
import okhttp3.*
import okio.ByteString
......@@ -22,7 +23,8 @@ class GetInfoUpdateService : Service() {
* 心跳检测时间
*/
private val HEART_BEAT_RATE = (15 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "https://hktest.ricepon.com:64377/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private val WEBSOCKET_HOST_AND_PORT = "${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private var mWebSocket: WebSocket? = null
var postCallBack: PostCallBack? = null
......
......@@ -11,7 +11,6 @@ import android.media.SoundPool
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.databinding.DataBindingUtil
......@@ -19,7 +18,6 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.ui.view.SwitchButton
import com.gingersoft.gsa.other_order_mode.R
......@@ -78,9 +76,9 @@ class OtherOrderActivity : BaseActivity() {
layoutHeight = layout_today_order_info.height.toFloat()
}
pageViewModel.getDeliveryInfo(this)
pageViewModel.getDeliveryConfigDTO(this)
}
/**
* 加載餐廳營業信息
*/
......@@ -192,7 +190,6 @@ class OtherOrderActivity : BaseActivity() {
}
}
})
}
override fun onServiceDisconnected(name: ComponentName) {
......
......@@ -44,6 +44,24 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
holder.binding.data = data
holder.binding.isSelf = data.order_type == 7
data.trkNo?.apply {
if (length > 0) {
holder.binding.deliveryState = when (data.curStat) {
1 -> "訂單已創建"
2 -> "配送員已接單"
3 -> "配送員到店附近"
4 -> "配送員已到店"
5 -> "配送中"
6 -> "到達目的地附近"
7 -> "訂單已完成"
8 -> "訂單已取消"//取餐前
9 -> "訂單已取消"//取餐後
10 -> "已指派另一位配送員"
else -> "訂單已創建"
}
}
}
var state: String? = null
val bg = GradientDrawable()
bg.cornerRadius = dp2px(5f).toFloat()
......
......@@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
......@@ -16,8 +15,6 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseFragment
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.scwang.smartrefresh.layout.header.BezierRadarHeader
import com.scwang.smartrefresh.layout.header.FalsifyHeader
import kotlinx.android.synthetic.main.fragment_other_order.*
/**
......@@ -44,7 +41,6 @@ class PlaceholderFragment : BaseFragment() {
getOrderList(this, false)
// }
})
}
// 初始化recyclerview
......@@ -76,7 +72,6 @@ class PlaceholderFragment : BaseFragment() {
}
// 綁定當前fragment的數據項
pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
Log.e("eee", "刷新數據")
it.let { adapter.setData(it) }
})
......@@ -123,4 +118,5 @@ class PlaceholderFragment : BaseFragment() {
}
}
}
}
\ No newline at end of file
......@@ -2,8 +2,8 @@ package com.gingersoft.gsa.other_order_mode.util
import android.app.Dialog
import android.content.Context
import android.util.Log
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
......@@ -11,7 +11,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOrderInfoDialogBinding
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOrderInfoDialogNewBinding
import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import com.jess.arms.utils.ArmsUtils
......@@ -28,10 +27,17 @@ object OtherOrderUtils {
layoutOrderInfoDialogBinding.data = orderData
layoutOrderInfoDialogBinding.isSelf = orderType == 7
layoutOrderInfoDialogBinding.totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
layoutOrderInfoDialogBinding.showBtn = showBtn
//如果有物流號,就不顯示指派送貨按鈕
// if (orderData.trkNo != null && orderData.trkNo!!.isNotEmpty() && orderStuats == 2) {
// layoutOrderInfoDialogBinding.showBtn = false
// } else {
layoutOrderInfoDialogBinding.showBtn = showBtn
// }
val btnContent: String
val type = if (orderType == 7) "自取" else "外賣"
val orderStatus: String
when (orderStuats) {
2 -> {
if (orderType == 7) {
......@@ -73,9 +79,13 @@ object OtherOrderUtils {
//確認訂單,調用接口,並打印
listenter?.invoke(data.data!![0], dialog)
}
hepler.getView<ImageView>(R.id.iv_close).setOnClickListener{
dialog.dismiss()
}
}
}.setWidth((ArmsUtils.getScreenWidth(context) * 0.9).toInt())
.setHeight((ArmsUtils.getScreenHeidth(context) * 0.8).toInt())
.setHeight((ArmsUtils.getScreenHeidth(context) * 0.9).toInt())
.createDialogView()
.show()
......
......@@ -38,409 +38,504 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_dialog_bg"
android:paddingTop="@dimen/dp_15"
android:paddingBottom="@dimen/dp_15">
<TextView
android:id="@+id/tv_order_name"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:text="@{data.order_from==2?@string/ricepon_order:@string/h5_order}"
android:textSize="@dimen/dp_16"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_order_state"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{orderStatus}"
android:textColor="#009788"
android:textSize="@dimen/dp_15"
android:visibility="@{showBtn?View.VISIBLE:View.GONE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_order_info"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_10"
app:layout_constraintBottom_toTopOf="@id/btn_assign_shipping"
app:layout_constraintTop_toBottomOf="@id/tv_order_state">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
android:background="@drawable/shape_dialog_bg"
android:layout_marginBottom="@dimen/dp_10"
android:paddingTop="@dimen/dp_15"
android:paddingBottom="@dimen/dp_15"
app:layout_constraintBottom_toTopOf="@id/iv_close"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_order_name"
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_total_amount_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="總金額"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_total_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:textColor="#BE1C42"
android:textSize="@dimen/dp_24"
android:layout_marginTop="@dimen/dp_5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_order_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_15"
android:text="@{@string/order_no + data.oRDER_NO}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount" />
<TextView
android:id="@+id/tv_create_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_no" />
<View
android:id="@+id/line_info_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_create_time" />
<TextView
android:id="@+id/tv_receiver_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_8"
android:gravity="right"
android:text="收貨人:"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_info_top" />
<TextView
android:id="@+id/tv_receiver"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.rECEIVER}"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toRightOf="@id/tv_receiver_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receiver_text" />
<TextView
android:id="@+id/tv_receive_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receiver" />
<TextView
android:id="@+id/tv_receive_phone"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.pHONE}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_phone_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_phone_text" />
<TextView
android:id="@+id/tv_receive_time_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receive_phone" />
<TextView
android:id="@+id/tv_receive_time"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{isSelf?data.takeTime:data.sEND_TIME}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_time_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_time_text" />
<TextView
android:id="@+id/tv_receive_address_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/meal_code:@string/receiving_address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receive_time" />
<TextView
android:id="@+id/tv_receive_address"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{isSelf?data.takeFoodCode:data.addressDetail}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_address_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_address_text" />
<View
android:id="@+id/line_info_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ef"
app:layout_constraintTop_toBottomOf="@id/tv_receive_address" />
<TextView
android:id="@+id/tv_food_details_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="商品詳情"
android:textColor="@color/black"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_info_bottom" />
<View
android:id="@+id/line_food_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_food_details_text" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
app:layout_constraintTop_toBottomOf="@id/line_food_top" />
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:text="@{data.order_from==2?@string/ricepon_order:@string/h5_order}"
android:textSize="@dimen/dp_16"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_order_state"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{orderStatus}"
android:textColor="#009788"
android:textSize="@dimen/dp_15"
android:visibility="@{showBtn?View.VISIBLE:View.INVISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/line_food_bottom"
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_order_info"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_10"
app:layout_constraintBottom_toTopOf="@id/btn_assign_shipping"
app:layout_constraintTop_toBottomOf="@id/tv_order_state">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/rv_food" />
<TextView
android:id="@+id/tv_total_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="合計:"
app:layout_constraintHorizontal_weight="0.7"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_total"
app:layout_constraintTop_toBottomOf="@id/line_food_bottom" />
<TextView
android:id="@+id/tv_total"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.tOTAL_AMOUNT), data.lunchbox),data.dELIVERY_CHARGE)}"
app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintLeft_toRightOf="@id/tv_total_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_text" />
<TextView
android:id="@+id/tv_lunchbox_cost_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="餐盒費:"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_total" />
<TextView
android:id="@+id/tv_lunchbox_cost"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.lunchbox}"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_lunchbox_cost_text" />
<TextView
android:id="@+id/tv_delivery_fee_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費:"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
<TextView
android:id="@+id/tv_delivery_fee"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_fee_text" />
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="折扣:"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_fee" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.discount_amount}"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_discount_text" />
<TextView
android:id="@+id/tv_total_amount_text2"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="總金額:"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_discount" />
<TextView
android:id="@+id/tv_total_amount2"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_amount_text2" />
<TextView
android:id="@+id/tv_pay_amount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="支付金額:"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text2" />
<TextView
android:id="@+id/tv_pay_amount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:textColor="#FF0000"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_pay_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btn_assign_shipping"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:background="@drawable/shape_green_btn"
android:text="@{btnContent}"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
android:visibility="@{showBtn?View.VISIBLE:View.GONE}"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<TextView
android:id="@+id/tv_total_amount_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="總金額"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_total_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:textColor="#BE1C42"
android:textSize="@dimen/dp_24"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_order_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_15"
android:text="@{@string/order_no + data.oRDER_NO}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount" />
<TextView
android:id="@+id/tv_create_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_no" />
<View
android:id="@+id/line_info_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_create_time" />
<TextView
android:id="@+id/tv_receiver_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_8"
android:gravity="right"
android:text="收貨人:"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_info_top" />
<TextView
android:id="@+id/tv_receiver"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.rECEIVER}"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toRightOf="@id/tv_receiver_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receiver_text" />
<TextView
android:id="@+id/tv_receive_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receiver" />
<TextView
android:id="@+id/tv_receive_phone"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.pHONE}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_phone_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_phone_text" />
<TextView
android:id="@+id/tv_receive_time_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receive_phone" />
<TextView
android:id="@+id/tv_receive_time"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{isSelf?data.takeTime:data.sEND_TIME}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_time_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_time_text" />
<TextView
android:id="@+id/tv_receive_address_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@{isSelf?@string/meal_code:@string/receiving_address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receive_time" />
<TextView
android:id="@+id/tv_receive_address"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{isSelf?data.takeFoodCode:data.addressDetail}"
app:layout_constraintLeft_toRightOf="@id/tv_receive_address_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_address_text" />
<TextView
android:id="@+id/tv_delivery_man_name_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@string/deliveryman"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_receive_address" />
<!-- android:visibility="@{(data.delivery_man_name==null || data.delivery_man_name.length()==0) ? View.GONE : View.VISIBLE}"-->
<TextView
android:id="@+id/tv_delivery_man_name"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.delivery_man_name}"
app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_name_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_man_name_text" />
<TextView
android:id="@+id/tv_delivery_man_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@string/deliveryman_phone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_man_name" />
<!-- android:visibility="@{(data.delivery_man_phone_num==null||data.delivery_man_phone_num.length()==0)?View.GONE:View.VISIBLE}"-->
<TextView
android:id="@+id/tv_delivery_man_phone"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{data.delivery_man_phone_num}"
app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_phone_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_man_phone_text" />
<TextView
android:id="@+id/tv_delivery_num_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="@string/logistics_number"
android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_man_phone" />
<TextView
android:id="@+id/tv_delivery_num"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{data.trkNo}"
android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toRightOf="@id/tv_delivery_num_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_num_text" />
<View
android:id="@+id/line_info_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ef"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_num" />
<TextView
android:id="@+id/tv_food_details_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="商品詳情"
android:textColor="@color/black"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_info_bottom" />
<View
android:id="@+id/line_food_top"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_food_details_text" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
app:layout_constraintTop_toBottomOf="@id/line_food_top" />
<View
android:id="@+id/line_food_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/rv_food" />
<TextView
android:id="@+id/tv_total_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="合計:"
app:layout_constraintHorizontal_weight="0.7"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_total"
app:layout_constraintTop_toBottomOf="@id/line_food_bottom" />
<TextView
android:id="@+id/tv_total"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.tOTAL_AMOUNT), data.lunchbox),data.dELIVERY_CHARGE)}"
app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintLeft_toRightOf="@id/tv_total_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_text" />
<TextView
android:id="@+id/tv_lunchbox_cost_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="餐盒費:"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_total" />
<TextView
android:id="@+id/tv_lunchbox_cost"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.lunchbox}"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_lunchbox_cost_text" />
<TextView
android:id="@+id/tv_delivery_fee_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費:"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
<TextView
android:id="@+id/tv_delivery_fee"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_fee_text" />
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="折扣:"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_fee" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.discount_amount}"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_discount_text" />
<TextView
android:id="@+id/tv_total_amount_text2"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="總金額:"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_discount" />
<TextView
android:id="@+id/tv_total_amount2"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_amount_text2" />
<TextView
android:id="@+id/tv_pay_amount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="支付金額:"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text2" />
<TextView
android:id="@+id/tv_pay_amount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + MoneyUtil.sub(total_amount, data.discount_amount)}"
android:textColor="#FF0000"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_pay_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/btn_assign_shipping"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_green_btn"
android:text="@{btnContent}"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
android:visibility="@{showBtn?View.VISIBLE:View.GONE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/iv_close"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:src="@drawable/dialog_close"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -11,6 +11,10 @@
type="com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList.DataBeanX.DataBean" />
<variable
name="delivery_state"
type="String" />
<variable
name="state"
type="String" />
......@@ -86,6 +90,15 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_delivery_state"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{delivery_state}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_order_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -99,11 +112,11 @@
<TextView
android:id="@+id/tv_order_time"
style="@style/otherOrder_item_create_time_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
style="@style/otherOrder_item_create_time_textStyle"
app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_order_user_name" />
......@@ -144,8 +157,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_5"
android:text="訂單號:"
android:text="取餐碼:"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num_text"
app:layout_constraintTop_toBottomOf="@id/tv_cellphone_num_text" />
......@@ -154,7 +166,7 @@
style="@style/otherOrder_item_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{data.oRDER_NO}"
android:text="@{data.takeFoodCode}"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintTop_toTopOf="@id/tv_order_num_text" />
......
......@@ -37,5 +37,7 @@
<string name="ricepon_order">ricepon訂單</string>
<string name="order_no">訂單編號:</string>
<string name="deliveryman">送貨員:</string>
<string name="deliveryman_phone">送貨員手機號:</string>
<string name="logistics_number">物流號:</string>
</resources>
......@@ -13,10 +13,9 @@
android:launchMode="singleTop"
android:theme="@style/print_TranslucentTheme" />
<activity android:name=".mvp.ui.activity.PrinterListActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<service android:name=".mvp.print.service.PrjService"/>
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
......
......@@ -10,6 +10,7 @@ import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.joe.print.mvp.print.service.PrjService;
import com.joe.print.mvp.ui.activity.IpPrintActivity;
import com.joe.print.mvp.ui.activity.PrintActivity;
import com.joe.print.mvp.ui.activity.PrinterListActivity;
......@@ -57,6 +58,13 @@ public class PrintComponent implements IComponent {
return printOrderInfo(cc);
case "printActivity":
return print(cc);
case "openPrintService":
//打開打印服務
Log.e("eee", "PrintComponent打開打印服務");
Intent intent = new Intent(cc.getContext(), PrjService.class);
cc.getContext().startService(intent);
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
default:
// cc.callAsync(new IComponentCallback() {
// @Override
......
//package com.joe.print.mvp.model.bean;
//
//import java.io.Serializable;
//
///**
// * Created by Wyh on 2020/1/16.
// * 打印機實體類
// */
//public class PrinterDeviceBean implements Serializable {
// private int id; //這個類是用來“新增”打印機的,不能有id。解析打印機列表用另一個類
//// private int uid;
// private int restaurantId;
// private String ip;
// private int port;
// private int type;
//// private long createTime;
//
// public PrinterDeviceBean() {
// }
//
// public PrinterDeviceBean(int id, int restaurantId, String ip, int port, int type) {
// this.id = id;
// this.restaurantId = restaurantId;
// this.ip = ip;
// this.port = port;
// this.type = type;
// }
//
// public PrinterDeviceBean(int restaurantId, String ip, int port, int type) {
// this.restaurantId = restaurantId;
// this.ip = ip;
// this.port = port;
// this.type = type;
// }
//
// public int getRestaurantId() {
// return restaurantId;
// }
//
// public void setRestaurantId(int restaurantId) {
// this.restaurantId = restaurantId;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
//// public int getUid() {
//// return uid;
//// }
////
//// public void setUid(int uid) {
//// this.uid = uid;
//// }
////
//// public long getCreateTime() {
//// return createTime;
//// }
////
//// public void setCreateTime(long createTime) {
//// this.createTime = createTime;
//// }
//}
package com.joe.print.mvp.model.server;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface GetPrintInfoService {
@GET("prg/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<LoginBean> getPrintInfo(@Query("restaurantId") String restaurantId);
}
......@@ -12,6 +12,8 @@ import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.PrinterAddContract;
import java.util.Objects;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
......@@ -87,7 +89,7 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model,
* 更新打印機信息
*/
public void updatePrinterInfo(PrinterDeviceBean deviceBean) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(deviceBean));
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), Objects.requireNonNull(JsonUtils.toJson(deviceBean)));
mModel.updatePrinter(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
......
......@@ -16,13 +16,12 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.AidlUtil;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
......@@ -333,7 +332,8 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}
private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
if (Objects.equals(SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, ""), "")) {
String deftultPrint = (String) SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, "");
if (deftultPrint.equals("")) {
// 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印
new DialogUtils(mContext, R.layout.print_dialog_select_device) {
@Override
......@@ -369,7 +369,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
});
}
}.createDialogView().show();
} else if (Objects.equals(SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, ""), Constans.LOCAL_PRINT)) {
} else if (deftultPrint.equals(Constans.LOCAL_PRINT)) {
// 默認打印方式為本地,進行本地打印
locationPrint(bitmaps, new PrintListener() {
@Override
......@@ -387,24 +387,29 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
setPrintState(PrintActivity.FINISH);
}
});
} else if (Objects.equals(SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, ""), Constans.IP_PRINT)) {
} else if (deftultPrint.equals(Constans.IP_PRINT)) {
// 默認打印方式為ip打印,調用ip打印方法
// 獲取默認ip打印機,
if (!Objects.equals(SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, ""), "")) {
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
//有默認打印機
PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean();
printerDeviceBean.setIp((String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, ""));
printerDeviceBean.setPort((Integer) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, 0));
printerDeviceBean.setType((Integer) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PAPER, 0));
ipDevicePrint(printerDeviceBean, bitmaps);
} else {
for (PrinterDeviceBean printerDeviceBean : printerDeviceBeans) {
if (printerDeviceBean.getStatus() == 2) {
//默認打印機
ipDevicePrint(printerDeviceBeans.get(0), bitmaps);
return;
}
}
//沒有默認打印機,彈出彈窗,讓用戶選擇ip打印機
showIpPrintDeviceList(printerDeviceBeans, bitmaps);
} else {
//沒有打印機,讓用戶去添加
setPrintState(PrintActivity.ADD_PRINT_DEVICE);
}
}
}
private void showIpPrintDeviceList(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
private void showIpPrintDeviceList
(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
if (printerDeviceBeans.size() == 1) {
//只有一台ip打印機時,直接打印
......@@ -428,6 +433,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}
.setHeight(ArmsUtils.getScreenHeidth(mContext) / 2)
.createDialogView()
.setOnDismissListener(dialog -> setPrintState(PrintActivity.DIMISS_LOADING))
.show();
}
} else {
......@@ -444,7 +450,9 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
/**
* ip設備打印
*/
public void ipDevicePrint(PrinterDeviceBean printerDeviceBean, List<Bitmap> bitmaps, PrintSocketHolder.OnStateChangedListener stateChangedListener, PrintExecutor.OnPrintResultListener resultListener) {
public void ipDevicePrint(PrinterDeviceBean
printerDeviceBean, List<Bitmap> bitmaps, PrintSocketHolder.OnStateChangedListener
stateChangedListener, PrintExecutor.OnPrintResultListener resultListener) {
int paperType = printerDeviceBean.getType();//打印紙類型 1:58mm,2::80mm
int printWidth;//打印出來的內容寬度
if (paperType == 1) {
......
package com.joe.print.mvp.print.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import com.jess.arms.integration.RepositoryManager;
import com.joe.print.mvp.model.server.GetPrintInfoService;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
/**
* 在用戶登錄成功後,打開打印service,每隔3~5秒請求一次。請求到了數據就進行打印邏輯
*/
public class PrjService extends Service {
private final String TAG = "PrjService";
@Inject
RxErrorHandler mErrorHandler;
@Override
public void onCreate() {
super.onCreate();
Log.e("eee", "打開打印服務");
//開始請求
Observable.interval(0,3, TimeUnit.SECONDS)
.doOnNext(aLong ->{
Log.d(TAG, "第" + aLong + "次輪詢");
/*
* 步骤3:通过Retrofit发送网络请求
*
**/
new RepositoryManager().obtainRetrofitService(GetPrintInfoService.class)
.getPrintInfo("26")
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> {})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> {})
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(Object o) {
Log.e("eee", "请求到:" + o);
}
@Override
public void onError(Throwable t) {
super.onError(t);
t.printStackTrace();
}
});
}).subscribe(new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Long aLong) {
}
@Override
public void onError(Throwable e) {
Log.d(TAG, "对Error事件作出响应" + e.getMessage());
}
@Override
public void onComplete() {
Log.d(TAG, "对onComplete事件作出响应");
}
});
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
......@@ -67,6 +67,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
public final static int FINISH = 1003;//關閉頁面
public final static int ADD_PRINT_DEVICE = 1004;//添加打印機
public static List<PrinterDeviceBean> printerDeviceBeans;
private String callId;
private PrinterRoot printerInIt;
......@@ -106,24 +107,32 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
initDialog();
PrinterDeviceBean deviceBean = (PrinterDeviceBean) getIntent().getSerializableExtra("deviceBean");
// if (type != PrinterRoot.PRINT_TEST) {
//不是测试才去获取打印机列表,获取到打印机列表之后就进行打印
mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
// }
printerInIt = PrinterRoot.getPrinterByType(type);
if (printerInIt != null) {
printerInIt.setmContext(mContext).setPrintListener(this);
}
// if (type == PrinterRoot.PRINT_TEST) {
// if (deviceBean != null) {
// printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
// } else {
// ToastUtils.show(mContext, "测试失败");
// }
// }
if (type == PrinterRoot.PRINT_TEST) {
if (deviceBean != null) {
printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
} else {
ToastUtils.show(mContext, "测试失败");
}
} else {
if (printerDeviceBeans == null || printerDeviceBeans.size() <= 0) {
mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
} else {
printerInIt.print(printerDeviceBeans);
}
}
}
private void initDialog() {
......@@ -294,12 +303,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public void showPrinterList(List<PrinterDeviceBean> deviceBeans) {
if (deviceBeans != null && deviceBeans.size() > 0) {
printerInIt.print(deviceBeans);
} else {
//沒有配置打印機
addPrintDevice();
}
printerDeviceBeans = deviceBeans;
printerInIt.print(printerDeviceBeans);
}
private void addPrintDevice() {
......
......@@ -7,6 +7,7 @@ import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
......@@ -55,7 +56,8 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
TextView printTest;
@BindView(R2.id.printer_type)
RadioGroup rgPaperType;
@BindView(R2.id.cb_set_default)
CheckBox mCbDefalute;
private PrinterDeviceBean printerDeviceBean;
private boolean isEditPrinter = false;//是否是編輯打印機
......@@ -79,15 +81,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override
public void initData(@Nullable Bundle savedInstanceState) {
isDefault = getIntent().getBooleanExtra("isDefault", false);
// etPort.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
String[] ips = new String[4];
// if (BuildConfig.DEBUG) {
// ips[0] = "192";
// ips[1] = "168";
// ips[2] = "1";
// ips[3] = "240";
// }
//如果不為空,則是編輯打印機,初始化信息
if (printerDeviceBean != null) {
mEdPrintName.setText(String.valueOf(printerDeviceBean.getName()));
......@@ -188,10 +182,6 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
ipAddress.append(editText.getText());
ipAddress.append(".");
}
// if (etPort.getText() == null || etPort.getText().toString().equals("")) {
// showMessage("請輸入端口號");
// return;
// }
hideKeyBoard();
int paperType = 1;//打印紙類型
......@@ -206,7 +196,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
} else {
deviceBean = new PrinterDeviceBean(mEdPrintName.getText().toString().trim(), 0, GsaCloudApplication.getRestaurantId(mContext), ipAddress.substring(0, ipAddress.lastIndexOf(".")), Integer.parseInt(port), paperType);
}
deviceBean.setStatus(mCbDefalute.isChecked() ? 2 : 1);
//添加打印機
if (v.getId() == R.id.printer_add) {
if (isEditPrinter && printerDeviceBean != null) {
......
package com.joe.print.mvp.ui.activity;
class aaa {
public static void main(String[] age) {
int[] arr = new int[]{4, 1, 8, 5, 3, 2, 9, 10, 6, 7};
int[] brr = new int[]{5, 1, 2, 3, 8, 4, 9, 10, 6, 7};
partition(arr, 0, 9);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + ",");
}
}
public static void quickSort(int[] arr, int startIndex, int endIndex) {
if (arr != null && arr.length > 0) {
int start = startIndex, end = endIndex;
int target = arr[startIndex];
while (start < end) {
while (start < end) {
if (arr[end] < target) {
swap(arr, start, end);
break;
} else {
end--;
}
}
while (start < end) {
if (arr[start] > target) {
swap(arr, start, end);
break;
} else {
start++;
}
}
}
}
}
public static void swap(int[] arr, int index1, int index2) {
int a = arr[index1];
arr[index1] = arr[index2];
arr[index2] = a;
}
// public static int[] getLeastNumbers(int[] arr, int k) {
// if (k == 0 || arr.length == 0) {
// return new int[0];
// }
// // 最后一个参数表示我们要找的是下标为k-1的数
// return quickSearch(arr, 0, arr.length - 1, k - 1);
// }
//
// private static int[] quickSearch(int[] nums, int lo, int hi, int k) {
// // 每快排切分1次,找到排序后下标为j的元素,如果j恰好等于k就返回j以及j左边所有的数;
// int j = partition(nums, lo, hi);
// if (j == k) {
// return Arrays.copyOf(nums, j + 1);
// }
// // 否则根据下标j与k的大小关系来决定继续切分左段还是右段。
// return j > k ? quickSearch(nums, lo, j - 1, k) : quickSearch(nums, j + 1, hi, k);
// }
//
// // 快排切分,返回下标j,使得比nums[j]小的数都在j的左边,比nums[j]大的数都在j的右边。
private static void partition(int[] nums, int lo, int hi) {
int k = nums[lo];
int i = lo, j = hi + 1;
while (true) {
while (++i <= hi && nums[i] < k);
while (--j >= lo && nums[j] > k);
if (i >= j) {
break;
}
// int t = nums[j];最近更新
// nums[j] = nums[i];
// nums[i] = t;
swap(nums, i, j);
}
nums[lo] = nums[j];
nums[j] = k;
swap(nums, i, j);
}
}
\ No newline at end of file
package com.joe.print.mvp.ui.adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
......@@ -14,14 +15,17 @@ import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.joe.print.R;
import org.w3c.dom.Text;
import java.math.BigDecimal;
import java.util.List;
import static com.qmuiteam.qmui.util.QMUIDisplayHelper.dp2px;
import static com.qmuiteam.qmui.util.QMUIDisplayHelper.px2dp;
public class OtherOrderAdapter extends BaseQuickAdapter<OrderDetails.DataBean.PRODUCTNAMEBean, BaseViewHolder> {
private Context context;
private int indentation;
private int indentation = 5;
private boolean isShowPrice;
public OtherOrderAdapter(Context context, @Nullable List<OrderDetails.DataBean.PRODUCTNAMEBean> data, boolean isShowPrice) {
......@@ -33,11 +37,13 @@ public class OtherOrderAdapter extends BaseQuickAdapter<OrderDetails.DataBean.PR
@Override
protected void convert(BaseViewHolder helper, OrderDetails.DataBean.PRODUCTNAMEBean item) {
helper.setText(R.id.tv_food_name, item.getPRODUCT_NAME());
helper.setText(R.id.tv_food_number, item.getNum());
helper.setText(R.id.tv_food_number, "x" + item.getNum());
helper.setText(R.id.tv_food_price, item.getPRICE());
helper.getView(R.id.tv_food_price).setVisibility(isShowPrice ? View.VISIBLE : View.GONE);
helper.getView(R.id.tv_food_price).setVisibility(isShowPrice ? View.VISIBLE : View.INVISIBLE);
if (helper.getAdapterPosition() == 0) {
indentation = new BigDecimal(((TextView) helper.getView(R.id.tv_food_name)).getPaint().measureText("哈")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
indentation = px2dp(context, (int) ((TextView) helper.getView(R.id.tv_food_name)).getTextSize());
Log.e("eee", "寬度:" + indentation);
}
if (item.getChild() != null && item.getChild().size() > 0) {
......@@ -58,11 +64,12 @@ public class OtherOrderAdapter extends BaseQuickAdapter<OrderDetails.DataBean.PR
private View getChild(String foodName, String foodNum, String price, int leftMargin) {
View view = LayoutInflater.from(context).inflate(R.layout.print_other_order_food_item, null, false);
ImageView ivNext = view.findViewById(R.id.iv_food_item_next);
ivNext.setPadding(dp2px(context, leftMargin), 0, 0, 0);
((TextView) view.findViewById(R.id.tv_food_name)).setText(foodName);
((TextView) view.findViewById(R.id.tv_food_number)).setText(foodNum);
// ((TextView) view.findViewById(R.id.tv_food_price)).setText(price);
TextView tvFoodName = view.findViewById(R.id.tv_food_name);
tvFoodName.setPadding(dp2px(context, leftMargin), 0, 0, 0);
tvFoodName.setText("-" + foodName);
((TextView) view.findViewById(R.id.tv_food_number)).setText("x" + foodNum);
((TextView) view.findViewById(R.id.tv_food_price)).setText(price);
view.findViewById(R.id.tv_food_price).setVisibility(isShowPrice ? View.VISIBLE : View.INVISIBLE);
return view;
}
......
package com.joe.print.mvp.ui.adapter;
import android.content.Context;
import android.view.View;
import android.widget.RadioButton;
import androidx.annotation.Nullable;
......@@ -29,35 +30,35 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
public PrinterListAdapter(@Nullable List<PrinterDeviceBean> data, Context mContext) {
super(R.layout.printer_item, data);
this.mContext = mContext;
selectPrintIp = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, "");
if ((Integer) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, -1) != -1) {
selectPrintPort = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, 0);
}
paperType = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PAPER, 0);
// selectPrintIp = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, "");
// if ((Integer) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, -1) != -1) {
// selectPrintPort = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, 0);
// }
// paperType = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PAPER, 0);
}
@Override
protected void convert(BaseViewHolder helper, PrinterDeviceBean item) {
if (selectPosition == -1) {
//ip、端口、紙張類型也要一致才是默認打印機
if (selectPrintIp.equals(item.getIp()) && paperType == item.getType()) {
if (selectPrintPort != null && item.getPort() != null) {
if (selectPrintPort.equals(item.getPort())) {
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
selectPosition = helper.getAdapterPosition();
}
} else if (selectPrintPort == null && item.getPort() == null) {
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
selectPosition = helper.getAdapterPosition();
}
} else {
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
}
} else if (selectPosition == helper.getAdapterPosition()) {
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
} else {
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
}
// if (selectPosition == -1) {
// //ip、端口、紙張類型也要一致才是默認打印機
// if (selectPrintIp.equals(item.getIp()) && paperType == item.getType()) {
// if (selectPrintPort != null && item.getPort() != null) {
// if (selectPrintPort.equals(item.getPort())) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// selectPosition = helper.getAdapterPosition();
// }
// } else if (selectPrintPort == null && item.getPort() == null) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// selectPosition = helper.getAdapterPosition();
// }
// } else {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
// }
// } else if (selectPosition == helper.getAdapterPosition()) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// } else {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
// }
helper.setText(R.id.tv_printer_name, item.getName() + "");
helper.setText(R.id.tv_printer_ip, String.format(mContext.getString(R.string.print_ip), item.getIp()));
......@@ -66,6 +67,8 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
} else {
helper.setText(R.id.tv_printer_port, String.format(mContext.getString(R.string.print_port), item.getPort() + ""));
}
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(item.getStatus() == 2);
helper.getView(R.id.tv_default_print).setVisibility(item.getStatus() == 2 ? View.VISIBLE : View.GONE);
// helper.setOnCheckedChangeListener(R.id.cb_printer_item, (buttonView, isChecked) -> {
// if (getRecyclerView() != null) {
// if (getRecyclerView().isComputingLayout()) {//如果recyclerView在刷新時
......@@ -75,15 +78,16 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
// }
// }
// });
helper.setOnClickListener(R.id.cb_printer_item, v -> {
if (getRecyclerView() != null) {
if (getRecyclerView().isComputingLayout()) {//如果recyclerView在刷新時
getRecyclerView().post(() -> setSelectPrint(helper, item, true));
} else {
setSelectPrint(helper, item, true);
}
}
});
// helper.setOnClickListener(R.id.cb_printer_item, v -> {
// if (getRecyclerView() != null) {
// if (getRecyclerView().isComputingLayout()) {//如果recyclerView在刷新時
// getRecyclerView().post(() -> setSelectPrint(helper, item, true));
// } else {
// setSelectPrint(helper, item, true);
// }
// }
// });
}
/**
......
......@@ -68,7 +68,7 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT);
ivSetLocationPrintBtn.setChecked(true);
} else {
//如果默認打印方式為本地,修改為IP打印
//如果默認打印方式為IP,修改為IP打印
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT);
ivSetLocationPrintBtn.setChecked(false);
}
......
......@@ -5,20 +5,78 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="@id/tv_order_type"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_order_type"
app:layout_constraintTop_toTopOf="@id/tv_order_type" />
<TextView
android:id="@+id/tv_order_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='外賣'
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_30"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="@id/tv_order_type"
app:layout_constraintLeft_toRightOf="@id/tv_order_type"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_order_type" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_pay_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="在線支付:支付寶HK"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_26"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_type"
android:id="@+id/tv_delivery_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='外賣'
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dp_5"
android:text="盡快送達:05-06 12:00"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_30" />
android:textSize="@dimen/dp_18"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_order_number"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='訂單號' />
android:text='訂單號:000001' />
<TextView
android:id="@+id/tv_order_create"
......@@ -28,10 +86,19 @@
android:text='下單時間' />
<TextView
android:id="@+id/tv_remark"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="備註:少油少鹽,微辣"
android:textSize="@dimen/dp_26"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" />
<androidx.recyclerview.widget.RecyclerView
......@@ -42,23 +109,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:singleLine="true"
android:text="------------------"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/dp_10">
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:barrierDirection="left"
app:constraint_referenced_ids="tv_pay_amount,tv_total_amount,tv_total,tv_lunchbox_cost,tv_delivery_fee,tv_discount" />
<!-- <androidx.constraintlayout.widget.Barrier-->
<!-- android:id="@+id/barrier"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical"-->
<!-- app:barrierDirection="left"-->
<!-- app:constraint_referenced_ids="tv_pay_amount,tv_total_amount,tv_total,tv_lunchbox_cost,tv_delivery_fee,tv_discount" />-->
<TextView
android:id="@+id/tv_total_text"
......@@ -67,7 +132,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="合計:"
app:layout_constraintRight_toLeftOf="@id/barrier"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
......@@ -75,6 +140,7 @@
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_text" />
......@@ -86,7 +152,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="餐盒費:"
app:layout_constraintRight_toLeftOf="@id/barrier"
android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_total" />
<TextView
......@@ -105,7 +172,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費:"
app:layout_constraintRight_toLeftOf="@id/barrier"
android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
<TextView
......@@ -124,7 +192,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="折扣:"
app:layout_constraintRight_toLeftOf="@id/barrier"
android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_delivery_fee" />
<TextView
......@@ -143,7 +212,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="總金額:"
app:layout_constraintRight_toLeftOf="@id/barrier"
android:textStyle="normal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_discount" />
<TextView
......@@ -154,25 +224,34 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_amount_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />
<TextView
android:id="@+id/tv_pay_amount_text"
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="支付金額:"
app:layout_constraintRight_toLeftOf="@id/barrier"
app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />
android:textSize="@dimen/dp_26"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_amount_line" />
<TextView
android:id="@+id/tv_pay_amount"
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10000"
android:textColor="#FF0000"
app:layout_constraintRight_toRightOf="parent"
android:text="$10000"
android:textSize="@dimen/dp_26"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@id/tv_pay_amount_text"
app:layout_constraintTop_toTopOf="@id/tv_pay_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -181,47 +260,85 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_pay_type"
android:id="@+id/tv_address"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="貨到付款"
android:textColor="@color/theme_333_color"
android:text="地址:******"
android:textSize="@dimen/dp_26" />
<TextView
android:id="@+id/tv_receiver"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:textColor="@color/theme_333_color" />
android:layout_marginTop="@dimen/dp_5"
android:text="收貨人:******" />
<TextView
android:id="@+id/tv_address"
android:id="@+id/tv_phone"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_marginTop="@dimen/dp_5"
android:layout_height="wrap_content"
android:text="手機號:******" />
<TextView
android:id="@+id/tv_receiver"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_phone"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="親愛的顧客,祝您用餐愉快,如您遇到任何問題請撥打8200 2022聯繫我們,期待您的下次光臨。" />
<TextView
android:id="@+id/tv_remark"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">
<TextView
android:id="@+id/tv_bottom_time_left_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_bottom_time"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_bottom_time"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2020-04-25 12:00:36 GS Support pos1"
app:layout_constraintLeft_toRightOf="@id/tv_bottom_time_left_line"
app:layout_constraintRight_toLeftOf="@id/tv_bottom_time_right_line" />
<TextView
android:id="@+id/tv_bottom_time_right_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line"
android:textColor="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/tv_bottom_time"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
......@@ -55,7 +55,7 @@
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/theme_333_color"
android:visibility="gone"
android:visibility="invisible"
android:textSize="@dimen/dp_20"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/tv_food_number"
......
......@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
......@@ -238,6 +239,32 @@
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="設為默認"
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<CheckBox
android:id="@+id/cb_set_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.7" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<TextView
android:id="@+id/print_test"
android:layout_width="match_parent"
......
......@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
......@@ -27,5 +28,4 @@
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
......@@ -11,6 +11,7 @@
android:id="@+id/cb_printer_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -21,11 +22,25 @@
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_10"
android:gravity="center"
android:text="asdasda"
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_16"
app:layout_constraintLeft_toRightOf="@id/cb_printer_item"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_default_print"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:background="@color/theme_color"
android:padding="@dimen/dp_1"
android:text="默認"
android:textColor="@color/white"
android:textSize="@dimen/dp_10"
app:layout_constraintLeft_toRightOf="@id/tv_printer_name"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_printer_ip"
......
......@@ -27,6 +27,7 @@ public class PrinterDeviceBean implements Serializable {
private Integer port;//端口
private int type;//打印機紙張類型 為1時是58mm,否則是88mm
private Integer status;//2為默認打印機,1為普通打印機
@Generated(hash = 626885316)
public PrinterDeviceBean() {
}
......@@ -49,9 +50,9 @@ public class PrinterDeviceBean implements Serializable {
this.type = type;
}
@Generated(hash = 2107713534)
@Generated(hash = 422399868)
public PrinterDeviceBean(int id, Long dbid, String name, Integer restaurantId, String ip, Integer port,
int type) {
int type, Integer status) {
this.id = id;
this.dbid = dbid;
this.name = name;
......@@ -59,6 +60,7 @@ public class PrinterDeviceBean implements Serializable {
this.ip = ip;
this.port = port;
this.type = type;
this.status = status;
}
public String getName() {
......@@ -116,4 +118,12 @@ public class PrinterDeviceBean implements Serializable {
public void setRestaurantId(Integer restaurantId) {
this.restaurantId = restaurantId;
}
public int getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
......@@ -31,6 +31,7 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
public final static Property Ip = new Property(4, String.class, "ip", false, "IP");
public final static Property Port = new Property(5, Integer.class, "port", false, "PORT");
public final static Property Type = new Property(6, int.class, "type", false, "TYPE");
public final static Property Status = new Property(7, Integer.class, "status", false, "STATUS");
}
......@@ -52,7 +53,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
"\"RESTAURANT_ID\" INTEGER," + // 3: restaurantId
"\"IP\" TEXT," + // 4: ip
"\"PORT\" INTEGER," + // 5: port
"\"TYPE\" INTEGER NOT NULL );"); // 6: type
"\"TYPE\" INTEGER NOT NULL ," + // 6: type
"\"STATUS\" INTEGER);"); // 7: status
}
/** Drops the underlying database table. */
......@@ -91,6 +93,11 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
stmt.bindLong(6, port);
}
stmt.bindLong(7, entity.getType());
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(8, status);
}
}
@Override
......@@ -123,6 +130,11 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
stmt.bindLong(6, port);
}
stmt.bindLong(7, entity.getType());
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(8, status);
}
}
@Override
......@@ -139,7 +151,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // restaurantId
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // ip
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // port
cursor.getInt(offset + 6) // type
cursor.getInt(offset + 6), // type
cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7) // status
);
return entity;
}
......@@ -153,6 +166,7 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
entity.setIp(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setPort(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setType(cursor.getInt(offset + 6));
entity.setStatus(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7));
}
@Override
......
......@@ -38,6 +38,10 @@ class OrderDetails {
* RECEIVER : 張學友 先生
* TOTAL_AMOUNT : 88.0
*/
var trkNo: String? = null
var delivery_man_phone_num: String? = null
var deliveryMode: String? = null
var delivery_man_name: String? = null
var Order_ID: Int = 0
var NUMBER: Int = 0
var MEMBER_NAME: String? = null
......@@ -93,7 +97,6 @@ class OrderDetails {
* PRODUCT_NAME : Pho
* child : [{"odsId":"1654488","PRICE":"0.0","num":"2","pid":"1654487","PRODUCT_NAME":"Pho"},{"odsId":"1654489","PRICE":"0.0","num":"2","pid":"1654487","PRODUCT_NAME":"rice flour"},{"odsId":"1654490","PRICE":"0.0","num":"2","pid":"1654487","PRODUCT_NAME":"Tang Meng"}]
*/
var odsId: String? = null
var PRICE: String? = null
var num: String? = null
......@@ -101,6 +104,7 @@ class OrderDetails {
var PRODUCT_NAME: String? = null
var child: List<ChildBean>? = null
var printseting: String? = null
class ChildBean {
/**
* odsId : 1654488
......@@ -109,7 +113,6 @@ class OrderDetails {
* pid : 1654487
* PRODUCT_NAME : Pho
*/
var odsId: String? = null
var PRICE: String? = null
var num: String? = null
......
package com.gingersoft.gsa.cloud.ui.widget.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
......@@ -11,6 +10,7 @@ import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.R;
......@@ -79,7 +79,7 @@ public class LoadingDialog {
return mLoadingDialog;
}
public static Dialog showDialogForLoading(Activity context) {
public static Dialog showDialogForLoading(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.ui_dialog_loading, null);
TextView loadingText = view.findViewById(R.id.tv_loading_dialog_text);
loadingText.setText(context.getString(R.string.base_loading));
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_3" />
<corners android:radius="@dimen/dp_8" />
<solid android:color="@color/theme_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<solid android:color="@color/transparent_sixty_theme_color" />
</shape>
\ No newline at end of file
......@@ -13,7 +13,6 @@
android:layout_height="wrap_content"
android:text="19" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<fade xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000" />
<?xml version="1.0" encoding="utf-8"?>
<slide xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="PublicTheme">
<item name="QMUITopBarStyle">@style/QDTopBar</item>
<item name="QMUITabSegmentStyle">@style/QMUITabSegmentStyle</item>
<item name="android:windowActivityTransitions">true</item>
</style>
</resources>
\ No newline at end of file
......@@ -10,6 +10,9 @@
<!--App主色调-->
<!-- <color name="theme_color">#BF1C42</color>-->
<color name="theme_color">#398BED</color>
<color name="transparent_sixty_theme_color">#99398BED</color>
<color name="normal_color">#333333</color>
<!-- 統一頁面背景色-->
<color name="theme_bg_color">#F0edf1</color>
......
......@@ -144,5 +144,5 @@
<string name="wai"></string>
<string name="amount_unit">$</string>
<string name="print_split_line">------------------------------------------------------------------------------------------------------</string>
<string name="print_split_line">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</string>
</resources>
......@@ -24,7 +24,7 @@
tools:replace="android:label">
<activity
android:name=".mvp.ui.activity.WelcomeActivity"
android:name=".mvp.ui.activity.mvp.ui.activity.WelcomeActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -34,9 +34,11 @@
</intent-filter>
</activity>
<activity
android:name=".mvp.ui.activity.LoginActivity"
android:name=".mvp.ui.activity.mvp.ui.activity.LoginActivity"
android:launchMode="singleTop" />
<activity android:name=".mvp.ui.activity.SwitchServerActivity" />
<activity android:name=".mvp.ui.activity.mvp.ui.activity.SwitchServerActivity" />
<activity android:name=".mvp.ui.activity.mvp.ui.activity.RecoverPasswordActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.gingersoft.gsa.cloud.user.login">
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.gingersoft.gsa.cloud.user.login">
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/user_login_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.LoginActivity"/>
<activity android:name=".mvp.ui.activity.SwitchServerActivity" />
<activity android:name=".mvp.ui.activity.WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/user_login_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.mvp.ui.activity.LoginActivity" />
<activity android:name=".mvp.ui.activity.mvp.ui.activity.SwitchServerActivity" />
<activity android:name=".mvp.ui.activity.mvp.ui.activity.WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".mvp.ui.activity.LoginOutActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360"/>
<meta-data
android:name="design_height_in_dp"
android:value="640"/>
</application>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".mvp.ui.activity.mvp.ui.activity.LoginOutActivity" />
<activity android:name=".mvp.ui.activity.mvp.ui.activity.RecoverPasswordActivity"/>
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="540" />
</application>
</manifest>
\ No newline at end of file
......@@ -4,8 +4,8 @@ import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.SwitchServerActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.SwitchServerActivity;
public class ComponentLogin implements IComponent {
......
......@@ -8,7 +8,7 @@ import com.gingersoft.gsa.cloud.user.login.di.module.LoginModule;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginContract;
import com.jess.arms.di.scope.ActivityScope;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.LoginActivity;
/**
......
......@@ -9,7 +9,7 @@ import com.gingersoft.gsa.cloud.user.login.di.module.SwitchServerModule;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.SwitchServerContract;
import com.jess.arms.di.scope.ActivityScope;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.SwitchServerActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.SwitchServerActivity;
/**
......
package com.gingersoft.gsa.cloud.user.login.di.component;
import com.gingersoft.gsa.cloud.user.login.di.module.WelcomeModule;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.WelcomeActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.WelcomeActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.ActivityScope;
......
......@@ -11,7 +11,7 @@ import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionTextItem;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.gingersoft.gsa.cloud.user.login.mvp.presenter.BaseLoginPresenter;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.SwitchServerActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.SwitchServerActivity;
import com.jess.arms.base.BaseActivity;
import java.util.ArrayList;
......
......@@ -3,23 +3,19 @@ package com.gingersoft.gsa.cloud.user.login.mvp.presenter;
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.util.Log;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.user.login.R;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.BaseLoginContract;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.LoginActivity;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.PermissionUtil;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
......@@ -85,6 +81,11 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
GsaCloudApplication.userName = info.getData().getUser().getUserName();
mRootView.showMessage("登陸成功");
mRootView.loginSuccess(info);
//開啟打印服務
CC.obtainBuilder("Component.Print")
.setActionName("openPrintService")
.build()
.call();
} else {
GsaCloudApplication.isLogin = false;
mRootView.showMessage(info.getErrMsg());
......
......@@ -5,7 +5,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.user.login.R;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginContract;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.LoginActivity;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.di.component;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.di.module.RecoverPasswordModule;
import com.jess.arms.di.scope.ActivityScope;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity.RecoverPasswordActivity;
@ActivityScope
@Component(modules = RecoverPasswordModule.class,dependencies = AppComponent.class)
public interface RecoverPasswordComponent {
void inject(RecoverPasswordActivity activity);
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.di.module;
import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.contract.RecoverPasswordContract;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.model.RecoverPasswordModel;
@Module
public class RecoverPasswordModule {
private RecoverPasswordContract.View view;
/**
* 构建RecoverPasswordModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
* @param view
*/
public RecoverPasswordModule(RecoverPasswordContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
RecoverPasswordContract.View provideRecoverPasswordView(){
return this.view;
}
@ActivityScope
@Provides
RecoverPasswordContract.Model provideRecoverPasswordModel(RecoverPasswordModel model){
return model;
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.contract;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
public interface RecoverPasswordContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel{
}
}
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.model;
import android.app.Application;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.contract.RecoverPasswordContract;
@ActivityScope
public class RecoverPasswordModel extends BaseModel implements RecoverPasswordContract.Model{
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public RecoverPasswordModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.presenter;
import android.app.Application;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.contract.RecoverPasswordContract;
@ActivityScope
public class RecoverPasswordPresenter extends BasePresenter<RecoverPasswordContract.Model, RecoverPasswordContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
@Inject
public RecoverPasswordPresenter (RecoverPasswordContract.Model model, RecoverPasswordContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
}
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.transition.Explode;
import android.transition.Slide;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -32,9 +36,11 @@ import com.gingersoft.gsa.cloud.user.login.di.component.DaggerLoginComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginContract;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginInterfaceImpl;
import com.gingersoft.gsa.cloud.user.login.mvp.presenter.LoginPresenter;
import com.google.android.material.textfield.TextInputEditText;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import java.util.List;
import java.util.Objects;
......@@ -65,9 +71,9 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
AppManager mAppManager;
@BindView(R2.id.ed_login_user_account)
EditText edAccount;
TextInputEditText edAccount;
@BindView(R2.id.ed_login_user_pwd)
EditText edPwd;
TextInputEditText edPwd;
@BindView(R2.id.iv_clear_pwd)
ImageView icClear;
@BindView(R2.id.iv_clear_account)
......@@ -78,8 +84,8 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
CheckBox mRbAutoLogin;
@BindView(R2.id.ic_look_pwd)
ImageView mIvSeePwd;
@BindView(R2.id.tv_app_version)
TextView mTvVersion;
@BindView(R2.id.btn_gsa_user_login)
QMUIAlphaButton mBtnLogin;
private boolean passwrodVisibility = false;
......@@ -101,26 +107,39 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override
public void initData(@Nullable Bundle savedInstanceState) {
try {
mTvVersion.setText("v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
// inside your activity (if you did not enable transitions in your theme)
// getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
// set an exit transition
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// getWindow().setExitTransition(new Explode());
// }
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Slide slide = new Slide();
// slide.setDuration(1000);
// getWindow().setExitTransition(slide);
// }
mPresenter.requestExternalStoragePermission();
//顯示記住的登錄名
if (!Objects.equals(SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, ""), "")) {
edAccount.setText("" + SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, ""));
mRbRememberPwd.setChecked(true);
}
//顯示記住的密碼
String pwd = Aes.aesDecrypt((String) SPUtils.get(mContext, UserConstans.LOGIN_PASSWORD, ""));
if (!TextUtil.isEmptyOrNullOrUndefined(pwd)) {
edPwd.setText(pwd);
editFocusChange(edPwd, true);
}
//自動登陸
mRbAutoLogin.setOnCheckedChangeListener((buttonView, isChecked) -> {
//選中自動登陸,選中記住密碼
if (isChecked) {
mRbRememberPwd.setChecked(true);
}
});
//記住密碼
mRbRememberPwd.setOnCheckedChangeListener((buttonView, isChecked) -> {
//如果用戶沒有選中記住密碼,那麼取消自動登陸選中
if (!isChecked) {
......@@ -130,15 +149,9 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
if ((boolean) SPUtils.get(mContext, UserConstans.AUTO_LOGIN, false)) {
//自動登陸
// mPresenter.login(SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, "") + "", pwd);
mRbAutoLogin.setChecked(true);
}
// if(GsaCloudApplication.getLoginToken(mContext).length() > 0){
// jumpActivity();
// finish();
// }
edAccount.setSelection(edAccount.getText().toString().length());
//輸入框監聽
edPwd.setOnFocusChangeListener(mOnFocusChangeListener);
edAccount.setOnFocusChangeListener(mOnFocusChangeListener);
edPwd.addTextChangedListener(new TextWatcher() {
......@@ -149,7 +162,6 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
......@@ -161,6 +173,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
icClear.setVisibility(View.VISIBLE);
mIvSeePwd.setVisibility(View.VISIBLE);
}
setLoginBtnState();
}
});
edAccount.addTextChangedListener(new TextWatcher() {
......@@ -180,41 +193,44 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override
public void afterTextChanged(Editable s) {
setLoginBtnState();
}
});
}
private View.OnFocusChangeListener mOnFocusChangeListener = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
editFocusChange(v, hasFocus);
if (v.getId() == R.id.ed_login_user_account && hasFocus) {
private View.OnFocusChangeListener mOnFocusChangeListener = this::editFocusChange;
/**
* 設置登陸按鈕狀態
*/
private void setLoginBtnState() {
if (edAccount.getText() != null && edAccount.getText().toString().length() > 0 && edPwd.getText() != null && edPwd.getText().toString().length() >= 6) {
mBtnLogin.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape_app_btn));
} else {
mBtnLogin.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape_app_btn_unclickable));
}
}
private void editFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (v.getId() == R.id.ed_login_user_pwd) {
//密碼框獲得焦點
if (edPwd.getText() != null && edPwd.getText().toString().length() > 0) {
icClear.setVisibility(View.VISIBLE);
mIvSeePwd.setVisibility(View.VISIBLE);
} else {
icClear.setVisibility(View.GONE);
mIvSeePwd.setVisibility(View.GONE);
}
} else if (v.getId() == R.id.ed_login_user_account) {
//賬號框獲得焦點
if (edAccount.getText() != null && edAccount.getText().toString().length() > 0) {
icClearAccount.setVisibility(View.VISIBLE);
} else {
icClearAccount.setVisibility(View.GONE);
}
} else {
icClearAccount.setVisibility(View.GONE);
}
}
};
private void editFocusChange(View v, boolean hasFocus) {
if (v.getId() == R.id.ed_login_user_pwd && hasFocus) {
//密碼框獲得焦點
if (edPwd.getText() != null && edPwd.getText().toString().length() > 0) {
icClear.setVisibility(View.VISIBLE);
mIvSeePwd.setVisibility(View.VISIBLE);
} else {
icClear.setVisibility(View.GONE);
mIvSeePwd.setVisibility(View.GONE);
}
} else {
icClear.setVisibility(View.GONE);
mIvSeePwd.setVisibility(View.GONE);
setLoginBtnState();
}
}
......@@ -332,7 +348,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
SPUtils.put(mContext, UserConstans.AUTO_LOGIN, mRbAutoLogin.isChecked());
}
@OnClick({R2.id.tv_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account, R2.id.tv_remember_pwd_text, R2.id.ic_look_pwd, R2.id.tv_auto_login_text})
@OnClick({R2.id.btn_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account, R2.id.tv_remember_pwd_text, R2.id.ic_look_pwd, R2.id.tv_auto_login_text, R2.id.tv_forget_pwd})
public void onClick(View v) {
switch (v.getId()) {
case R.id.ic_look_pwd:
......@@ -341,12 +357,10 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
//如果选中,显示密码
mIvSeePwd.setImageDrawable(getResources().getDrawable(R.mipmap.ic_password_show));
edPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
edPwd.setSelection(edPwd.getText().toString().length());
} else {
//否则隐藏密码
mIvSeePwd.setImageDrawable(getResources().getDrawable(R.mipmap.ic_password_hide));
edPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
edPwd.setSelection(edPwd.getText().toString().length());
}
edPwd.setSelection(edPwd.getText() == null ? 0 : edPwd.getText().toString().length());
break;
......@@ -361,9 +375,13 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
mRbRememberPwd.setChecked(true);
}
break;
case R.id.tv_gsa_user_login:
case R.id.btn_gsa_user_login:
//登陸
if (edAccount.getText() != null && edPwd.getText() != null) {
if (edPwd.getText() == null || edPwd.getText().length() < 6) {
edPwd.setError("請輸入6~20位長度的密碼");
} else if (edAccount.getText() == null || edAccount.getText().length() <= 0) {
edAccount.setError("請輸入賬戶名或手機號");
} else {
mPresenter.login(edAccount.getText().toString(), edPwd.getText().toString());
}
break;
......@@ -377,6 +395,10 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
edPwd.setText("");
icClear.setVisibility(View.GONE);
break;
case R.id.tv_forget_pwd:
//忘記密碼
startActivity(new Intent(this, RecoverPasswordActivity.class));
break;
}
}
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.transition.Explode;
import android.transition.Fade;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.view.Window;
import com.gingersoft.gsa.cloud.user.login.R;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.di.component.DaggerRecoverPasswordComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.di.module.RecoverPasswordModule;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.contract.RecoverPasswordContract;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.presenter.RecoverPasswordPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import static com.jess.arms.utils.Preconditions.checkNotNull;
public class RecoverPasswordActivity extends BaseActivity<RecoverPasswordPresenter> implements RecoverPasswordContract.View {
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerRecoverPasswordComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.recoverPasswordModule(new RecoverPasswordModule(this))
.build()
.inject(this);
}
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Fade fade = new Fade();
// fade.setDuration(1000);
// getWindow().setEnterTransition(fade);
// }
// }
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.layout_recover_password; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
findViewById(R.id.iv_recover_pwd_back).setOnClickListener(v -> killMyself());
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
}
@Override
public void hideLoading() {
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
}
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.mvp.ui.activity;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_app_btn" android:state_checkable="true" />
<item android:drawable="@drawable/shape_app_btn" android:state_focused="true" />
<item android:drawable="@drawable/shape_app_btn_unclickable" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_recover_pwd_back"
android:layout_width="wrap_content"
android:paddingLeft="@dimen/dp_15"
android:layout_height="?attr/qmui_topbar_height"
android:src="@drawable/ic_black_back"
custom:layout_constraintLeft_toLeftOf="parent"
custom:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/welcome_forget_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_40"
android:text="找回密碼"
android:textSize="@dimen/dp_26"
custom:layout_constraintLeft_toLeftOf="parent"
custom:layout_constraintRight_toRightOf="parent"
custom:layout_constraintTop_toBottomOf="@id/iv_recover_pwd_back" />
<TextView
android:id="@+id/tv_forget_pwd_phone_number"
style="@style/user_login_edit_title_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_55"
android:text="手機號"
custom:layout_constraintLeft_toLeftOf="parent"
custom:layout_constraintTop_toBottomOf="@id/welcome_forget_pwd" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/forget_mobile"
style="@style/user_login_edit_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:hint="請輸入手機號"
android:inputType="phone"
android:maxLength="11"
custom:layout_constraintLeft_toLeftOf="@id/tv_forget_pwd_phone_number"
custom:layout_constraintRight_toLeftOf="@id/btn_get_verify_code"
custom:layout_constraintTop_toBottomOf="@id/tv_forget_pwd_phone_number" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_get_verify_code"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:paddingLeft="@dimen/dp_14"
android:paddingRight="@dimen/dp_14"
android:text="獲取驗證碼"
android:textColor="@color/white"
custom:layout_constraintBottom_toBottomOf="@id/forget_mobile"
custom:layout_constraintRight_toRightOf="@id/line_phone_edit"
custom:layout_constraintTop_toTopOf="@id/forget_mobile" />
<View
android:id="@+id/line_phone_edit"
android:layout_width="0dp"
android:layout_height="@dimen/dp_1"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_15"
android:background="@color/user_login_line_color"
custom:layout_constraintLeft_toLeftOf="parent"
custom:layout_constraintRight_toRightOf="parent"
custom:layout_constraintTop_toBottomOf="@id/forget_mobile" />
<TextView
android:id="@+id/tv_forget_pwd_verify"
style="@style/user_login_edit_title_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_30"
android:text="驗證碼"
custom:layout_constraintLeft_toLeftOf="@id/tv_forget_pwd_phone_number"
custom:layout_constraintTop_toBottomOf="@id/line_phone_edit" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/forget_verify"
style="@style/user_login_edit_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:hint="請輸入驗證碼"
android:inputType="phone"
android:maxLength="6"
custom:layout_constraintLeft_toLeftOf="@id/line_phone_edit"
custom:layout_constraintRight_toRightOf="@id/line_phone_edit"
custom:layout_constraintTop_toBottomOf="@id/tv_forget_pwd_verify" />
<View
android:id="@+id/line_verify_code"
android:layout_width="0dp"
android:layout_height="@dimen/dp_1"
android:background="@color/user_login_line_color"
custom:layout_constraintLeft_toLeftOf="@id/line_phone_edit"
custom:layout_constraintRight_toRightOf="@id/line_phone_edit"
custom:layout_constraintTop_toBottomOf="@id/forget_verify" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/next_step_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_20"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:text="下一步"
android:textColor="@color/white"
custom:layout_constraintBottom_toBottomOf="parent"
custom:layout_constraintLeft_toLeftOf="@id/line_phone_edit"
custom:layout_constraintRight_toRightOf="@id/line_phone_edit" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -6,7 +6,9 @@
android:background="@color/theme_white_color"
android:clipChildren="true"
android:fillViewport="true"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="@dimen/dp_18"
android:paddingRight="@dimen/dp_18">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
......@@ -20,40 +22,33 @@
android:layout_marginTop="80dp"
android:text="@string/user_login_welcome_login"
android:textColor="@color/user_login_title_color"
android:textSize="@dimen/title_text_size"
android:textSize="@dimen/dp_26"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/login_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
<TextView
android:id="@+id/tv_account_text"
style="@style/user_login_edit_title_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@color/theme_color"
android:padding="8dp"
android:src="@mipmap/ic_user"
android:text="賬戶"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/login_title" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_login_user_account"
style="@style/user_login_edit_style"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@null"
android:hint="請輸入賬戶"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:hint="請輸入賬戶名或手機號"
android:maxLength="16"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:singleLine="true"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/user_login_edit_color"
android:textSize="@dimen/edit_text_size"
app:layout_constraintBottom_toBottomOf="@id/login_icon"
app:layout_constraintLeft_toRightOf="@id/login_icon"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/iv_clear_account"
app:layout_constraintTop_toTopOf="@id/login_icon" />
app:layout_constraintTop_toBottomOf="@id/tv_account_text" />
<ImageView
android:id="@+id/iv_clear_account"
......@@ -67,46 +62,53 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/ed_login_user_account" />
<ImageView
android:id="@+id/iv_login_pwd_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:background="@color/theme_color"
android:padding="8dp"
android:src="@mipmap/ic_pwd"
app:layout_constraintLeft_toLeftOf="parent"
<View
android:id="@+id/line_account"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:background="@color/user_login_line_color"
app:layout_constraintTop_toBottomOf="@id/ed_login_user_account" />
<EditText
<TextView
android:id="@+id/tv_password_text"
style="@style/user_login_edit_title_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:text="密碼"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_account" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_login_user_pwd"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#00000000"
android:gravity="center_vertical"
android:hint="請輸入密碼"
android:layout_height="wrap_content"
style="@style/user_login_edit_style"
android:layout_marginTop="@dimen/dp_5"
android:hint="輸入6~20個字符"
android:inputType="textPassword"
android:maxLength="16"
android:paddingLeft="@dimen/dp_10"
android:maxLength="20"
android:paddingRight="@dimen/dp_10"
android:singleLine="true"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/user_login_edit_color"
android:textSize="@dimen/edit_text_size"
app:layout_constraintBottom_toBottomOf="@id/iv_login_pwd_icon"
app:layout_constraintLeft_toRightOf="@id/iv_login_pwd_icon"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/ic_look_pwd"
app:layout_constraintTop_toTopOf="@id/iv_login_pwd_icon" />
app:layout_constraintTop_toBottomOf="@id/tv_password_text" />
<View
android:id="@+id/line_password"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:background="@color/user_login_line_color"
app:layout_constraintTop_toBottomOf="@id/ed_login_user_pwd" />
<CheckBox
android:id="@+id/rb_auto_login"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_15"
app:layout_constraintLeft_toLeftOf="@id/iv_login_pwd_icon"
app:layout_constraintTop_toBottomOf="@id/ed_login_user_pwd" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_password" />
<TextView
android:id="@+id/tv_auto_login_text"
......@@ -126,9 +128,8 @@
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_15"
app:layout_constraintLeft_toRightOf="@id/tv_auto_login_text"
app:layout_constraintTop_toBottomOf="@id/ed_login_user_pwd" />
app:layout_constraintTop_toTopOf="@id/rb_auto_login" />
<TextView
android:id="@+id/tv_remember_pwd_text"
......@@ -169,40 +170,27 @@
android:id="@+id/tv_forget_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="忘記密碼?"
android:textSize="14dp"
android:visibility="invisible"
app:layout_constraintLeft_toLeftOf="parent"
android:text="找回密碼"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16"
android:visibility="visible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/rb_remember_password" />
app:layout_constraintBottom_toBottomOf="@id/rb_auto_login"
app:layout_constraintTop_toBottomOf="@id/rb_auto_login"
app:layout_constraintTop_toTopOf="@id/rb_auto_login" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/tv_gsa_user_login"
android:id="@+id/btn_gsa_user_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:background="@drawable/shape_app_btn"
android:layout_marginBottom="@dimen/dp_20"
android:background="@drawable/selector_login_btn"
android:gravity="center"
android:padding="10dp"
android:text="登錄"
android:textColor="#fff"
android:textSize="16dp"
app:layout_constraintTop_toBottomOf="@id/tv_forget_pwd" />
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:id="@+id/tv_app_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
android:text="v1.0"
android:textSize="@dimen/sp_16"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
......@@ -2,4 +2,5 @@
<resources>
<color name="user_login_title_color">@color/theme_333_color</color>
<color name="user_login_edit_color">@color/theme_hint_color</color>
<color name="user_login_line_color">#E4E4E4</color>
</resources>
<resources>
<!-- 登陸頁面輸入框標題字體樣式-->
<style name="user_login_edit_title_style">
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/color_3c</item>
</style>
<style name="user_login_edit_style">
<item name="android:textSize">@dimen/dp_18</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textColorHint">@color/user_login_edit_color</item>
<item name="android:background">@null</item>
<item name="android:paddingTop">@dimen/dp_8</item>
<item name="android:paddingBottom">@dimen/dp_8</item>
<item name="android:maxLines">1</item>
</style>
</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