Commit c9784e1c by Wyh

4.24 接單已完成

parent 4222a1bf
......@@ -221,7 +221,7 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
private void stopDownDisposable() {
for (int i = 0; i < mDownDisposable.size(); i++) {
if (mDownDisposable.get(i) != null && mDownDisposable.get(i).isDisposed() == false)
if (mDownDisposable.get(i) != null && !mDownDisposable.get(i).isDisposed())
mDownDisposable.get(i).dispose();
}
mDownDisposable.clear();
......
......@@ -9,12 +9,14 @@ import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.download.R;
......@@ -22,21 +24,14 @@ import com.gingersoft.gsa.cloud.download.R2;
import com.gingersoft.gsa.cloud.download.di.component.DaggerDownloadComponent;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter;
import com.gingersoft.gsa.cloud.ui.utils.AndroidWorkaround;
import com.gingersoft.gsa.cloud.ui.view.WaveHelper;
import com.gingersoft.gsa.cloud.ui.view.WaveView;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -67,13 +62,16 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@BindView(R2.id.tv_progress)
TextView tv_progress;
@BindView(R2.id.wave_download)
WaveView waveView;
private WaveHelper mWaveHelper;
/**
* 那個頁面跳轉下載
* 1#登錄頁選擇餐廳
* 2#其他
*/
private int fromPage =1;
private int fromPage = 1;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -98,11 +96,27 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mWaveHelper = new WaveHelper(waveView);
mPresenter.initAdapter();
mPresenter.downAllList();
}
@Override
protected void onResume() {
super.onResume();
if (mWaveHelper != null)
mWaveHelper.start();
}
@Override
protected void onPause() {
super.onPause();
if (mWaveHelper != null)
mWaveHelper.cancel();
}
@Override
public void initIntent() {
fromPage = CCUtil.getNavigateParam(this, "fromPage", 1);
}
......@@ -110,18 +124,8 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
@Override
public void initTopBar() {
tv_title.setText("數據下載");
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
killMyself();
}
});
btn_refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPresenter.downAllList();
}
});
btn_back.setOnClickListener(v -> killMyself());
btn_refresh.setOnClickListener(v -> mPresenter.downAllList());
}
@Override
......
......@@ -5,12 +5,12 @@
android:layout_height="match_parent"
android:background="@mipmap/down_decoration">
<!-- <com.qmuiteam.qmui.widget.QMUITopBar-->
<!-- android:id="@+id/topbar"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="?attr/qmui_topbar_height"-->
<!-- android:layout_marginTop="@dimen/dp_20"-->
<!-- android:background="@color/trans" />-->
<!-- <com.qmuiteam.qmui.widget.QMUITopBar-->
<!-- android:id="@+id/topbar"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="?attr/qmui_topbar_height"-->
<!-- android:layout_marginTop="@dimen/dp_20"-->
<!-- android:background="@color/trans" />-->
<RelativeLayout
android:layout_width="match_parent"
......@@ -23,66 +23,79 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="@drawable/qmui_icon_topbar_back"
android:layout_marginLeft="@dimen/dp_15"/>
android:layout_marginLeft="@dimen/dp_15"
android:src="@drawable/qmui_icon_topbar_back" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/theme_white_color"
android:text="數據下載"
android:layout_centerInParent="true"
android:textSize="@dimen/sp_16"/>
android:text="數據下載"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_16" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/btn_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_refresh"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_15"/>
android:layout_marginRight="@dimen/dp_15"
android:src="@drawable/icon_refresh" />
</RelativeLayout>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="@dimen/dp_80"
android:weightSum="2">
android:orientation="vertical">
<FrameLayout
android:id="@+id/frame_top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
app:layout_constraintBottom_toTopOf="@id/recycle_download"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/down_cloud"/>
android:src="@mipmap/down_cloud" />
<TextView
android:id="@+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100%"
android:layout_gravity="center"
android:layout_marginTop="@dimen/dp_12"
android:text="100%"
android:textColor="#13B7F5"
android:textSize="@dimen/sp_24" />
</FrameLayout>
<com.gingersoft.gsa.cloud.ui.view.WaveView
android:id="@+id/wave_download"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behindWaveColor="#ccc"
app:frontWaveColor="#ffffff"
app:waveShape="square" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_download"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fadeScrollbars="false"
android:background="@mipmap/down_wave"
android:listSelector="@color/theme_background_color"
android:paddingTop="@dimen/dp_50"
android:listSelector="@color/theme_background_color"/>
</LinearLayout>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/frame_top"
app:layout_constraintVertical_weight="1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
......@@ -3,7 +3,6 @@
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/theme_white_color"
android:descendantFocusability="blocksDescendants"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
......
......@@ -202,23 +202,23 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
List<Function> functions = new ArrayList<>();
functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
functions.add(new Function((long) 138, 150, 5, "餐臺模式", R.drawable.ic_dining_table_mode, 0));
functions.add(new Function((long) 139, 150, 5, "外送模式", R.drawable.ic_delivery_mode, 1));
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model, 1));
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode, 1));
functions.add(new Function((long) 139, 150, 5, "外送模式", R.drawable.ic_delivery_mode_close, 1));
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 1));
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
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) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 1));
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, 1));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management, 1));
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) 152, 0, 5, "員工", 0, 0));
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management, 1));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management, 1));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record, 1));
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record_close, 1));
//將功能列表數據分組
SparseArray<String> parents = new SparseArray<>();
SparseArray<List<Function>> funMap = new SparseArray<>();
......
......@@ -206,6 +206,7 @@
android:id="@+id/rv_staff_management"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
......@@ -250,7 +251,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
</com.lihang.ShadowLayout>
......
......@@ -2,14 +2,15 @@
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="@dimen/dp_20"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_main_home_item_function_icon"
android:layout_width="@dimen/dp_32"
android:layout_height="wrap_content"
android:layout_width="@dimen/dp_26"
android:layout_height="@dimen/dp_26"
android:scaleType="fitCenter"
android:src="@drawable/ic_dining_table" />
<TextView
......
apply from: rootProject.file('cc-settings.gradle')
//apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
if (project.ext.runAsApp) {
applicationId "com.gingersoft.gsa.other_order_mode"
......@@ -18,28 +22,32 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true
}
}
// javaCompileOptions {
// annotationProcessorOptions {
// arguments = [AROUTER_MODULE_NAME: project.getName()]
// includeCompileClasspath true
// }
// }
}
resourcePrefix "otherOrder"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
buildTypes {
debug {
buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false
proguardFiles 'proguard.cfg'
}
release {
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "USE_CANARY", "false"
minifyEnabled false
zipAlignEnabled false
proguardFiles 'proguard.cfg'
}
}
}
......@@ -57,7 +65,7 @@ dependencies {
//协程
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
// implementation 'org.jetbrains.kotlinx:kotlinx-cor outines-android:1.1.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
//gson和scalars轉換器
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
......@@ -66,4 +74,8 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
if (project.ext.runAsApp) {
addComponent 'print-module'
}
}
......@@ -3,27 +3,12 @@
package="com.gingersoft.gsa.other_order_mode">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<application>
<activity
android:name=".OtherOrderActivity"
android:label="@string/app_name">
<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>
android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name" />
<service android:name=".service.GetInfoUpdateService" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
......
......@@ -13,7 +13,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".OtherOrderActivity"
android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -27,6 +27,7 @@
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
</application>
</manifest>
\ No newline at end of file
......@@ -4,6 +4,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.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity;
public class OtherOrderComponent implements IComponent {
......
package com.gingersoft.gsa.other_order_mode.data
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
class HistoryOrderRepository private constructor(private val network: CoolWeatherNetwork) {
suspend fun getHistoryOrderList(restaurantId: String, status: String, pageIndex: String, pageSize: String, orderNo: String = "", phone: String = "") = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.add("status", status)
.add("pageIndex", pageIndex)
.add("pageSize", pageSize)
.add("orderNo", orderNo)
.add("phone", phone)
.build()
val heWeather = network.getHistoryOrderList(requestBody)
heWeather
}
suspend fun getOrderInfo(orderId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.build()
val data = network.getOrderInfo(requestBody)
data
}
companion object {
private lateinit var instance: HistoryOrderRepository
fun getInstance(network: CoolWeatherNetwork): HistoryOrderRepository {
if (!::instance.isInitialized) {
synchronized(HistoryOrderRepository::class.java) {
if (!::instance.isInitialized) {
instance = HistoryOrderRepository(network)
}
}
}
return instance
}
}
}
\ No newline at end of file
......@@ -39,7 +39,39 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
data
}
suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("orderId", orderId)
.add("selfOrderId", selfOrderId)
.add("status", status.toString())
.add("mobile", mobile)
.add("sender", sender)
.add("isPush", isPush.toString())//1送貨 2確認訂單 結賬傳0
.add("orderType", orderType.toString())
.build()
val data = network.updateOrderStatus(requestBody)
data
}
suspend fun updateSelfOrderStatus(ids: String, status: String, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("ids", ids)
.add("status", status)
.add("restaurantId", restaurantId)
.build()
val data = network.updateSelfOrderStatus(requestBody)
data
}
suspend fun getDeliveryInfo(restId: String, userId: String) = withContext(Dispatchers.IO){
val requestBody = FormBody.Builder()
.add("restId", restId)
.add("userId", userId)
.build()
val data = network.getDeliveryInfo(requestBody)
data
}
companion object {
private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class DeliveryBean(val data: List<Data>,
val success: Boolean,
val sysTime: Long) {
data class Data(
val id: Int,
val mobile: String,
val userName: String
)
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
/**
* 統一轉換類
*/
class FoodDetailsTranBean(var odsId: String?, var PRICE: String?,
var num: String?, var pid: String?,
var PRODUCT_NAME: String?) {
object FoodDetails{
fun getByPRODUCTNAMEBean(bean: OrderDetails.DataBean.PRODUCTNAMEBean): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
fun getByChildBeanX(bean: OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
fun getByChildBean(bean: OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean): FoodDetailsTranBean {
return FoodDetailsTranBean(bean.odsId, bean.PRICE, bean.num, bean.pid, bean.PRODUCT_NAME)
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.model.bean
class HistoryOrderBean {
/**
* success : true
* sysTime : 1587026350363
* data : [{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)15:30~16:00","PHONE":"18995813316","orderPayType":1,"ORDER_NO":"26201551325454427","STATUS":4,"PAY_AMOUNT":60,"Id":4350992,"CREATE_TIME":"Mar 27, 2020 3:23:45 PM","takeFoodCode":"0036","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)立即","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200681304157037","STATUS":4,"PAY_AMOUNT":60,"Id":4348789,"CREATE_TIME":"Mar 27, 2020 12:27:21 PM","takeFoodCode":"0035","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)立即","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200221368356841","STATUS":4,"PAY_AMOUNT":46,"Id":4348785,"CREATE_TIME":"Mar 27, 2020 12:27:07 PM","takeFoodCode":"0034","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:30~13:00","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26201371328853396","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348780,"CREATE_TIME":"Mar 27, 2020 12:26:44 PM","takeFoodCode":"0033","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26203051303752129","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348467,"CREATE_TIME":"Mar 27, 2020 11:47:59 AM","takeFoodCode":"0032","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26201611370358516","STATUS":4,"PAY_AMOUNT":9999,"Id":4348434,"CREATE_TIME":"Mar 27, 2020 11:42:35 AM","takeFoodCode":"0031","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26201341375950995","STATUS":4,"PAY_AMOUNT":44.9,"Id":4348392,"CREATE_TIME":"Mar 27, 2020 11:35:35 AM","takeFoodCode":"0030","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26200871312851078","STATUS":4,"PAY_AMOUNT":9999,"Id":4348287,"CREATE_TIME":"Mar 27, 2020 11:18:44 AM","takeFoodCode":"0029","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"嘟嘟嘟1","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"15073379600","orderPayType":1,"ORDER_NO":"26202231360959188","STATUS":4,"PAY_AMOUNT":9999,"Id":4348114,"CREATE_TIME":"Mar 27, 2020 10:43:53 AM","takeFoodCode":"0028","order_type":7,"RECEIVER":""},{"MEMBER_NAME":"Li","ADDRESS_DETAIL":"","takeTime":"03-27 (週五)12:00~12:30","PHONE":"13554770615","orderPayType":1,"ORDER_NO":"26200591367856595","STATUS":4,"PAY_AMOUNT":46,"Id":4347838,"CREATE_TIME":"Mar 27, 2020 9:51:13 AM","takeFoodCode":"0027","order_type":7,"RECEIVER":""},{"sumnum":1827}]
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: ArrayList<DataBean>? = null
fun isSuccess(): Boolean {
return success
}
fun setSuccess(success: Boolean) {
this.success = success
}
fun getSysTime(): Long {
return sysTime
}
fun setSysTime(sysTime: Long) {
this.sysTime = sysTime
}
fun getData(): ArrayList<DataBean>? {
return data
}
fun setData(data: ArrayList<DataBean>) {
this.data = data
}
class DataBean {
/**
* MEMBER_NAME : Li
* ADDRESS_DETAIL :
* takeTime : 03-27 (週五)15:30~16:00
* PHONE : 18995813316
* orderPayType : 1
* ORDER_NO : 26201551325454427
* STATUS : 4
* PAY_AMOUNT : 60.0
* Id : 4350992
* CREATE_TIME : Mar 27, 2020 3:23:45 PM
* takeFoodCode : 0036
* order_type : 7
* RECEIVER :
* sumnum : 1827
*/
var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null
var takeTime: String? = null
var PHONE: String? = null
var orderPayType: Int = 0
var ORDER_NO: String? = null
var STATUS: Int = 0
var PAY_AMOUNT: Double = 0.toDouble()
var Id: Int = 0
var CREATE_TIME: String? = null
var takeFoodCode: String? = null
var order_type: Int = 0
var RECEIVER: String? = null
var sumnum: Int = 0
}
}
\ No newline at end of file
......@@ -59,7 +59,7 @@ class OrderList {
* Open_Status : 1
*/
var STATUS: Int = 0
var STATUS: Int = 0//0,1為待確認,2為製作中,3待取餐或送貨中
var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null
var PAY_AMOUNT: Double = 0.toDouble()
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class UpdateOrderBean {
/**
* success : true
* sysTime : 1587095130753
* data : {"msgs":"確認成功!","code":"1","selfUrl":"https://hktest.ricepon.com:64377/member-web/api/h5/orderNotify?type=6&restaurantId=4413643","jsonObject":{"code":200,"data":{"code":200,"msg":"success","data":{"username":{},"password":{},"token":{},"type":6,"data":"修改訂單狀態消息,參數:restaurantId=4413643"}}}}
*/
var success: Boolean = false
var sysTime: Long = 0
}
\ 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
......@@ -21,18 +22,28 @@ class CoolWeatherNetwork {
suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await()
suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await()
suspend fun updateSelfOrderStatus(requestBody: RequestBody) = orderService.updateSelfOrderStatus(requestBody).await()
suspend fun getDeliveryInfo(requestBody: RequestBody) = orderService.getDeliveryInfo(requestBody).await()
suspend fun getHistoryOrderList(requestBody: RequestBody) = orderService.getHistoryOrderList(requestBody).await()
private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation ->
enqueue(object : Callback<T> {
override fun onFailure(call: Call<T>, t: Throwable) {
t.printStackTrace()
continuation.resumeWithException(t)
}
override fun onResponse(call: Call<T>, response: Response<T>) {
val body = response.body()
if (body != null) continuation.resume(body)
else continuation.resumeWithException(RuntimeException("response body is null"))
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.api
import com.gingersoft.gsa.other_order_mode.data.model.bean.MessageBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.*
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.Body
......@@ -16,8 +15,18 @@ interface WeatherService {
@POST("wx/updateRestOpenStatus")
fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean>
@POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
@POST("wechat/updateOrderStatus")
fun updateOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("wechat/updateSelfOrderStatus")
fun updateSelfOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
@POST("wechat/findRestDelivery")
fun getDeliveryInfo(@Body requestBody: RequestBody): Call<DeliveryBean>
@POST("wechat/findHistoryOrderList")
fun getHistoryOrderList(@Body requestBody: RequestBody): Call<HistoryOrderBean>
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.factory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel
class HistoryOrderModelFactory(private val repository: HistoryOrderRepository) : ViewModelProvider.NewInstanceFactory() {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return HistoryOrderViewModel(repository) as T
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model
package com.gingersoft.gsa.other_order_mode.model.factory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
class WeatherModelFactory(private val repository: WeatherRepository) : ViewModelProvider.NewInstanceFactory() {
......@@ -11,4 +11,5 @@ class WeatherModelFactory(private val repository: WeatherRepository) : ViewModel
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
return PageViewModel(repository) as T
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.HistoryOrderBean
import kotlinx.coroutines.launch
class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepository) : ViewModel() {
var data = MutableLiveData<HistoryOrderBean>()
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getHistoryOrderList(pageIndex: String, orderNum: String = "", listener: (HistoryOrderBean) -> Unit) {
launch({
var phone = ""
var orderNumber = ""
if (orderNum.length <= 11) {
phone = orderNum
} else {
orderNumber = orderNum
}
historyOrderRepository.getHistoryOrderList("26", "4", pageIndex, "10", orderNumber, phone).apply {
this.getData()?.let {
if (it.size > 0) {
it.removeAt(it.size - 1)
}
if (pageIndex != "1") {
data.value!!.getData()!!.addAll(it)
data.value!!.setSuccess(true)
}
}
if (pageIndex == "1") {
data.value = this
}
listener.invoke(data.value!!)
}
}, {
//出錯
it.printStackTrace()
})
}
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getOrderInfo(orderId: String, listener: (OrderDetails) -> Unit) {
launch({
historyOrderRepository.getOrderInfo(orderId).apply {
listener.invoke(this)
}
}, {
//出錯
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
} catch (e: Throwable) {
error(e)
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.model.viewModel
import android.app.Dialog
import android.content.Context
import android.util.Log
import android.view.Gravity
import android.view.WindowManager
import android.widget.TextView
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.billy.cc.core.component.CC
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.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.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() {
companion object {
var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var fragmentType = arrayOf("0", "0", "0", "2", "7")
}
var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>()
//其他的所有數據
var otherInfo = MutableLiveData<OrderList.DataBeanX.DataBean>()
//刷新狀態,有數據更新就會更改這個變量,將這個變量修改為allOrderStatus...上面五種狀態,fragment中監聽這個變量,再調用接口獲取最新數據
var refreshState = MutableLiveData<Int>()
//訂單號
var orderNo: String = ""
//手機號
var phone: String = ""
//派送員信息
var deliveryBean: DeliveryBean? = null
/**
* 獲取訂單信息
*/
fun getOrderList(position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) {
launch({
repository.requestOrderList(fragmentStatus[position], fragmentType[position], page, orderNo, phone).apply {
loadInfo(listener, isLoadMore, position)
}
}, {
//出錯
})
}
private fun OrderList.loadInfo(listener: (String) -> Unit, isLoadMore: Boolean, position: Int) {
listener.invoke("加載完成")
if (getData() != null && getData()?.data != null) {
val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean>
if (myData.isNotEmpty()) {
//取得最後一個對象,裡面有營業狀態和外賣訂單數,自取訂單數
val dataBean: OrderList.DataBeanX.DataBean = myData[myData.size - 1]
if (dataBean.Open_Status != null) {
restaurantState.value = dataBean.Open_Status!! == "1"
}
if (myData.size == 1) {
otherInfo.value = myData[0]
} else {
otherInfo.value = myData[myData.size - 1]
}
myData.removeAt(myData.size - 1)
if (isLoadMore) {
if (mOrderList[position].value != null) {
mOrderList[position].value!!.addAll(myData)
} else {
mOrderList[position].value = myData
}
} else {
mOrderList[position].value = myData
}
} else {
}
}
}
//餐廳營業狀態,控制按鈕
var restaurantState = MutableLiveData<Boolean>()
/**
* 修改餐廳營業狀態
*/
fun setRestaurantState(context: Context, state: Boolean) {
launch({
Log.e("eee", "點擊狀態$state")
if (state) {
updateRestOpenStatus(state)
} else {
//暫停接單,彈窗向用戶確認是否關閉
object : DialogUtils(context, R.layout.other_order_pause_orders) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
hepler.getView<TextView>(R.id.tv_dialog_confirm).setOnClickListener {
it.isClickable = false
launch({
updateRestOpenStatus(state).let {
dialog.dismiss()
}
}, {
})
}
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss()
}
}
}.createDialogView().show()
}
}, {
})
}
/**
* 修改餐廳營業狀態
*/
suspend fun updateRestOpenStatus(state: Boolean) {
repository.updateRestOpenStatus(state).apply {
if (isSuccess()) {
restaurantState.value = state
}
}
}
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getOrderInfo(orderId: String, listener: (OrderDetails?) -> Unit) {
launch({
repository.getOrderInfo(orderId).apply {
listener.invoke(this)
}
}, {
//出錯
listener.invoke(null)
})
}
/**
* 待確認 --- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬
* 更新訂單信息,自取或是外賣
* status 0,1待確認
* 2 已確認,外賣是指派送單,自取是製作完成
*/
fun updateOrderStatus(context: Context, data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, listener: (Boolean) -> Unit) {
launch({
val status = when (data.STATUS) {
0 -> 2
1 -> 2
2 -> 3
3 -> 4
else -> 0
}
val isPush = when (status) {
2 -> 2
3 -> 1
4 -> 0
else -> 2
}
if (data.order_type == 2) {
// 外賣
if (status == 3) {
//指派送貨,選擇派送員
if (deliveryBean != null && deliveryBean!!.data.isNotEmpty()) {
selectorDelivery(listener, context, data, status, isPush)
} else {
ToastUtils.show(context, "沒有送貨員信息")
}
} else if (status == 4) {
//結賬,彈窗確認是否結賬
object : DialogUtils(context, R.layout.other_order_pause_orders) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
hepler.setText(R.id.tv_warning_title, "是否確認結賬?")
hepler.getView<TextView>(R.id.tv_dialog_confirm).setOnClickListener {
launch({
updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
listener.invoke(success)
}
}, {
})
}
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss()
listener.invoke(false)
}
}
}.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, "送單失敗")
}
}
}
}
} else {
// 自取的確認訂單
repository.updateSelfOrderStatus(data.Id.toString(), status.toString(), "26").apply {
listener.invoke(success)
}
}
}, {
})
}
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)
}
/**
* 選擇派送員
*/
private fun selectorDelivery(listener: (Boolean) -> Unit, context: Context, data: OrderList.DataBeanX.DataBean, status: Int, isPush: Int) {
//顯示選擇派送員
listener.invoke(false)//關閉彈窗。但是不刷新頁面
object : DialogUtils(context, R.layout.other_order_layout_assign_deliveryman) {
override fun initLayout(hepler: ViewHepler?, dialog: Dialog?) {
hepler!!.getView<TextView>(R.id.tv_delivery_cancel).setOnClickListener {
dialog!!.dismiss()
}
val confirmBtn: TextView = hepler.getView(R.id.tv_delivery_confirm)
var selectIndex = -1
val recycler = hepler.getView<RecyclerView>(R.id.rv_delivery)
recycler.layoutManager = GridLayoutManager(context, 4)
val deliveryAdapter = DeliveryAdapter(context, deliveryBean!!.data)
recycler.adapter = deliveryAdapter
deliveryAdapter.setOnItemClickListener { adapter, view, position ->
selectIndex = position
deliveryAdapter.selectIndex = position
adapter.notifyDataSetChanged()
confirmBtn.background = context.resources.getDrawable(R.drawable.shape_green_btn)
}
confirmBtn.setOnClickListener {
if (selectIndex != -1) {
launch({
updateOrderStatus(data.Id.toString(), "", status, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, deliveryBean!!.data[deliveryAdapter.selectIndex].userName, isPush, data.order_type).apply {
if (this.success) {
dialog?.dismiss()
//回調
listener.invoke(success)//刷新頁面
ToastUtils.show(context, "訂單開始派送")
} else {
ToastUtils.show(context, "訂單派送失敗")
}
}
}, {
})
} else {
ToastUtils.show(context, "請至少選擇一個送貨員")
}
}
}
}.setWidth(WindowManager.LayoutParams.MATCH_PARENT)
.setHeight((ArmsUtils.getScreenHeidth(context) * 0.5).toInt())
.createDialogView()
.setGravity(Gravity.BOTTOM)
.show()
}
/**
* 獲取配送員信息
*/
fun getDeliveryInfo() {
launch({
repository.getDeliveryInfo("26", "329").apply {
deliveryBean = this
}
}, {
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
} catch (e: Throwable) {
error(e)
}
}
}
\ No newline at end of file
......@@ -6,9 +6,13 @@ import android.os.Binder
import android.os.Handler
import android.os.IBinder
import android.util.Log
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.google.gson.Gson
import okhttp3.*
import okio.ByteString
import org.json.JSONObject
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit
class GetInfoUpdateService : Service() {
......@@ -39,7 +43,7 @@ class GetInfoUpdateService : Service() {
return this@GetInfoUpdateService
}
fun setOnPostCallBack(postCallBack: PostCallBack?){
fun setOnPostCallBack(postCallBack: PostCallBack?) {
this@GetInfoUpdateService.postCallBack = postCallBack
}
......@@ -69,8 +73,9 @@ class GetInfoUpdateService : Service() {
override fun onOpen(webSocket: WebSocket?, response: Response?) {//开启长连接成功的回调
super.onOpen(webSocket, response)
mWebSocket = webSocket
webSocket!!.send(sendMsg)
Log.e("aaa", "onOpen$sendMsg")
val token = "weixin_" + GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService) + "_" + getRandomString(24)
Log.e("eee", "token:$token")
webSocket!!.send(Gson().toJson(MsgBean(1, token)))
}
override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调
......@@ -107,10 +112,23 @@ class GetInfoUpdateService : Service() {
override fun onFailure(webSocket: WebSocket?, t: Throwable?, response: Response?) {//长连接连接失败的回调
super.onFailure(webSocket, t, response)
Log.e("aaa", "onFailure" + t!!.message)
InitSocketThread().start()//创建一个新的连接
}
})
client.dispatcher().executorService().shutdown()
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测
// mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测
}
/*获取一条随机字符串*/
fun getRandomString(length: Int): String { //length表示生成字符串的长度
val base = "abcdefghijklmnopqrstuvwxyz0123456789" + System.currentTimeMillis()
val random = Random()
val sb = StringBuffer()
for (i in 0 until length) {
val number = random.nextInt(base.length)
sb.append(base[number])
}
return sb.toString()
}
......@@ -123,7 +141,7 @@ class GetInfoUpdateService : Service() {
if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态
Log.e("aaa", "連接狀態:$isSuccess")
if (!isSuccess!!) {//长连接已断开
if (isSuccess != null && !isSuccess) {//长连接已断开
mHandler.removeCallbacks(this)
mWebSocket?.cancel()//取消掉以前的长连接
InitSocketThread().start()//创建一个新的连接
......@@ -150,4 +168,5 @@ class GetInfoUpdateService : Service() {
}
}
class MsgBean(var type: Int, var token: String)
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.activity
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.HistoryOrderAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import kotlinx.android.synthetic.main.activity_history_order.*
class HistoryOrderActivity : BaseActivity() {
private lateinit var mViewModel: HistoryOrderViewModel
private var mHistoryOrderAdapter: HistoryOrderAdapter? = null
private var pageIndex = 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_history_order)
initAppTop()
rv_history_order.layoutManager = LinearLayoutManager(this)
initViewModel()
getHistoryInfo()
initSearch()
initRefresh()
}
private fun getHistoryInfo(page: Int = pageIndex, orderNum: String = "") {
showLoading()
mViewModel.getHistoryOrderList(page.toString(), orderNum) {
cancelDialogForLoading()
refresh_layout.setEnableLoadMore(it.getData() != null)
refresh_layout.finishRefresh()
refresh_layout.finishLoadMore()
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) }
rv_history_order.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter {
showLoading()
mViewModel.getOrderInfo(it.Id.toString()) { it2 ->
cancelDialogForLoading()
if (it2.data != null && it2.data!!.isNotEmpty()) {
//顯示彈窗
OtherOrderUtils.showOrderDetailsDialog(this@HistoryOrderActivity, it2, it.STATUS, it.order_type, false) { _, _ ->
//確認訂單、指派送貨點擊事件
}
} else {
ToastUtils.show(this, "未查詢到訂單信息")
}
}
}
} else {
mHistoryOrderAdapter!!.data = it.getData()
mHistoryOrderAdapter!!.notifyDataSetChanged()
}
}
}
private fun initViewModel() {
mViewModel = ViewModelProvider(this, InjectorUtil.getHistoryModelFactory())[HistoryOrderViewModel::class.java]
}
private fun initSearch() {
iv_search_order.setOnClickListener {
//搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
getHistoryInfo(1, ed_order_num_search.text.toString())
} else {
ToastUtils.show(this@HistoryOrderActivity, "請輸入手機號或訂單號")
}
}
}
private fun initRefresh() {
//设置 Header 顏色
refresh_layout.setPrimaryColorsId(R.color.color_f0, R.color.color_66)
//下拉刷新,加載更多
refresh_layout.setOnRefreshListener {
pageIndex = 1
getHistoryInfo()
}
refresh_layout.setOnLoadMoreListener {
pageIndex++
getHistoryInfo()
}
}
private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.history_order)
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode
package com.gingersoft.gsa.other_order_mode.ui.activity
import android.animation.ValueAnimator
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.media.AudioAttributes
import android.media.AudioManager
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.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
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
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel
import com.gingersoft.gsa.other_order_mode.ui.main.SectionsPagerAdapter
import com.gingersoft.gsa.other_order_mode.ui.adapter.SectionsPagerAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.activity_other_order.*
class OtherOrderActivity : AppCompatActivity() {
class OtherOrderActivity : BaseActivity() {
private lateinit var pageViewModel: PageViewModel
private val instance by lazy { this }
......@@ -40,54 +45,69 @@ class OtherOrderActivity : AppCompatActivity() {
)
private val colors = arrayOf(
"#FF5722",
"#009688",
"#1E9FFF",
"#FFB800",
"#393D49"
R.color.other_order_num_color_first,
R.color.other_order_num_color_second,
R.color.other_order_num_color_third,
R.color.other_order_num_color_fourth,
R.color.other_order_num_color_fifth
)
private var titls: ArrayList<TextView> = ArrayList()
private var titles: ArrayList<TextView> = ArrayList()
private var layoutHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
var binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
binding.switchBtn = btn_switch_restaurant_state
//開啟websocket
var intent = Intent(this, GetInfoUpdateService::class.java)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java]
initWebsocket()
initAppTop()
initSwitchRestStatus()
//綁定營業按鈕狀態
pageViewModel.restaurantState.observe(this, Observer {
btn_switch_restaurant_state.isChecked = it
tv_restaurant_state.text = if (it) {
resources.getString(R.string.normal)
} else {
resources.getString(R.string.rest)
val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager, ints)
view_pager.adapter = sectionsPagerAdapter
view_pager.offscreenPageLimit = 4
searchMethod(view_pager)
initTabs()
//餐廳營業信息
loadRestaurantInfo(binding)
layout_today_order_info.post {
layoutHeight = layout_today_order_info.height.toFloat()
}
pageViewModel.getDeliveryInfo()
}
})
val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager, ints)
val viewPager: ViewPager = findViewById(R.id.view_pager)
viewPager.adapter = sectionsPagerAdapter
viewPager.offscreenPageLimit = 4
iv_search_order.setOnClickListener {
//搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
pageViewModel.phone = ed_order_num_search.text.toString()
pageViewModel.getOrderList(viewPager.currentItem, "0", false) {}
} else {
ToastUtils.show(this@OtherOrderActivity, "請輸入手機號或訂單號")
/**
* 加載餐廳營業信息
*/
private fun loadRestaurantInfo(binding: ActivityOtherOrderBinding) {
pageViewModel.otherInfo.observe(this, Observer {
binding.data = pageViewModel
sb_takeaway.max = if (it.MaxOrder == 0) 1 else it.MaxOrder
sb_takeaway.progress = it.num
sb_self.max = it.maxOrderSelf
sb_self.progress = it.selflNum
if (it.orderType_2 != null) {
tv_takeaway_num.text = it.orderType_2!!.typeDayOrderNum.toString()
tv_takeaway_amount.text = "$" + it.orderType_2!!.typeTotalAmount.toString()
}
if (it.orderType_7 != null) {
tv_today_self_order_num.text = it.orderType_7!!.typeDayOrderNum.toString()
tv_today_self_amount_num.text = "$" + it.orderType_7!!.typeTotalAmount.toString()
}
})
}
tabs.setupWithViewPager(viewPager)
/**
* 初始化viewpager的tab指示器
*/
private fun initTabs() {
tabs.setupWithViewPager(view_pager)
for (i in 0 until ints.size) {
//获取每一个tab对象
......@@ -98,14 +118,11 @@ class OtherOrderActivity : AppCompatActivity() {
//通过tab对象找到自定义视图的ID
val mTvTitle = tabAt.customView!!.findViewById<TextView>(R.id.tv_table_item_title)
val mNumber = tabAt.customView!!.findViewById<TextView>(R.id.tv_table_item_num)
titls.add(mNumber)
titles.add(mNumber)
mTvTitle.setText(ints[i])
val drawable = GradientDrawable()
drawable.setColor(Color.parseColor(colors[i]))
drawable.cornerRadius = 5f
mNumber.background = drawable
mNumber.text = "0"
mNumber.setTextColor(this@OtherOrderActivity.resources.getColor(colors[i]))
while (pageViewModel.mOrderList.size <= i) {
pageViewModel.mOrderList.add(MutableLiveData())
}
......@@ -114,34 +131,49 @@ class OtherOrderActivity : AppCompatActivity() {
})
}
}
}
//餐廳營業信息
pageViewModel.otherInfo.observe(this, Observer {
binding.data = pageViewModel
sb_takeaway.maxValue = it.MaxOrder
sb_takeaway.progress = it.num
sb_self.maxValue = it.maxOrderSelf
sb_self.progress = it.selflNum
if (it.orderType_2 != null) {
tv_takeaway_num.text = it.orderType_2!!.typeDayOrderNum.toString()
tv_takeaway_amount.text = "$" + it.orderType_2!!.typeTotalAmount.toString()
/**
* 搜索
*/
private fun searchMethod(viewPager: ViewPager) {
iv_search_order.setOnClickListener {
//搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
pageViewModel.phone = ed_order_num_search.text.toString()
pageViewModel.getOrderList(viewPager.currentItem, "0", false) {}
} else {
ToastUtils.show(this@OtherOrderActivity, "請輸入手機號或訂單號")
}
if (it.orderType_7 != null) {
tv_today_self_order_num.text = it.orderType_7!!.typeDayOrderNum.toString()
tv_today_self_amount_num.text = "$" + it.orderType_7!!.typeTotalAmount.toString()
}
})
cl_order_info.post {
layoutHeight = cl_order_info.height.toFloat()
}
/**
* 切換餐廳狀態按鈕
*/
private fun initSwitchRestStatus() {
btn_switch_restaurant_state.setOnClickListener {
pageViewModel.setRestaurantState(this, !(it as SwitchButton).statusBasedOnPos)
}
//綁定營業按鈕狀態
pageViewModel.restaurantState.observe(this, Observer {
btn_switch_restaurant_state.isChecked = it
})
btn_open_or_close_info.setOnClickListener {
setOrderInfoOpenOrClose()
}
}
private fun initWebsocket() {
//開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
}
private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
var bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind
val bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind
bind.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack {
override fun callBack(type: Int) {
//-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
......@@ -149,6 +181,7 @@ class OtherOrderActivity : AppCompatActivity() {
|| type == 6 || type == 7) {
//播放提示音
pageViewModel.refreshState.postValue(type)
initSoundPool()
}
}
})
......@@ -160,26 +193,76 @@ class OtherOrderActivity : AppCompatActivity() {
}
}
private var soundPool: SoundPool? = null
fun initSoundPool() {
//实例化SoundPool
//sdk版本21是SoundPool 的一个分水岭
if (soundPool == null) {
if (Build.VERSION.SDK_INT >= 21) {
val builder = SoundPool.Builder()
//传入最多播放音频数量,
builder.setMaxStreams(1)
//AudioAttributes是一个封装音频各种属性的方法
val attrBuilder = AudioAttributes.Builder()
//设置音频流的合适的属性
attrBuilder.setLegacyStreamType(AudioManager.STREAM_MUSIC)
//加载一个AudioAttributes
builder.setAudioAttributes(attrBuilder.build())
soundPool = builder.build()
} else {
/**
* 第一个参数:int maxStreams:SoundPool对象的最大并发流数
* 第二个参数:int streamType:AudioManager中描述的音频流类型
*第三个参数:int srcQuality:采样率转换器的质量。 目前没有效果。 使用0作为默认值。
*/
soundPool = SoundPool(1, AudioManager.STREAM_MUSIC, 0)
}
}
//可以通过四种途径来记载一个音频资源:
//1.通过一个AssetFileDescriptor对象
//int load(AssetFileDescriptor afd, int priority)
//2.通过一个资源ID
//int load(Context context, int resId, int priority)
//3.通过指定的路径加载
//int load(String path, int priority)
//4.通过FileDescriptor加载
//int load(FileDescriptor fd, long offset, long length, int priority)
//声音ID 加载音频资源,这里用的是第二种,第三个参数为priority,声音的优先级*API中指出,priority参数目前没有效果,建议设置为1。
val voiceId = soundPool!!.load(this, R.raw.newordervocal, 1)
//异步需要等待加载完成,音频才能播放成功
soundPool!!.setOnLoadCompleteListener { soundPool, sampleId, status ->
if (status == 0) {
//第一个参数soundID
//第二个参数leftVolume为左侧音量值(范围= 0.0到1.0)
//第三个参数rightVolume为右的音量值(范围= 0.0到1.0)
//第四个参数priority 为流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理
//第五个参数loop 为音频重复播放次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次
//第六个参数 rate为播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率)
soundPool.play(voiceId, 1f, 1f, 1, 0, 1f)
}
}
}
private var isOpen: Boolean = true
/**
* 顯示或收起餐廳營業信息
*/
private fun setOrderInfoOpenOrClose() {
btn_open_or_close_info.isClickable = false
isOpen = !isOpen
//如果是打開的,則關閉
val heightAnimation = if (isOpen)
ValueAnimator.ofFloat(0f, layoutHeight)
ValueAnimator.ofFloat(1f, layoutHeight)
else
ValueAnimator.ofFloat(layoutHeight, 0f)
ValueAnimator.ofFloat(layoutHeight, 1f)
heightAnimation.duration = 200
heightAnimation.addUpdateListener { animation ->
val `val` = animation.animatedValue as Float
setViewHeight(cl_order_info, `val`.toInt())
btn_open_or_close_info.text =
if (isOpen) {
val height = animation.animatedValue as Float
setViewHeight(layout_today_order_info, height.toInt())
btn_open_or_close_info.text = if (isOpen)
"點擊收起"
} else {
"點擊展開"
}
else
"查看詳情"
btn_open_or_close_info.isClickable = true
}
heightAnimation.start()
......@@ -191,9 +274,16 @@ class OtherOrderActivity : AppCompatActivity() {
view.requestLayout()
}
/**
* 初始化標題欄
*/
private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.app_name)
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_other_order_bar.addRightImageButton(R.drawable.ic_history_order, R.id.iv_history).setOnClickListener {
//歷史訂單
startActivity(Intent(this, HistoryOrderActivity::class.java))
}
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.DeliveryBean
class DeliveryAdapter(val context: Context, data: List<DeliveryBean.Data>) : BaseQuickAdapter<DeliveryBean.Data, BaseViewHolder>(R.layout.other_order_delivery_item, data) {
var selectIndex = -1
override fun convert(helper: BaseViewHolder?, item: DeliveryBean.Data?) {
helper!!.setText(R.id.tv_delivery_name, item!!.userName)
if (helper.adapterPosition == selectIndex) {
helper.setBackgroundRes(R.id.layout_delivery_item, R.drawable.shape_delivery_item_btn)
helper.setTextColor(R.id.tv_delivery_name, context.resources.getColor(R.color.order_state0_color))
} else {
helper.setBackgroundRes(R.id.layout_delivery_item, R.drawable.shape_delivery_item_btn_normal)
helper.setTextColor(R.id.tv_delivery_name, context.resources.getColor(R.color.color_c8))
}
}
}
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.FoodDetailsTranBean
import com.gingersoft.gsa.other_order_mode.databinding.LayoutDialogFoodItemBinding
import com.qmuiteam.qmui.util.QMUIDisplayHelper.dp2px
class FoodListAdapter(private val context: Context, private val productnameBeans: List<OrderDetails.DataBean.PRODUCTNAMEBean>) : RecyclerView.Adapter<FoodListAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.layout_dialog_food_item, parent, false))
}
override fun getItemCount(): Int {
return productnameBeans.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.binding.data = FoodDetailsTranBean.FoodDetails.getByPRODUCTNAMEBean(productnameBeans[position])
holder.binding.price = productnameBeans[position].PRICE!!.toFloat()
if (productnameBeans[position].child != null) {
if (productnameBeans[position].child!!.isNotEmpty()) {
for (child in productnameBeans[position].child!!) {
val foodChild = getChild(FoodDetailsTranBean.FoodDetails.getByChildBeanX(child), 10)
val content = foodChild.findViewById<LinearLayout>(R.id.layout_food_content)
if (child.child != null) {
if (child.child!!.isNotEmpty()) {
for (childBean in child.child!!) {
content.addView(getChild(FoodDetailsTranBean.FoodDetails.getByChildBean(childBean), 20))
}
}
}
holder.content.addView(foodChild)
}
}
}
}
private fun getChild(child: FoodDetailsTranBean, leftMargin: Int): View {
val foodChildChild = LayoutInflater.from(context).inflate(R.layout.layout_dialog_food_item, null, false)
val childBinding: LayoutDialogFoodItemBinding = DataBindingUtil.bind(foodChildChild)!!
childBinding.data = child
childBinding.price = child.PRICE!!.toFloat()
val childNext = foodChildChild.findViewById<ImageView>(R.id.iv_food_item_next)
childNext.visibility = View.VISIBLE
// val childParams = childNext.layoutParams as ConstraintLayout.LayoutParams
childNext.setPadding(dp2px(context, leftMargin), 0, 0, 0)
// childNext.layoutParams = childParams
return foodChildChild
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutDialogFoodItemBinding = DataBindingUtil.bind(itemView)!!
val content: LinearLayout = itemView.findViewById(R.id.layout_food_content)
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.HistoryOrderBean.DataBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutHistoryOrderItemBinding
import com.scwang.smartrefresh.layout.util.SmartUtil
class HistoryOrderAdapter(private val context: Context, var data: List<DataBean>?) : RecyclerView.Adapter<HistoryOrderAdapter.ViewHolder>() {
//item點擊事件
private var listenter: ((item: DataBean) -> Unit)? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.layout_history_order_item, parent, false))
}
override fun getItemCount(): Int {
return if (data == null) {
0
} else {
data!!.size
}
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val data = data?.get(position)
holder.binding.data = data
//堂食外賣背景
val orderingMethodBg = GradientDrawable()
orderingMethodBg.shape = GradientDrawable.OVAL
holder.binding.orderingMethod =
when {
data!!.order_type == 2 -> {
orderingMethodBg.setColor(getColor(R.color.order_state2_color))
"外"
}
data.order_type == 7 -> {
orderingMethodBg.setColor(getColor(R.color.order_state3_color))
"自"
}
else -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color))
"堂"
}
}
holder.binding.orderingMethodBg = orderingMethodBg
//支付方式背景 data.orderPayType==1?@color/table_send:@color/table_use
//data.orderPayType==1?@string/cash_on_delivery:@string/online_payments
val payMethodBg = GradientDrawable()
payMethodBg.cornerRadius = SmartUtil.dp2px(10f).toFloat()
holder.binding.payMethod =
when {
data.orderPayType == 1 -> {
payMethodBg.setColor(getColor(R.color.cash_on_delivery_bg))
"貨到付款"
}
else -> {
payMethodBg.setColor(getColor(R.color.online_payments_bg))
"在線支付"
}
}
holder.binding.payMethodBg = payMethodBg
holder.itemView.setOnClickListener {
listenter?.invoke(data)
}
}
private fun getColor(color: Int): Int {
return context.resources.getColor(color)
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutHistoryOrderItemBinding = DataBindingUtil.bind(itemView)!!
}
fun setOnItemClickListenter(listenter: (item: DataBean) -> Unit) {
this.listenter = listenter
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -15,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding
import com.scwang.smartrefresh.layout.util.SmartUtil.dp2px
class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.ViewHolder>() {
......@@ -40,18 +42,18 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val data = this.databeans!![position]
holder.binding.data = data
holder.binding.isSelf = data.order_type == 7
var state: String? = null
val bg = GradientDrawable()
bg.cornerRadius = 10F
bg.cornerRadius = dp2px(5f).toFloat()
when {
data.STATUS == 0 -> {
state = "待確"
state = "待確"
bg.setColor(getColor(R.color.order_state0_color))
}
data.STATUS == 1 -> {
state = "待確"
state = "待確"
bg.setColor(getColor(R.color.order_state0_color))
}
data.STATUS == 2 -> {
......@@ -62,7 +64,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
state = if (data.order_type == 7) {
"待取餐"
} else {
"送貨中"
"派送中"
}
bg.setColor(getColor(R.color.order_state2_color))
}
......@@ -76,11 +78,11 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
holder.binding.orderingMethod =
when {
data.order_type == 2 -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color))
orderingMethodBg.setColor(getColor(R.color.order_state2_color))
"外"
}
data.order_type == 7 -> {
orderingMethodBg.setColor(getColor(R.color.self_order_bg))
orderingMethodBg.setColor(getColor(R.color.order_state3_color))
"自"
}
else -> {
......@@ -93,7 +95,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
//支付方式背景 data.orderPayType==1?@color/table_send:@color/table_use
//data.orderPayType==1?@string/cash_on_delivery:@string/online_payments
val payMethodBg = GradientDrawable()
payMethodBg.cornerRadius = 10F
payMethodBg.cornerRadius = dp2px(10f).toFloat()
holder.binding.payMethod =
when {
data.orderPayType == 1 -> {
......@@ -126,17 +128,17 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutOtherOrderItemBinding = DataBindingUtil.bind(itemView)!!
@BindingAdapter("imageUrl")
fun bindImageUrl(view: ImageView, imageUrl: String) {
var options: RequestOptions = RequestOptions()
.centerCrop()
.dontAnimate()
Glide.with(view)
.load(imageUrl)
.apply(options)
.into(view)
}
//
// @BindingAdapter("imageUrl")
// fun bindImageUrl(view: ImageView, imageUrl: String) {
// val options: RequestOptions = RequestOptions()
// .centerCrop()
// .dontAnimate()
//
// Glide.with(view)
// .load(imageUrl)
// .apply(options)
// .into(view)
// }
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.main
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.gingersoft.gsa.other_order_mode.ui.fragment.PlaceholderFragment
/**
* A [FragmentPagerAdapter] that returns a fragment corresponding to
......
package com.gingersoft.gsa.other_order_mode.ui.base
import androidx.appcompat.app.AppCompatActivity
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
open class BaseActivity : AppCompatActivity() {
fun showLoading(message: String? = null) {
if (message != null)
LoadingDialog.showDialogForLoading(this, message, true)
else
LoadingDialog.showDialogForLoading(this)
}
fun cancelDialogForLoading(){
LoadingDialog.cancelDialogForLoading()
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.base
import androidx.fragment.app.Fragment
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
open class BaseFragment : Fragment() {
fun showLoading(message: String? = null) {
if (message != null)
LoadingDialog.showDialogForLoading(activity, message, true)
else
LoadingDialog.showDialogForLoading(activity)
}
fun cancelDialogForLoading() {
LoadingDialog.cancelDialogForLoading()
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.main
package com.gingersoft.gsa.other_order_mode.ui.fragment
import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOrderInfoDialogBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
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.jess.arms.utils.ArmsUtils
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.*
/**
* A placeholder fragment containing a simple view.
*/
class PlaceholderFragment : Fragment() {
class PlaceholderFragment : BaseFragment() {
private lateinit var pageViewModel: PageViewModel
private var page = 1
......@@ -30,63 +31,70 @@ class PlaceholderFragment : Fragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
//第一次進入獲取數據
// 第一次進入獲取數據
getOrderList(this, false)
//綁定狀態,如果這個值發生變化
// 綁定狀態,如果這個值發生變化
refreshState.observe(viewLifecycleOwner, Observer {
//觸發刷新,判斷是否更新
//並且type一致//
// 觸發刷新,判斷是否更新
// 並且type一致
//如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
Log.e("eee", "$it,當前fragment的" + PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!])
// if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
getOrderList(this, false)
}
// }
})
}
//初始化recyclerview
// 初始化recyclerview
rv_other_order.layoutManager = LinearLayoutManager(activity)
val adapter = OtherOrdersAdapter(activity!!)
adapter.setOnItemClickListenter {
//點擊查詢食品詳情
pageViewModel.getOrderInfo(it.Id.toString()) { it1 ->
adapter.setOnItemClickListenter { data ->
// 點擊查詢食品詳情
showLoading()
pageViewModel.getOrderInfo(data.Id.toString()) { it1 ->
//顯示彈窗
object : DialogUtils(activity, R.layout.layout_order_info_dialog) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (it1.getData() != null && it1.getData()!!.isNotEmpty()) {
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogBinding = DataBindingUtil.bind(hepler.contentView)!!
layoutOrderInfoDialogBinding.data = it1.getData()!![0]
cancelDialogForLoading()
if (this@PlaceholderFragment.context != null && it1 != null) {
OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { _, dialog ->
pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
dialog.dismiss()
if (it) {
// 關閉彈窗,並刷新頁面
refresh()
}
}
}
}
}.setHeight((ArmsUtils.getScreenHeidth(activity) * 0.6).toInt())
.createDialogView()
.show()
}
}
rv_other_order.adapter = adapter
while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
pageViewModel.mOrderList.add(MutableLiveData())
}
//綁定當前fragment的數據項
// 綁定當前fragment的數據項
pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
it.let { adapter.setData(it) }
})
//下拉刷新,加載更多
// 设置 Header 顏色
refresh_layout.setPrimaryColorsId(R.color.color_f0, R.color.color_66)
// 下拉刷新,加載更多
refresh_layout.setOnRefreshListener {
page = 0
pageViewModel.orderNo = ""
pageViewModel.phone = ""
getOrderList(pageViewModel, false)
refresh()
}
refresh_layout.setOnLoadMoreListener {
page++
getOrderList(pageViewModel, true)
}
}
// rv_other_order
private fun refresh() {
page = 0
pageViewModel.orderNo = ""
pageViewModel.phone = ""
getOrderList(pageViewModel, false)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
......
package com.gingersoft.gsa.other_order_mode.ui.main
import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import kotlinx.coroutines.launch
class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
companion object {
var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var fragmentType = arrayOf("0", "0", "0", "2", "7")
}
var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>()
//其他的所有數據
var otherInfo = MutableLiveData<OrderList.DataBeanX.DataBean>()
//刷新狀態,有數據更新就會更改這個變量,將這個變量修改為allOrderStatus...上面五種狀態,fragment中監聽這個變量,再調用接口獲取最新數據
var refreshState = MutableLiveData<Int>()
//訂單號
var orderNo: String = ""
//手機號
var phone: String = ""
/**
* 獲取訂單信息
*/
fun getOrderList(position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) {
launch({
repository.requestOrderList(fragmentStatus[position], fragmentType[position], page, orderNo, phone).apply {
loadInfo(listener, isLoadMore, position)
}
}, {
//出錯
})
}
private fun OrderList.loadInfo(listener: (String) -> Unit, isLoadMore: Boolean, position: Int) {
listener.invoke("加載完成")
if (getData() != null && getData()?.data != null) {
val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean>
if (myData.isNotEmpty()) {
//取得最後一個對象,裡面有營業狀態和外賣訂單數,自取訂單數
val dataBean: OrderList.DataBeanX.DataBean = myData[myData.size - 1]
if (dataBean.Open_Status != null) {
restaurantState.value = dataBean.Open_Status!! == "1"
}
if (myData.size == 1) {
otherInfo.value = myData[0]
} else {
otherInfo.value = myData[myData.size - 1]
}
myData.removeAt(myData.size - 1)
if (isLoadMore) {
if (mOrderList[position].value != null) {
mOrderList[position].value!!.addAll(myData)
} else {
mOrderList[position].value = myData
}
} else {
mOrderList[position].value = myData
}
} else {
Log.e("aaa", "數據為空")
}
}
}
//餐廳營業狀態,控制按鈕
var restaurantState = MutableLiveData<Boolean>()
/**
* 修改餐廳營業狀態
*/
fun setRestaurantState(state: Boolean) {
launch({
repository.updateRestOpenStatus(state).apply {
if (isSuccess()) {
restaurantState.value = state
}
}
}, {
})
}
/**
* 根據訂單id獲取訂單詳細信息
*/
fun getOrderInfo(orderId: String, listener: (OrderDetails) -> Unit) {
launch({
repository.getOrderInfo(orderId).apply {
listener.invoke(this)
}
}, {
//出錯
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
} catch (e: Throwable) {
error(e)
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.util
import com.gingersoft.gsa.other_order_mode.data.HistoryOrderRepository
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.network.CoolWeatherNetwork
import com.gingersoft.gsa.other_order_mode.model.WeatherModelFactory
import com.gingersoft.gsa.other_order_mode.model.factory.HistoryOrderModelFactory
import com.gingersoft.gsa.other_order_mode.model.factory.WeatherModelFactory
object InjectorUtil {
fun getWeatherModelFactory() = WeatherModelFactory(getWeatherRepository())
private fun getWeatherRepository() = WeatherRepository.getInstance(CoolWeatherNetwork.getInstance())
fun getHistoryModelFactory() = HistoryOrderModelFactory(getHistoryRepository())
private fun getHistoryRepository() = HistoryOrderRepository.getInstance(CoolWeatherNetwork.getInstance())
}
\ No newline at end of file
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.TextView
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
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
object OtherOrderUtils {
fun showOrderDetailsDialog(context: Context, data: OrderDetails, orderStuats: Int, orderType: Int, showBtn: Boolean = true, listenter: ((data: OrderDetails.DataBean, dialog: Dialog) -> Unit)?) {
object : DialogUtils(context, R.layout.layout_order_info_dialog_new) {
override fun initLayout(hepler: ViewHepler, dialog: Dialog) {
if (data.data != null) {
val tvStatus = hepler.getView<TextView>(R.id.tv_order_state)
val orderData = data.data!![0]
val layoutOrderInfoDialogBinding: LayoutOrderInfoDialogNewBinding = DataBindingUtil.bind(hepler.contentView)!!
layoutOrderInfoDialogBinding.data = orderData
layoutOrderInfoDialogBinding.isSelf = orderType == 7
layoutOrderInfoDialogBinding.totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
layoutOrderInfoDialogBinding.showBtn = showBtn
val btnContent: String
val type = if (orderType == 7) "自取" else "外賣"
val orderStatus: String
when (orderStuats) {
2 -> {
if (orderType == 7) {
//自取
btnContent = "製作完成"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
} else {
btnContent = "指派送貨"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color))
}
orderStatus = "製作中"
}
3 -> {
btnContent = "結賬"
if (orderType == 7) {
//自取
orderStatus = "待取餐"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state3_color))
} else {
orderStatus = "派送中"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state2_color))
}
}
else -> {
btnContent = "確認訂單"
orderStatus = "待確認"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
}
}
layoutOrderInfoDialogBinding.orderStatus = type + orderStatus
layoutOrderInfoDialogBinding.btnContent = btnContent
}
val rvFood: RecyclerView = hepler.getView(R.id.rv_food)
rvFood.layoutManager = LinearLayoutManager(context)
rvFood.adapter = FoodListAdapter(context, data.data!![0].PRODUCT_NAME!!)
hepler.getView<Button>(R.id.btn_assign_shipping).setOnClickListener {
//指派送貨或是確認訂單?
//確認訂單,調用接口,並打印
listenter?.invoke(data.data!![0], dialog)
}
}
}.setWidth((ArmsUtils.getScreenWidth(context) * 0.9).toInt())
.setHeight((ArmsUtils.getScreenHeidth(context) * 0.8).toInt())
.createDialogView()
.show()
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/online_payments_bg" android:state_checked="true"/>
<item android:color="@color/online_payments_bg" android:state_selected="true" />
<item android:color="@color/color_ccc" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#E4E4E4" />
<corners android:radius="@dimen/dp_4" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#FFCC33" />
<corners android:radius="@dimen/dp_4" />
</shape>
</clip>
</item>
......@@ -17,6 +18,7 @@
<clip>
<shape>
<solid android:color="#FFCC33" />
<corners android:radius="@dimen/dp_4" />
</shape>
</clip>
</item>
......
<?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/white" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/white" />
</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:bottomLeftRadius="@dimen/dp_8"
android:bottomRightRadius="@dimen/dp_8" />
<solid android:color="@color/white" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/white" />
</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/white" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_ccc" />
</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:topLeftRadius="@dimen/dp_8"
android:topRightRadius="@dimen/dp_8" />
<solid android:color="@color/white" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_f0"
android:orientation="vertical"
tools:context=".ui.activity.OtherOrderActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_f0"
android:orientation="vertical"
app:elevation="@dimen/dp_0">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/qm_other_order_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10">
<EditText
android:id="@+id/ed_order_num_search"
android:layout_width="0dp"
android:layout_height="@dimen/dp_38"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_search_bg"
android:hint="請輸入手機號或訂單號"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_search_order"
android:layout_width="@dimen/dp_50"
android:layout_height="0dp"
android:padding="@dimen/dp_10"
android:src="@mipmap/ic_search"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="@id/ed_order_num_search"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_history_order"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel" />
<import type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" />
<variable
name="data"
type="PageViewModel" />
<variable
name="switchBtn"
type="com.gingersoft.gsa.cloud.ui.view.SwitchButton" />
</data>
type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" />
· </data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OtherOrderActivity">
android:background="@color/color_f0"
tools:context=".ui.activity.OtherOrderActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_f0"
app:elevation="@dimen/dp_0">
<com.qmuiteam.qmui.widget.QMUITopBar
......@@ -39,7 +36,7 @@
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_f0"
android:background="@color/white"
app:tabPaddingEnd="-1dp"
app:tabPaddingStart="-1dp" />
<!--item無法填滿左右時,加入下面這兩個-->
......@@ -50,22 +47,37 @@
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_2"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10">
android:paddingRight="@dimen/dp_10">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_search_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/shape_white_top_border"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="@dimen/dp_10"
app:layout_constraintTop_toTopOf="parent">
<com.qmuiteam.qmui.widget.QMUIProgressBar
<ProgressBar
android:id="@+id/sb_takeaway"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:progressDrawable="@drawable/shape_seekbar_bg"
app:layout_constraintCircleRadius="@dimen/dp_5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/dividing_line"
app:layout_constraintTop_toTopOf="parent"
app:qmui_background_color="#E4E4E4"
app:qmui_progress_color="#FFCC33" />
app:qmui_background_color="@color/color_e4"
app:qmui_progress_color="@color/theme_color"
app:qmui_stroke_round_cap="true"
app:qmui_type="type_rect" />
<TextView
android:id="@+id/tv_month_takeaway_num_text"
......@@ -73,9 +85,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="本月外賣訂單數:"
android:textColor="@color/color_ccc"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_month_takeaway_num"
app:layout_constraintTop_toBottomOf="@id/sb_takeaway" />
<TextView
......@@ -83,9 +95,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{String.valueOf(data.otherInfo.num + @string/slash + data.otherInfo.maxOrder)}"
android:textColor="@color/color_ccc"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@id/tv_month_takeaway_num_text"
app:layout_constraintRight_toRightOf="@id/sb_takeaway"
app:layout_constraintTop_toTopOf="@id/tv_month_takeaway_num_text" />
......@@ -93,23 +105,26 @@
android:id="@+id/dividing_line"
android:layout_width="@dimen/dp_1"
android:layout_height="0dp"
android:background="@color/theme_333_color"
android:background="@color/color_cf"
app:layout_constraintBottom_toBottomOf="@id/sb_takeaway"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/sb_takeaway" />
<com.qmuiteam.qmui.widget.QMUIProgressBar
<ProgressBar
android:id="@+id/sb_self"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_5"
android:background="@drawable/shape_seekbar_bg"
android:progressDrawable="@drawable/shape_seekbar_bg"
app:layout_constraintCircleRadius="@dimen/dp_5"
app:layout_constraintLeft_toRightOf="@id/dividing_line"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:qmui_background_color="#E4E4E4"
app:qmui_progress_color="#FFCC33" />
app:qmui_background_color="@color/color_e4"
app:qmui_progress_color="@color/theme_color"
app:qmui_type="type_circle" />
<TextView
android:id="@+id/tv_month_self_num_text"
......@@ -117,9 +132,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="本月自取訂單數:"
android:textColor="@color/color_ccc"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toLeftOf="@id/sb_self"
app:layout_constraintRight_toLeftOf="@id/tv_month_self_num"
app:layout_constraintTop_toBottomOf="@id/sb_self" />
<TextView
......@@ -127,15 +142,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{String.valueOf(data.otherInfo.selflNum + @string/slash +data.otherInfo.maxOrderSelf)}"
android:textColor="@color/color_ccc"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@id/tv_month_self_num_text"
app:layout_constraintRight_toRightOf="@id/sb_self"
app:layout_constraintTop_toTopOf="@id/tv_month_self_num_text" />
<EditText
android:id="@+id/ed_order_num_search"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_height="@dimen/dp_35"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_search_bg"
......@@ -153,7 +168,7 @@
android:id="@+id/iv_search_order"
android:layout_width="@dimen/dp_50"
android:layout_height="0dp"
android:padding="@dimen/dp_11"
android:padding="@dimen/dp_10"
android:src="@mipmap/ic_search"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="@id/ed_order_num_search"
......@@ -163,44 +178,35 @@
<com.gingersoft.gsa.cloud.ui.view.SwitchButton
android:id="@+id/btn_switch_restaurant_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="@dimen/dp_40"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
app:elevation="0dp"
android:textSize="@dimen/dp_12"
app:kswThumbColor="@color/white"
app:kswBackRadius="@dimen/dp_20"
app:kswThumbMarginTop="@dimen/dp_4"
app:kswBackColor="@color/selector_switch_button"
app:kswThumbMarginBottom="@dimen/dp_4"
app:kswTextOff="@string/resting"
app:kswTextOn="@string/open"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search"
app:switcherBtn_height="@dimen/dp_30"
app:switcherBtn_width="@dimen/dp_72"
bind:OnCheckChangedListener="@{(state)-> data.setRestaurantState(state)}" />
<TextView
android:id="@+id/tv_restaurant_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="@id/btn_switch_restaurant_state"
app:layout_constraintLeft_toLeftOf="@id/btn_switch_restaurant_state"
app:layout_constraintRight_toRightOf="@id/btn_switch_restaurant_state"
app:layout_constraintTop_toTopOf="@id/btn_switch_restaurant_state" />
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_today_order_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/shape_ccc_border"
android:padding="@dimen/dp_10"
app:layout_constraintTop_toBottomOf="@id/ed_order_num_search">
android:background="@color/white"
app:layout_constraintTop_toBottomOf="@id/layout_search_info">
<TextView
android:id="@+id/tv_today_order_num_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="今日總訂單數"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/line_today_info"
app:layout_constraintTop_toTopOf="parent" />
......@@ -219,83 +225,90 @@
app:layout_constraintTop_toBottomOf="@id/tv_today_order_num_text" />
<View
android:id="@+id/line_details_info"
android:layout_width="0dp"
android:layout_height="@dimen/dp_0_5"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/grey_400"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_today_order_num" />
<View
android:id="@+id/line_today_order_info"
android:layout_width="@dimen/dp_1"
android:layout_width="@dimen/dp_0_5"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/grey_400"
app:layout_constraintBottom_toBottomOf="@id/tv_takeaway_num"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/line_today_info"
app:layout_constraintTop_toBottomOf="@id/tv_today_order_num" />
app:layout_constraintTop_toBottomOf="@id/line_details_info" />
<TextView
android:id="@+id/tv_takeaway_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="外賣:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintHorizontal_chainStyle="packed"
android:text="外賣"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_takeaway_num"
app:layout_constraintRight_toLeftOf="@id/line_today_order_info"
app:layout_constraintTop_toTopOf="@id/line_today_order_info" />
<TextView
android:id="@+id/tv_takeaway_num"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
android:text=""
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toRightOf="@id/tv_takeaway_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/line_today_order_info"
app:layout_constraintTop_toTopOf="@id/line_today_order_info" />
app:layout_constraintTop_toBottomOf="@id/tv_takeaway_text" />
<TextView
android:id="@+id/tv_self_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自取:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
android:text="自取"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toRightOf="@id/line_today_order_info"
app:layout_constraintRight_toLeftOf="@id/tv_today_self_order_num"
app:layout_constraintRight_toRightOf="@id/line_today_info"
app:layout_constraintTop_toTopOf="@id/line_today_order_info" />
<TextView
android:id="@+id/tv_today_self_order_num"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toRightOf="@id/tv_self_text"
app:layout_constraintRight_toLeftOf="@id/line_today_info"
app:layout_constraintTop_toTopOf="@id/line_today_order_info" />
app:layout_constraintLeft_toRightOf="@id/line_today_order_info"
app:layout_constraintRight_toRightOf="@id/line_today_info"
app:layout_constraintTop_toBottomOf="@id/tv_self_text" />
<View
android:id="@+id/line_today_info"
android:layout_width="@dimen/dp_1"
android:layout_width="@dimen/dp_0_5"
android:layout_height="0dp"
android:background="@color/color_ccc"
app:layout_constraintBottom_toTopOf="@id/line_today_order_info"
android:background="@color/grey_400"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_today_amount_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="今日營業總金額"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@id/line_today_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="@id/tv_today_order_num_text" />
<TextView
android:id="@+id/tv_today_amount"
......@@ -313,74 +326,71 @@
<View
android:id="@+id/line_today_amount_info"
android:layout_width="@dimen/dp_1"
android:layout_width="@dimen/dp_0_5"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/theme_333_color"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/grey_400"
app:layout_constraintBottom_toBottomOf="@id/tv_takeaway_amount"
app:layout_constraintLeft_toRightOf="@id/line_today_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_today_amount" />
app:layout_constraintTop_toBottomOf="@id/line_details_info" />
<TextView
android:id="@+id/tv_takeaway_amount_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="外賣:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
android:text="外賣"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toRightOf="@id/line_today_info"
app:layout_constraintRight_toLeftOf="@id/tv_takeaway_amount"
app:layout_constraintRight_toLeftOf="@id/line_today_amount_info"
app:layout_constraintTop_toTopOf="@id/line_today_amount_info" />
<TextView
android:id="@+id/tv_takeaway_amount"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toRightOf="@id/tv_takeaway_amount_text"
app:layout_constraintRight_toLeftOf="@id/line_today_amount_info"
app:layout_constraintTop_toTopOf="@id/line_today_amount_info" />
app:layout_constraintLeft_toLeftOf="@id/tv_takeaway_amount_text"
app:layout_constraintRight_toRightOf="@id/tv_takeaway_amount_text"
app:layout_constraintTop_toBottomOf="@id/tv_takeaway_amount_text" />
<TextView
android:id="@+id/tv_self_amount_text"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自取:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
android:text="自取"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toRightOf="@id/line_today_amount_info"
app:layout_constraintRight_toLeftOf="@id/tv_today_self_amount_num"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/line_today_amount_info" />
<TextView
android:id="@+id/tv_today_self_amount_num"
style="@style/otherOrderInfoDialogTextStyle_font_style_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toRightOf="@id/tv_self_amount_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/line_today_amount_info" />
app:layout_constraintLeft_toLeftOf="@id/tv_self_amount_text"
app:layout_constraintRight_toRightOf="@id/tv_self_amount_text"
app:layout_constraintTop_toBottomOf="@id/tv_self_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/btn_open_or_close_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
android:background="@color/color_e4"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_5"
android:background="@drawable/shape_white_bottom_border"
android:gravity="center"
android:text="點擊收起"
android:textColor="@color/white"
android:textSize="@dimen/dp_14" />
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12" />
</com.google.android.material.appbar.AppBarLayout>
......
......@@ -5,7 +5,7 @@
<variable
name="viewModel"
type="com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel" />
type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" />
</data>
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="data"
type="com.gingersoft.gsa.other_order_mode.data.model.bean.FoodDetailsTranBean" />
<variable
name="price"
type="Float" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_12">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_food_number"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_food_item_next"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/item_next"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/tv_food_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_food_name" />
<TextView
android:id="@+id/tv_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.pRODUCT_NAME}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
app:layout_constraintLeft_toRightOf="@id/iv_food_item_next"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_food_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{@string/count + data.num}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
android:gravity="right"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/layout_food_name"
app:layout_constraintRight_toLeftOf="@id/tv_food_price"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<TextView
android:id="@+id/tv_food_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="@{@string/amount_unit + data.pRICE}"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15"
android:visibility="@{price > 0 ? View.VISIBLE : View.INVISIBLE}"
app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintLeft_toRightOf="@id/tv_food_number"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<LinearLayout
android:id="@+id/layout_food_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@id/layout_food_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.gingersoft.gsa.cloud.base.utils.time.TimeUtils" />
<variable
name="data"
type="com.gingersoft.gsa.other_order_mode.data.model.bean.HistoryOrderBean.DataBean" />
<variable
name="orderingMethod"
type="String" />
<variable
name="payMethod"
type="String" />
<variable
name="orderingMethodBg"
type="android.graphics.drawable.Drawable" />
<variable
name="payMethodBg"
type="android.graphics.drawable.Drawable" />
</data>
<com.lihang.ShadowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_7"
android:layout_marginRight="@dimen/dp_7"
app:hl_cornerRadius="@dimen/dp_8"
app:hl_shadowLimit="@dimen/dp_3">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10">
<TextView
android:id="@+id/tv_payment_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@{payMethodBg}"
android:paddingLeft="@dimen/dp_5"
android:paddingTop="@dimen/dp_1"
android:paddingRight="@dimen/dp_5"
android:paddingBottom="@dimen/dp_1"
android:text="@{payMethod}"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_ordering_method"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_8"
android:background="@{orderingMethodBg}"
android:gravity="center"
android:text="@{orderingMethod}"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toRightOf="@id/tv_payment_method"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_order_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{data.rECEIVER}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_ordering_method" />
<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)}"
app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_order_user_name" />
<ImageView
android:id="@+id/iv_end"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/ic_has_end"
app:layout_constraintBottom_toTopOf="@id/tv_order_amount"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_time" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_order_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:barrierDirection="right"
app:constraint_referenced_ids="tv_address_text,tv_cellphone_num_text,tv_order_num_text" />
<TextView
android:id="@+id/tv_cellphone_num_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="手機號:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_user_name" />
<TextView
android:id="@+id/tv_cellphone_num"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="@{data.PHONE}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toLeftOf="@id/iv_end"
app:layout_constraintTop_toTopOf="@id/tv_cellphone_num_text" />
<TextView
android:id="@+id/tv_order_num_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_5"
android:text="訂單號:"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num_text"
app:layout_constraintTop_toBottomOf="@id/tv_cellphone_num_text" />
<TextView
android:id="@+id/tv_order_num"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.ORDER_NO}"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintRight_toLeftOf="@id/iv_end"
app:layout_constraintTop_toTopOf="@id/tv_order_num_text" />
<TextView
android:id="@+id/tv_address_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_5"
android:text="@{data.order_type==7?@string/meal_code:@string/address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_num_text" />
<TextView
android:id="@+id/tv_address"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.order_type==7?data.takeFoodCode:data.ADDRESS_DETAIL}"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintRight_toLeftOf="@id/iv_end"
app:layout_constraintTop_toTopOf="@id/tv_address_text" />
<TextView
android:id="@+id/tv_order_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + data.PAY_AMOUNT}"
android:textColor="@color/red_600"
android:textSize="@dimen/sp_14"
app:layout_constraintBottom_toBottomOf="@id/tv_address"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_address" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.lihang.ShadowLayout>
</layout>
\ No newline at end of file
......@@ -11,16 +11,27 @@
<import type="android.view.View" />
<variable
name="total_amount"
type="Double" />
<variable
name="data"
type="com.gingersoft.gsa.other_order_mode.data.model.bean.OrderDetails.DataBean" />
type="com.gingersoft.gsa.cloud.print.bean.OrderDetails.DataBean" />
<!-- 是否自取-->
<variable
name="isSelf"
type="Boolean" />
<variable
name="btnContent"
type="String" />
</data>
<!-- OrderList.DataBeanX.DataBean-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_dialog_bg"
android:orientation="vertical"
android:padding="@dimen/dp_10">
<TextView
......@@ -28,7 +39,8 @@
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H5訂單"
android:textSize="@dimen/dp_16"
android:text="@{data.order_from==2?@string/ricepon_order:@string/h5_order}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -64,7 +76,7 @@
android:id="@+id/scroll_order_info"
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
android:paddingBottom="@dimen/dp_10"
app:layout_constraintBottom_toTopOf="@id/btn_assign_shipping"
app:layout_constraintTop_toBottomOf="@id/line_info_top">
......@@ -72,9 +84,7 @@
android:id="@+id/cl_order_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10">
android:orientation="vertical">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_order_info"
......@@ -113,6 +123,7 @@
android:layout_marginTop="@dimen/dp_5"
android:gravity="right"
android:text="收貨人:"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_create_time" />
......@@ -123,6 +134,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.rECEIVER}"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receiver_text" />
......@@ -134,7 +146,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="收貨電話:"
android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receiver" />
......@@ -157,7 +169,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="收貨時間:"
android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receive_phone" />
......@@ -167,7 +179,7 @@
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.sEND_TIME}"
android:text="@{isSelf?data.takeTime:data.sEND_TIME}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_time_text" />
......@@ -179,7 +191,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:gravity="right"
android:text="收貨地址:"
android:text="@{isSelf?@string/meal_code:@string/receiving_address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/barrier_order_info"
app:layout_constraintTop_toBottomOf="@id/tv_receive_time" />
......@@ -189,7 +201,7 @@
style="@style/otherOrderInfoDialogTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@{data.addressDetail}"
android:text="@{isSelf?data.takeFoodCode:data.addressDetail}"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_receive_address_text" />
......@@ -319,7 +331,7 @@
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + data.tOTAL_AMOUNT}"
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_text" />
......@@ -339,7 +351,7 @@
style="@style/otherOrderInfoDialogBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{@string/amount_unit + MoneyUtil.sub(data.pAY_AMOUNT, data.discount_amount)}"
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" />
......@@ -348,15 +360,15 @@
<Button
android:id="@+id/btn_assign_shipping"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:background="@color/theme_color"
android:text="指派送貨"
android:background="@drawable/shape_app_btn"
android:text="@{btnContent}"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/scroll_order_info"
app:layout_constraintVertical_bias="1" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.gingersoft.gsa.cloud.base.utils.time.TimeUtils" />
<import type="com.gingersoft.gsa.cloud.base.utils.MoneyUtil" />
<import type="android.view.View" />
<variable
name="total_amount"
type="Double" />
<variable
name="data"
type="com.gingersoft.gsa.cloud.print.bean.OrderDetails.DataBean" />
<!-- 是否自取-->
<variable
name="isSelf"
type="Boolean" />
<variable
name="btnContent"
type="String" />
<variable
name="orderStatus"
type="String" />
<variable
name="showBtn"
type="Boolean" />
</data>
<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_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="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" />
<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: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>
</layout>
\ No newline at end of file
......@@ -34,6 +34,10 @@
name="payMethodBg"
type="android.graphics.drawable.Drawable" />
<!-- 是否自取-->
<variable
name="isSelf"
type="Boolean" />
</data>
<com.lihang.ShadowLayout
......@@ -58,10 +62,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@{payMethodBg}"
android:paddingLeft="@dimen/dp_5"
android:paddingTop="@dimen/dp_1"
android:paddingRight="@dimen/dp_5"
android:paddingBottom="@dimen/dp_1"
android:paddingLeft="@dimen/dp_6"
android:paddingTop="@dimen/dp_2"
android:paddingRight="@dimen/dp_6"
android:paddingBottom="@dimen/dp_2"
android:text="@{payMethod}"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"
......@@ -87,7 +91,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="@{data.rECEIVER}"
android:textColor="@color/theme_333_color"
android:textColor="@color/theme_text_color"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -99,8 +103,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
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" />
......@@ -115,45 +118,43 @@
<TextView
android:id="@+id/tv_cellphone_num_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="手機號:"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_user_name" />
<TextView
android:id="@+id/tv_cellphone_num"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="@{data.pHONE}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
app:layout_constraintTop_toTopOf="@id/tv_cellphone_num_text" />
<TextView
android:id="@+id/tv_order_num_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_5"
android:text="訂單號:"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num_text"
app:layout_constraintTop_toBottomOf="@id/tv_cellphone_num_text" />
<TextView
android:id="@+id/tv_order_num"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{data.oRDER_NO}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintTop_toTopOf="@id/tv_order_num_text" />
......@@ -174,24 +175,22 @@
<TextView
android:id="@+id/tv_address_text"
style="@style/otherOrder_item_info_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginTop="@dimen/dp_5"
android:text="地址:"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
android:text="@{isSelf?@string/meal_code:@string/address}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_num_text" />
<TextView
android:id="@+id/tv_address"
style="@style/otherOrder_item_info_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_5"
android:text="@{data.aDDRESS_DETAIL}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
android:text="@{isSelf?data.takeFoodCode:data.aDDRESS_DETAIL}"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintRight_toLeftOf="@id/tv_order_amount"
app:layout_constraintTop_toTopOf="@id/tv_address_text" />
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
......@@ -10,18 +11,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全部"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
android:textColor="@color/black"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_table_item_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_5"
android:text="11"
android:textColor="@color/white"
android:textSize="@dimen/dp_12" />
android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@id/tv_table_item_title"
app:layout_constraintBottom_toTopOf="@id/tv_table_item_title"
app:layout_constraintTop_toTopOf="@id/tv_table_item_title" />
</LinearLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/layout_delivery_item"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/dp_5"
android:background="@drawable/shape_delivery_item_btn_normal"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_delivery_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:textColor="@color/color_c8"
android:textSize="@dimen/dp_17" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_20">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_dialog_bg"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="指派送貨員"
android:textColor="@color/black"
android:textSize="@dimen/dp_17" />
<TextView
android:id="@+id/tv_delivery_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:text="取消"
android:textColor="@color/color_c8"
android:textSize="@dimen/dp_17" />
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_delivery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_10" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_delivery_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_16"
android:layout_marginRight="@dimen/dp_16"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_fifty_tran_green_btn"
android:gravity="center"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:text="確定"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_white_eight_corners_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_30"
android:paddingTop="@dimen/dp_12"
android:paddingRight="@dimen/dp_30"
android:paddingBottom="@dimen/dp_12">
<ImageView
android:layout_width="@dimen/dp_58"
android:layout_height="@dimen/dp_58"
android:src="@drawable/ic_warning" />
<TextView
android:id="@+id/tv_warning_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_22"
android:text="是否暫停接單?"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_20" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dialog_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_red_five_radius_bg"
android:paddingLeft="@dimen/dp_28"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_28"
android:paddingBottom="@dimen/dp_10"
android:text="確定"
android:textColor="@color/white"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_dialog_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_28"
android:background="@drawable/shape_3c_cancel_btn_bg"
android:paddingLeft="@dimen/dp_28"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_28"
android:paddingBottom="@dimen/dp_10"
android:text="取消"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_white_eight_corners_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_30"
android:paddingTop="@dimen/dp_12"
android:paddingRight="@dimen/dp_30"
android:paddingBottom="@dimen/dp_12">
<ImageView
android:layout_width="@dimen/dp_58"
android:layout_height="@dimen/dp_58"
android:src="@drawable/ic_warning" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_22"
android:text="是否確認結賬?"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_20" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dialog_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_red_five_radius_bg"
android:paddingLeft="@dimen/dp_28"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_28"
android:paddingBottom="@dimen/dp_10"
android:text="確定"
android:textColor="@color/white"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_dialog_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_28"
android:background="@drawable/shape_3c_cancel_btn_bg"
android:paddingLeft="@dimen/dp_28"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_28"
android:paddingBottom="@dimen/dp_10"
android:text="取消"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -3,4 +3,11 @@
<!-- <color name="colorPrimary">#008577</color>-->
<!-- <color name="colorPrimaryDark">#00574B</color>-->
<!-- <color name="colorAccent">#D81B60</color>-->
<color name="other_order_num_color_first">#FF5722</color>
<color name="other_order_num_color_second">#009688</color>
<color name="other_order_num_color_third">#1E9FFF</color>
<color name="other_order_num_color_fourth">#FFB800</color>
<color name="other_order_num_color_fifth">#393D49</color>
</resources>
......@@ -5,4 +5,8 @@
<dimen name="appbar_padding">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen>
<dimen name="other_order_info_dialog_content_marginLeft">@dimen/dp_10</dimen>
<dimen name="other_order_info_dialog_content_marginRight">@dimen/dp_10</dimen>
</resources>
<resources>
<string name="app_name">訂單管理</string>
<string name="history_order">歷史訂單</string>
<string name="tab_text_1">全部</string>
<string name="tab_text_2">待確認</string>
<string name="tab_text_3">製作中</string>
......@@ -8,7 +9,33 @@
<string name="slash">/</string>
<string name="amount_unit">$</string>
<string name="minus_amount_unit">-$</string>
<string name="count">x</string>
<string name="normal">正常</string>
<string name="rest">休息</string>
<string name="open">營業中</string>
<string name="resting">休息中</string>
<string name="receiving_telephone">收貨電話:</string>
<string name="reserved_telephone">預留電話:</string>
<string name="receiving_time">收貨時間:</string>
<string name="self_taking_time">自取時間:</string>
<string name="receiving_address">收貨地址:</string>
<string name="meal_code">取餐碼:</string>
<string name="address">地址:</string>
<string name="table_number">檯號:</string>
<string name="self">自取</string>
<string name="takeaway">外送</string>
<string name="order_number">單號:</string>
<string name="create_order_time">下單時間:</string>
<string name="remark">備註:</string>
<string name="h5_order">H5訂單</string>
<string name="ricepon_order">ricepon訂單</string>
<string name="order_no">訂單編號:</string>
</resources>
......@@ -23,12 +23,65 @@
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item>
</style>
<style name="otherOrderInfoDialogTextStyle">
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">normal</item>
</style>
<style name="otherOrderInfoDialogTextStyle_font_style_twelve" parent="font_style_twelve">
<item name="android:textColor">@color/color_3c</item>
</style>
<style name="otherOrderInfoDialogTextStyle_font_style_twenty" parent="font_style_twenty">
<item name="android:textColor">@color/theme_333_color</item>
</style>
<style name="otherOrderInfoPrintBoldTextStyle">
<item name="android:textSize">@dimen/dp_18</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item>
</style>
<!-- 彈窗_收貨標題字體樣式-->
<style name="otherOrderReceiving_title_textStyle">
<item name="android:textColor">@color/color_50</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<!-- 彈窗_收貨標題信息字體樣式-->
<style name="otherOrderReceiving_information_textStyle">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textStyle">bold</item>
</style>
<!-- 彈窗_金額標題字體樣式-->
<style name="otherOrder_bill_textStyle">
<item name="android:textColor">@color/color_3c</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<style name="otherOrder_bill_info_textStyle">
<item name="android:textColor">@color/color_3c</item>
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textStyle">bold</item>
</style>
<!-- 訂單列表item的訂單信息名稱字體樣式-->
<style name="otherOrder_item_info_title_textStyle">
<item name="android:textColor">@color/theme_text_color</item>
<item name="android:textSize">@dimen/dp_12</item>
</style>
<!-- 訂單列表item的訂單信息字體樣式-->
<style name="otherOrder_item_info_textStyle">
<item name="android:textColor">@color/color_86</item>
<item name="android:textSize">@dimen/dp_12</item>
</style>
<!-- 訂單列表item的下單時間字體樣式-->
<style name="otherOrder_item_create_time_textStyle">
<item name="android:textColor">@color/color_66</item>
<item name="android:textSize">@dimen/dp_12</item>
</style>
</resources>
......@@ -43,7 +43,7 @@ public abstract class ObjPool<T, R> {
if (t == null) {
t = newInstance(r);
}
if (t != null && t instanceof Initable) {
if (t instanceof Initable) {
((Initable<R>) t).init(r);
}
return t;
......
......@@ -31,7 +31,7 @@ import java.util.Map;
/**
* 結賬單
*/
public class PrintBill extends PrinterInIt {
public class PrintBill extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
......
......@@ -12,9 +12,9 @@ import java.util.List;
import java.util.Map;
/**
* 清機報表
* view
*/
public class PrintCleanMachine extends PrinterInIt {
public class PrintCleanMachine extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
......
......@@ -27,7 +27,7 @@ import java.util.Objects;
/**
* 廚房單打印
*/
public class PrintKitchen extends PrinterInIt {
public class PrintKitchen extends PrinterRoot {
// String[] printLocation = new String[]{"k1", "k2"};
......
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.joe.print.mvp.ui.adapter.OtherOrderAdapter;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.joe.print.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class PrintOtherOrder extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
OrderDetails.DataBean dataBean = MyOrderManage.getDataBean();
if (dataBean != null) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
//廚房單,可能會有多個IP打印
//獲得ip打印列表,
//再將食品數據根據打印位置分組。
//打印一組之後,關閉連接,切換第二台打印機ip,如此循環
//打印完成之後,返回所有打印結果。
Map<String, List<OrderDetails.DataBean.PRODUCTNAMEBean>> foodMaps = new HashMap<>();
String emptyPrintLocation = "";//部分食品沒有打印位置時設置為此key,比如這是第一個食品,沒有打印位置時
int lastEmptyPrintLocationIndex = 0;//上一次遍歷到第一個食品時都沒有打印位置時,開始的食品位置
//獲取這個訂單的一級食品
if (dataBean.getPRODUCT_NAME() != null) {
for (int i = 0; i < dataBean.getPRODUCT_NAME().size(); i++) {
OrderDetails.DataBean.PRODUCTNAMEBean food = dataBean.getPRODUCT_NAME().get(i);
if (TextUtil.isEmptyOrNullOrUndefined(food.getPrintseting())) {
//如果沒有打印位置,向上尋找
if (i == 0) {
food.setPrintseting(emptyPrintLocation);
addToMap(foodMaps, food);
} else {
for (int j = i - 1; j >= lastEmptyPrintLocationIndex; j--) {
//一直遍歷,直到找到有打印位置的食品
// 如果所有食品都沒有打印位置的情況,為了避免多次遍歷
// 如果本次遍歷到第一個食品,都沒有打印位置,記錄下這一次開始遍歷的下標,下一次遍歷到這個位置就停止
if (!TextUtil.isEmptyOrNullOrUndefined(dataBean.getPRODUCT_NAME().get(j).getPrintseting())) {
//一直遍歷,直到找到有打印位置的食品
//判斷是否帶*號
if (Objects.requireNonNull(dataBean.getPRODUCT_NAME().get(j).getPrintseting()).contains("*")) {
//帶*號,則需要取得通過下標加去掉*號的標識來取得map中的集合,將i食品裝進去,這樣就能打印在一張紙上
//如果沒取得集合,則通過打印位置去map取得集合,將j食品從map中移除,將這個j食品的和i食品裝一起
// 生成新的key。為當前下標+"標識符"+去掉*的打印位置,不帶*的key取得的食品集合才能打印在一張紙上。
String newKey = j + DELIMITER + dataBean.getPRODUCT_NAME().get(j).getPrintseting().replaceAll("\\*", "");
//通過newKey取得map中的集合
List<OrderDetails.DataBean.PRODUCTNAMEBean> newKeyfoods = foodMaps.get(newKey);
if (newKeyfoods != null) {
newKeyfoods.add(food);
} else {
List<OrderDetails.DataBean.PRODUCTNAMEBean> printsetingFoods = foodMaps.get(dataBean.getPRODUCT_NAME().get(j).getPrintseting());
if (printsetingFoods != null) {//理論上不會為空
printsetingFoods.remove(printsetingFoods.lastIndexOf(dataBean.getPRODUCT_NAME().get(j)));
//移除掉之後,put到newkey中
List<OrderDetails.DataBean.PRODUCTNAMEBean> newFoods = new ArrayList<>();
newFoods.add(dataBean.getPRODUCT_NAME().get(j));
newFoods.add(food);
foodMaps.put(newKey, newFoods);
}
}
break;
} else {
//沒有*號,不需要做多餘的操作
food.setPrintseting(dataBean.getPRODUCT_NAME().get(j).getPrintseting());
addToMap(foodMaps, food);
}
} else if (j == lastEmptyPrintLocationIndex) {
//從i到0的打印位置都沒有,記錄下i,下次只遍歷到i就停下來
lastEmptyPrintLocationIndex = i;
//如果找到最初的那個食品,也沒有打印位置,設置打印位置為"null"
food.setPrintseting(emptyPrintLocation);
addToMap(foodMaps, food);
}
}
}
} else {
//有打印位置,
//已經保存過這個位置的,
addToMap(foodMaps, food);
}
}
}
//通過打印位置生成多張用於打印的bitmap
for (Map.Entry<String, List<OrderDetails.DataBean.PRODUCTNAMEBean>> entry : foodMaps.entrySet()) {
String key = entry.getKey();
List<Bitmap> bitmaps = new ArrayList<>();
if (key.contains("*")) {
//如果帶*號,這個集合就需要切紙,每個食品都需要單獨在一張廚房單上
for (OrderDetails.DataBean.PRODUCTNAMEBean orderDetail : entry.getValue()) {
List<OrderDetails.DataBean.PRODUCTNAMEBean> orders = new ArrayList<>();//這裡new集合是因為下面的方法需要的參數是list集合
orders.add(orderDetail);
//獲取廚房單圖片
Bitmap bitmap = getOrderKitchenBitmap(mContext, orders, dataBean);
bitmaps.add(bitmap);
}
} else {
//獲取廚房單圖片
Bitmap bitmap = getOrderKitchenBitmap(mContext, entry.getValue(), dataBean);
//不帶*號,所有同樣廚房位置的食品都在一張紙上
bitmaps.add(bitmap);
}
bitmapMaps.put(key, bitmaps);
}
//如果需要打印印單,加上
List<Bitmap> bitmaps = new ArrayList<>();
bitmaps.add(initPrintView(mContext, dataBean));
merge2ResultMap(bitmapMaps, "", bitmaps);
return bitmapMaps;
}
return null;
}
private void addToMap(Map<String, List<OrderDetails.DataBean.PRODUCTNAMEBean>> foodMaps, OrderDetails.DataBean.PRODUCTNAMEBean food) {
if (foodMaps.get(food.getPrintseting()) != null) {
Objects.requireNonNull(foodMaps.get(food.getPrintseting())).add(food);
} else {
List<OrderDetails.DataBean.PRODUCTNAMEBean> newFoods = new ArrayList<>();
newFoods.add(food);
foodMaps.put(Objects.requireNonNull(food.getPrintseting()), newFoods);
}
}
//獲取廚房單圖片
private Bitmap getOrderKitchenBitmap(Context context, List<OrderDetails.DataBean.PRODUCTNAMEBean> orderDetail, OrderDetails.DataBean dataBean) {
View view = LinearLayout.inflate(context, R.layout.print_other_order_food, null);
TextView tvOrderType = view.findViewById(R.id.tv_order_type);//訂單類型。外賣or自取
TextView tvCreateTime = view.findViewById(R.id.tv_order_create_time);
TextView tvOperator = view.findViewById(R.id.tv_operator_name);//操作人員
TextView tvSendTime = view.findViewById(R.id.tv_order_send_time);
TextView tvOrderNum = view.findViewById(R.id.tv_order_number);
RecyclerView rvFood = view.findViewById(R.id.rv_order_food);
if (dataBean.getOrder_type() == 2) {
tvOrderType.setText("外賣");
} else {
tvOrderType.setText("自取");
}
//送貨時間
if (!TextUtil.isEmptyOrNullOrUndefined(dataBean.getSEND_TIME())) {
tvSendTime.setVisibility(View.VISIBLE);
tvSendTime.setText("送貨時間:" + dataBean.getSEND_TIME());
} else {
tvSendTime.setVisibility(View.GONE);
}
tvOperator.setText("操作:" + GsaCloudApplication.getMemberName(context));
//創建時間
tvCreateTime.setText(TimeUtils.parseTimeRepeat(dataBean.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
//訂單號
tvOrderNum.setText("訂單號:" + dataBean.getORDER_NO());
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(new OtherOrderAdapter(context, orderDetail));
return viewToBitmap(context, view);
}
private Bitmap initPrintView(Context context, OrderDetails.DataBean data) {
View view = LayoutInflater.from(context).inflate(R.layout.print_confirm_order_view, null, false);
// 訂單類型
setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外賣" : "自取");
// 訂單號
setText(view, R.id.tv_order_number, "訂單號:" + data.getORDER_NO());
//訂單創建時間
setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
String amountUnit = context.getString(R.string.amount_unit);
//總金額
setText(view, R.id.tv_total, amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(Objects.requireNonNull(data.getTOTAL_AMOUNT())), data.getLunchbox()), data.getDELIVERY_CHARGE()));
//餐盒費
setAmount(data.getLunchbox(), view.findViewById(R.id.tv_lunchbox_cost_text), view.findViewById(R.id.tv_lunchbox_cost), amountUnit);
//配送費
setAmount(data.getDELIVERY_CHARGE(), view.findViewById(R.id.tv_delivery_fee_text), view.findViewById(R.id.tv_delivery_fee), amountUnit);
//折扣
setAmount(data.getDiscount_amount(), view.findViewById(R.id.tv_discount_text), view.findViewById(R.id.tv_discount), amountUnit);
//總金額
setText(view, R.id.tv_total_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
//支付金額
setText(view, R.id.tv_pay_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
//支付類型:貨到付款,在線支付
setText(view, R.id.tv_pay_type, data.getOrderPayType() == 1 ? "貨到付款" : "在線支付");
//收貨地址
setText(view, R.id.tv_address, context.getString(R.string.address) + data.getAddressDetail());
//收貨人
setText(view, R.id.tv_receiver, "收貨人:" + data.getRECEIVER());
//手機號
setText(view, R.id.tv_phone, "手機號:" + data.getPHONE());
//備註
setText(view, R.id.tv_remark, "備註:" + data.getRemark());
if (data.getPRODUCT_NAME() != null) {
RecyclerView rvFoodList = view.findViewById(R.id.rv_order_print_food);
rvFoodList.setLayoutManager(new LinearLayoutManager(context));
rvFoodList.setAdapter(new OtherOrderAdapter(context, data.getPRODUCT_NAME()));
}
return viewToBitmap(context, view);
}
private void setAmount(Double data, TextView tvText, TextView tvAmount, String amountUnit) {
if (data <= 0) {
tvText.setVisibility(View.GONE);
tvAmount.setVisibility(View.GONE);
} else {
tvText.setVisibility(View.VISIBLE);
tvAmount.setVisibility(View.VISIBLE);
tvAmount.setText(amountUnit + data.toString());
}
}
}
......@@ -29,7 +29,7 @@ import java.util.Map;
/**
* 上菜紙打印
*/
public class PrintServe extends PrinterInIt {
public class PrintServe extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
......
......@@ -30,7 +30,7 @@ import java.util.Map;
/**
* 印單打印
*/
public class PrintSlip extends PrinterInIt {
public class PrintSlip extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
......@@ -44,24 +44,6 @@ public class PrintSlip extends PrinterInIt {
}
/**
* 把Map中Key相同,则各个value添加到一起,汇总值
* 把partMap数据合并放到resultMap中。
*
* @param resultMap
*/
public static <T, F, K extends Collection<F>> Map merge2ResultMap(Map<T, K> resultMap, T key2, K value) {
for (Map.Entry<T, K> entry : resultMap.entrySet()) {
T key = entry.getKey();
if (resultMap.containsKey(key2)) {
resultMap.get(key2).addAll(value);
} else {
resultMap.put(key2, value);
}
}
return resultMap;
}
/**
* 獲取"印單"圖片
*
* @param context
......
......@@ -15,7 +15,7 @@ import java.util.Map;
/**
* 測試頁打印
*/
public class PrintTest extends PrinterInIt {
public class PrintTest extends PrinterRoot {
@Override
......
......@@ -8,6 +8,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
......@@ -40,11 +41,12 @@ import com.sunmi.peripheral.printer.InnerResultCallbcak;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener {
public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener {
public final static int PRINT_TEST = -1;//測試頁
public final static int PRINT_SERVE = 0;//上菜紙
......@@ -52,6 +54,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
public final static int PRINT_BILL = 2;//結賬單
public final static int PRINT_KITCHEN = 3;//送單,廚房單
public final static int PRINT_CLEAN_MACHINE = 4;//清機報表
public final static int PRINT_OTHER_ORDER = 5;//接單內容打印
private final static int SUNMI_PAPER_WIDTH = 360;//商米打印機紙張寬度
private final static int N5_PAPER_WIDTH = 500;//N5打印機紙張寬度
......@@ -62,7 +65,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
private PrintListener printListener;
private Map<String, List<Bitmap>> listMap;
public static PrinterInIt getPrinterByType(int type) {
public static PrinterRoot getPrinterByType(int type) {
if (type == PRINT_TEST) {
return new PrintTest();
} else if (type == PRINT_SERVE) {
......@@ -75,20 +78,44 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
return new PrintKitchen();
} else if (type == PRINT_CLEAN_MACHINE) {
return new PrintCleanMachine();
} else if (type == PRINT_OTHER_ORDER) {
return new PrintOtherOrder();
}
return null;
}
public PrinterInIt setmContext(Context mContext) {
public PrinterRoot setmContext(Context mContext) {
this.mContext = mContext;
return this;
}
public PrinterInIt setPrintListener(PrintListener printListener) {
public PrinterRoot setPrintListener(PrintListener printListener) {
this.printListener = printListener;
return this;
}
public void setText(View parentView, int viewId, String text) {
((TextView) parentView.findViewById(viewId)).setText(text);
}
/**
* 把Map中Key相同,则各个value添加到一起,汇总值
* 把partMap数据合并放到resultMap中。
*
* @param resultMap
*/
public static <T, F, K extends Collection<F>> Map merge2ResultMap(Map<T, K> resultMap, T key2, K value) {
for (Map.Entry<T, K> entry : resultMap.entrySet()) {
T key = entry.getKey();
if (resultMap.containsKey(key2)) {
Objects.requireNonNull(resultMap.get(key2)).addAll(value);
} else {
resultMap.put(key2, value);
}
}
return resultMap;
}
/**
* @param mContext
* @return key為打印位置,值為圖片集合的map
......@@ -102,6 +129,13 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
printListener.printFile();
return;
}
//當配置打印多張時執行
// int x = 2;
// for (int i = 0; i < x; i++) {
// for (Map.Entry<String, List<Bitmap>> entry : listMap.entrySet()) {
// merge2ResultMap(listMap, entry.getKey(), entry.getValue());
// }
// }
// 先不管有沒有默認打印位置
// 第一步先查看map中的key是不是空的"",有key就要獲取打印機列表,找到對應打印機打印。如果沒有找到打印機再去找默認打印機
// 如果沒有key,則是走默認打印機流程
......@@ -259,7 +293,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
int lastIndex = key.lastIndexOf(DELIMITER);
key = key.substring(lastIndex + 1);
if (key.replaceAll("\\*", "").trim().equals(printerDeviceBeans.get(i).getName())) {
if (key.replaceAll("\\*", "").trim().equalsIgnoreCase(printerDeviceBeans.get(i).getName())) {
//如果key(打印位置)去掉*號和打印機名稱相同,則在這台機器上打印
ipDevicePrint(printerDeviceBeans.get(i), bitmaps);
isPrint = true;
......@@ -282,6 +316,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
* @return 打印內容
*/
private List<Bitmap> getPrintBitmapByPrintLocation(String key) {
if (listMap != null) {
for (Map.Entry<String, List<Bitmap>> entry : listMap.entrySet()) {
if (!entry.getKey().equals("")) {
//有打印位置
......@@ -293,6 +328,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
}
}
}
}
return null;
}
......@@ -370,6 +406,10 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
private void showIpPrintDeviceList(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
if (printerDeviceBeans.size() == 1) {
//只有一台ip打印機時,直接打印
ipDevicePrint(printerDeviceBeans.get(0), bitmaps);
} else {
new DialogUtils(mContext, R.layout.print_dialog_internet_list) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
......@@ -389,6 +429,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
.setHeight(ArmsUtils.getScreenHeidth(mContext) / 2)
.createDialogView()
.show();
}
} else {
//沒有打印機,讓用戶去添加
setPrintState(PrintActivity.ADD_PRINT_DEVICE);
......@@ -500,7 +541,7 @@ public abstract class PrinterInIt implements PrintSocketHolder.OnStateChangedLis
recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color)));
adapter.setOnItemClickListener((adapter12, view, position) -> {
//顯示打印失敗的食品。
if(printerFileDevices.get(position).getName() != null) {
if (printerFileDevices.get(position).getName() != null) {
PrintFileBitmapAdapter bitmapAdapter = new PrintFileBitmapAdapter(getPrintBitmapByPrintLocation(printerFileDevices.get(position).getName()));
recyclerView.setAdapter(bitmapAdapter);
}
......
......@@ -33,7 +33,7 @@ import com.joe.print.di.component.DaggerPrintComponent;
import com.joe.print.mvp.contract.PrintContract;
import com.joe.print.mvp.presenter.PrintPresenter;
import com.joe.print.mvp.print.PrintListener;
import com.joe.print.mvp.print.PrinterInIt;
import com.joe.print.mvp.print.PrinterRoot;
import java.util.ArrayList;
import java.util.List;
......@@ -68,7 +68,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
public final static int ADD_PRINT_DEVICE = 1004;//添加打印機
private String callId;
private PrinterInIt printerInIt;
private PrinterRoot printerInIt;
private Dialog mLoadingDialog;
private TextView mTvLoadingTip;
......@@ -100,7 +100,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
* 1:印單
* 2:結賬單
* 3:廚房單
* 4:清機報表
* 4:打印view
*/
int type = CCUtil.getNavigateParam(this, "type", -1);
......@@ -108,22 +108,22 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
PrinterDeviceBean deviceBean = (PrinterDeviceBean) getIntent().getSerializableExtra("deviceBean");
if (type != PrinterInIt.PRINT_TEST) {
// if (type != PrinterRoot.PRINT_TEST) {
//不是测试才去获取打印机列表,获取到打印机列表之后就进行打印
mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
}
// }
printerInIt = PrinterInIt.getPrinterByType(type);
printerInIt = PrinterRoot.getPrinterByType(type);
if (printerInIt != null) {
printerInIt.setmContext(mContext).setPrintListener(this);
}
if (type == PrinterInIt.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, "测试失败");
// }
// }
}
private void initDialog() {
......@@ -138,9 +138,10 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
// window.getDecorView().setBackgroundResource(android.R.color.transparent);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
if (!this.isFinishing()) {
mLoadingDialog.show();
// mLoadingDialog.setOnDismissListener(dialog -> dismiss());
setLoadingText("加載中...");
}
} catch (Exception e) {
e.printStackTrace();
}
......@@ -330,4 +331,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mLoadingDialog != null) {
mLoadingDialog.dismiss();
}
}
}
package com.joe.print.mvp.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import com.joe.print.R;
import java.math.BigDecimal;
import java.util.List;
import static com.qmuiteam.qmui.util.QMUIDisplayHelper.dp2px;
public class OtherOrderAdapter extends BaseQuickAdapter<OrderDetails.DataBean.PRODUCTNAMEBean, BaseViewHolder> {
private Context context;
private int indentation;
public OtherOrderAdapter(Context context, @Nullable List<OrderDetails.DataBean.PRODUCTNAMEBean> data) {
super(R.layout.print_other_order_food_item, data);
this.context = context;
}
@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_price, item.getPRICE());
if (helper.getAdapterPosition() == 0) {
indentation = new BigDecimal(((TextView) helper.getView(R.id.tv_food_name)).getPaint().measureText("哈")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
}
if (item.getChild() != null && item.getChild().size() > 0) {
LinearLayout childLayout = helper.getView(R.id.layout_food_content);
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX : item.getChild()) {
View secondView = getChild(childBeanX.getPRODUCT_NAME(), childBeanX.getNum(), childBeanX.getPRICE(), indentation);
childLayout.addView(secondView);
if (childBeanX.getChild() != null && childBeanX.getChild().size() > 0) {
LinearLayout secondLayout = secondView.findViewById(R.id.layout_food_content);
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean childBean : childBeanX.getChild()) {
secondLayout.addView(getChild(childBean.getPRODUCT_NAME(), childBean.getNum(), childBean.getPRICE(), indentation * 2));
}
}
}
}
}
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);
return view;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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" />
<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='訂單號' />
<TextView
android:id="@+id/tv_order_create"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='下單時間' />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:textColor="@color/theme_333_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_print_food"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:singleLine="true"
android:text="------------------"
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">
<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"
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_toTopOf="parent" />
<TextView
android:id="@+id/tv_total"
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" />
<TextView
android:id="@+id/tv_lunchbox_cost_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" />
<TextView
android:id="@+id/tv_lunchbox_cost"
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_lunchbox_cost_text" />
<TextView
android:id="@+id/tv_delivery_fee_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_lunchbox_cost" />
<TextView
android:id="@+id/tv_delivery_fee"
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_delivery_fee_text" />
<TextView
android:id="@+id/tv_discount_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_delivery_fee" />
<TextView
android:id="@+id/tv_discount"
style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_discount_text" />
<TextView
android:id="@+id/tv_total_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_discount" />
<TextView
android:id="@+id/tv_total_amount"
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_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" />
<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"
app:layout_constraintTop_toTopOf="@id/tv_pay_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_pay_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="貨到付款"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_26" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="---------------------------------------------------------------------------------------------------"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_address"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_receiver"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_phone"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_remark"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- 接單的廚房單-->
<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_26" />
<TextView
android:id="@+id/tv_order_create_time"
style="@style/print_other_order_eighteen_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="廚房時間:12346546" />
<TextView
android:id="@+id/tv_operator_name"
style="@style/print_other_order_eighteen_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="操作test" />
<TextView
android:id="@+id/tv_order_send_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送貨時間:04-15"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_22" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_food"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/print_split_line" />
<TextView
android:id="@+id/tv_order_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="訂單號:000032"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_18" />
</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:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_6">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintHorizontal_weight="0.7"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_food_number"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_food_item_next"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/item_next"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/tv_food_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_food_name" />
<TextView
android:id="@+id/tv_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_20"
app:layout_constraintLeft_toRightOf="@id/iv_food_item_next"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_food_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_20"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/layout_food_name"
app:layout_constraintRight_toLeftOf="@id/tv_food_price"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<TextView
android:id="@+id/tv_food_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/theme_333_color"
android:visibility="gone"
android:textSize="@dimen/dp_20"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/tv_food_number"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<LinearLayout
android:id="@+id/layout_food_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@id/layout_food_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -35,7 +35,8 @@
android:layout_weight="0.7"
android:background="@null"
android:hint="請輸入打印機名稱"
android:maxLines="1"
android:maxLength="20"
android:singleLine="true"
android:textColor="@color/normal_color"
android:textColorHint="@color/hint_color"
android:textSize="@dimen/dp_14">
......
<resources>
<string name="app_name">print-Module</string>
<string name="print_ip">IP:%1$s</string>
<string name="print_port">端口號:%1$s</string>
<string name="create_order_time">下單時間:</string>
<string name="address">地址:</string>
</resources>
......@@ -17,4 +17,19 @@
<item name="android:paddingTop">@dimen/printer_add_input_paddingTop</item>
<item name="android:paddingBottom">@dimen/printer_add_input_paddingBottom</item>
</style>
<style name="print_other_order_eighteen_style">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_18</item>
</style>
<style name="printOtherOrderTextStyle_font_style_twenty" parent="font_style_twenty">
<item name="android:textColor">@color/theme_333_color</item>
</style>
<style name="printOtherOrderInfoPrintBoldTextStyle">
<item name="android:textSize">@dimen/dp_18</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
\ No newline at end of file
......@@ -69,7 +69,7 @@ dependencies {
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
api rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
implementation rootProject.ext.dependencies["fastjson"]
implementation rootProject.ext.dependencies["zxing"]
implementation rootProject.ext.dependencies["progressmanager"]
......
......@@ -5,11 +5,13 @@ import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 作者:ELEGANT_BIN
......@@ -45,7 +47,7 @@ public class OrderDetail implements Serializable {
//折扣比例
private double PERCENTAGE = 0.00;
//套餐编號
private long comid ;
private long comid;
//細項編號
private long mid;
//修改数量前的数量
......@@ -686,7 +688,7 @@ public class OrderDetail implements Serializable {
*/
public static OrderDetail discountTransOrderDetail(Discount discount, double sourcePrice) {
double discountPrice = Discount.calculationDiscount(discount,sourcePrice);
double discountPrice = Discount.calculationDiscount(discount, sourcePrice);
OrderDetail orderDetail = new OrderDetail();
orderDetail.setProductName(discount.getRemark());
......@@ -706,4 +708,45 @@ public class OrderDetail implements Serializable {
return orderDetail;
}
public static List<OrderDetail> productNameBeanTransOrderDetail(List<OrderDetails.DataBean.PRODUCTNAMEBean> orderDetails) {
if (orderDetails != null) {
List<OrderDetail> orderDetailList = new ArrayList<>();
for (OrderDetails.DataBean.PRODUCTNAMEBean bean : orderDetails) {
OrderDetail orderData = new OrderDetail();
orderData.setProductName(bean.getPRODUCT_NAME());
orderData.setPrice(Double.parseDouble(Objects.requireNonNull(bean.getPRICE())));
orderData.setNumber(Integer.parseInt(Objects.requireNonNull(bean.getNum())));
orderData.setPrintseting(bean.getPrintseting());
orderData.setItemType(1);
if (bean.getChild() != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX childBeanX : bean.getChild()) {
OrderDetail childOrderData = new OrderDetail();
childOrderData.setProductName(childBeanX.getPRODUCT_NAME());
childOrderData.setPrice(Double.parseDouble(Objects.requireNonNull(childBeanX.getPRICE())));
childOrderData.setNumber(Integer.parseInt(Objects.requireNonNull(childBeanX.getNum())));
childOrderData.setPrintseting(childBeanX.getPrintseting());
childOrderData.setItemType(2);
if (childBeanX.getChild() != null) {
for (OrderDetails.DataBean.PRODUCTNAMEBean.ChildBeanX.ChildBean childBean : childBeanX.getChild()) {
OrderDetail childOrderData2 = new OrderDetail();
childOrderData2.setProductName(childBean.getPRODUCT_NAME());
childOrderData2.setPrice(Double.parseDouble(Objects.requireNonNull(childBean.getPRICE())));
childOrderData2.setNumber(Integer.parseInt(Objects.requireNonNull(childBean.getNum())));
childOrderData2.setPrintseting(childBean.getPrintseting());
childOrderData2.setItemType(3);
orderDetailList.add(childOrderData2);
}
}
orderDetailList.add(childOrderData);
}
}
orderDetailList.add(orderData);
}
return orderDetailList;
}
return null;
}
}
......@@ -6,6 +6,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod;
import com.gingersoft.gsa.cloud.print.bean.OrderDetails;
import java.util.ArrayList;
import java.util.Date;
......@@ -21,6 +22,8 @@ import java.util.List;
public class MyOrderManage {
private static MyOrderManage myOrderManage;
//外賣接單
private static OrderDetails.DataBean dataBean;
public static MyOrderManage getInstance() {
if (myOrderManage == null) {
......@@ -1107,6 +1110,14 @@ public class MyOrderManage {
this.select_Full_end_position = select_Full_end_position;
}
public static OrderDetails.DataBean getDataBean() {
return dataBean;
}
public static void setDataBean(OrderDetails.DataBean dataBean) {
MyOrderManage.dataBean = dataBean;
}
public int getSeqno() {
return seqno;
}
......
......@@ -60,7 +60,7 @@ public class CommonConfiguration {
*/
public void saveModifierTopIdConfiguration(List<Modifier> datas) {
for (Modifier datasBean : datas) {
if (datasBean.getMid() != 0 && datasBean.getTopId() != 0) {
if (datasBean.getMid() != null && datasBean.getTopId() != null && datasBean.getMid() != 0 && datasBean.getTopId() != 0) {
mModifierTopIdList.put(Integer.parseInt(datasBean.getMid() + ""), datasBean.getTopId());
}
}
......
......@@ -452,11 +452,11 @@ public class TimeUtils {
try {
date = new Date(time);
} catch (IllegalArgumentException e) {
e.printStackTrace();
// e.printStackTrace();
try {
date = dateFormat.parse(time);
} catch (ParseException ex) {
ex.printStackTrace();
// ex.printStackTrace();
}
}
if (date != null) {
......@@ -464,6 +464,4 @@ public class TimeUtils {
}
return time;
}
}
......@@ -6,6 +6,8 @@ import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
......@@ -13,6 +15,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -32,6 +35,8 @@ public abstract class DialogUtils {
private int style = R.style.PhotoDialog;
private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT;
private int mHeight = WindowManager.LayoutParams.WRAP_CONTENT;
private int mMaxHeight;
private ViewHepler viewHepler;
public DialogUtils(Context mContext, int xmlLayout) {
this.mContext = mContext;
......@@ -53,19 +58,24 @@ public abstract class DialogUtils {
return this;
}
public DialogUtils setMaxHeight(int maxHeight) {
mMaxHeight = maxHeight;
return this;
}
public DialogUtils createDialogView() {
dialog = new Dialog(mContext, style);
final ViewHepler viewHepler = getViewHepler();
viewHepler = getViewHepler();
initLayout(viewHepler, dialog);
dialog.setContentView(viewHepler.getContentView());
Window dialogWindow = dialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
// WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER);
//将对话框的大小按屏幕大小的百分比设置
// WindowManager m = activity.getWindowManager();
// Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
......@@ -73,6 +83,18 @@ public abstract class DialogUtils {
}
p.height = mHeight;
p.width = mWidth;
// WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// DisplayMetrics metrics = new DisplayMetrics();
// wm.getDefaultDisplay().getMetrics(metrics);
//
// if (metrics.heightPixels < mMaxHeight) {
// dialog.getWindow().setLayout(mWidth, mHeight);
// } else {
// dialog.getWindow().setLayout(mWidth, mMaxHeight);
// }
dialogWindow.setAttributes(p);
// android Activity改成dialog样式后 怎设置点击空白处关闭窗体,点击窗体以外的地方关闭窗体
dialog.setCanceledOnTouchOutside(true);
......@@ -81,6 +103,7 @@ public abstract class DialogUtils {
return this;
}
public Dialog getDialog() {
return dialog;
}
......@@ -92,11 +115,26 @@ public abstract class DialogUtils {
return this;
}
public DialogUtils setGravity(int gravity) {
if (dialog != null && dialog.getWindow() != null) {
dialog.getWindow().setGravity(gravity);
}
return this;
}
public DialogUtils show() {
dialog.show();
return this;
}
public View getView() {
if (viewHepler != null) {
return viewHepler.getContentView();
} else {
return null;
}
}
public boolean isShowing() {
return dialog != null && dialog.isShowing();
}
......
......@@ -19,6 +19,7 @@ package com.gingersoft.gsa.cloud.print;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.util.Log;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
......@@ -51,7 +52,7 @@ public class PrintSocketHolder {
public static final int ERROR_6 = -6;// 关闭Socket出错
public static final int ERROR_100 = -100;// 失败
private static final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");//蓝牙打印UUID
// private String ip;
// private String ip;
// private int port = 9100;
private PrinterDeviceBean printerDeviceBean;
private BluetoothDevice mDevice;
......@@ -83,9 +84,12 @@ public class PrintSocketHolder {
//设置 超时时间
socket.setSoTimeout(PrintConstans.SO_TIMEOUT);
socket.connect(socketAddress, PrintConstans.PRINT_TIMEOUT);//开始连接ip
Log.e("eee", "連接狀態:" + socket.isConnected());
}
} catch (Exception e) {
closeSocket();
Log.e("eee", "連接報錯:" + e.getMessage());
e.printStackTrace();
return ERROR_2;
}
return ERROR_0;
......@@ -123,6 +127,7 @@ public class PrintSocketHolder {
return ERROR_4;
}
}
closeSocket();//成功後關閉連接
return ERROR_0;
}
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
package com.gingersoft.gsa.cloud.print.bean
class OrderDetails {
......@@ -8,33 +8,9 @@ class OrderDetails {
* data : [{"Order_ID":50349,"NUMBER":1,"MEMBER_NAME":"忆逝1","PRICE":88,"discount_amount":0,"PHONE":"15728241877","ORDER_NO":"26202811401145744","Lunchbox":0,"remark":"","pid":0,"PRODUCT_NAME":[{"odsId":"1650249","PRICE":"88.0","num":"1","pid":"0","PRODUCT_NAME":"脆炸粟米蟹肉餅"}],"odsId":1650249,"addressDetail":"香港長沙灣青山道479 - 479A號麗昌工廠大廈 704 室及 802 室(接待處於 704 室蘋果迷你倉 - 荔枝角 (麗昌分店)分店","DELIVERY_CHARGE":0,"order_from":7,"sender":"","SEND_TIME":"盡快送達 18:27","PAY_AMOUNT":88,"ID":50349,"CREATE_TIME":"2020-04-02 17:57:29.0","takeFoodCode":"0","RECEIVER":"張學友 先生","TOTAL_AMOUNT":"88.0"}]
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: List<DataBean>? = null
fun isSuccess(): Boolean {
return success
}
fun setSuccess(success: Boolean) {
this.success = success
}
fun getSysTime(): Long {
return sysTime
}
fun setSysTime(sysTime: Long) {
this.sysTime = sysTime
}
fun getData(): List<DataBean>? {
return data
}
fun setData(data: List<DataBean>) {
this.data = data
}
var success: Boolean = false
var sysTime: Long = 0
var data: List<DataBean>? = null
class DataBean {
/**
......@@ -62,12 +38,12 @@ class OrderDetails {
* RECEIVER : 張學友 先生
* TOTAL_AMOUNT : 88.0
*/
var Order_ID: Int = 0
var NUMBER: Int = 0
var MEMBER_NAME: String? = null
var PRICE: Double = 0.toDouble()
var discount_amount: Double = 0.toDouble()
var takeTime: String? = null
var PHONE: String? = null
var ORDER_NO: String? = null
var Lunchbox: Double = 0.toDouble()
......@@ -85,22 +61,63 @@ class OrderDetails {
var takeFoodCode: String? = null
var RECEIVER: String? = null
var TOTAL_AMOUNT: String? = null
//後台不會返回
var order_type: Int = 0
var orderPayType: Int = 0
var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null
class PRODUCTNAMEBean {
/**
* odsId : 1650249
* PRICE : 88.0
* num : 1
* odsId : 1654481
* PRICE : 760.0
* num : 2
* pid : 0
* PRODUCT_NAME : 脆炸粟米蟹肉餅
* PRODUCT_NAME : Black Pepper Crab
* child : [{"odsId":"1654482","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Pho"},{"odsId":"1654483","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"rice flour"},{"odsId":"1654484","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Tang Meng"},{"odsId":"1654485","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Black Pepper Tiger Prawn"},{"odsId":"1654486","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Chilli Tiger Prawn"},{"odsId":"1654487","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Black Pepper Crab","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"}]},{"odsId":"1654491","PRICE":"0.0","num":"2","pid":"1654481","PRODUCT_NAME":"Kam Heong Crab"}]
*/
var odsId: String? = null
var PRICE: String? = null
var num: String? = null
var pid: String? = null
var PRODUCT_NAME: String? = null
var child: List<ChildBeanX>? = null
var printseting: String? = null
class ChildBeanX {
/**
* odsId : 1654482
* PRICE : 0.0
* num : 2
* pid : 1654481
* 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 PRICE: String? = null
var num: String? = null
var pid: String? = null
var producT_NAME: String? = null
var PRODUCT_NAME: String? = null
var child: List<ChildBean>? = null
var printseting: String? = null
class ChildBean {
/**
* odsId : 1654488
* PRICE : 0.0
* num : 2
* pid : 1654487
* PRODUCT_NAME : Pho
*/
var odsId: String? = null
var PRICE: String? = null
var num: String? = null
var pid: String? = null
var PRODUCT_NAME: String? = null
var printseting: String? = null
}
}
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view;
import android.content.res.ColorStateList;
public class ColorUtils {
private static final int ENABLE_ATTR = android.R.attr.state_enabled;
private static final int CHECKED_ATTR = android.R.attr.state_checked;
private static final int PRESSED_ATTR = android.R.attr.state_pressed;
public static ColorStateList generateThumbColorWithTintColor(final int tintColor) {
int[][] states = new int[][]{
{-ENABLE_ATTR, CHECKED_ATTR},
{-ENABLE_ATTR},
{PRESSED_ATTR, -CHECKED_ATTR},
{PRESSED_ATTR, CHECKED_ATTR},
{CHECKED_ATTR},
{-CHECKED_ATTR}
};
int[] colors = new int[] {
tintColor - 0xAA000000,
0xFFBABABA,
tintColor - 0x99000000,
tintColor - 0x99000000,
tintColor | 0xFF000000,
0xFFEEEEEE
};
return new ColorStateList(states, colors);
}
public static ColorStateList generateBackColorWithTintColor(final int tintColor) {
int[][] states = new int[][]{
{-ENABLE_ATTR, CHECKED_ATTR},
{-ENABLE_ATTR},
{CHECKED_ATTR, PRESSED_ATTR},
{-CHECKED_ATTR, PRESSED_ATTR},
{CHECKED_ATTR},
{-CHECKED_ATTR}
};
int[] colors = new int[] {
tintColor - 0xE1000000,
0x10000000,
tintColor - 0xD0000000,
0x20000000,
tintColor - 0xD0000000,
0x20000000
};
return new ColorStateList(states, colors);
}
}
package com.gingersoft.gsa.cloud.ui.view;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Build;
import android.os.Bundle;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.ViewConfiguration;
import android.view.ViewParent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.CompoundButton;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.base.R;
import org.jetbrains.annotations.NotNull;
public class SwitchButton extends CompoundButton {
public static final float DEFAULT_BACK_MEASURE_RATIO = 1.8f;
public static final int DEFAULT_THUMB_SIZE_DP = 20;
public static final int DEFAULT_THUMB_MARGIN_DP = 2;
public static final int DEFAULT_TEXT_MARGIN_DP = 2;
public static final int DEFAULT_ANIMATION_DURATION = 250;
public static final int DEFAULT_TINT_COLOR = 0x327FC2;
private static int[] CHECKED_PRESSED_STATE = new int[]{android.R.attr.state_checked, android.R.attr.state_enabled, android.R.attr.state_pressed};
private static int[] UNCHECKED_PRESSED_STATE = new int[]{-android.R.attr.state_checked, android.R.attr.state_enabled, android.R.attr.state_pressed};
private Drawable mThumbDrawable, mBackDrawable;
private ColorStateList mBackColor, mThumbColor;
private float mThumbRadius, mBackRadius;
private RectF mThumbMargin;
private float mBackMeasureRatio;
private long mAnimationDuration;
// fade back drawable or color when dragging or animating
private boolean mFadeBack;
private int mTintColor;
private PointF mThumbSizeF;
private int mCurrThumbColor, mCurrBackColor, mNextBackColor, mOnTextColor, mOffTextColor;
private Drawable mCurrentBackDrawable, mNextBackDrawable;
private RectF mThumbRectF, mBackRectF, mSafeRectF, mTextOnRectF, mTextOffRectF;
private Paint mPaint;
// whether using Drawable for thumb or back
private boolean mIsThumbUseDrawable, mIsBackUseDrawable;
private boolean mDrawDebugRect = false;
private ObjectAnimator mProcessAnimator;
// animation control
private float mProcess;
// temp position of thumb when dragging or animating
private RectF mPresentThumbRectF;
private float mStartX, mStartY, mLastX;
private int mTouchSlop;
private int mClickTimeout;
private Paint mRectPaint;
private CharSequence mTextOn;
private CharSequence mTextOff;
private TextPaint mTextPaint;
private Layout mOnLayout;
private Layout mOffLayout;
private float mTextWidth;
private float mTextHeight;
private float mTextMarginH;
private CompoundButton.OnCheckedChangeListener mChildOnCheckedChangeListener;
public SwitchButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}
public SwitchButton(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public SwitchButton(Context context) {
super(context);
init(null);
}
private void init(AttributeSet attrs) {
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint.setStyle(Paint.Style.STROKE);
mRectPaint.setStrokeWidth(getResources().getDisplayMetrics().density);
mTextPaint = getPaint();
mThumbRectF = new RectF();
mBackRectF = new RectF();
mSafeRectF = new RectF();
mThumbSizeF = new PointF();
mThumbMargin = new RectF();
mTextOnRectF = new RectF();
mTextOffRectF = new RectF();
mProcessAnimator = ObjectAnimator.ofFloat(this, "process", 0, 0).setDuration(DEFAULT_ANIMATION_DURATION);
mProcessAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mPresentThumbRectF = new RectF();
Resources res = getResources();
float density = res.getDisplayMetrics().density;
Drawable thumbDrawable = null;
ColorStateList thumbColor = null;
float margin = density * DEFAULT_THUMB_MARGIN_DP;
float marginLeft = 0;
float marginRight = 0;
float marginTop = 0;
float marginBottom = 0;
float thumbWidth = density * DEFAULT_THUMB_SIZE_DP;
float thumbHeight = density * DEFAULT_THUMB_SIZE_DP;
float thumbRadius = density * DEFAULT_THUMB_SIZE_DP / 2;
float backRadius = thumbRadius;
Drawable backDrawable = null;
ColorStateList backColor = null;
float backMeasureRatio = DEFAULT_BACK_MEASURE_RATIO;
int animationDuration = DEFAULT_ANIMATION_DURATION;
boolean fadeBack = true;
int tintColor = Integer.MIN_VALUE;
String textOn = null;
String textOff = null;
float textMarginH = density * DEFAULT_TEXT_MARGIN_DP;
TypedArray ta = attrs == null ? null : getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
if (ta != null) {
thumbDrawable = ta.getDrawable(R.styleable.SwitchButton_kswThumbDrawable);
thumbColor = ta.getColorStateList(R.styleable.SwitchButton_kswThumbColor);
margin = ta.getDimension(R.styleable.SwitchButton_kswThumbMargin, margin);
marginLeft = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginLeft, margin);
marginRight = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginRight, margin);
marginTop = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginTop, margin);
marginBottom = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginBottom, margin);
thumbWidth = ta.getDimension(R.styleable.SwitchButton_kswThumbWidth, thumbWidth);
thumbHeight = ta.getDimension(R.styleable.SwitchButton_kswThumbHeight, thumbHeight);
thumbRadius = ta.getDimension(R.styleable.SwitchButton_kswThumbRadius, Math.min(thumbWidth, thumbHeight) / 2.f);
backRadius = ta.getDimension(R.styleable.SwitchButton_kswBackRadius, thumbRadius + density * 2f);
backDrawable = ta.getDrawable(R.styleable.SwitchButton_kswBackDrawable);
backColor = ta.getColorStateList(R.styleable.SwitchButton_kswBackColor);
backMeasureRatio = ta.getFloat(R.styleable.SwitchButton_kswBackMeasureRatio, backMeasureRatio);
animationDuration = ta.getInteger(R.styleable.SwitchButton_kswAnimationDuration, animationDuration);
fadeBack = ta.getBoolean(R.styleable.SwitchButton_kswFadeBack, true);
tintColor = ta.getColor(R.styleable.SwitchButton_kswTintColor, tintColor);
textOn = ta.getString(R.styleable.SwitchButton_kswTextOn);
textOff = ta.getString(R.styleable.SwitchButton_kswTextOff);
textMarginH = ta.getDimension(R.styleable.SwitchButton_kswTextMarginH, textMarginH);
ta.recycle();
}
// text
mTextOn = textOn;
mTextOff = textOff;
mTextMarginH = textMarginH;
// thumb drawable and color
mThumbDrawable = thumbDrawable;
mThumbColor = thumbColor;
mIsThumbUseDrawable = mThumbDrawable != null;
mTintColor = tintColor;
if (mTintColor == Integer.MIN_VALUE) {
mTintColor = DEFAULT_TINT_COLOR;
}
if (!mIsThumbUseDrawable && mThumbColor == null) {
mThumbColor = ColorUtils.generateThumbColorWithTintColor(mTintColor);
mCurrThumbColor = mThumbColor.getDefaultColor();
}
if (mIsThumbUseDrawable) {
thumbWidth = Math.max(thumbWidth, mThumbDrawable.getMinimumWidth());
thumbHeight = Math.max(thumbHeight, mThumbDrawable.getMinimumHeight());
}
mThumbSizeF.set(thumbWidth, thumbHeight);
// back drawable and color
mBackDrawable = backDrawable;
mBackColor = backColor;
mIsBackUseDrawable = mBackDrawable != null;
if (!mIsBackUseDrawable && mBackColor == null) {
mBackColor = ColorUtils.generateBackColorWithTintColor(mTintColor);
mCurrBackColor = mBackColor.getDefaultColor();
mNextBackColor = mBackColor.getColorForState(CHECKED_PRESSED_STATE, mCurrBackColor);
}
// margin
mThumbMargin.set(marginLeft, marginTop, marginRight, marginBottom);
// size & measure params must larger than 1
mBackMeasureRatio = mThumbMargin.width() >= 0 ? Math.max(backMeasureRatio, 1) : backMeasureRatio;
mThumbRadius = thumbRadius;
mBackRadius = backRadius;
mAnimationDuration = animationDuration;
mFadeBack = fadeBack;
mProcessAnimator.setDuration(mAnimationDuration);
setFocusable(true);
setClickable(true);
// sync checked status
if (isChecked()) {
setProcess(1);
}
}
private Layout makeLayout(CharSequence text) {
return new StaticLayout(text, mTextPaint, (int) Math.ceil(Layout.getDesiredWidth(text, mTextPaint)), Layout.Alignment.ALIGN_CENTER, 1.f, 0, false);
}
public class SwitchButton extends View {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mOnLayout == null && mTextOn != null) {
mOnLayout = makeLayout(mTextOn);
}
if (mOffLayout == null && mTextOff != null) {
mOffLayout = makeLayout(mTextOff);
}
setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec));
}
private float switchElevation;
private float switcherCornerRadius;
boolean isChecked;
private int measureWidth(int widthMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int measuredWidth;
private float iconRadius;
private float iconClipRadius;
private float iconCollapsedWidth;
private float iconHeight = 0f;
int minWidth = ceil(mThumbSizeF.x * mBackMeasureRatio);
if (mIsBackUseDrawable) {
minWidth = Math.max(minWidth, mBackDrawable.getMinimumWidth());
}
float onWidth = mOnLayout != null ? mOnLayout.getWidth() : 0;
float offWidth = mOffLayout != null ? mOffLayout.getWidth() : 0;
if (onWidth != 0 || offWidth != 0) {
mTextWidth = Math.max(onWidth, offWidth) + mTextMarginH * 2 + 10;
float left = minWidth - mThumbSizeF.x;
if (left < mTextWidth) {
minWidth += mTextWidth - left;
}
}
minWidth = Math.max(minWidth, ceil(minWidth + mThumbMargin.left + mThumbMargin.right));
minWidth = Math.max(minWidth, minWidth + getPaddingLeft() + getPaddingRight());
minWidth = Math.max(minWidth, getSuggestedMinimumWidth());
private RectF switcherRect = new RectF(0f, 0f, 0f, 0f);
private Paint switcherPaint = new Paint(Paint.ANTI_ALIAS_FLAG);//繪製switcher按鈕的paint
if (widthMode == MeasureSpec.EXACTLY) {
measuredWidth = Math.max(minWidth, widthSize);
} else {
measuredWidth = minWidth;
if (widthMode == MeasureSpec.AT_MOST) {
measuredWidth = Math.min(measuredWidth, widthSize);
}
}
private RectF iconRect = new RectF(0f, 0f, 0f, 0f);
private RectF iconClipRect = new RectF(0f, 0f, 0f, 0f);
private Paint iconPaint = new Paint(Paint.ANTI_ALIAS_FLAG);//繪製按鈕上的icon
return measuredWidth;
}
private Paint iconClipPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private int measureHeight(int heightMeasureSpec) {
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
int measuredHeight;
private Paint shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Bitmap shadow;
private float shadowOffset;
int minHeight = ceil(Math.max(mThumbSizeF.y, mThumbSizeF.y + mThumbMargin.top + mThumbMargin.right));
float onHeight = mOnLayout != null ? mOnLayout.getHeight() : 0;
float offHeight = mOffLayout != null ? mOffLayout.getHeight() : 0;
if (onHeight != 0 || offHeight != 0) {
mTextHeight = Math.max(onHeight, offHeight);
minHeight = ceil(Math.max(minHeight, mTextHeight));
}
minHeight = Math.max(minHeight, getSuggestedMinimumHeight());
minHeight = Math.max(minHeight, minHeight + getPaddingTop() + getPaddingBottom());
@ColorInt
private int onColor;
@ColorInt
private int offColor;
@ColorInt
private int iconColor;
@ColorInt
private int currentColor;
if (heightMode == MeasureSpec.EXACTLY) {
measuredHeight = Math.max(minHeight, heightSize);
} else {
measuredHeight = minHeight;
if (heightMode == MeasureSpec.AT_MOST) {
measuredHeight = Math.min(measuredHeight, heightSize);
}
}
private float iconProgress = 0f;
return measuredHeight;
}
private AnimatorSet animatorSet = new AnimatorSet();
//默認寬高
private int defHeight = 0;
private int defWidth = 0;
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
Log.e("eee", "onSizeChanged");
if (w != oldw || h != oldh) {
setup();
}
}
private float onClickOffset = 0;
private float iconTranslateX = 0f;
private int ceil(double dimen) {
return (int) Math.ceil(dimen);
}
OnCheckChangedListener checkChangedListener;
/**
* set up the rect of back and thumb
*/
private void setup() {
float thumbTop = getPaddingTop() + Math.max(0, mThumbMargin.top);
float thumbLeft = getPaddingLeft() + Math.max(0, mThumbMargin.left);
private final long SWITCHER_ANIMATION_DURATION = 800L;
private final long COLOR_ANIMATION_DURATION = 300L;
private final long TRANSLATE_ANIMATION_DURATION = 200L;
private final float ON_CLICK_RADIUS_OFFSET = 2f;
private final double BOUNCE_ANIM_AMPLITUDE_IN = 0.2;
private final double BOUNCE_ANIM_AMPLITUDE_OUT = 0.15;
private final double BOUNCE_ANIM_FREQUENCY_IN = 14.5;
private final double BOUNCE_ANIM_FREQUENCY_OUT = 12.0;
if (mOnLayout != null && mOffLayout != null) {
if (mThumbMargin.top + mThumbMargin.bottom > 0) {
// back is higher than thumb
float addition = (getMeasuredHeight() - getPaddingBottom() - getPaddingTop() - mThumbSizeF.y - mThumbMargin.top - mThumbMargin.bottom) / 2;
thumbTop += addition;
}
}
private final String STATE = "switch_state";
private final String KEY_CHECKED = "checked";
if (mIsThumbUseDrawable) {
mThumbSizeF.x = Math.max(mThumbSizeF.x, mThumbDrawable.getMinimumWidth());
mThumbSizeF.y = Math.max(mThumbSizeF.y, mThumbDrawable.getMinimumHeight());
}
public SwitchButton(Context context) {
this(context, null);
mThumbRectF.set(thumbLeft, thumbTop, thumbLeft + mThumbSizeF.x, thumbTop + mThumbSizeF.y);
float backLeft = mThumbRectF.left - mThumbMargin.left;
float textDiffWidth = Math.min(0, (Math.max(mThumbSizeF.x * mBackMeasureRatio, mThumbSizeF.x + mTextWidth) - mThumbRectF.width() - mTextWidth) / 2);
float textDiffHeight = Math.min(0, (mThumbRectF.height() + mThumbMargin.top + mThumbMargin.bottom - mTextHeight) / 2);
mBackRectF.set(backLeft + textDiffWidth,
mThumbRectF.top - mThumbMargin.top + textDiffHeight,
backLeft + mThumbMargin.left + Math.max(mThumbSizeF.x * mBackMeasureRatio, mThumbSizeF.x + mTextWidth) + mThumbMargin.right + textDiffWidth,
mThumbRectF.bottom + mThumbMargin.bottom - textDiffHeight);
mSafeRectF.set(mThumbRectF.left, 0, mBackRectF.right - mThumbMargin.right - mThumbRectF.width(), 0);
float minBackRadius = Math.min(mBackRectF.width(), mBackRectF.height()) / 2.f;
mBackRadius = Math.min(minBackRadius, mBackRadius);
if (mBackDrawable != null) {
mBackDrawable.setBounds((int) mBackRectF.left, (int) mBackRectF.top, ceil(mBackRectF.right), ceil(mBackRectF.bottom));
}
public SwitchButton(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
if (mOnLayout != null) {
float marginOnX = mBackRectF.left + (mBackRectF.width() - mThumbRectF.width() - mOnLayout.getWidth()) / 2 - mThumbMargin.left + mTextMarginH * (mThumbMargin.left > 0 ? 1 : -1);
float marginOnY = mBackRectF.top + (mBackRectF.height() - mOnLayout.getHeight()) / 2;
mTextOnRectF.set(marginOnX, marginOnY, marginOnX + mOnLayout.getWidth(), marginOnY + mOnLayout.getHeight());
}
public SwitchButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr);
if (mOffLayout != null) {
float marginOffX = mBackRectF.right - (mBackRectF.width() - mThumbRectF.width() - mOffLayout.getWidth()) / 2 + mThumbMargin.right - mOffLayout.getWidth() - mTextMarginH * (mThumbMargin.right > 0 ? 1 : -1);
float marginOffY = mBackRectF.top + (mBackRectF.height() - mOffLayout.getHeight()) / 2;
mTextOffRectF.set(marginOffX, marginOffY, marginOffX + mOffLayout.getWidth(), marginOffY + mOffLayout.getHeight());
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
private void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwitchButton, defStyleAttr, R.style.MySwitcher);
switchElevation = typedArray.getDimension(R.styleable.SwitchButton_elevation, 0f);
onColor = typedArray.getColor(R.styleable.SwitchButton_switcherBtn_on_color, 0);
offColor = typedArray.getColor(R.styleable.SwitchButton_switcherBtn_off_color, 0);
iconColor = typedArray.getColor(R.styleable.SwitchButton_switcherBtn_icon_color, 0);
isChecked = typedArray.getBoolean(R.styleable.SwitchButton_android_checked, true);
// fade back
if (mIsBackUseDrawable) {
if (mFadeBack && mCurrentBackDrawable != null && mNextBackDrawable != null) {
int alpha = (int) (255 * (isChecked() ? getProcess() : (1 - getProcess())));
mCurrentBackDrawable.setAlpha(alpha);
mCurrentBackDrawable.draw(canvas);
alpha = 255 - alpha;
mNextBackDrawable.setAlpha(alpha);
mNextBackDrawable.draw(canvas);
} else {
mBackDrawable.setAlpha(255);
mBackDrawable.draw(canvas);
}
} else {
if (mFadeBack) {
int alpha;
int colorAlpha;
// curr back
alpha = (int) (255 * (isChecked() ? getProcess() : (1 - getProcess())));
colorAlpha = Color.alpha(mCurrBackColor);
colorAlpha = colorAlpha * alpha / 255;
mPaint.setARGB(colorAlpha, Color.red(mCurrBackColor), Color.green(mCurrBackColor), Color.blue(mCurrBackColor));
canvas.drawRoundRect(mBackRectF, mBackRadius, mBackRadius, mPaint);
// next back
alpha = 255 - alpha;
colorAlpha = Color.alpha(mNextBackColor);
colorAlpha = colorAlpha * alpha / 255;
mPaint.setARGB(colorAlpha, Color.red(mNextBackColor), Color.green(mNextBackColor), Color.blue(mNextBackColor));
canvas.drawRoundRect(mBackRectF, mBackRadius, mBackRadius, mPaint);
mPaint.setAlpha(255);
} else {
mPaint.setColor(mCurrBackColor);
canvas.drawRoundRect(mBackRectF, mBackRadius, mBackRadius, mPaint);
}
}
// text
Layout switchText = getProcess() > 0.5 ? mOnLayout : mOffLayout;
RectF textRectF = getProcess() > 0.5 ? mTextOnRectF : mTextOffRectF;
if (switchText != null && textRectF != null) {
int alpha = (int) (255 * (getProcess() >= 0.75 ? getProcess() * 4 - 3 : (getProcess() < 0.25 ? 1 - getProcess() * 4 : 0)));
int textColor = getProcess() > 0.5 ? mOnTextColor : mOffTextColor;
int colorAlpha = Color.alpha(textColor);
colorAlpha = colorAlpha * alpha / 255;
switchText.getPaint().setARGB(colorAlpha, Color.red(textColor), Color.green(textColor), Color.blue(textColor));
canvas.save();
canvas.translate(textRectF.left, textRectF.top);
switchText.draw(canvas);
canvas.restore();
}
// thumb
mPresentThumbRectF.set(mThumbRectF);
mPresentThumbRectF.offset(mProcess * mSafeRectF.width(), 0);
if (mIsThumbUseDrawable) {
mThumbDrawable.setBounds((int) mPresentThumbRectF.left, (int) mPresentThumbRectF.top, ceil(mPresentThumbRectF.right), ceil(mPresentThumbRectF.bottom));
mThumbDrawable.draw(canvas);
} else {
mPaint.setColor(mCurrThumbColor);
canvas.drawRoundRect(mPresentThumbRectF, mThumbRadius, mThumbRadius, mPaint);
}
if (!isChecked) {
setIconProgress(1f);
if (mDrawDebugRect) {
mRectPaint.setColor(Color.parseColor("#AA0000"));
canvas.drawRect(mBackRectF, mRectPaint);
mRectPaint.setColor(Color.parseColor("#0000FF"));
canvas.drawRect(mPresentThumbRectF, mRectPaint);
mRectPaint.setColor(Color.parseColor("#00CC00"));
canvas.drawRect(getProcess() > 0.5 ? mTextOnRectF : mTextOffRectF, mRectPaint);
}
}
if (isChecked) {
setCurrentColor(onColor);
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
Log.e("eee", "drawableStateChanged");
if (!mIsThumbUseDrawable && mThumbColor != null) {
mCurrThumbColor = mThumbColor.getColorForState(getDrawableState(), mCurrThumbColor);
} else {
setCurrentColor(offColor);
setDrawableState(mThumbDrawable);
}
iconPaint.setColor(iconColor);
defHeight = typedArray.getDimensionPixelOffset(R.styleable.SwitchButton_switcherBtn_height, 0);
defWidth = typedArray.getDimensionPixelOffset(R.styleable.SwitchButton_switcherBtn_width, 0);
int[] nextState = isChecked() ? UNCHECKED_PRESSED_STATE : CHECKED_PRESSED_STATE;
ColorStateList textColors = getTextColors();
if (textColors != null) {
int defaultTextColor = textColors.getDefaultColor();
mOnTextColor = textColors.getColorForState(CHECKED_PRESSED_STATE, defaultTextColor);
mOffTextColor = textColors.getColorForState(UNCHECKED_PRESSED_STATE, defaultTextColor);
}
if (!mIsBackUseDrawable && mBackColor != null) {
mCurrBackColor = mBackColor.getColorForState(getDrawableState(), mCurrBackColor);
mNextBackColor = mBackColor.getColorForState(nextState, mCurrBackColor);
} else {
if (mBackDrawable instanceof StateListDrawable && mFadeBack) {
mBackDrawable.setState(nextState);
mNextBackDrawable = mBackDrawable.getCurrent().mutate();
} else {
mNextBackDrawable = null;
}
setDrawableState(mBackDrawable);
if (mBackDrawable != null) {
mCurrentBackDrawable = mBackDrawable.getCurrent().mutate();
}
}
}
typedArray.recycle();
//
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.e("eee", "onTouchEvent");
if (!isEnabled() || !isClickable()) {
return false;
}
int action = event.getAction();
float deltaX = event.getX() - mStartX;
float deltaY = event.getY() - mStartY;
// status the view going to change to when finger released
boolean nextStatus;
switch (action) {
case MotionEvent.ACTION_DOWN:
catchView();
mStartX = event.getX();
mStartY = event.getY();
mLastX = mStartX;
setPressed(true);
break;
case MotionEvent.ACTION_MOVE:
float x = event.getX();
setProcess(getProcess() + (x - mLastX) / mSafeRectF.width());
mLastX = x;
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
setPressed(false);
nextStatus = getStatusBasedOnPos();
float time = event.getEventTime() - event.getDownTime();
if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
performClick();
} else {
if (nextStatus != isChecked()) {
playSoundEffect(SoundEffectConstants.CLICK);
setChecked(nextStatus);
} else {
animateToState(nextStatus);
}
}
break;
if (!isLollipopAndAbove() && switchElevation > 0f) {
shadowPaint.setColorFilter(new PorterDuffColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN));
shadowPaint.setAlpha(51); // 20%
setShadowBlurRadius(switchElevation);
setLayerType(LAYER_TYPE_SOFTWARE, null);
default:
break;
}
setOnClickListener(v -> animateSwitch());
return true;
}
float iconTranslateA;
float iconTranslateB;
public void setOnClickOffset(float onClickOffset) {
this.onClickOffset = onClickOffset;
switcherRect.left = onClickOffset + shadowOffset;
switcherRect.top = onClickOffset + shadowOffset / 2;
switcherRect.right = getWidth() - onClickOffset - shadowOffset;
switcherRect.bottom = getHeight() - onClickOffset - shadowOffset - shadowOffset / 2;
if (!isLollipopAndAbove()) {
generateShadow();
/**
* return the status based on position of thumb
*
* @return
*/
public boolean getStatusBasedOnPos() {
return getProcess() > 0.5f;
}
public final float getProcess() {
return mProcess;
}
public final void setProcess(final float process) {
float tp = process;
if (tp > 1) {
tp = 1;
} else if (tp < 0) {
tp = 0;
}
this.mProcess = tp;
invalidate();
}
public void setCurrentColor(int currentColor) {
this.currentColor = currentColor;
switcherPaint.setColor(currentColor);
iconClipPaint.setColor(currentColor);
@Override
public boolean performClick() {
Log.e("eee", "performClick" + !getStatusBasedOnPos());
// return super.performClick();
// animateToState(!getStatusBasedOnPos());
if (onClickListener != null) {
onClickListener.onClick(this);
return true;
}
return false;
}
public void setIconProgress(float value) {
if (iconProgress != value) {
iconProgress = value;
float iconOffset = lerp(0f, iconRadius - iconCollapsedWidth / 2, value);
iconRect.left = getWidth() - switcherCornerRadius - iconCollapsedWidth / 2 - iconOffset;
iconRect.right = getWidth() - switcherCornerRadius + iconCollapsedWidth / 2 + iconOffset;
private OnClickListener onClickListener;
float clipOffset = lerp(0f, iconClipRadius, value);
iconClipRect.set(
iconRect.centerX() - clipOffset,
iconRect.centerY() - clipOffset,
iconRect.centerX() + clipOffset,
iconRect.centerY() + clipOffset
);
if (!isLollipopAndAbove()) {
generateShadow();
public void setOnClickListener(OnClickListener onClickListener) {
this.onClickListener = onClickListener;
}
postInvalidateOnAnimation();
/**
* processing animation
*
* @param checked checked or unChecked
*/
protected void animateToState(boolean checked) {
if (mProcessAnimator == null) {
return;
}
if (mProcessAnimator.isRunning()) {
mProcessAnimator.cancel();
}
mProcessAnimator.setDuration(mAnimationDuration);
if (checked) {
mProcessAnimator.setFloatValues(mProcess, 1f);
} else {
mProcessAnimator.setFloatValues(mProcess, 0);
}
mProcessAnimator.start();
}
private void animateSwitch() {
if (checkChangedListener != null) {
checkChangedListener.onChanged(!isChecked);
private void catchView() {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
}
animatorSet.cancel();
animatorSet = new AnimatorSet();
setOnClickOffset(ON_CLICK_RADIUS_OFFSET);
@Override
public void setChecked(final boolean checked) {
Log.e("eee", "setChecked");
// animate before super.setChecked() become user may call setChecked again in OnCheckedChangedListener
if (isChecked() != checked) {
animateToState(checked);
}
super.setChecked(checked);
}
double amplitude = BOUNCE_ANIM_AMPLITUDE_IN;
double frequency = BOUNCE_ANIM_FREQUENCY_IN;
iconTranslateA = 0f;
iconTranslateB = -(getWidth() - shadowOffset - switcherCornerRadius * 2);
float newProgress = 1f;
public void setCheckedNoEvent(final boolean checked) {
if (mChildOnCheckedChangeListener == null) {
setChecked(checked);
} else {
super.setOnCheckedChangeListener(null);
setChecked(checked);
setOnCheckedChangeListener(mChildOnCheckedChangeListener);
}
}
if (!isChecked) {
amplitude = BOUNCE_ANIM_AMPLITUDE_OUT;
frequency = BOUNCE_ANIM_FREQUENCY_OUT;
iconTranslateA = iconTranslateB;
iconTranslateB = -shadowOffset;
newProgress = 0f;
public void setCheckedImmediatelyNoEvent(boolean checked) {
if (mChildOnCheckedChangeListener == null) {
setCheckedImmediately(checked);
} else {
super.setOnCheckedChangeListener(null);
setCheckedImmediately(checked);
setOnCheckedChangeListener(mChildOnCheckedChangeListener);
}
}
ValueAnimator switcherAnimator = ValueAnimator.ofFloat(iconProgress, newProgress);
switcherAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setIconProgress((float) animation.getAnimatedValue());
public void toggleNoEvent() {
if (mChildOnCheckedChangeListener == null) {
toggle();
} else {
super.setOnCheckedChangeListener(null);
toggle();
setOnCheckedChangeListener(mChildOnCheckedChangeListener);
}
}
});
switcherAnimator.setInterpolator(new BounceInterpolator(amplitude, frequency));
switcherAnimator.setDuration(SWITCHER_ANIMATION_DURATION);
ValueAnimator translateAnimator = ValueAnimator.ofFloat(0f, 1f);
translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
iconTranslateX = lerp(iconTranslateA, iconTranslateB, value);
public void toggleImmediatelyNoEvent() {
if (mChildOnCheckedChangeListener == null) {
toggleImmediately();
} else {
super.setOnCheckedChangeListener(null);
toggleImmediately();
setOnCheckedChangeListener(mChildOnCheckedChangeListener);
}
}
});
translateAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
onClickOffset = 0f;
public void setOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
super.setOnCheckedChangeListener(onCheckedChangeListener);
Log.e("eee", "setOnCheckedChangeListener");
mChildOnCheckedChangeListener = onCheckedChangeListener;
}
});
translateAnimator.setDuration(TRANSLATE_ANIMATION_DURATION);
int toColor;
if (!isChecked) {
toColor = onColor;
} else {
toColor = offColor;
public void setCheckedImmediately(boolean checked) {
super.setChecked(checked);
if (mProcessAnimator != null && mProcessAnimator.isRunning()) {
mProcessAnimator.cancel();
}
setProcess(checked ? 1 : 0);
invalidate();
}
iconClipPaint.setColor(toColor);
public void toggleImmediately() {
setCheckedImmediately(!isChecked());
}
ValueAnimator colorAnimator = new ValueAnimator();
colorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setCurrentColor((int) animation.getAnimatedValue());
}
});
colorAnimator.setIntValues(currentColor, toColor);
colorAnimator.setEvaluator(new ArgbEvaluator());
colorAnimator.setDuration(COLOR_ANIMATION_DURATION);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
isChecked = !isChecked;
private void setDrawableState(Drawable drawable) {
if (drawable != null) {
int[] myDrawableState = getDrawableState();
drawable.setState(myDrawableState);
invalidate();
}
});
animatorSet.playTogether(switcherAnimator, translateAnimator, colorAnimator);
animatorSet.start();
}
private void setShadowBlurRadius(Float elevation) {
float maxElevation = dip2px(getContext(), 24f);
switchElevation = Math.min(25f * (elevation / maxElevation), 25f);
public boolean isDrawDebugRect() {
return mDrawDebugRect;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
public void setDrawDebugRect(boolean drawDebugRect) {
mDrawDebugRect = drawDebugRect;
invalidate();
}
if (widthMode != MeasureSpec.EXACTLY || heightMode != MeasureSpec.EXACTLY) {
width = defWidth;
height = defHeight;
public long getAnimationDuration() {
return mAnimationDuration;
}
//不是21以上,寬高需要加上z軸*2
if (!isLollipopAndAbove()) {
width += switchElevation * 2;
height += switchElevation * 2;
public void setAnimationDuration(long animationDuration) {
mAnimationDuration = animationDuration;
}
setMeasuredDimension(width, height);
public Drawable getThumbDrawable() {
return mThumbDrawable;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (isLollipopAndAbove()) {//21以上
setOutlineProvider(new SwitchOutline(w, h));
setElevation(switchElevation);
} else {
shadowOffset = switchElevation;
iconTranslateX = -shadowOffset;
}
this.switcherRect.left = this.shadowOffset;
this.switcherRect.top = this.shadowOffset / (float) 2;
this.switcherRect.right = (float) this.getWidth() - this.shadowOffset;
this.switcherRect.bottom = (float) this.getHeight() - this.shadowOffset - this.shadowOffset / (float) 2;
//圓角為高度的一半
this.switcherCornerRadius = ((float) this.getHeight() - this.shadowOffset * (float) 2) / 2.0F;
//內部的icon圓角為按鈕圓角的0.6倍
this.iconRadius = this.switcherCornerRadius * 0.6F;
//應該是圓的圓角
this.iconClipRadius = this.iconRadius / 2.25F;//icon剪輯半徑
//
this.iconCollapsedWidth = this.iconRadius - this.iconClipRadius;
this.iconHeight = this.iconRadius * 2.0F;
//left 為寬度減去 按鈕圓角 減去
this.iconRect.set((float) this.getWidth() - this.switcherCornerRadius - this.iconCollapsedWidth / (float) 2, ((float) this.getHeight() - this.iconHeight) / 2.0F - this.shadowOffset / (float) 2, (float) this.getWidth() - this.switcherCornerRadius + this.iconCollapsedWidth / (float) 2, (float) this.getHeight() - ((float) this.getHeight() - this.iconHeight) / 2.0F - this.shadowOffset / (float) 2);
if (!this.isChecked) {
this.iconRect.left = (float) this.getWidth() - this.switcherCornerRadius - this.iconCollapsedWidth / (float) 2 - (this.iconRadius - this.iconCollapsedWidth / (float) 2);
this.iconRect.right = (float) this.getWidth() - this.switcherCornerRadius + this.iconCollapsedWidth / (float) 2 + (this.iconRadius - this.iconCollapsedWidth / (float) 2);
this.iconClipRect.set(this.iconRect.centerX() - this.iconClipRadius, this.iconRect.centerY() - this.iconClipRadius, this.iconRect.centerX() + this.iconClipRadius, this.iconRect.centerY() + this.iconClipRadius);
this.iconTranslateX = -((float) this.getWidth() - this.shadowOffset - this.switcherCornerRadius * (float) 2);
public void setThumbDrawable(Drawable thumbDrawable) {
mThumbDrawable = thumbDrawable;
mIsThumbUseDrawable = mThumbDrawable != null;
setup();
refreshDrawableState();
requestLayout();
invalidate();
}
if (!isLollipopAndAbove()) {
this.generateShadow();
public void setThumbDrawableRes(int thumbDrawableRes) {
setThumbDrawable(ContextCompat.getDrawable(getContext(), thumbDrawableRes));
}
public Drawable getBackDrawable() {
return mBackDrawable;
}
private void generateShadow() {
if (switchElevation == 0f) {
return;
public void setBackDrawable(Drawable backDrawable) {
mBackDrawable = backDrawable;
mIsBackUseDrawable = mBackDrawable != null;
setup();
refreshDrawableState();
requestLayout();
invalidate();
}
if (!isInEditMode()) {
if (shadow == null) {
shadow = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ALPHA_8);
} else {
shadow.eraseColor(Color.TRANSPARENT);
public void setBackDrawableRes(int backDrawableRes) {
setBackDrawable(ContextCompat.getDrawable(getContext(), backDrawableRes));
}
Canvas c = new Canvas(shadow);
c.drawRoundRect(switcherRect, switcherCornerRadius, switcherCornerRadius, shadowPaint);
public ColorStateList getBackColor() {
return mBackColor;
}
RenderScript rs = RenderScript.create(getContext());
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8(rs));
Allocation input = Allocation.createFromBitmap(rs, shadow);
Allocation output = Allocation.createTyped(rs, input.getType());
blur.setRadius(switchElevation);
blur.setInput(input);
blur.forEach(output);
output.copyTo(shadow);
input.destroy();
output.destroy();
blur.destroy();
public void setBackColor(ColorStateList backColor) {
mBackColor = backColor;
if (mBackColor != null) {
setBackDrawable(null);
}
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// shadow,繪製陰影
if (!isLollipopAndAbove() && switchElevation > 0f && !isInEditMode()) {
canvas.drawBitmap(shadow, 0f, shadowOffset, null);
public void setBackColorRes(int backColorRes) {
setBackColor(ContextCompat.getColorStateList(getContext(), backColorRes));
}
// switcher 繪製按鈕外部,
canvas.drawRoundRect(switcherRect, switcherCornerRadius, switcherCornerRadius, switcherPaint);
public ColorStateList getThumbColor() {
return mThumbColor;
}
// icon
canvas.translate(iconTranslateX, 0);
canvas.drawRoundRect(iconRect, switcherCornerRadius, switcherCornerRadius, iconPaint);
/* don't draw clip path if icon is collapsed (to prevent drawing small circle
on rounded rect when switch is isChecked)*/
if (iconClipRect.width() > iconCollapsedWidth) {
canvas.drawRoundRect(iconClipRect, iconRadius, iconRadius, iconClipPaint);
public void setThumbColor(ColorStateList thumbColor) {
mThumbColor = thumbColor;
if (mThumbColor != null) {
setThumbDrawable(null);
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private final class SwitchOutline extends ViewOutlineProvider {
private int width;
private int height;
public void setThumbColorRes(int thumbColorRes) {
setThumbColor(ContextCompat.getColorStateList(getContext(), thumbColorRes));
}
public void getOutline(@NotNull View view, @NotNull Outline outline) {
outline.setRoundRect(0, 0, this.width, this.height, switcherCornerRadius);
public float getBackMeasureRatio() {
return mBackMeasureRatio;
}
public int getWidth() {
return this.width;
public void setBackMeasureRatio(float backMeasureRatio) {
mBackMeasureRatio = backMeasureRatio;
requestLayout();
}
public void setWidth(int var1) {
this.width = var1;
public RectF getThumbMargin() {
return mThumbMargin;
}
public int getHeight() {
return this.height;
public void setThumbMargin(RectF thumbMargin) {
if (thumbMargin == null) {
setThumbMargin(0, 0, 0, 0);
} else {
setThumbMargin(thumbMargin.left, thumbMargin.top, thumbMargin.right, thumbMargin.bottom);
}
}
public void setHeight(int var1) {
this.height = var1;
public void setThumbMargin(float left, float top, float right, float bottom) {
mThumbMargin.set(left, top, right, bottom);
requestLayout();
}
public SwitchOutline(int width, int height) {
this.width = width;
this.height = height;
public void setThumbSize(float width, float height) {
mThumbSizeF.set(width, height);
setup();
requestLayout();
}
public float getThumbWidth() {
return mThumbSizeF.x;
}
public float getThumbHeight() {
return mThumbSizeF.y;
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
super.onRestoreInstanceState(((Bundle) state).getParcelable(STATE));
isChecked = ((Bundle) state).getBoolean(KEY_CHECKED);
if (!isChecked) {
forceUncheck();
public void setThumbSize(PointF size) {
if (size == null) {
float defaultSize = getResources().getDisplayMetrics().density * DEFAULT_THUMB_SIZE_DP;
setThumbSize(defaultSize, defaultSize);
} else {
setThumbSize(size.x, size.y);
}
}
public PointF getThumbSizeF() {
return mThumbSizeF;
}
public void setOnCheckChangedListener(OnCheckChangedListener checkChangedListener) {
this.checkChangedListener = checkChangedListener;
public float getThumbRadius() {
return mThumbRadius;
}
public interface OnCheckChangedListener {
void onChanged(boolean state);
public void setThumbRadius(float thumbRadius) {
mThumbRadius = thumbRadius;
if (!mIsThumbUseDrawable) {
invalidate();
}
}
public boolean isChecked() {
return isChecked;
public PointF getBackSizeF() {
return new PointF(mBackRectF.width(), mBackRectF.height());
}
public void setChecked(boolean checked) {
if (this.isChecked != checked) {
// if (withAnimation) {
animateSwitch();
// } else {
// this.isChecked = checked;
// if (!checked) {
// currentColor = offColor;
// iconProgress = 1f;
// } else {
// currentColor = onColor;
// iconProgress = 0f;
// }
// }
public float getBackRadius() {
return mBackRadius;
}
public void setBackRadius(float backRadius) {
mBackRadius = backRadius;
if (!mIsBackUseDrawable) {
invalidate();
}
}
private void forceUncheck() {
setCurrentColor(offColor);
setIconProgress(1f);
public boolean isFadeBack() {
return mFadeBack;
}
public void setFadeBack(boolean fadeBack) {
mFadeBack = fadeBack;
}
// onRestoreInstanceState
public float lerp(float a, float b, float t) {
return a + (b - a) * t;
public int getTintColor() {
return mTintColor;
}
/**
* dip转pix
*
* @param dpValue
* @return
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
public void setTintColor(int tintColor) {
mTintColor = tintColor;
mThumbColor = ColorUtils.generateThumbColorWithTintColor(mTintColor);
mBackColor = ColorUtils.generateBackColorWithTintColor(mTintColor);
mIsBackUseDrawable = false;
mIsThumbUseDrawable = false;
// call this method to refresh color states
refreshDrawableState();
invalidate();
}
public void setText(CharSequence onText, CharSequence offText) {
mTextOn = onText;
mTextOff = offText;
mOnLayout = null;
mOffLayout = null;
requestLayout();
}
public boolean isLollipopAndAbove() {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP;
@Override
public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.onText = mTextOn;
ss.offText = mTextOff;
return ss;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
SavedState ss = (SavedState) state;
setText(ss.onText, ss.offText);
super.onRestoreInstanceState(ss.getSuperState());
}
static class SavedState extends BaseSavedState {
CharSequence onText;
CharSequence offText;
SavedState(Parcelable superState) {
super(superState);
}
}
private SavedState(Parcel in) {
super(in);
onText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
offText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
TextUtils.writeToParcel(onText, out, flags);
TextUtils.writeToParcel(offText, out, flags);
}
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import java.util.ArrayList;
import java.util.List;
public class WaveHelper {
private WaveView mWaveView;
private AnimatorSet mAnimatorSet;
public WaveHelper(WaveView waveView) {
mWaveView = waveView;
initAnimation();
}
public void start() {
mWaveView.setShowWave(true);
if (mAnimatorSet != null) {
mAnimatorSet.start();
}
}
private void initAnimation() {
List<Animator> animators = new ArrayList<>();
// horizontal animation.
// wave waves infinitely.
ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat(
mWaveView, "waveShiftRatio", 0f, 1f);
waveShiftAnim.setRepeatCount(ValueAnimator.INFINITE);
waveShiftAnim.setDuration(1000);
waveShiftAnim.setInterpolator(new LinearInterpolator());
animators.add(waveShiftAnim);
// vertical animation.
// water level increases from 0 to center of WaveView
// ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat(
// mWaveView, "waterLevelRatio", 0.5f, 0.8f);
// waterLevelAnim.setDuration(10000);
// waterLevelAnim.setInterpolator(new DecelerateInterpolator());
// animators.add(waterLevelAnim);
// amplitude animation.
// wave grows big then grows small, repeatedly
ObjectAnimator amplitudeAnim = ObjectAnimator.ofFloat(
mWaveView, "amplitudeRatio", 0.01f, 0.03f);
amplitudeAnim.setRepeatCount(ValueAnimator.INFINITE);
amplitudeAnim.setRepeatMode(ValueAnimator.REVERSE);
amplitudeAnim.setDuration(5000);
amplitudeAnim.setInterpolator(new LinearInterpolator());
animators.add(amplitudeAnim);
mAnimatorSet = new AnimatorSet();
mAnimatorSet.playTogether(animators);
}
public void cancel() {
if (mAnimatorSet != null) {
// mAnimatorSet.cancel();
mAnimatorSet.end();
}
}
}
/*
* Copyright (C) 2015, gelitenight(gelitenight@gmail.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
public class WaveView extends View {
/**
* +------------------------+
* |<--wave length-> |______
* | /\ | /\ | |
* | / \ | / \ | amplitude
* | / \ | / \ | |
* |/ \ |/ \|__|____
* | \ / | |
* | \ / | |
* | \ / | |
* | \/ | water level
* | | |
* | | |
* +------------------------+__|____
*/
private static final float DEFAULT_AMPLITUDE_RATIO = 0.05f;
private static final float DEFAULT_WATER_LEVEL_RATIO = 0.5f;
private static final float DEFAULT_WAVE_LENGTH_RATIO = 1.0f;
private static final float DEFAULT_WAVE_SHIFT_RATIO = 0.0f;
public static final int DEFAULT_BEHIND_WAVE_COLOR = Color.parseColor("#28FFFFFF");
public static final int DEFAULT_FRONT_WAVE_COLOR = Color.parseColor("#3CFFFFFF");
public static final ShapeType DEFAULT_WAVE_SHAPE = ShapeType.CIRCLE;
public enum ShapeType {
CIRCLE,
SQUARE
}
// if true, the shader will display the wave
private boolean mShowWave;
// shader containing repeated waves
private BitmapShader mWaveShader;
// shader matrix
private Matrix mShaderMatrix;
// paint to draw wave
private Paint mViewPaint;
// paint to draw border
private Paint mBorderPaint;
private float mDefaultAmplitude;
private float mDefaultWaterLevel;
private float mDefaultWaveLength;
private double mDefaultAngularFrequency;
private float mAmplitudeRatio = DEFAULT_AMPLITUDE_RATIO;
private float mWaveLengthRatio = DEFAULT_WAVE_LENGTH_RATIO;
private float mWaterLevelRatio = DEFAULT_WATER_LEVEL_RATIO;
private float mWaveShiftRatio = DEFAULT_WAVE_SHIFT_RATIO;
private int mBehindWaveColor = DEFAULT_BEHIND_WAVE_COLOR;
private int mFrontWaveColor = DEFAULT_FRONT_WAVE_COLOR;
private ShapeType mShapeType = DEFAULT_WAVE_SHAPE;
public WaveView(Context context) {
super(context);
init();
}
public WaveView(Context context, AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public WaveView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(attrs);
}
private void init() {
mShaderMatrix = new Matrix();
mViewPaint = new Paint();
mViewPaint.setAntiAlias(true);
}
private void init(AttributeSet attrs) {
init();
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs,
R.styleable.WaveView, 0, 0);
mAmplitudeRatio = typedArray.getFloat(R.styleable.WaveView_amplitudeRatio, DEFAULT_AMPLITUDE_RATIO);
mWaterLevelRatio = typedArray.getFloat(R.styleable.WaveView_waveWaterLevel, DEFAULT_WATER_LEVEL_RATIO);
mWaveLengthRatio = typedArray.getFloat(R.styleable.WaveView_waveLengthRatio, DEFAULT_WAVE_LENGTH_RATIO);
mWaveShiftRatio = typedArray.getFloat(R.styleable.WaveView_waveShiftRatio, DEFAULT_WAVE_SHIFT_RATIO);
mFrontWaveColor = typedArray.getColor(R.styleable.WaveView_frontWaveColor, DEFAULT_FRONT_WAVE_COLOR);
mBehindWaveColor = typedArray.getColor(R.styleable.WaveView_behindWaveColor, DEFAULT_BEHIND_WAVE_COLOR);
mShapeType = typedArray.getInt(R.styleable.WaveView_waveShape, 0) == 0 ? ShapeType.CIRCLE : ShapeType.SQUARE;
mShowWave = typedArray.getBoolean(R.styleable.WaveView_showWave, true);
typedArray.recycle();
}
public float getWaveShiftRatio() {
return mWaveShiftRatio;
}
/**
* Shift the wave horizontally according to <code>waveShiftRatio</code>.
*
* @param waveShiftRatio Should be 0 ~ 1. Default to be 0.
* Result of waveShiftRatio multiples width of WaveView is the length to shift.
*/
public void setWaveShiftRatio(float waveShiftRatio) {
if (mWaveShiftRatio != waveShiftRatio) {
mWaveShiftRatio = waveShiftRatio;
invalidate();
}
}
public float getWaterLevelRatio() {
return mWaterLevelRatio;
}
/**
* Set water level according to <code>waterLevelRatio</code>.
*
* @param waterLevelRatio Should be 0 ~ 1. Default to be 0.5.
* Ratio of water level to WaveView height.
*/
public void setWaterLevelRatio(float waterLevelRatio) {
if (mWaterLevelRatio != waterLevelRatio) {
mWaterLevelRatio = waterLevelRatio;
invalidate();
}
}
public float getAmplitudeRatio() {
return mAmplitudeRatio;
}
/**
* Set vertical size of wave according to <code>amplitudeRatio</code>
*
* @param amplitudeRatio Default to be 0.05. Result of amplitudeRatio + waterLevelRatio should be less than 1.
* Ratio of amplitude to height of WaveView.
*/
public void setAmplitudeRatio(float amplitudeRatio) {
if (mAmplitudeRatio != amplitudeRatio) {
mAmplitudeRatio = amplitudeRatio;
invalidate();
}
}
public float getWaveLengthRatio() {
return mWaveLengthRatio;
}
/**
* Set horizontal size of wave according to <code>waveLengthRatio</code>
*
* @param waveLengthRatio Default to be 1.
* Ratio of wave length to width of WaveView.
*/
public void setWaveLengthRatio(float waveLengthRatio) {
mWaveLengthRatio = waveLengthRatio;
}
public boolean isShowWave() {
return mShowWave;
}
public void setShowWave(boolean showWave) {
mShowWave = showWave;
}
public void setBorder(int width, int color) {
if (mBorderPaint == null) {
mBorderPaint = new Paint();
mBorderPaint.setAntiAlias(true);
mBorderPaint.setStyle(Style.STROKE);
}
mBorderPaint.setColor(color);
mBorderPaint.setStrokeWidth(width);
invalidate();
}
public void setWaveColor(int behindWaveColor, int frontWaveColor) {
mBehindWaveColor = behindWaveColor;
mFrontWaveColor = frontWaveColor;
if (getWidth() > 0 && getHeight() > 0) {
// need to recreate shader when color changed
mWaveShader = null;
createShader();
invalidate();
}
}
public void setShapeType(ShapeType shapeType) {
mShapeType = shapeType;
invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
createShader();
}
/**
* Create the shader with default waves which repeat horizontally, and clamp vertically
*/
private void createShader() {
mDefaultAngularFrequency = 2.0f * Math.PI / DEFAULT_WAVE_LENGTH_RATIO / getWidth();
mDefaultAmplitude = getHeight() * DEFAULT_AMPLITUDE_RATIO;
mDefaultWaterLevel = getHeight() * DEFAULT_WATER_LEVEL_RATIO;
mDefaultWaveLength = getWidth();
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint wavePaint = new Paint();
wavePaint.setStrokeWidth(2);
wavePaint.setAntiAlias(true);
// Draw default waves into the bitmap
// y=Asin(ωx+φ)+h
final int endX = getWidth() + 1;
final int endY = getHeight() + 1;
float[] waveY = new float[endX];
wavePaint.setColor(mBehindWaveColor);
for (int beginX = 0; beginX < endX; beginX++) {
double wx = beginX * mDefaultAngularFrequency;
float beginY = (float) (mDefaultWaterLevel + mDefaultAmplitude * Math.sin(wx));
canvas.drawLine(beginX, beginY, beginX, endY, wavePaint);
waveY[beginX] = beginY;
}
wavePaint.setColor(mFrontWaveColor);
final int wave2Shift = (int) (mDefaultWaveLength / 4);
for (int beginX = 0; beginX < endX; beginX++) {
canvas.drawLine(beginX, waveY[(beginX + wave2Shift) % endX], beginX, endY, wavePaint);
}
// use the bitamp to create the shader
mWaveShader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
mViewPaint.setShader(mWaveShader);
}
@Override
protected void onDraw(Canvas canvas) {
// modify paint shader according to mShowWave state
if (mShowWave && mWaveShader != null) {
// first call after mShowWave, assign it to our paint
if (mViewPaint.getShader() == null) {
mViewPaint.setShader(mWaveShader);
}
// sacle shader according to mWaveLengthRatio and mAmplitudeRatio
// this decides the size(mWaveLengthRatio for width, mAmplitudeRatio for height) of waves
mShaderMatrix.setScale(
mWaveLengthRatio / DEFAULT_WAVE_LENGTH_RATIO,
mAmplitudeRatio / DEFAULT_AMPLITUDE_RATIO,
0,
mDefaultWaterLevel);
// translate shader according to mWaveShiftRatio and mWaterLevelRatio
// this decides the start position(mWaveShiftRatio for x, mWaterLevelRatio for y) of waves
mShaderMatrix.postTranslate(
mWaveShiftRatio * getWidth(),
(DEFAULT_WATER_LEVEL_RATIO - mWaterLevelRatio) * getHeight());
// assign matrix to invalidate the shader
mWaveShader.setLocalMatrix(mShaderMatrix);
float borderWidth = mBorderPaint == null ? 0f : mBorderPaint.getStrokeWidth();
switch (mShapeType) {
case CIRCLE:
if (borderWidth > 0) {
canvas.drawCircle(getWidth() / 2f, getHeight() / 2f,
(getWidth() - borderWidth) / 2f - 1f, mBorderPaint);
}
float radius = getWidth() / 2f - borderWidth;
canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, radius, mViewPaint);
break;
case SQUARE:
if (borderWidth > 0) {
canvas.drawRect(
borderWidth / 2f,
borderWidth / 2f,
getWidth() - borderWidth / 2f - 0.5f,
getHeight() - borderWidth / 2f - 0.5f,
mBorderPaint);
}
canvas.drawRect(borderWidth, borderWidth, getWidth() - borderWidth,
getHeight() - borderWidth, mViewPaint);
break;
}
} else {
mViewPaint.setShader(null);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_7"/>
<stroke android:color="@color/color_3c" android:width="@dimen/dp_1"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="@dimen/dp_1"
android:color="@color/order_state0_color" />
<corners android:radius="@dimen/dp_8" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_c8" />
<corners android:radius="@dimen/dp_8" />
</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_5" />
<solid android:color="@color/tran_fifty_order_state0_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_5" />
<solid android:color="@color/order_state0_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">
<solid android:color="#BE1C42"/>
<corners android:radius="@dimen/dp_7"/>
</shape>
\ No newline at end of file
......@@ -411,12 +411,39 @@
</declare-styleable>
<declare-styleable name="SwitchButton">
<attr name="elevation" />
<attr name="switcherBtn_width" format="dimension"/>
<attr name="switcherBtn_height" format="dimension"/>
<attr name="android:checked" format="boolean" />
<attr name="switcherBtn_on_color" format="color" />
<attr name="switcherBtn_off_color" format="color" />
<attr name="switcherBtn_icon_color" format="color" />
<attr name="kswThumbDrawable" format="reference"/>
<attr name="kswThumbColor" format="color|reference"/>
<attr name="kswThumbMargin" format="dimension|reference"/>
<attr name="kswThumbMarginTop" format="dimension|reference"/>
<attr name="kswThumbMarginBottom" format="dimension|reference"/>
<attr name="kswThumbMarginLeft" format="dimension|reference"/>
<attr name="kswThumbMarginRight" format="dimension|reference"/>
<attr name="kswThumbWidth" format="dimension|reference"/>
<attr name="kswThumbHeight" format="dimension|reference"/>
<attr name="kswThumbRadius" format="dimension|reference"/>
<attr name="kswBackRadius" format="dimension|reference"/>
<attr name="kswBackDrawable" format="reference"/>
<attr name="kswBackColor" format="color|reference"/>
<attr name="kswFadeBack" format="boolean"/>
<attr name="kswBackMeasureRatio" format="float"/>
<attr name="kswAnimationDuration" format="integer"/>
<attr name="kswTintColor" format="color|reference"/>
<attr name="kswTextOn" format="string"/>
<attr name="kswTextOff" format="string"/>
<attr name="kswTextMarginH" format="dimension"/>
</declare-styleable>
<declare-styleable name="WaveView">
<attr name="waveWaterLevel" format="float" />
<attr name="amplitudeRatio" format="float" />
<attr name="waveLengthRatio" format="float" />
<attr name="waveShiftRatio" format="float" />
<attr name="frontWaveColor" format="color" />
<attr name="behindWaveColor" format="color" />
<attr name="waveShape" format="enum">
<enum name="circle" value="0" />
<enum name="square" value="1" />
</attr>
<attr name="showWave" format="boolean" />
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -449,18 +449,26 @@
<color name="color_3c">#3c3c3c</color>
<color name="color_e4">#E4E4E4</color>
<color name="color_f0">#F0F0F0</color>
<color name="color_cf">#CFCFCF</color>
<color name="color_a9">#A9A9A9</color>
<color name="color_66">#666</color>
<color name="color_86">#868686</color>
<color name="color_ef">#efefef</color>
<color name="color_50">#505050</color>
<color name="tran_fifty_order_state0_color">#7F009788</color>
<!-- 待確認背景色-->
<color name="order_state0_color">#6EBE8C</color>
<color name="order_state0_color">#009788</color>
<!-- 製作中背景色-->
<color name="order_state1_color">#5896F4</color>
<color name="order_state1_color">#249EF7</color>
<!-- 送貨中中背景色-->
<color name="order_state2_color">#FF5722</color>
<color name="order_state2_color">#FF720A</color>
<!-- 待取餐背景色-->
<color name="order_state3_color">#FF5722</color>
<color name="order_state3_color">#00479D</color>
<!-- 在線支付背景色-->
<color name="cash_on_delivery_bg">#FF5722</color>
<color name="online_payments_bg">#6EBE8C</color>
<color name="cash_on_delivery_bg">#E1BF32</color>
<color name="online_payments_bg">#6EBF8D</color>
<color name="self_order_bg">#FFCC33</color>
......
......@@ -18,4 +18,5 @@
<resources>
<item name="qmui_arch_swipe_layout_in_back" type="id"/>
<item name="iv_left_back" type="id"/>
<item name="iv_history" type="id"/>
</resources>
\ No newline at end of file
......@@ -143,4 +143,6 @@
<string name="tang"></string>
<string name="wai"></string>
<string name="amount_unit">$</string>
<string name="print_split_line">------------------------------------------------------------------------------------------------------</string>
</resources>
......@@ -5,6 +5,7 @@
<item name="shadow_right">@drawable/shadow_right</item>
<item name="shadow_bottom">@drawable/shadow_bottom</item>
</style>
<style name="PhotoDialog" parent="@android:style/Theme.Light">
<item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
......@@ -292,12 +293,34 @@
<item name="android:textColor">@color/theme_hint_color</item>
</style>
<style name="MySwitcher">
<item name="switcherBtn_width">@dimen/dp_46</item>
<item name="switcherBtn_height">@dimen/dp_26</item>
<item name="switcherBtn_on_color">@color/switcher_on_color</item>
<item name="switcherBtn_off_color">@color/switcher_off_color</item>
<item name="switcherBtn_icon_color">@color/switcher_icon_color</item>
<item name="elevation">@dimen/switcher_elevation</item>
<!-- <style name="MySwitcher">-->
<!-- <item name="switcherBtn_width">@dimen/dp_46</item>-->
<!-- <item name="switcherBtn_height">@dimen/dp_26</item>-->
<!-- <item name="switcherBtn_on_color">@color/switcher_on_color</item>-->
<!-- <item name="switcherBtn_off_color">@color/switcher_off_color</item>-->
<!-- <item name="switcherBtn_icon_color">@color/switcher_icon_color</item>-->
<!-- <item name="elevation">@dimen/switcher_elevation</item>-->
<!-- </style>-->
<style name="font_style_twelve">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_12</item>
</style>
<style name="font_style_fourteen">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_14</item>
</style>
<style name="font_style_sixteen">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<style name="font_style_eighteen">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_18</item>
</style>
<style name="font_style_twenty">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_20</item>
</style>
</resources>
......@@ -34,8 +34,8 @@ android {
dependencies {
def lintVersion = '26.4.2'
compileOnly "com.android.tools.lint:lint-api:$lintVersion"
compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
// compileOnly "com.android.tools.lint:lint-api:$lintVersion"
// compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
}
......
......@@ -62,7 +62,7 @@ dependencies {
api rootProject.ext.dependencies["annotations"]
api rootProject.ext.dependencies["design"]
api rootProject.ext.dependencies["constraintlayout"]
lintChecks project(':qm-lintrule')
// lintChecks project(':qm-lintrule')
//test
testImplementation 'junit:junit:4.12'
......
......@@ -308,7 +308,14 @@ public class QMUIProgressBar extends View {
}
private int parseValueToWidth() {
if (mMaxValue == 0) {
return 0;
}
if (mValue / mMaxValue != 0) {
return mWidth * mValue / mMaxValue;
} else {
return 0;
}
}
public int getProgress() {
......
......@@ -547,6 +547,8 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
CreateOrderRequest request = getCreateOrderRequest(getOrderFoodLists());
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(request));
String json = GsonUtils.GsonString(request);
MyOrderManage.getInstance().setNewFoodList(getOrderFoodLists());
printSendOrder(true);
mModel.createOrder(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
......
......@@ -199,7 +199,9 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements
String tableno = "";
if (!OpenTableManage.getDefault().isSplite()) {
if (OpenTableManage.getDefault().getTableBean() != null) {
tableno = OpenTableManage.getDefault().getTableBean().getTableName();
}
} else {
tableno = OpenTableManage.getDefault().getTableBean().getTableName().trim() + "-" + OpenTableManage.getDefault().getSplitNo().trim();
}
......
......@@ -10,6 +10,12 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.table.R;
......@@ -19,16 +25,12 @@ import com.gingersoft.gsa.cloud.table.mvp.contract.AllTableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.AllTablePresenter;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderContentActivity;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.GridDividerItemDecoration;
import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.layout.QMUIRelativeLayout;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.util.QMUIResHelper;
import com.qmuiteam.qmui.widget.QMUIEmptyView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
......@@ -41,13 +43,6 @@ import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import static android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE;
......
......@@ -18,8 +18,7 @@
android:label="@string/user_login_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label">
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">
......
......@@ -88,6 +88,11 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
} else {
GsaCloudApplication.isLogin = false;
mRootView.showMessage(info.getErrMsg());
if (IAcitivity instanceof LoginActivity) {
} else {
mRootView.launchActivity(new Intent(IAcitivity, LoginActivity.class));
}
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
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