Commit 3104f3a5 by 宁斌

Merge branch 'loach'

# Conflicts:
#	base-module/src/main/java/com/gingersoft/gsa/cloud/constans/HttpsConstans.java
#	base-module/src/main/java/com/gingersoft/gsa/cloud/ui/recylcler/event/RecyItemTouchHelperCallback.java
#	config.gradle
#	main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/model/service/MainService.java
#	main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/presenter/NewMainPresenter.java
#	main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
#	main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/fragment/BusinessReportFragment.java
#	manager-module/src/main/java/com/gingersoft/gsa/cloud/manager/mvp/model/bean/request/TableRequest.java
#	manager-module/src/main/java/com/gingersoft/gsa/cloud/manager/mvp/ui/fragment/AddTableFragment.java
#	manager-module/src/main/java/com/gingersoft/gsa/cloud/manager/mvp/ui/fragment/TableListFragment.java
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/data/model/bean/CancelReason.kt
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/model/viewModel/PageViewModel.kt
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/activity/OtherOrderActivity.kt
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/fragment/DeliveryFragment.kt
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/fragment/HistoryFragment.kt
#	other_order_mode/src/main/java/com/gingersoft/gsa/other_order_mode/ui/fragment/PlaceholderFragment.kt
#	other_order_mode/src/main/res/layout/fragment_delivery_list.xml
#	other_order_mode/src/main/res/layout/item_delivery_layout.xml
#	other_order_mode/src/main/res/values/styles.xml
#	print-module/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
#	print-module/src/main/java/com/joe/print/mvp/print/TestPrintDataMaker.java
#	print-module/src/main/java/com/joe/print/mvp/ui/activity/IpPrintActivity.java
#	table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/presenter/TablePresenter.java
#	table-module/src/main/java/com/gingersoft/gsa/cloud/table/mvp/ui/adapter/TableAdapter.java
parents a019cd85 76597c05
package com.gingersoft.gsa.cloud.manager.mvp.model.bean;
package com.gingersoft.gsa.cloud.base.common.bean;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionTextItem;
import com.qmuiteam.qmui.widget.section.QMUISection;
import java.io.Serializable;
import java.util.ArrayList;
......
......@@ -81,6 +81,10 @@ public class TableBean {
private Long orderId;
private String qrCode;
private int seatCount;
/**最大就餐人數*/
private Integer maxSeatCount;
/**最小就餐人數*/
private Integer minSeatCount;
private String createTime;
private String createBy;
private String qrCodeImg;
......@@ -108,6 +112,12 @@ public class TableBean {
* 排序
*/
private int sort;
/**
0#堂食
1#外賣
2#自取
*/
private int type;
public DataBean() {
......@@ -120,6 +130,8 @@ public class TableBean {
this.restaurantId = dataBean.restaurantId;
this.qrCode = dataBean.qrCode;
this.seatCount = dataBean.seatCount;
this.maxSeatCount = dataBean.maxSeatCount;
this.minSeatCount = dataBean.minSeatCount;
this.createTime = dataBean.createTime;
this.createBy = dataBean.createBy;
this.qrCodeImg = dataBean.qrCodeImg;
......@@ -130,6 +142,7 @@ public class TableBean {
this.person = dataBean.person;
this.useStatus = dataBean.useStatus;
this.sort = dataBean.sort;
this.type = dataBean.type;
}
public int getPerson() {
......@@ -196,6 +209,22 @@ public class TableBean {
this.seatCount = seatCount;
}
public Integer getMaxSeatCount() {
return maxSeatCount;
}
public void setMaxSeatCount(Integer maxSeatCount) {
this.maxSeatCount = maxSeatCount;
}
public Integer getMinSeatCount() {
return minSeatCount;
}
public void setMinSeatCount(Integer minSeatCount) {
this.minSeatCount = minSeatCount;
}
public String getCreateTime() {
return createTime;
}
......@@ -259,5 +288,13 @@ public class TableBean {
public void setSort(int sort) {
this.sort = sort;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
}
package com.gingersoft.gsa.cloud.manager.mvp.model.bean;
package com.gingersoft.gsa.cloud.base.common.bean;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.qmuiteam.qmui.widget.section.QMUISection;
import java.io.Serializable;
......@@ -34,7 +33,7 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
* regionId : 1
*/
private int id;
private long id;
/**區域ID*/
private int regionId;
/**區域名稱*/
......@@ -43,7 +42,12 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
private int restaurantId;
private Long orderId;
private String qrCode;
/**默認就餐人數*/
private int seatCount;
/**最大就餐人數*/
private int maxSeatCount;
/**最小就餐人數*/
private int minSeatCount;
private String createTime;
private String createBy;
private String qrCodeImg;
......@@ -71,10 +75,29 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
* 排序
*/
private int sort;
/**
0:堂食
1:外賣
2:自取
*/
private int type = -1;
public static final int TABLE_TYPE_CANTEEN = 0;
public static final int TABLE_TYPE_TAKEAWAY = 1;
public static final int TABLE_TYPE_SELF_FETCHING = 2;
/**
* 自定義字段
*/
/**是否選中*/
private boolean isChecked = false;
/**
* UI类型:
* 餐台 0
* 新增(+) 1
*/
private int layoutType = 0;
public TableItem() {
}
......@@ -88,6 +111,8 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
this.restaurantId = dataBean.restaurantId;
this.qrCode = dataBean.qrCode;
this.seatCount = dataBean.seatCount;
this.maxSeatCount = dataBean.maxSeatCount;
this.minSeatCount = dataBean.minSeatCount;
this.createTime = dataBean.createTime;
this.createBy = dataBean.createBy;
this.qrCodeImg = dataBean.qrCodeImg;
......@@ -98,6 +123,7 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
this.person = dataBean.person;
this.useStatus = dataBean.useStatus;
this.sort = dataBean.sort;
this.type = dataBean.type;
this.isChecked = dataBean.isChecked;
}
......@@ -117,11 +143,11 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
this.useStatus = useStatus;
}
public int getId() {
public long getId() {
return id;
}
public void setId(int id) {
public void setId(long id) {
this.id = id;
}
......@@ -181,6 +207,30 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
this.seatCount = seatCount;
}
public int getMaxSeatCount() {
return maxSeatCount;
}
public void setMaxSeatCount(int maxSeatCount) {
this.maxSeatCount = maxSeatCount;
}
public int getMinSeatCount() {
return minSeatCount;
}
public void setMinSeatCount(int minSeatCount) {
this.minSeatCount = minSeatCount;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getCreateTime() {
return createTime;
}
......@@ -253,6 +303,14 @@ public class TableItem implements Serializable, QMUISection.Model<TableItem>{
isChecked = checked;
}
public int getLayoutType() {
return layoutType;
}
public void setLayoutType(int layoutType) {
this.layoutType = layoutType;
}
@Override
public TableItem cloneForDiff() {
return null;
......
......@@ -141,6 +141,24 @@ public class TimeUtils {
return sf.format(endDate);
}
/**@param beginTime 開始時間
* @param distance 差距: 昨天天傳負一,今天傳零,明天傳一
* @param type 類型: 1、天 Calendar.DATE 2、年Calendar.YEAR 3、月Calendar.MONTH
* @param sf {@link #DEFAULT_DATE_MD}
* @return 獲得從開始時間+distance(偏移時間的年月日)
*/
public static String getBeginDistanceDate(Calendar beginTime, int distance, int type, SimpleDateFormat sf) {
beginTime.set(type, beginTime.get(type) + distance);
Date endDate = null;
try {
endDate = sf.parse(sf.format(beginTime.getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
return sf.format(endDate);
}
/**
* @param beginTime 開始時間
* @param distance 差距: 昨天天傳負一,今天傳零,明天傳一
......
......@@ -94,10 +94,10 @@ public class HttpsConstans {
//修改這個值,修改微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據
public static String WECHAR_REPORT_SERVER_ADDRESS;// = (isFormal ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
public static void init(Context context, boolean isSwitchServer) {
public static void init(Context context,boolean isSwitchServer) {
isFormal = (int) SPUtils.get(context, "isFormal", 1);
if (!isSwitchServer) {
isFormal = BuildConfig.DEBUG ? 2 : 1;
if (!BuildConfig.DEBUG && !isSwitchServer) {
isFormal = 1;
}
// _SERVER_ADDRESS = (isFormal == 1 ? HTTP_ADDRESS_URL_FORMAL : "http://a.ricepon.com:61177") + "/member-web/api/";
// ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = isFormal ==1 ? HTTP_ADDRESS_URL_FORMAL : REPORT_TEST_ADDRESS;
......@@ -106,45 +106,45 @@ public class HttpsConstans {
// REPORT_SERVER_ADDRESS = (isFormal ==1 ? REPORT_FORMAL_ADDRESS : REPORT_TEST_ADDRESS) + REPORT_PATH;//測試:REPORT_FORMAL_ADDRESS 正式:REPORT_TEST_ADDRESS
// WECHAR_REPORT_SERVER_ADDRESS = (isFormal == 1 ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
switch (isFormal) {
switch (isFormal){
case 1:
_SERVER_ADDRESS = HTTP_ADDRESS_URL_FORMAL + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL ;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL + PATH;
ROOT_URL = ROOT_FORMAL_URL;
REPORT_SERVER_ADDRESS = REPORT_FORMAL_ADDRESS + REPORT_PATH;
ROOT_URL = ROOT_FORMAL_URL ;
REPORT_SERVER_ADDRESS = REPORT_FORMAL_ADDRESS +REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_FORMAL_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break;
case 2:
_SERVER_ADDRESS = "http://a.ricepon.com:61177" + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_HK + PATH;
ROOT_URL = ROOT_HK_TEST_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
ROOT_URL = ROOT_HK_TEST_URL ;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break;
case 3:
_SERVER_ADDRESS = ROOT_SERVER_YOU_CHANG_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_YOU_CHANG_HK;
ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
ROOT_URL = ROOT_SZ_URL ;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break;
case 4:
_SERVER_ADDRESS = ROOT_SERVER_SHI_WEI_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_WEI_HK;
ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
ROOT_URL = ROOT_SZ_URL ;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break;
case 5:
_SERVER_ADDRESS = ROOT_SERVER_SHI_SHU_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_SHU_HK;
ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
ROOT_URL = ROOT_SZ_URL ;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break;
}
......
......@@ -2,7 +2,11 @@ package com.gingersoft.gsa.cloud.ui.recylcler.event;
import android.graphics.Color;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.base.delegate.IActivity;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
......@@ -23,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
*/
public class RecyItemTouchHelperCallback<H extends QMUISection.Model<H>, T extends QMUISection.Model<T>> extends ItemTouchHelper.Callback {
private final String TAG = getClass().getSimpleName();
RecyclerView.Adapter mAdapter;
boolean isSwipeEnable;
boolean isFirstDragUnable;
......@@ -60,35 +65,49 @@ public class RecyItemTouchHelperCallback<H extends QMUISection.Model<H>, T exten
return false;
}
if (fromPosition < toPosition) {
for (int i = fromPosition; i < toPosition; i++) {
if (mAdapter instanceof QMUIStickySectionAdapter) {
QMUIStickySectionAdapter sectionAdapter = (QMUIStickySectionAdapter) mAdapter;
QMUIStickySectionAdapter.ViewHolder holder = (QMUIStickySectionAdapter.ViewHolder) viewHolder;
int pos = holder.isForStickyHeader ? i : holder.getAdapterPosition();
int ItemIndex = ((QMUIStickySectionAdapter) mAdapter).getItemIndex(pos);
QMUISection<H, T> qmuiSections = ((QMUIStickySectionAdapter) mAdapter).getSection(ItemIndex);
QMUISection<H, T> qmuiSections = sectionAdapter.getSection(holder.getAdapterPosition());
List<?> list = qmuiSections.getItemList();
Collections.swap(list, ItemIndex, ItemIndex + 1);
int fromIndex = sectionAdapter.getItemIndex(fromPosition);
int toIndex = sectionAdapter.getItemIndex(toPosition);
if ((fromIndex + 1) == list.size())
return false;
for (int i = fromIndex; i < toIndex; i++) {
Collections.swap(list, i, i + 1);
}
} else {
for (int i = fromPosition; i < toPosition; i++) {
Collections.swap(((DefaultAdapter) mAdapter).getInfos(), i, i + 1);
}
}
} else {
for (int i = fromPosition; i > toPosition; i--) {
if (mAdapter instanceof QMUIStickySectionAdapter) {
QMUIStickySectionAdapter sectionAdapter = (QMUIStickySectionAdapter) mAdapter;
QMUIStickySectionAdapter.ViewHolder holder = (QMUIStickySectionAdapter.ViewHolder) viewHolder;
int pos = holder.isForStickyHeader ? i : holder.getAdapterPosition();
int ItemIndex = ((QMUIStickySectionAdapter) mAdapter).getItemIndex(pos);
QMUISection<H, T> qmuiSections = ((QMUIStickySectionAdapter) mAdapter).getSection(ItemIndex);
QMUISection<H, T> qmuiSections = sectionAdapter.getSection(holder.getAdapterPosition());
List<?> list = qmuiSections.getItemList();
Collections.swap(list, ItemIndex, ItemIndex - 1);
int fromIndex = sectionAdapter.getItemIndex(fromPosition);
int toIndex = sectionAdapter.getItemIndex(toPosition);
if ((fromIndex + 1) == list.size())
return false;
for (int i = fromIndex; i > toIndex; i--) {
Collections.swap(list, i, i - 1);
}
} else {
for (int i = fromPosition; i > toPosition; i--) {
Collections.swap(((DefaultAdapter) mAdapter).getInfos(), i, i - 1);
}
}
}
mAdapter.notifyItemMoved(fromPosition, toPosition);
mAdapter.notifyItemChanged(toPosition);
mAdapter.notifyItemChanged(fromPosition);
return true;
}
......@@ -115,6 +134,50 @@ public class RecyItemTouchHelperCallback<H extends QMUISection.Model<H>, T exten
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
viewHolder.itemView.setBackgroundColor(Color.WHITE);
String ids = "";
if (mAdapter instanceof QMUIStickySectionAdapter) {
QMUIStickySectionAdapter adapter = (QMUIStickySectionAdapter) mAdapter;
List<QMUISection<H, T>> qmuiSectionList = adapter.getCurrentData();
ids = getTableIds(qmuiSectionList);
} else {
DefaultAdapter adapter = (DefaultAdapter) mAdapter;
ids = getTableAreaIds(adapter.getInfos());
}
// mAdapter.notifyDataSetChanged();
if (onMoveListener != null) {
onMoveListener.onMoveFinish(ids);
}
}
private String getTableIds(List<QMUISection<H, T>> qmuiSectionList) {
StringBuilder builder = new StringBuilder();
for (QMUISection<H, T> qmuiSections : qmuiSectionList) {
for (T t : qmuiSections.getItemList()) {
TableItem tableItem = (TableItem) t;
if (tableItem.getLayoutType() == 0) {
builder.append(tableItem.getId());
builder.append(",");
}
}
}
String str = builder.toString();
if (str.endsWith(",")) {
str = str.substring(0, str.length() - 1);
}
return str;
}
private String getTableAreaIds(List<TableArea> tableAreaList) {
StringBuilder builder = new StringBuilder();
for (TableArea tableArea : tableAreaList) {
builder.append(tableArea.getId());
builder.append(",");
}
String str = builder.toString();
if (str.endsWith(",")) {
str = str.substring(0, str.length() - 1);
}
return str;
}
@Override
......@@ -126,4 +189,14 @@ public class RecyItemTouchHelperCallback<H extends QMUISection.Model<H>, T exten
public boolean isItemViewSwipeEnabled() {
return isSwipeEnable;
}
private onMoveListener onMoveListener;
public void setOnMoveListener(RecyItemTouchHelperCallback.onMoveListener onMoveListener) {
this.onMoveListener = onMoveListener;
}
public interface onMoveListener {
void onMoveFinish(String ids);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-06-13
* 修订历史:2020-06-13
* 描述:
*/
public class TriangleLabelView extends View {
private static final String TAG = TriangleLabelView.class.getSimpleName();
private static class PaintHolder {
String text = "";
Paint paint;
int color;
float size;
float height;
float width;
int style;
void initPaint() {
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(color);
paint.setTextAlign(Paint.Align.CENTER);
paint.setTextSize(size);
if (style == 1) {
paint.setTypeface(Typeface.SANS_SERIF);
} else if (style == 2) {
paint.setTypeface(Typeface.DEFAULT_BOLD);
}
}
void resetStatus() {
Rect rectText = new Rect();
paint.getTextBounds(text, 0, text.length(), rectText);
width = rectText.width();
height = rectText.height();
}
}
private PaintHolder primary = new PaintHolder();
private PaintHolder secondary = new PaintHolder();
private float topPadding;
private float bottomPadding;
private float centerPadding;
private Paint trianglePaint;
private int backGroundColor;
private int width;
private int height;
private static final int DEGREES_LEFT = -45;
private static final int DEGREES_RIGHT = 45;
private Corner corner;
public enum Corner {
TOP_LEFT(1),
TOP_RIGHT(2),
BOTTOM_LEFT(3),
BOTTOM_RIGHT(4),;
private final int type;
Corner(int type) {
this.type = type;
}
private boolean top() {
return this == TOP_LEFT || this == TOP_RIGHT;
}
private boolean left() {
return this == TOP_LEFT || this == BOTTOM_LEFT;
}
private static Corner from(int type) {
for (Corner c : values()) {
if (c.type == type) return c;
}
return Corner.TOP_LEFT;
}
}
public TriangleLabelView(Context context) {
this(context, null);
}
public TriangleLabelView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TriangleLabelView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TriangleLabelView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TriangleLabelView);
this.topPadding = ta.getDimension(R.styleable.TriangleLabelView_labelTopPadding, dp2px(7));
this.centerPadding = ta.getDimension(R.styleable.TriangleLabelView_labelCenterPadding, dp2px(3));
this.bottomPadding = ta.getDimension(R.styleable.TriangleLabelView_labelBottomPadding, dp2px(3));
this.backGroundColor = ta.getColor(R.styleable.TriangleLabelView_backgroundColor, Color.parseColor("#66000000"));
this.primary.color = ta.getColor(R.styleable.TriangleLabelView_primaryTextColor, Color.WHITE);
this.secondary.color = ta.getColor(R.styleable.TriangleLabelView_secondaryTextColor, Color.WHITE);
this.primary.size = ta.getDimension(R.styleable.TriangleLabelView_primaryTextSize, sp2px(11));
this.secondary.size = ta.getDimension(R.styleable.TriangleLabelView_secondaryTextSize, sp2px(8));
final String primary = ta.getString(R.styleable.TriangleLabelView_primaryText);
if (primary != null) {
this.primary.text = primary;
}
final String secondary = ta.getString(R.styleable.TriangleLabelView_secondaryText);
if (secondary != null) {
this.secondary.text = secondary;
}
this.primary.style = ta.getInt(R.styleable.TriangleLabelView_primaryTextStyle, 2);
this.secondary.style = ta.getInt(R.styleable.TriangleLabelView_secondaryTextStyle, 0);
this.corner = Corner.from(ta.getInt(R.styleable.TriangleLabelView_corner, 1));
ta.recycle();
this.primary.initPaint();
this.secondary.initPaint();
trianglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
trianglePaint.setColor(backGroundColor);
this.primary.resetStatus();
this.secondary.resetStatus();
}
public void setLabelTopPadding(float dp) {
topPadding = dp2px(dp);
}
public float getLabelTopPadding() {
return topPadding;
}
public void setLabelCenterPadding(float dp) {
centerPadding = dp2px(dp);
relayout();
}
public float getLabelCenterPadding() {
return centerPadding;
}
public void setLabelBottomPadding(float dp) {
bottomPadding = dp2px(dp);
relayout();
}
public float getLabelBottomPadding() {
return bottomPadding;
}
public void setPrimaryText(String text) {
primary.text = text;
primary.resetStatus();
relayout();
}
public void setPrimaryText(@StringRes int textRes) {
primary.text = getContext().getString(textRes);
primary.resetStatus();
relayout();
}
public String getPrimaryText() {
return primary.text;
}
public void setSecondaryText(String smallText) {
secondary.text = smallText;
secondary.resetStatus();
relayout();
}
public void setSecondaryText(@StringRes int textRes) {
secondary.text = getContext().getString(textRes);
secondary.resetStatus();
relayout();
}
public String getSecondaryText() {
return secondary.text;
}
public void setPrimaryTextColor(@ColorInt int color) {
primary.color = color;
primary.initPaint();
primary.resetStatus();
relayout();
}
public void setPrimaryTextColorResource(@ColorRes int colorResource) {
primary.color = ContextCompat.getColor(getContext(), colorResource);
primary.initPaint();
primary.resetStatus();
relayout();
}
public void setSecondaryTextColor(@ColorInt int color) {
secondary.color = color;
secondary.initPaint();
secondary.resetStatus();
relayout();
}
public void setSecondaryTextColorResource(@ColorRes int colorResource) {
secondary.color = ContextCompat.getColor(getContext(), colorResource);
secondary.initPaint();
secondary.resetStatus();
relayout();
}
public void setPrimaryTextSize(float sp) {
primary.size = sp2px(sp);
relayout();
}
public void setSecondaryTextSize(float sp) {
secondary.size = sp2px(sp);
relayout();
}
public float getPrimaryTextSize() {
return primary.size;
}
public float getSecondaryTextSize() {
return secondary.size;
}
public void setTriangleBackgroundColor(@ColorInt int color) {
backGroundColor = color;
trianglePaint.setColor(backGroundColor);
relayout();
}
public void setTriangleBackgroundColorResource(@ColorRes int colorResource) {
backGroundColor = ContextCompat.getColor(getContext(), colorResource);
trianglePaint.setColor(backGroundColor);
relayout();
}
public int getTriangleBackGroundColor() {
return backGroundColor;
}
public void setCorner(Corner corner) {
this.corner = corner;
relayout();
}
public Corner getCorner() {
return corner;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
// translate
if (corner.top()) {
canvas.translate(0, (float) ((height * Math.sqrt(2)) - height));
}
// rotate
if (corner.top()) {
if (corner.left()) {
canvas.rotate(DEGREES_LEFT, 0, height);
} else {
canvas.rotate(DEGREES_RIGHT, width, height);
}
} else {
if (corner.left()) {
canvas.rotate(DEGREES_RIGHT, 0, 0);
} else {
canvas.rotate(DEGREES_LEFT, width, 0);
}
}
// draw triangle
@SuppressLint("DrawAllocation")
Path path = new Path();
if (corner.top()) {
path.moveTo(0, height);
path.lineTo(width / 2, 0);
path.lineTo(width, height);
} else {
path.moveTo(0, 0);
path.lineTo(width / 2, height);
path.lineTo(width, 0);
}
path.close();
canvas.drawPath(path, trianglePaint);
// draw secondaryText
// if (corner.top()) {
// canvas.drawText(secondary.text, (width) / 2, topPadding + secondary.height, secondary.paint);
// canvas.drawText(primary.text, (width) / 2, (topPadding + secondary.height + centerPadding + primary.height), primary.paint);
// } else {
// canvas.drawText(secondary.text, (width) / 2, bottomPadding + secondary.height + centerPadding + primary.height, secondary.paint);
// canvas.drawText(primary.text, (width) / 2, (bottomPadding + primary.height), primary.paint);
// }
canvas.restore();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
height = (int) (topPadding + centerPadding + bottomPadding + secondary.height + primary.height);
width = 2 * height;
int realHeight = (int) (height * Math.sqrt(2));
setMeasuredDimension(width, realHeight);
}
public int dp2px(float dpValue) {
final float scale = getContext().getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public float sp2px(float spValue) {
final float scale = getContext().getResources().getDisplayMetrics().scaledDensity;
return spValue * scale;
}
/**
* Should be called whenever what we're displaying could have changed.
*/
private void relayout() {
invalidate();
requestLayout();
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* 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.qm;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
import com.qmuiteam.qmui.layout.QMUIFrameLayout;
import androidx.customview.widget.ViewDragHelper;
/**
* Created by cgspine on 2018/3/22.
*/
public class QDShadowAdjustLayout extends QMUIFrameLayout {
ViewDragHelper viewDragHelper;
public QDShadowAdjustLayout(Context context) {
this(context, null);
}
public QDShadowAdjustLayout(Context context, AttributeSet attrs) {
super(context, attrs);
viewDragHelper = ViewDragHelper.create(this, new ViewDragHelper.Callback() {
@Override
public boolean tryCaptureView(View child, int pointerId) {
return child.getId() == R.id.layout_for_test;
}
@Override
public int clampViewPositionHorizontal(View child, int left, int dx) {
return left;
}
@Override
public int clampViewPositionVertical(View child, int top, int dy) {
return top;
}
});
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return viewDragHelper.shouldInterceptTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
viewDragHelper.processTouchEvent(event);
return true;
}
}
......@@ -54,12 +54,10 @@ public class QDSectionHeaderView extends LinearLayout {
mTitleTv.setTextSize(16);
mTitleTv.setTextColor(Color.BLACK);
mTitleTv.setPadding(paddingHor, 0, paddingHor, 0);
addView(mTitleTv, new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
addView(mTitleTv, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
mArrowView = new AppCompatImageView(context);
mArrowView.setImageDrawable(QMUIResHelper.getAttrDrawable(getContext(),
R.attr.qmui_common_list_item_chevron));
mArrowView.setImageDrawable(QMUIResHelper.getAttrDrawable(getContext(), R.attr.qmui_common_list_item_chevron));
mArrowView.setScaleType(ImageView.ScaleType.CENTER);
addView(mArrowView, new LinearLayout.LayoutParams(headerHeight, headerHeight));
}
......
package com.gingersoft.gsa.cloud.ui.widget.dialog;
import android.app.Activity;
import android.text.InputType;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.base.R;
......@@ -22,6 +23,7 @@ public class CommonTipDialog {
/**
* 提示dialog 確認后執行對應方法
*
* @param context
* @param msg
* @param c
......@@ -30,16 +32,16 @@ public class CommonTipDialog {
* @param parameterTypes
* @param parameters
*/
public static void showDoubtDialog(Activity context,String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
public static void showDoubtDialog(Activity context, String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context);
dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_doubt);
dialogBuilder.setMessage(msg);
if(!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction(R.drawable.shape_3c_cancel_btn_bg,"取消", (dialog, index) -> dialog.dismiss());
if (!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction(R.drawable.shape_3c_cancel_btn_bg, "取消", (dialog, index) -> dialog.dismiss());
}
dialogBuilder.addAction(R.drawable.shape_red_five_radius_bg, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
if(TextUtils.isEmpty(methodName)){
if (TextUtils.isEmpty(methodName)) {
return;
}
try {
......@@ -59,6 +61,7 @@ public class CommonTipDialog {
/**
* 危險警示dialog 確認后執行對應方法
*
* @param context
* @param msg
* @param c
......@@ -67,16 +70,16 @@ public class CommonTipDialog {
* @param parameterTypes
* @param parameters
*/
public static void showSurpisedDialog(Activity context,String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
public static void showSurpisedDialog(Activity context, String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context);
dialogBuilder.setMessage(msg);
dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_surprised);
if(!TextUtils.isEmpty(methodName)) {
if (!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction("取消", (dialog, index) -> dialog.dismiss());
}
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
if(TextUtils.isEmpty(methodName)){
if (TextUtils.isEmpty(methodName)) {
return;
}
try {
......@@ -96,6 +99,7 @@ public class CommonTipDialog {
/**
* 警示dialog 確認后執行對應方法
*
* @param context
* @param msg
* @param c
......@@ -104,16 +108,16 @@ public class CommonTipDialog {
* @param parameterTypes
* @param parameters
*/
public static void showWarnDialog(Activity context,String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
public static void showWarnDialog(Activity context, String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context);
dialogBuilder.setMessage(msg);
dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_warn);
if(!TextUtils.isEmpty(methodName)) {
if (!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction("取消", (dialog, index) -> dialog.dismiss());
}
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
if(TextUtils.isEmpty(methodName)){
if (TextUtils.isEmpty(methodName)) {
return;
}
try {
......@@ -133,6 +137,7 @@ public class CommonTipDialog {
/**
* 取消 dialog 確認后執行對應方法
*
* @param context
* @param msg
* @param c
......@@ -141,16 +146,16 @@ public class CommonTipDialog {
* @param parameterTypes
* @param parameters
*/
public static void showCancelDialog(Activity context,String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
public static void showCancelDialog(Activity context, String msg, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context);
dialogBuilder.setMessage(msg);
dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_cancel);
if(!TextUtils.isEmpty(methodName)) {
if (!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction("取消", (dialog, index) -> dialog.dismiss());
}
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
if(TextUtils.isEmpty(methodName)){
if (TextUtils.isEmpty(methodName)) {
return;
}
try {
......@@ -177,4 +182,46 @@ public class CommonTipDialog {
dialogBuilder.create(R.style.MyDialogTheme2).show();
}
/**
* 輸入型 dialog 確認后執行對應方法
*
* @param context
* @param title
* @param placeholder
* @param c
* @param object
* @param methodName
* @param parameterTypes
* @param parameters
*/
public static void showEditTextDialog(Activity context, String title, String placeholder, Class c, Object object, String methodName, Class[] parameterTypes, Object[] parameters) {
final QMUIDialog.EditTextDialogBuilder dialogBuilder = new QMUIDialog.EditTextDialogBuilder(context);
dialogBuilder.setTitle(title);
dialogBuilder.setPlaceholder(placeholder);
dialogBuilder.setInputType(InputType.TYPE_CLASS_TEXT);
if (!TextUtils.isEmpty(methodName)) {
dialogBuilder.addAction("取消", (dialog, index) -> dialog.dismiss());
}
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
if (TextUtils.isEmpty(methodName)) {
return;
}
try {
Method method = c.getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
method.invoke(object, parameters);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
});
dialogBuilder.create(R.style.MyDialogTheme2).show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<!-- 倒三角 -->
<rotate
android:fromDegrees="-45"
android:pivotX="-45%"
android:pivotY="45%"
android:toDegrees="45"
>
<shape android:shape="rectangle">
<solid android:color="#f00" />
</shape>
</rotate>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/shape_id">
<!-- 正三角 -->
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="100%"
android:pivotY="100%">
<shape android:shape="rectangle">
<solid android:color="@color/theme_white_color"/>
</shape>
</rotate>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="AvatarView">
<attr name="showLabel" format="boolean" />
<attr name="avatarSize" format="dimension" />
<attr name="avatarSrc" format="reference" />
<attr name="labelSrc" format="reference" />
</declare-styleable>
<declare-styleable name="TriangleLabelView">
<attr name="backgroundColor" format="color" />
<attr name="primaryTextColor" format="color" />
<attr name="secondaryTextColor" format="color" />
<attr name="primaryText" format="string" />
<attr name="secondaryText" format="string" />
<attr name="primaryTextSize" format="dimension" />
<attr name="secondaryTextSize" format="dimension" />
<attr name="labelTopPadding" format="dimension" />
<attr name="labelCenterPadding" format="dimension" />
<attr name="labelBottomPadding" format="dimension" />
<attr name="primaryTextStyle">
<enum name="normal" value="0" />
<enum name="italic" value="1" />
<enum name="bold" value="2" />
</attr>
<attr name="secondaryTextStyle">
<enum name="normal" value="0" />
<enum name="italic" value="1" />
<enum name="bold" value="2" />
</attr>
<attr name="corner">
<enum name="leftTop" value="1" />
<enum name="rightTop" value="2" />
<enum name="leftBottom" value="3" />
<enum name="rightBottom" value="4" />
</attr>
</declare-styleable>
<declare-styleable name="SwipeBackLayout">
<attr name="edge_flag">
<enum name="left" value="0" />
......
......@@ -22,5 +22,5 @@
<item name="topbar_right_change_button" type="id"/>
<item name="layout_for_test" type="id"/>
</resources>
\ No newline at end of file
......@@ -5,8 +5,8 @@ ext {
buildToolsVersion: '28.0.3',
minSdkVersion : 19, //N5收銀機應用安卓開發環境要求Android OS Version: 5.1Android SDK Min Version: 19
targetSdkVersion : 28,
versionCode : 3,
versionName : "1.0.3"
versionCode : 2,
versionName : "1.0.2"
]
version = [
......
......@@ -18,10 +18,6 @@ public interface MainService {
Observable<Object> loginOut(@Body RequestBody requestBody);
@Headers({"Domain-Name: update_version"})
@POST("restaurant/clearHeartbeat" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<Object> clearHeartbeat(@Body RequestBody requestBody);
@Headers({"Domain-Name: update_version"})
@POST("system/checkAppVersion" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<CheckVersionRequest> checkAppVersion(@Body RequestBody requestBody);
}
......@@ -5,7 +5,6 @@ import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.main.R;
......@@ -121,25 +120,7 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
public void loginOut() {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) + "")
.build();
CC.obtainBuilder("Component.OtherOrder")
.setActionName("closeHeart")
.build()
.call();
mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
mModel.loginOut(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
......@@ -148,6 +129,7 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
mRootView.loginOut();
......@@ -156,21 +138,19 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
}
});
}
});
}
public void updateAPK(int type, String downApkURL) {
if (type == 4 || type == 5) {
if (type == 4) {
if(type == 4 || type == 5){
if(type == 4){
try {
DeviceUtils.launchAppDetail(IActivity, mApplication.getPackageName(), "com.android.vending");
} catch (Exception e) {
//跳转goole play下载app
WebActivity.startWebActivity_url(IActivity, downApkURL, WebActivity.RIGHT_TYPE_REFRESH);
}
} else {
}else{
try {
DeviceUtils.launchAppDetail(IActivity, mApplication.getPackageName(), "com.android.vending");
DeviceUtils.launchAppDetail(IActivity,mApplication.getPackageName(), "com.android.vending");
} catch (Exception e) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
......
......@@ -130,12 +130,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onResume() {
super.onResume();
// mPresenter.checkAppVersion();
mPresenter.checkAppVersion();
}
@Override
......@@ -241,24 +236,21 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
List<Function> functions = new ArrayList<>();
// if (!BuildConfig.DEBUG) {
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.order, "order"));
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_close, 0));
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 0));
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.manager, "manager"));
functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
//// functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "外賣接單", R.drawable.ic_takeaway_orders, 0));
// functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 0));
functions.add(new Function((long) 143, 151, 5, "餐檯管理", R.drawable.ic_dining_table_management, 0));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
//// functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1));
//// functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1));
//// functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.employee, "employee"));
functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
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));
......@@ -310,7 +302,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
private void functionClick(String name, int status) {
// switch (status){
// case STATUS_NONACTIVATED:
// ToastUtils.show(mContext, "服務暫未開通,敬請期待");
// ToastUtils.show(mContext, "服務暫未開通,請前往開通");
// return;
// case STATUS_TIME_LIMIT:
// ToastUtils.show(mContext, "服務已到期,請前往續費");
......
......@@ -38,7 +38,6 @@ import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import java.sql.Time;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
......@@ -76,8 +75,6 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
TextView mRestaurantName;
@BindView(R2.id.tv_start_time)
TextView mTvStartTime;
@BindView(R2.id.tv_end_time)
TextView mTvEndTime;
@BindView(R2.id.iv_start_time_triangle)
......@@ -88,7 +85,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
private BusinessInfoAdapter businessInfoAdapter;
//查詢多少天的數據
private int manyDay = 7;
private int manyDay = 6;
public static BusinessReportFragment newInstance() {
BusinessReportFragment fragment = new BusinessReportFragment();
......@@ -114,15 +111,14 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
public void initData(@Nullable Bundle savedInstanceState) {
//獲取一段時間內的營業信息,默認獲取七天的數據
String startTime = TimeUtils.getOldDate(-manyDay);
// mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(-1));
// mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(-1));
mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(1));
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(1));
mRestaurantName.setText(GsaCloudApplication.getRestaurantName(mContext));
mTvStartTime.setText(startTime);
mTvEndTime.setText(TimeUtils.getOldDate(0));
getBetweenInfo();
}
/**
......@@ -199,6 +195,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
*/
@Override
public void loadChart(List<MainBusinessBean.DataBean> data) {
manyDay = data.size();
Object[] chartData = new Object[manyDay];
String[] xData = new String[manyDay];
......@@ -342,7 +339,29 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
} else {
mTvEndTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
}
getBetweenInfo();
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// int month = calendar.get(Calendar.MONTH);
// int day = calendar.get(Calendar.DAY_OF_MONTH);
// calendar.setTime(new Date());
// //如果不是當前月份,那麼報表最多顯示最近七天
// if (month != calendar.get(Calendar.MONTH)) {
// manyDay = 7;
// } else {
// //如果選中的是當前月份,判斷天數是否大於7
// if (calendar.get(Calendar.DAY_OF_MONTH) - day > 7) {
// manyDay = 7;
// } else {
// manyDay = calendar.get(Calendar.DAY_OF_MONTH) - day;
// if (manyDay < 0) {
// manyDay = 0;
// }
// }
// }
mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
}).setOnDismissListener(o -> {
if (triangleView.isOpen()) {
triangleView.toggle();
......@@ -354,24 +373,4 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
e.printStackTrace();
}
}
private void getBetweenInfo() {
try {
//計算出兩個日期間隔的天數
Calendar startCal = Calendar.getInstance();
startCal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvStartTime.getText().toString()));
Calendar endCal = Calendar.getInstance();
endCal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvEndTime.getText().toString()));
manyDay = TimeUtils.daysBetween(startCal, endCal) - 1;
if (manyDay < 0) {
manyDay = 0;
}
} catch (ParseException e) {
e.printStackTrace();
}
mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
}
}
......@@ -237,7 +237,7 @@
android:layout_marginRight="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4"
app:hl_dy="@dimen/main_shadow_dy"
android:visibility="gone"
android:visibility="visible"
app:hl_shadowBackColor="@color/white"
app:hl_shadowColor="@color/shadow_color"
app:hl_shadowLimit="@dimen/main_shadow_limit">
......
......@@ -19,7 +19,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/dp_8"
android:singleLine="true"
android:text="餐檯模式"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" />
......
package com.gingersoft.gsa.cloud.manager.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import java.util.List;
/**
* ================================================
......@@ -20,6 +23,8 @@ public interface TableListContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void showEmptyView(boolean isSuccess, int size, Throwable t);
List<TableItem> getTableList();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
package com.gingersoft.gsa.cloud.manager.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
......@@ -34,6 +33,10 @@ public interface TableManageContract {
void queryTablesSuccess(List<TableItem> tables, int type);
void showEmptyView(boolean isSuccess, int size, Throwable t);
void onStartRefreshTableData();
void onPauseRefreshTableData();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......@@ -55,5 +58,10 @@ public interface TableManageContract {
Observable<BaseResult> queryTables();
Observable<BaseResult> changeAreaSort(RequestBody requestBody);
Observable<BaseResult> changeTableSort(RequestBody requestBody);
Observable<BaseResult> updateTableServiceCharge(RequestBody requestBody);
}
}
......@@ -158,4 +158,49 @@ public class TableManageModel extends BaseModel implements TableManageContract.M
.queryTable(restaurantId);
}
@Override
public Observable<BaseResult> changeAreaSort(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(TableManageService.class)
.changeAreaSort(requestBody)
.flatMap(new Function<BaseResult, Observable<BaseResult>>() {
@Override
public Observable<BaseResult> apply(BaseResult info) throws Exception {
if (info != null && info.isSuccess()) {
return queryAreas();
}
return null;
}
});
}
@Override
public Observable<BaseResult> changeTableSort(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(TableManageService.class)
.changeTableSort(requestBody)
.flatMap(new Function<BaseResult, Observable<BaseResult>>() {
@Override
public Observable<BaseResult> apply(BaseResult info) throws Exception {
if (info != null && info.isSuccess()) {
return queryTables();
}
return null;
}
});
}
@Override
public Observable<BaseResult> updateTableServiceCharge(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(TableManageService.class)
.updateTableServiceCharge(requestBody)
.flatMap(new Function<BaseResult, Observable<BaseResult>>() {
@Override
public Observable<BaseResult> apply(BaseResult info) throws Exception {
if (info != null && info.isSuccess()) {
return queryTables();
}
return null;
}
});
}
}
\ No newline at end of file
......@@ -16,13 +16,22 @@ public class TableRequest {
private int regionId;
/**餐檯名*/
private String tableName;
/**座位数*/
private int seatCount;
/**默認就餐人數*/
private Integer seatCount;
/**最大就餐人數*/
private Integer maxSeatCount;
/**最小就餐人數*/
private Integer minSeatCount;
/**服務費*/
private Double serviceCharge;
/**排序*/
private int sort;
/**
0#堂食
1#外賣
2#自取
*/
private int type;
public int getRestaurantId() {
return restaurantId;
......@@ -56,6 +65,34 @@ public class TableRequest {
this.seatCount = seatCount;
}
public void setSeatCount(Integer seatCount) {
this.seatCount = seatCount;
}
public Integer getMaxSeatCount() {
return maxSeatCount;
}
public void setMaxSeatCount(Integer maxSeatCount) {
this.maxSeatCount = maxSeatCount;
}
public Integer getMinSeatCount() {
return minSeatCount;
}
public void setMinSeatCount(Integer minSeatCount) {
this.minSeatCount = minSeatCount;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public Double getServiceCharge() {
return serviceCharge;
}
......@@ -75,26 +112,36 @@ public class TableRequest {
public static class Update {
private int id;
private long id;
private int restaurantId;
/**區域ID*/
private int regionId;
/**餐檯名*/
private String tableName;
/**座位数*/
private int seatCount;
/**默認就餐人數*/
private Integer seatCount;
/**最大就餐人數*/
private Integer maxSeatCount;
/**最小就餐人數*/
private Integer minSeatCount;
/**服務費*/
private Double serviceCharge;
/**排序*/
private int sort;
/**
0:堂食
1:外賣
2:自取
*/
private int type = -1;
public int getId() {
public long getId() {
return id;
}
public void setId(int id) {
public void setId(long id) {
this.id = id;
}
......@@ -130,6 +177,34 @@ public class TableRequest {
this.seatCount = seatCount;
}
public void setSeatCount(Integer seatCount) {
this.seatCount = seatCount;
}
public Integer getMaxSeatCount() {
return maxSeatCount;
}
public void setMaxSeatCount(Integer maxSeatCount) {
this.maxSeatCount = maxSeatCount;
}
public Integer getMinSeatCount() {
return minSeatCount;
}
public void setMinSeatCount(Integer minSeatCount) {
this.minSeatCount = minSeatCount;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public Double getServiceCharge() {
return serviceCharge;
}
......@@ -147,4 +222,28 @@ public class TableRequest {
}
}
public static class UpdateServiceCharge {
private long id;
/**服務費*/
private Double serviceCharge;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Double getServiceCharge() {
return serviceCharge;
}
public void setServiceCharge(Double serviceCharge) {
this.serviceCharge = serviceCharge;
}
}
}
......@@ -51,4 +51,13 @@ public interface TableManageService {
@POST("restaurant/exchangeSort" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> changeAreaSort(@Body RequestBody requestBody);
@POST("restaurantTable/exchangeSort" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> changeTableSort(@Body RequestBody requestBody);
@POST("restaurantTable/updateRestaurantTableBatch" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateTableServiceCharge(@Body RequestBody requestBody);
}
......@@ -2,8 +2,8 @@ package com.gingersoft.gsa.cloud.manager.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionHeader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
......@@ -90,9 +90,22 @@ public class TableListPresenter extends BasePresenter<TableListContract.Model, T
/**
* 組合區域集合
*/
public List<TableArea> assembleAreaList(List<TableItem> tableList) {
public List<TableArea> assembleAreaList(List<TableArea> areaList, List<TableItem> tableList) {
removeOtherAreaItem(areaList);
if (areaList.size() > 0) {
for (TableItem table : tableList) {
if (table.getRegionId() == -1) {
//將沒有區域的檯 放到其他下面
TableArea newArea = new TableArea();
newArea.setId(-1);
newArea.setRegionName("其他");
areaList.add(newArea);
break;
}
}
return areaList;
}
boolean addOther = false;
List<TableArea> areaList = new ArrayList<>();
for (TableItem table : tableList) {
if (table.getRegionId() != -1) {
if (!equalsAreaId(areaList, table.getRegionId())) {
......@@ -124,6 +137,14 @@ public class TableListPresenter extends BasePresenter<TableListContract.Model, T
return false;
}
private void removeOtherAreaItem(List<TableArea> areaList) {
for (int i = areaList.size() - 1; i >= 0; i--) {
if (areaList.get(i).getRegionName().equals("其他")) {
areaList.remove(i);
}
}
}
public List<QMUISection<SectionHeader, TableItem>> tableAreaTransformToSection(List<TableArea> mItems) {
List<QMUISection<SectionHeader, TableItem>> qmuiSections = new ArrayList<>();
for (int i = 0; i < mItems.size(); i++) {
......@@ -139,6 +160,23 @@ public class TableListPresenter extends BasePresenter<TableListContract.Model, T
if (Objects.requireNonNull(tableArea.getTableItemList().size()) > 0) {
contents.addAll(tableArea.getTableItemList());
}
contents.add(createAddTableItem(tableArea));
return new QMUISection(header, contents, false);
}
/**
* 创建+按钮
*
* @return
*/
private TableItem createAddTableItem(TableArea tableArea) {
TableItem item = new TableItem();
item.setLayoutType(1);
item.setStatus(0);
item.setRegionId(tableArea.getId());
item.setRegionName(tableArea.getRegionName());
return item;
}
}
package com.gingersoft.gsa.cloud.manager.mvp.presenter;
import android.app.Application;
import android.os.CountDownTimer;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.constans.GoldConstants;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.AreaRequest;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.TableRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity;
import com.jess.arms.base.delegate.IActivity;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
......@@ -61,10 +61,16 @@ public class TableManagePresenter extends BasePresenter<TableManageContract.Mode
@Inject
AppManager mAppManager;
//定时获取餐台 定时器
private GetTableTimer tableTimer;
private Disposable mGetTablesDataDisposable;
private TableManageActivity IActivity;
@Inject
public TableManagePresenter(TableManageContract.Model model, TableManageContract.View rootView) {
super(model, rootView);
this.IActivity = (TableManageActivity) rootView;
}
@Override
......@@ -155,11 +161,11 @@ public class TableManagePresenter extends BasePresenter<TableManageContract.Mode
});
}
public void queryAreas(RefreshLayout refreshLayout) {
public void queryAreas(RefreshLayout refreshLayout, boolean showLoading) {
mModel.queryAreas()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> {
if (refreshLayout == null) {
if (refreshLayout == null && showLoading) {
mRootView.showLoading(null);
}
})
......@@ -291,20 +297,14 @@ public class TableManagePresenter extends BasePresenter<TableManageContract.Mode
mRootView.showMessage("更新失敗");
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
}
});
}
public void queryTables(RefreshLayout refreshLayout) {
public void queryTables(RefreshLayout refreshLayout, boolean showLoading) {
mModel.queryTables()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> {
if (refreshLayout == null) {
if (refreshLayout == null && showLoading) {
mRootView.showLoading(null);
}
})
......@@ -315,6 +315,12 @@ public class TableManagePresenter extends BasePresenter<TableManageContract.Mode
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onSubscribe(Disposable d) {
super.onSubscribe(d);
mGetTablesDataDisposable = d;
}
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
......@@ -355,5 +361,167 @@ public class TableManagePresenter extends BasePresenter<TableManageContract.Mode
});
}
public void changeAreaSort(String ids) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", String.valueOf(GsaCloudApplication.getRestaurantId(mApplication)))
.add("ids", ids)
.build();
LogUtil.d(TAG, "changeAreaSort " + " ids:" + ids );
mModel.changeAreaSort(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
List<TableArea> tableAreas = JsonUtils.parseArray(info.getData(), TableArea.class);
if (tableAreas.size() > 0) {
mRootView.queryAreasSuccess(tableAreas, TableManageActivity.CHANGE_AREA_SORT);
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showMessage("更新失敗");
}
}
});
}
public void changeTableSort(String ids) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", String.valueOf(GsaCloudApplication.getRestaurantId(mApplication)))
.add("ids", ids)
.build();
LogUtil.d(TAG, "changeTableSort " + " ids:" + ids );
mModel.changeTableSort(requestBody)
.subscribeOn(Schedulers.io())
// .doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
// .doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
List<TableItem> tableItems = JsonUtils.parseArray(info.getData(), TableItem.class);
if (tableItems.size() > 0) {
mRootView.queryTablesSuccess(tableItems, TableManageActivity.CHANGE_TABLE_SORT);
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showMessage("更新失敗");
}
}
});
}
private String getTableIds() {
StringBuilder builder = new StringBuilder();
for (TableItem tableItem : IActivity.getTableList()) {
builder.append(tableItem.getId());
builder.append(",");
}
String str = builder.toString();
if (str.endsWith(",")) {
str = str.substring(0, str.length() - 1);
}
return str;
}
public void updateTableServiceCharge(List<TableRequest.UpdateServiceCharge> request) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(request));
String json = GsonUtils.GsonString(request);
mModel.updateTableServiceCharge(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
List<TableItem> tableItems = JsonUtils.parseArray(info.getData(), TableItem.class);
if (tableItems.size() > 0) {
mRootView.queryTablesSuccess(tableItems, TableManageActivity.UPDATE_TABLE_SERVICE_CHARGE);
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showEmptyView(true, 0, null);
}
} else {
mRootView.showMessage("更新失敗");
}
}
});
}
public void initGetTableTimer() {
if (tableTimer == null) {
tableTimer = new GetTableTimer(GoldConstants.refreshTime * 1000, GoldConstants.refreshTime * 1000);
}
TableManageActivity.isRefreshData = true;
tableTimer.start();
}
public void startTableTimer() {
if (tableTimer != null) {
tableTimer.start();
}
}
public void cancelTableTimer() {
if (tableTimer != null) {
tableTimer.cancel();
}
}
/**
* 计时器类 定時更新餐台数据
*/
private class GetTableTimer extends CountDownTimer {
public GetTableTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
}
@Override
public void onFinish() {// 计时完毕时触发
if (TableManageActivity.isRefreshData) {
queryAreas(null, false);
queryTables(null, false);
}
this.start();
}
@Override
public void onTick(long millisUntilFinished) {// 计时过程显示
}
}
public Disposable getGetTablesDataDisposable() {
return mGetTablesDataDisposable;
}
}
......@@ -2,28 +2,15 @@ package com.gingersoft.gsa.cloud.manager.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.constans.MealConstant;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.AreaRequest;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.TableRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.fragment.AddAreaFragment;
import com.gingersoft.gsa.cloud.manager.mvp.ui.fragment.AddTableFragment;
import com.gingersoft.gsa.cloud.manager.mvp.ui.fragment.AreaListFragment;
import com.gingersoft.gsa.cloud.manager.mvp.ui.fragment.TableListFragment;
import com.gingersoft.gsa.cloud.ui.utils.AnimateUtils;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
......@@ -32,35 +19,17 @@ import com.gingersoft.gsa.cloud.manager.mvp.contract.TableManageContract;
import com.gingersoft.gsa.cloud.manager.mvp.presenter.TableManagePresenter;
import com.gingersoft.gsa.cloud.manager.R;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import me.yokeyword.fragmentation.ISupportFragment;
import me.yokeyword.fragmentation.anim.DefaultHorizontalAnimator;
import me.yokeyword.fragmentation.anim.FragmentAnimator;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -79,6 +48,11 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/
public class TableManageActivity extends BaseFragmentActivity<TableManagePresenter> implements TableManageContract.View {
/**
* 輪訓刷新餐檯數據
*/
public static boolean isRefreshData = true;
public static final int ADD_TABLE_RESULT_SUCCESS = 100;
public static final int ADD_AREA_RESULT_SUCCESS = 200;
......@@ -92,7 +66,14 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
public static final byte UPDATE_TABLE_SUCCESS = 22;
public static final byte QUERY_TABLE_SUCCESS = 23;
public static final byte CHANGE_AREA_SORT = 30;
public static final byte CHANGE_TABLE_SORT = 31;
public static final byte UPDATE_TABLE_SERVICE_CHARGE = 32;
private List<TableArea> mTableAreaList = new ArrayList<>();
private List<TableItem> mTableList = new ArrayList<>();
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -115,6 +96,11 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
if (findFragment(TableListFragment.class) == null) {
loadRootFragment(R.id.fl_container, TableListFragment.newInstance());
}
}
public void initGetTableTimer() {
mPresenter.initGetTableTimer();
}
@Override
......@@ -142,7 +128,7 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
}
public void queryAreas(RefreshLayout refreshLayout) {
mPresenter.queryAreas(refreshLayout);
mPresenter.queryAreas(refreshLayout, true);
}
public void addTable(TableRequest.Add request) {
......@@ -158,7 +144,19 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
}
public void queryTables(RefreshLayout refreshLayout) {
mPresenter.queryTables(refreshLayout);
mPresenter.queryTables(refreshLayout, true);
}
public void changeAreaSort(String ids) {
mPresenter.changeAreaSort(ids);
}
public void changeTableSort(String ids) {
mPresenter.changeTableSort(ids);
}
public void updateTableServiceCharge(List<TableRequest.UpdateServiceCharge> request) {
mPresenter.updateTableServiceCharge(request);
}
@Override
......@@ -233,11 +231,15 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
switch (type) {
case ADD_AREA_SUCCESS:
case UPDATE_AREA_SUCCESS:
AddAreaFragment addAreaFragment = (AddAreaFragment) fragment;
addAreaFragment.pop();
AreaListFragment areaListFragment = findFragment(AreaListFragment.class);
AreaListFragment areaListFragment = (AreaListFragment) fragment;
if (areaListFragment != null) {
areaListFragment.updateAreaData(areas);
if (type == ADD_AREA_SUCCESS) {
areaListFragment.addSuccess();
}
}
TableListFragment tableListFragment = findFragment(TableListFragment.class);
if(tableListFragment != null){
tableListFragment.updateTableData(mTableAreaList, mTableList);
}
break;
case DELETE_AREA_SUCCESS:
......@@ -246,29 +248,43 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
case QUERY_AREA_SUCCESS:
break;
case CHANGE_AREA_SORT:
break;
}
}
}
@Override
public void queryTablesSuccess(List<TableItem> tables, int type) {
if (mTableList.size() > 0) {
mTableList.clear();
}
this.mTableList.addAll(tables);
ISupportFragment fragment = getTopFragment();
if (fragment != null) {
if (fragment instanceof TableListFragment) {
TableListFragment tableListFragment = (TableListFragment) fragment;
tableListFragment.updateTableData(tables);
tableListFragment.updateTableData(mTableAreaList, tables);
}
TableListFragment tableListFragment = findFragment(TableListFragment.class);
switch (type) {
case ADD_TABLE_SUCCESS:
case UPDATE_TABLE_SUCCESS:
AddTableFragment addTableFragment = (AddTableFragment) fragment;
addTableFragment.pop();
TableListFragment tableListFragment = findFragment(TableListFragment.class);
if (tableListFragment != null) {
tableListFragment.updateTableData(tables);
tableListFragment.updateTableData(mTableAreaList, tables);
}
break;
case DELETE_TABLE_SUCCESS:
case UPDATE_TABLE_SERVICE_CHARGE:
if (fragment instanceof TableListFragment) {
tableListFragment.backEdit();
}
break;
case CHANGE_TABLE_SORT:
break;
case QUERY_TABLE_SUCCESS:
......@@ -290,8 +306,28 @@ public class TableManageActivity extends BaseFragmentActivity<TableManagePresent
}
}
@Override
public void onStartRefreshTableData() {
isRefreshData = true;
mPresenter.startTableTimer();
mPresenter.queryTables(null, false);
}
@Override
public void onPauseRefreshTableData() {
isRefreshData = false;
mPresenter.cancelTableTimer();
//立刻停止獲取餐檯接口
if (mPresenter.getGetTablesDataDisposable() != null && !mPresenter.getGetTablesDataDisposable().isDisposed()) {
mPresenter.getGetTablesDataDisposable().dispose();
}
}
public List<TableArea> getTableAreaList() {
return mTableAreaList;
}
public List<TableItem> getTableList() {
return mTableList;
}
}
package com.gingersoft.gsa.cloud.manager.mvp.ui.adapter;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.EditText;
import com.gingersoft.gsa.cloud.manager.R;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
......@@ -50,12 +50,12 @@ public class AreaManageAdapter extends DefaultAdapter<TableArea> {
return R.layout.manager_item_manage_area;
}
class TopTableAreaItemHolder extends BaseHolder<TableArea> {
public class TopTableAreaItemHolder extends BaseHolder<TableArea> {
@BindView(R2.id.tv_name)
TextView tv_name;
// @BindView(R2.id.tv_edit)
// TextView tv_edit;
@BindView(R2.id.ed_name)
EditText ed_name;
// @BindView(R2.id.ed_input_name)
// TextView ed_input_name;
@BindView(R2.id.cb_checked)
CheckBox cb_checked;
......@@ -65,7 +65,18 @@ public class AreaManageAdapter extends DefaultAdapter<TableArea> {
@Override
public void setData(TableArea datasBean, int position) {
tv_name.setText(datasBean.getRegionName());
ed_name.setText(datasBean.getRegionName());
ed_name.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
String name = ed_name.getText().toString();
if (onTextChangedListener != null && !name.equals(datasBean.getRegionName())) {
onTextChangedListener.afterTextChanged(datasBean, name);
}
}
}
});
// tv_edit.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
......@@ -82,8 +93,14 @@ public class AreaManageAdapter extends DefaultAdapter<TableArea> {
datasBean.setChecked(isChecked);
}
});
ed_name.setCursorVisible(true);
ed_name.setFocusable(true);
ed_name.setFocusableInTouchMode(true);
} else {
cb_checked.setVisibility(View.GONE);
ed_name.setCursorVisible(false);
ed_name.setFocusable(false);
ed_name.setFocusableInTouchMode(false);
}
}
}
......@@ -92,15 +109,15 @@ public class AreaManageAdapter extends DefaultAdapter<TableArea> {
isRadioEdit = radioEdit;
}
private OnClickListener onClickListener;
private OnTextChangedListener onTextChangedListener;
public void setOnClickListener(OnClickListener onClickListener) {
this.onClickListener = onClickListener;
public void addTextChangedListener(OnTextChangedListener onTextChangedListener) {
this.onTextChangedListener = onTextChangedListener;
}
public interface OnClickListener {
public interface OnTextChangedListener {
void onItemClick(View v, TableArea function);
void afterTextChanged(TableArea datasBean, String s);
}
}
package com.gingersoft.gsa.cloud.manager.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.manager.R;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionHeader;
import com.gingersoft.gsa.cloud.ui.view.TriangleLabelView;
import com.gingersoft.gsa.cloud.ui.view.TriangleView;
import com.gingersoft.gsa.cloud.ui.view.qm.QDLoadingItemView;
import com.gingersoft.gsa.cloud.ui.view.section.QDSectionHeaderView;
import com.jess.arms.utils.DeviceUtils;
import com.qmuiteam.qmui.layout.QMUIRelativeLayout;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -34,10 +43,28 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
private Context context;
private boolean isRadioEdit = false;
//Item行数(行数根据数据自动计算)
private int ItemRowCount = 6;
//Item高度
private int ItemColHeight;
private int mRadius;
private float mShadowAlpha = 0.25f;
private int mShadowElevationDp = 14;
public void initItemDispalyHeight() {
float screenHeight = DeviceUtils.getScreenHeight(context) - 75 - 75;
ItemColHeight = (int) Math.ceil((double) screenHeight / (double) (ItemRowCount));
ItemColHeight = ItemColHeight - 3;
}
@NonNull
@Override
protected QMUIStickySectionAdapter.ViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
this.context = viewGroup.getContext();
this.mRadius = QMUIDisplayHelper.dp2px(context, 5);
initItemDispalyHeight();
return new QMUIStickySectionAdapter.ViewHolder(new QDSectionHeaderView(viewGroup.getContext()));
}
......@@ -76,14 +103,32 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
TableItem tableItem = section.getItemAt(itemIndex);
viewHolder.tv_name.setText(tableItem.getTableName());
if (tableItem.getLayoutType() == 1) {
viewHolder.fl_add_table.setVisibility(View.VISIBLE);
viewHolder.rl_table.setVisibility(View.GONE);
initAddItemDispalyMetrics(viewHolder);
viewHolder.ll_container.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
setBackGroundWork(viewHolder, Color.parseColor("#FFFFFFFF"), R.color.black,R.color.theme_black);
} else {
viewHolder.rl_table.setVisibility(View.VISIBLE);
viewHolder.fl_add_table.setVisibility(View.GONE);
initTableItemData(viewHolder, tableItem);
initTableItemDispalyMetrics(viewHolder);
initTableBackground(viewHolder, tableItem);
if (tableItem.getServiceCharge() > 0) {
viewHolder.tv_service_fee.setText(tableItem.getServiceCharge() + "%");
viewHolder.tv_service_fee.setVisibility(View.VISIBLE);
} else {
viewHolder.tv_service_fee.setVisibility(View.INVISIBLE);
}
if (isRadioEdit) {
if (isRadioEdit && tableItem.getUseStatus() == 0) {
viewHolder.cb_checked.setChecked(tableItem.isChecked());
viewHolder.cb_checked.setVisibility(View.VISIBLE);
viewHolder.cb_checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
......@@ -96,26 +141,154 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
viewHolder.cb_checked.setVisibility(View.GONE);
}
}
viewHolder.ll_container.setRadiusAndShadow(mRadius, QMUIDisplayHelper.dp2px(context, mShadowElevationDp), mShadowAlpha);
}
private void initTableItemData(ViewHolder viewHolder, TableItem item) {
viewHolder.tv_table.setText(item.getTableName());
if (item.getStatus() != 0) {
viewHolder.tv_people.setVisibility(View.VISIBLE);
if (item.getMinSeatCount() != 0 || item.getMaxSeatCount() != 0) {
viewHolder.tv_people.setText(item.getMinSeatCount() + "-" + item.getMaxSeatCount() + "人");
} else {
viewHolder.tv_people.setText("");
}
viewHolder.tv_table.setMaxLines(1);
} else {
//未開檯空間足夠可換行顯示
viewHolder.tv_table.setMaxLines(2);
viewHolder.tv_people.setVisibility(View.GONE);
}
if (item.getStatus() != 0) {
switch (item.getType()) {
case TableItem.TABLE_TYPE_CANTEEN:
viewHolder.tv_type_labe.setText("堂");
viewHolder.tv_type_labe.setTextColor(Color.parseColor("#249B65"));
break;
case TableItem.TABLE_TYPE_TAKEAWAY:
viewHolder.tv_type_labe.setText("外");
viewHolder.tv_type_labe.setTextColor(Color.parseColor("#FF720A"));
break;
case TableItem.TABLE_TYPE_SELF_FETCHING:
viewHolder.tv_type_labe.setText("自");
viewHolder.tv_type_labe.setTextColor(Color.parseColor("#00479D"));
break;
}
viewHolder.fl_table_type.setVisibility(View.VISIBLE);
} else {
viewHolder.fl_table_type.setVisibility(View.GONE);
}
}
private void initTableBackground(ViewHolder viewHolder, TableItem item) {
// if (item.getSplitStatus() != 0) {
// setBackGroundWork(item, "888", R.drawable.tablebutton_splite, R.drawable.tablebutton_splite_new, R.color.black);
// } else {
viewHolder.ll_container.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
if (item.getUseStatus() == 1) {
setBackGroundWork(viewHolder, Color.parseColor("#FFD14141"), R.color.theme_white_color,R.color.theme_black);
} else {
switch (item.getStatus()) {
case 0:
setBackGroundWork(viewHolder, Color.parseColor("#FFFFFFFF"), R.color.black,R.color.theme_black);
break;
case 1:
// setBackGroundWork(item, "2", R.drawable.table_shape_table_send, R.drawable.tablebutton_glassgreen_new, R.color.theme_white_color); break;
case 2:
setBackGroundWork(viewHolder, Color.parseColor("#FF249B65"), R.color.theme_white_color,R.color.theme_white_color);
break;
case 3:
setBackGroundWork(viewHolder, Color.parseColor("#FFE5AC00"), R.color.theme_white_color,R.color.theme_white_color);
break;
case 4:
case 5:
case 6:
setBackGroundWork(viewHolder, ContextCompat.getColor(context, R.color.Violet), R.color.theme_white_color,R.color.theme_white_color);
break;
}
}
}
private void initTableItemDispalyMetrics(ViewHolder viewHolder) {
if (viewHolder.tv_table.getGravity() != Gravity.CENTER) {
viewHolder.rl_table.setGravity(Gravity.CENTER);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) viewHolder.rl_table.getLayoutParams();
lp.height = ItemColHeight;
viewHolder.rl_table.setLayoutParams(lp);
}
viewHolder.rl_table.setMinimumHeight(ItemColHeight);
RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
relativeLayout.height = ItemColHeight;
viewHolder.rl_table.setLayoutParams(relativeLayout);
}
private void setBackGroundWork(ViewHolder viewHolder, int defaultMainback, int defaultFontColor,int serviceFeeFontColor) {
if (defaultMainback != -1) {
viewHolder.ll_container.setBackgroundColor(defaultMainback);
}
viewHolder.tv_table.setTextColor(context.getResources().getColor(defaultFontColor));
viewHolder.tv_service_fee.setTextColor(context.getResources().getColor(serviceFeeFontColor));
}
private void initAddItemDispalyMetrics(ViewHolder viewHolder) {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) viewHolder.fl_add_table.getLayoutParams();
viewHolder.fl_add_table.setLayoutParams(lp);
viewHolder.fl_add_table.setMinimumHeight(ItemColHeight);
RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
relativeLayout.height = ItemColHeight;
viewHolder.fl_add_table.setLayoutParams(relativeLayout);
}
public void setRadioEdit(boolean radioEdit) {
isRadioEdit = radioEdit;
}
public class ViewHolder extends QMUIStickySectionAdapter.ViewHolder {
@BindView(R2.id.tv_name)
TextView tv_name;
@BindView(R2.id.ll_container)
QMUIRelativeLayout ll_container;
@BindView(R2.id.rl_table)
RelativeLayout rl_table;
@BindView(R2.id.tv_table)
TextView tv_table;
@BindView(R2.id.tv_people)
TextView tv_people;
// @BindView(R2.id.btn_showMain)
// Button btn_showMain;
// @BindView(R2.id.iv_vip)
// ImageView iv_vip;
// @BindView(R2.id.tv_scan_flag)
// TextView tv_scan_flag;
@BindView(R2.id.tv_service_fee)
TextView tv_service_fee;
@BindView(R2.id.cb_checked)
CheckBox cb_checked;
@BindView(R2.id.fl_add_table)
FrameLayout fl_add_table;
@BindView(R2.id.fl_table_type)
FrameLayout fl_table_type;
@BindView(R2.id.tlv_table_type)
TriangleLabelView tlv_table_type;
@BindView(R2.id.tv_type_labe)
TextView tv_type_labe;
public ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
public TextView getTvName() {
return tv_name;
return tv_table;
}
public TextView getTvServiceFee() {
......@@ -126,6 +299,7 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
TableItem item = getSectionItem(position);
return item;
}
}
}
......@@ -13,7 +13,7 @@ import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.AreaRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
......
......@@ -3,19 +3,18 @@ package com.gingersoft.gsa.cloud.manager.mvp.ui.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.TableRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
......@@ -32,16 +31,10 @@ import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -66,15 +59,21 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
private TableManageActivity mActivity;
private QMUIPopup mNormalPopup;
private QMUICommonListItemView areaItemView;
private EditText tableNameEditText, peopleNumberEditText, serverchargeEditText, tableSortEditText;
private QMUICommonListItemView tableTypeItemView;
private EditText tableNameEditText, peopleMixNumberEditText, peopleMaxNumberEditText, defalutPeopleNumberEditText, serverchargeEditText;
private static final String TABLE_AREA = "table";
private TableItem mTableItem;
private int currentAreaId;
/**
* 餐檯類型
*/
private String[] tableTypes = {"堂食", "外賣", "自取"};
private int tableType = -1;
public static AddTableFragment newInstance(TableItem item) {
AddTableFragment fragment = new AddTableFragment();
if (item != null) {
......@@ -119,7 +118,7 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
Button rightButton = mTopBar.addRightTextButton("保存", R.id.qmui_dialog_edit_right_icon);
rightButton.setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
rightButton.setOnClickListener(v -> {
if (mTableItem != null) {
if (mTableItem.getLayoutType() == 0) {
//修改
mActivity.updateTable(createUpdateTableRequest(mTableItem.getId()));
} else {
......@@ -129,7 +128,7 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
}
});
mTopBar.setBackgroundResource(R.color.theme_color);
if (mTableItem != null) {
if (mTableItem.getLayoutType() == 0) {
mTopBar.setTitle("修改餐檯").setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
} else {
mTopBar.setTitle("添加餐檯").setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
......@@ -140,101 +139,179 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
int height = QMUIResHelper.getAttrDimen(mContext, com.qmuiteam.qmui.R.attr.qmui_list_item_height);
areaItemView = mGroupListView.createItemView(null,
"區域",
getAreaName(),
QMUICommonListItemView.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
height);
areaItemView.setTipPosition(QMUICommonListItemView.TIP_POSITION_RIGHT);
/**
* 區域,餐檯名稱
*/
QMUICommonListItemView tableAreaItemView = mGroupListView.createItemView("區域");
tableAreaItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
TextView textView = new TextView(mContext);
textView.setText(getAreaName());
textView.setTextSize(16);
textView.setTextColor(ContextCompat.getColor(mContext, R.color.theme_grey_color));
tableAreaItemView.addAccessoryCustomView(textView);
QMUICommonListItemView tableNameItemView = mGroupListView.createItemView("餐檯名稱");
tableNameItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
tableNameEditText = new EditText(mContext);
tableNameEditText.setHint("必填");
if (mTableItem != null) {
if (mTableItem.getLayoutType() == 0) {
tableNameEditText.setText(mTableItem.getTableName());
}
tableNameEditText.setWidth(QMUIDisplayHelper.dp2px(mActivity, 75));
// tableNameEditText.setWidth(QMUIDisplayHelper.dp2px(mActivity, 75));
tableNameEditText.setTextSize(16);
tableNameEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
tableNameItemView.addAccessoryCustomView(tableNameEditText);
int size = QMUIDisplayHelper.dp2px(mContext, 20);
QMUIGroupListView.newSection(mContext)
.setLeftIconSize(size, ViewGroup.LayoutParams.WRAP_CONTENT)
.addItemView(tableAreaItemView, null)
.addItemView(tableNameItemView, null)
.setMiddleSeparatorInset(QMUIDisplayHelper.dp2px(mContext, 16), 0)
.addTo(mGroupListView);
/**
* 就餐人數範圍,默認人數
*/
QMUICommonListItemView peopleNumberItemView = mGroupListView.createItemView("就餐人數");
peopleNumberItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
peopleNumberEditText = new EditText(mContext);
peopleNumberEditText.setHint("必填");
if (mTableItem != null) {
peopleNumberEditText.setText(mTableItem.getSeatCount() + "");
}
peopleNumberEditText.setWidth(QMUIDisplayHelper.dp2px(mActivity, 75));
peopleNumberEditText.setTextSize(16);
peopleNumberEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
peopleNumberEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
peopleNumberItemView.addAccessoryCustomView(peopleNumberEditText);
peopleMixNumberEditText = new EditText(mContext);
peopleMixNumberEditText.setHint("最少人數");
if (mTableItem.getLayoutType() == 0) {
peopleMixNumberEditText.setText(mTableItem.getMinSeatCount() + "");
}
peopleMixNumberEditText.setGravity(Gravity.CENTER);
peopleMixNumberEditText.setTextSize(13);
peopleMixNumberEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
peopleMixNumberEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
peopleMixNumberEditText.setBackground(ArmsUtils.getDrawablebyResource(mContext, R.drawable.shape_delivery_item_btn_normal));
TextView tv_line = new TextView(mContext);
tv_line.setGravity(Gravity.CENTER);
tv_line.setText("一");
tv_line.setTextSize(14);
tv_line.setTextColor(ContextCompat.getColor(mContext, R.color.theme_black));
peopleMaxNumberEditText = new EditText(mContext);
peopleMaxNumberEditText.setHint("最多人數");
if (mTableItem.getLayoutType() == 0) {
peopleMaxNumberEditText.setText(mTableItem.getMaxSeatCount() + "");
}
peopleMaxNumberEditText.setGravity(Gravity.CENTER);
peopleMaxNumberEditText.setTextSize(13);
peopleMaxNumberEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
peopleMaxNumberEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
peopleMaxNumberEditText.setBackground(ArmsUtils.getDrawablebyResource(mContext, R.drawable.shape_delivery_item_btn_normal));
peopleNumberItemView.addAccessoryCustomView(peopleMixNumberEditText);
peopleNumberItemView.addAccessoryCustomView(tv_line);
peopleNumberItemView.addAccessoryCustomView(peopleMaxNumberEditText);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER | Gravity.RIGHT;
params.width = 130;
peopleMixNumberEditText.setLayoutParams(params);
FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
params2.gravity = Gravity.CENTER | Gravity.RIGHT;
params2.width = 30;
params2.rightMargin = 150;
tv_line.setLayoutParams(params2);
FrameLayout.LayoutParams params3 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
params3.gravity = Gravity.CENTER | Gravity.RIGHT;
params3.width = 130;
params3.rightMargin = 200;
peopleMaxNumberEditText.setLayoutParams(params3);
QMUICommonListItemView defalutPeopleNumberItemView = mGroupListView.createItemView("默認人數");
defalutPeopleNumberItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
defalutPeopleNumberEditText = new EditText(mContext);
defalutPeopleNumberEditText.setHint("0");
if (mTableItem.getLayoutType() == 0) {
defalutPeopleNumberEditText.setText(mTableItem.getSeatCount() + "");
}
defalutPeopleNumberEditText.setTextSize(16);
defalutPeopleNumberEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
defalutPeopleNumberEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
defalutPeopleNumberItemView.addAccessoryCustomView(defalutPeopleNumberEditText);
TextView tv_people = new TextView(mContext);
tv_people.setGravity(Gravity.CENTER);
tv_people.setText("人");
tv_people.setTextSize(14);
tv_people.setTextColor(ContextCompat.getColor(mContext, R.color.theme_black));
defalutPeopleNumberItemView.addAccessoryCustomView(tv_people);
FrameLayout.LayoutParams params5 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
params5.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
tv_people.setLayoutParams(params5);
FrameLayout.LayoutParams params6 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.MATCH_PARENT);
params6.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
params6.rightMargin = 60;
defalutPeopleNumberEditText.setLayoutParams(params6);
QMUIGroupListView.newSection(getContext())
.setLeftIconSize(size, ViewGroup.LayoutParams.WRAP_CONTENT)
.addItemView(peopleNumberItemView, null)
.addItemView(defalutPeopleNumberItemView, null)
.setMiddleSeparatorInset(QMUIDisplayHelper.dp2px(getContext(), 16), 0)
.addTo(mGroupListView);
/**
* 餐桌類型
*/
tableTypeItemView = mGroupListView.createItemView(null,
"餐桌類型",
getTableType(),
QMUICommonListItemView.HORIZONTAL,
QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
height);
tableTypeItemView.setTipPosition(QMUICommonListItemView.TIP_POSITION_RIGHT);
QMUIGroupListView.newSection(getContext())
.setLeftIconSize(size, ViewGroup.LayoutParams.WRAP_CONTENT)
.addItemView(tableTypeItemView, new View.OnClickListener() {
@Override
public void onClick(View v) {
showTableTypeBottomSheetList(true, true, false, "餐檯類型",
tableTypes, true, false);
}
})
.setMiddleSeparatorInset(QMUIDisplayHelper.dp2px(getContext(), 16), 0)
.addTo(mGroupListView);
/**
* 服務費
*/
QMUICommonListItemView serverchargeItemView = mGroupListView.createItemView("服務費%");
serverchargeItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
serverchargeEditText = new EditText(mContext);
serverchargeEditText.setHint("0");
if (mTableItem != null) {
serverchargeEditText.setHint("请输入服务费");
if (mTableItem.getLayoutType() == 0 && mTableItem.getServiceCharge() != 0) {
serverchargeEditText.setText(mTableItem.getServiceCharge() + "");
}
serverchargeEditText.setWidth(QMUIDisplayHelper.dp2px(mActivity, 75));
serverchargeEditText.setTextSize(16);
serverchargeEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
serverchargeEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
serverchargeItemView.addAccessoryCustomView(serverchargeEditText);
QMUICommonListItemView tableSortItemView = mGroupListView.createItemView("餐桌排序");
tableSortItemView.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CUSTOM);
tableSortEditText = new EditText(mContext);
// tableSortEditText.setHint("100");
if (mTableItem != null) {
tableSortEditText.setText(mTableItem.getSort() + "");
}else {
tableSortEditText.setText("100");
}
tableSortEditText.setWidth(QMUIDisplayHelper.dp2px(mActivity, 75));
tableSortEditText.setTextSize(16);
tableSortEditText.setBackgroundColor(ContextCompat.getColor(mContext, R.color.trans));
tableSortEditText.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
tableSortItemView.addAccessoryCustomView(tableSortEditText);
tableSortItemView.showNewTip(true);
tableSortItemView.setNewTipImage(R.drawable.question_prompt);
tableSortItemView.setNewTipClick(new View.OnClickListener() {
@Override
public void onClick(View v) {
showSortTip(v);
}
});
int size = QMUIDisplayHelper.dp2px(mContext, 20);
QMUIGroupListView.newSection(mContext)
QMUIGroupListView.newSection(getContext())
.setLeftIconSize(size, ViewGroup.LayoutParams.WRAP_CONTENT)
.addItemView(areaItemView, new View.OnClickListener() {
@Override
public void onClick(View v) {
showAreaBottomSheetList(true, true, false, "所在區域",
mActivity.getTableAreaList(), true, false);
}
})
.addItemView(tableNameItemView, null)
.addItemView(peopleNumberItemView, null)
.addItemView(serverchargeItemView, null)
.addItemView(tableSortItemView, null)
.setMiddleSeparatorInset(QMUIDisplayHelper.dp2px(mContext, 16), 0)
.setMiddleSeparatorInset(QMUIDisplayHelper.dp2px(getContext(), 16), 0)
.addTo(mGroupListView);
}
private void showAreaBottomSheetList(boolean gravityCenter,
private void showTableTypeBottomSheetList(boolean gravityCenter,
boolean addCancelBtn,
boolean withIcon,
CharSequence title,
List<TableArea> areaList,
String[] tableTypeList,
boolean allowDragDismiss,
boolean withMark) {
QMUIBottomSheet.BottomListSheetBuilder builder = new QMUIBottomSheet.BottomListSheetBuilder(getActivity());
......@@ -246,63 +323,33 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
.setOnSheetItemClickListener(new QMUIBottomSheet.BottomListSheetBuilder.OnSheetItemClickListener() {
@Override
public void onClick(QMUIBottomSheet dialog, View itemView, int position, String tag) {
currentAreaId = areaList.get(position).getId();
areaItemView.setDetailText(tag);
tableType = position;
tableTypeItemView.setDetailText(tableTypeList[position]);
dialog.dismiss();
}
});
if (withMark) {
builder.setCheckedIndex(40);
}
for (TableArea item : areaList) {
builder.addItem(item.getRegionName());
for (String item : tableTypeList) {
builder.addItem(item);
}
builder.build().show();
}
private void showSortTip(View v) {
TextView textView = new TextView(mContext);
textView.setLineSpacing(QMUIDisplayHelper.dp2px(mContext, 4), 1.0f);
int padding = QMUIDisplayHelper.dp2px(mContext, 20);
textView.setPadding(padding, padding, padding, padding);
textView.setText("默認值為100,數字越小排序\n" + "越靠前!");
int color = QMUIResHelper.getAttrColor(mContext, R.attr.app_skin_common_title_text_color);
textView.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_black));
// QMUISkinValueBuilder builder = QMUISkinValueBuilder.acquire();
// builder.textColor(R.attr.app_skin_common_title_text_color);
// QMUISkinHelper.setSkinValue(textView, builder);
// builder.release();
mNormalPopup = QMUIPopups.popup(mContext, QMUIDisplayHelper.dp2px(mContext, 250))
.preferredDirection(QMUIPopup.DIRECTION_BOTTOM)
.view(textView)
.edgeProtection(QMUIDisplayHelper.dp2px(mContext, 20))
.dimAmount(0.6f)
.animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER)
.onDismiss(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
}
})
.show(v);
}
private String getAreaName() {
String areaName = "";
if (mTableItem != null) {
//修改操作
areaName = mTableItem.getRegionName();
String areaName = mTableItem.getRegionName();
currentAreaId = mTableItem.getRegionId();
} else {
//添加操作
if (mActivity.getTableAreaList().size() > 0) {
areaName = mActivity.getTableAreaList().get(0).getRegionName();
currentAreaId = mActivity.getTableAreaList().get(0).getId();
} else {
areaName = "其他";
return areaName;
}
private String getTableType() {
String tableType = "";
if (mTableItem != null && mTableItem.getType() != -1) {
//修改操作
tableType = tableTypes[mTableItem.getType()];
}
return areaName;
return tableType;
}
@Override
......@@ -348,16 +395,20 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
if (!TextUtils.isEmpty(serverchargeEditText.getText().toString())) {
addTableRequest.setServiceCharge(Double.parseDouble(serverchargeEditText.getText().toString()));
}
if (!TextUtils.isEmpty(peopleNumberEditText.getText().toString())) {
addTableRequest.setSeatCount(Integer.parseInt(peopleNumberEditText.getText().toString()));
if (!TextUtils.isEmpty(defalutPeopleNumberEditText.getText().toString())) {
addTableRequest.setSeatCount(Integer.parseInt(defalutPeopleNumberEditText.getText().toString()));
}
if (!TextUtils.isEmpty(peopleMaxNumberEditText.getText().toString())) {
addTableRequest.setMaxSeatCount(Integer.parseInt(peopleMaxNumberEditText.getText().toString()));
}
if (!TextUtils.isEmpty(tableSortEditText.getText().toString())) {
addTableRequest.setSort(Integer.parseInt(tableSortEditText.getText().toString()));
if (!TextUtils.isEmpty(peopleMixNumberEditText.getText().toString())) {
addTableRequest.setMinSeatCount(Integer.parseInt(peopleMixNumberEditText.getText().toString()));
}
addTableRequest.setType(tableType);
return addTableRequest;
}
public TableRequest.Update createUpdateTableRequest(int id) {
public TableRequest.Update createUpdateTableRequest(long id) {
TableRequest.Update update = new TableRequest.Update();
update.setId(id);
update.setRegionId(currentAreaId);
......@@ -366,12 +417,16 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
if (!TextUtils.isEmpty(serverchargeEditText.getText().toString())) {
update.setServiceCharge(Double.parseDouble(serverchargeEditText.getText().toString()));
}
if (!TextUtils.isEmpty(peopleNumberEditText.getText().toString())) {
update.setSeatCount(Integer.parseInt(peopleNumberEditText.getText().toString()));
if (!TextUtils.isEmpty(defalutPeopleNumberEditText.getText().toString())) {
update.setSeatCount(Integer.parseInt(defalutPeopleNumberEditText.getText().toString()));
}
if (!TextUtils.isEmpty(tableSortEditText.getText().toString())) {
update.setSort(Integer.parseInt(tableSortEditText.getText().toString()));
if (!TextUtils.isEmpty(peopleMaxNumberEditText.getText().toString())) {
update.setMaxSeatCount(Integer.parseInt(peopleMaxNumberEditText.getText().toString()));
}
if (!TextUtils.isEmpty(peopleMixNumberEditText.getText().toString())) {
update.setMinSeatCount(Integer.parseInt(peopleMixNumberEditText.getText().toString()));
}
update.setType(tableType);
return update;
}
......@@ -380,10 +435,15 @@ public class AddTableFragment extends BaseFragment<AddTablePresenter> implements
showMessage("請輸入餐檯名稱");
return false;
}
if (TextUtils.isEmpty(peopleNumberEditText.getText().toString())) {
showMessage("請輸入就餐人數");
// if (TextUtils.isEmpty(defalutPeopleNumberEditText.getText().toString())) {
// showMessage("請輸入就餐人數");
// return false;
// }
if (tableType == -1) {
showMessage("請選擇餐桌類型");
return false;
}
return true;
}
}
package com.gingersoft.gsa.cloud.manager.mvp.ui.fragment;
import android.content.Intent;
import android.graphics.Color;
import android.net.ParseException;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.AreaRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity;
import com.gingersoft.gsa.cloud.manager.mvp.ui.adapter.AreaManageAdapter;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.recylcler.event.OnRecyclerItemClickListener;
import com.gingersoft.gsa.cloud.ui.recylcler.event.RecyItemTouchHelperCallback;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.google.gson.JsonIOException;
......@@ -37,38 +37,28 @@ import com.gingersoft.gsa.cloud.manager.mvp.presenter.AreaListPresenter;
import com.gingersoft.gsa.cloud.manager.R;
import com.qmuiteam.qmui.alpha.QMUIAlphaFrameLayout;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUIEmptyView;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.yanzhenjie.recyclerview.OnItemClickListener;
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
import com.yanzhenjie.recyclerview.SwipeMenuItem;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.yanzhenjie.recyclerview.touch.OnItemMoveListener;
import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import org.json.JSONException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity.ADD_AREA_RESULT_SUCCESS;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -97,14 +87,22 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
@BindView(R2.id.fl_add_area)
QMUIAlphaFrameLayout fl_add_area;
@BindView(R2.id.ll_add_area_layout)
LinearLayout ll_add_area_layout;
@BindView(R2.id.ll_bottom_operat)
LinearLayout ll_bottom_operat;
@BindView(R2.id.ed_area_name)
EditText ed_area_name;
@BindView(R2.id.cb_all_select)
CheckBox cb_all_select;
private TableManageActivity mActivity;
private AreaManageAdapter mAreaManageAdapter;
private List<TableArea> mTableAreaList = new ArrayList<>();
private boolean isSave = false;
private boolean isRadioEdit;
public static AreaListFragment newInstance() {
......@@ -135,6 +133,16 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
initAdapter();
initRefreshLayout();
mActivity.queryAreas(null);
cb_all_select.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
for (int i = 0; i < mTableAreaList.size(); i++) {
mTableAreaList.get(i).setChecked(isChecked);
}
mAreaManageAdapter.notifyDataSetChanged();
}
});
}
@Override
......@@ -176,6 +184,33 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
}
});
RecyItemTouchHelperCallback itemTouchHelperCallback = new RecyItemTouchHelperCallback(mAreaManageAdapter);
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback);
itemTouchHelper.attachToRecyclerView(recycler_area);
recycler_area.addOnItemTouchListener(new OnRecyclerItemClickListener(recycler_area) {
@Override
public void onItemClick(RecyclerView.ViewHolder viewHolder) {
}
@Override
public void onLongClick(RecyclerView.ViewHolder viewHolder) {
// AreaManageAdapter.TopTableAreaItemHolder viewHolder1 = (AreaManageAdapter.TopTableAreaItemHolder) viewHolder;
// Toast.makeText(mActivity, "長按:" + viewHolder1.getAdapterPosition(), Toast.LENGTH_SHORT).show();
// if (viewHolder.getLayoutPosition() != 0) {
// itemTouchHelper.startDrag(viewHolder);
// }
}
});
itemTouchHelperCallback.setOnMoveListener(new RecyItemTouchHelperCallback.onMoveListener() {
@Override
public void onMoveFinish(String ids) {
mActivity.changeAreaSort(ids);
}
});
}
private void initAdapter() {
......@@ -185,13 +220,20 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
mAreaManageAdapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener() {
@Override
public void onItemClick(View view, int viewType, Object data, int position) {
if (isRadioEdit) {
TableArea tableArea = (TableArea) data;
tableArea.setChecked(!tableArea.isChecked());
mAreaManageAdapter.notifyDataSetChanged();
} else {
start(AddAreaFragment.newInstance((TableArea) data));
// if (isRadioEdit) {
// TableArea tableArea = (TableArea) data;
// tableArea.setChecked(!tableArea.isChecked());
// mAreaManageAdapter.notifyDataSetChanged();
// } else {
// start(AddAreaFragment.newInstance((TableArea) data));
// }
}
});
mAreaManageAdapter.addTextChangedListener(new AreaManageAdapter.OnTextChangedListener() {
@Override
public void afterTextChanged(TableArea datasBean, String name) {
mActivity.updateArea(createUpateAreaRequest(datasBean.getId(), name));
}
});
}
......@@ -207,11 +249,15 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
recycler_area.setVisibility(View.VISIBLE);
}
public void addSuccess(){
ed_area_name.setText("");
}
@Override
public void setData(@Nullable Object data) {
}
private void initCheckedStatus(){
private void initCheckedStatus() {
for (int i = 0; i < mTableAreaList.size(); i++) {
mTableAreaList.get(i).setChecked(false);
}
......@@ -220,26 +266,37 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
@OnClick(R2.id.fl_add_area)
void onClickAddArea() {
startForResult(AddAreaFragment.newInstance(null), ADD_AREA_RESULT_SUCCESS);
if(ll_add_area_layout.getVisibility() == View.GONE){
ll_add_area_layout.setVisibility(View.VISIBLE);
}else {
ll_add_area_layout.setVisibility(View.GONE);
}
@OnClick(R2.id.btn_all_select)
void onClickAddSelect() {
for (int i = 0; i < mTableAreaList.size(); i++) {
mTableAreaList.get(i).setChecked(true);
}
mAreaManageAdapter.notifyDataSetChanged();
}
@OnClick(R2.id.btn_anti_select)
void onClickAntiSelect() {
for (int i = 0; i < mTableAreaList.size(); i++) {
TableArea tableArea = mTableAreaList.get(i);
tableArea.setChecked(!tableArea.isChecked());
@OnClick(R2.id.btn_save_area)
void onClickSaveArea() {
if (addCondition()) {
mActivity.addArea(createAddAreaRequest());
}
mAreaManageAdapter.notifyDataSetChanged();
}
// @OnClick(R2.id.cb_all_select)
// void onClickAddSelect() {
// for (int i = 0; i < mTableAreaList.size(); i++) {
// mTableAreaList.get(i).setChecked(true);
// }
// mAreaManageAdapter.notifyDataSetChanged();
// }
// @OnClick(R2.id.btn_anti_select)
// void onClickAntiSelect() {
// for (int i = 0; i < mTableAreaList.size(); i++) {
// TableArea tableArea = mTableAreaList.get(i);
// tableArea.setChecked(!tableArea.isChecked());
// }
// mAreaManageAdapter.notifyDataSetChanged();
// }
@OnClick(R2.id.btn_sure)
void onClickSure() {
String ids = getDeleteIds();
......@@ -344,6 +401,30 @@ public class AreaListFragment extends BaseFragment<AreaListPresenter> implements
recycler_area.setAdapter(adapter);
}
public boolean addCondition() {
if (TextUtils.isEmpty(ed_area_name.getText().toString())) {
showMessage("請輸入區域名稱");
return false;
}
return true;
}
public AreaRequest.Add createAddAreaRequest() {
int restaurantId = GsaCloudApplication.getRestaurantId(mContext);
AreaRequest.Add areaRequest = new AreaRequest.Add();
areaRequest.setRestaurantId(restaurantId);
areaRequest.setRegionName(ed_area_name.getText().toString());
// areaRequest.setSort(Integer.parseInt(ed_area_sort.getText().toString()));
return areaRequest;
}
public AreaRequest.Update createUpateAreaRequest(int id, String name) {
AreaRequest.Update areaRequest = new AreaRequest.Update();
areaRequest.setId(id);
areaRequest.setRegionName(name);
// areaRequest.setSort(Integer.parseInt(ed_area_sort.getText().toString()));
return areaRequest;
}
private void showRadioEdit() {
if (isRadioEdit) {
......
package com.gingersoft.gsa.cloud.manager.mvp.ui.fragment;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Rect;
import android.net.ParseException;
import android.os.Bundle;
import android.os.Message;
import android.text.InputType;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.manager.R2;
import com.gingersoft.gsa.cloud.manager.di.component.DaggerTableListComponent;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.TableItem;
import com.gingersoft.gsa.cloud.base.common.bean.TableArea;
import com.gingersoft.gsa.cloud.manager.mvp.model.bean.request.TableRequest;
import com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity;
import com.gingersoft.gsa.cloud.manager.mvp.ui.adapter.AreaManageAdapter;
import com.gingersoft.gsa.cloud.manager.mvp.ui.adapter.TableManageSectiontAdapter;
import com.gingersoft.gsa.cloud.ui.adapter.BasTextSectiontAdapter;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionHeader;
import com.gingersoft.gsa.cloud.ui.recylcler.event.OnRecyclerItemClickListener;
import com.gingersoft.gsa.cloud.ui.recylcler.event.RecyItemTouchHelperCallback;
import com.gingersoft.gsa.cloud.ui.utils.AnimateUtils;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.google.gson.JsonIOException;
......@@ -43,10 +39,11 @@ import com.gingersoft.gsa.cloud.manager.mvp.presenter.TableListPresenter;
import com.gingersoft.gsa.cloud.manager.R;
import com.qmuiteam.qmui.alpha.QMUIAlphaFrameLayout;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUIEmptyView;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
......@@ -60,7 +57,6 @@ import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -72,9 +68,10 @@ import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.base.common.bean.OrderDetail.DISCOUNT_TYPE;
import static android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_SETTLING;
import static com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity.ADD_AREA_RESULT_SUCCESS;
import static com.gingersoft.gsa.cloud.manager.mvp.ui.activity.TableManageActivity.ADD_TABLE_RESULT_SUCCESS;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -103,11 +100,13 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
@BindView(R2.id.fl_add_table)
QMUIAlphaFrameLayout fl_add_table;
@BindView(R2.id.tv_area)
QMUIAlphaTextView tv_area;
@BindView(R2.id.ll_bottom_operat)
LinearLayout ll_bottom_operat;
@BindView(R2.id.cb_all_select)
CheckBox cb_all_select;
private Button rightButton;
private TableManageActivity mActivity;
......@@ -117,6 +116,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
private TableManageSectiontAdapter mAdapter;
private List<QMUISection<SectionHeader, TableItem>> mTableAreaSectionList = new ArrayList<>();
private boolean initLoad = false;
/**
* 是否編輯
*/
......@@ -161,14 +161,42 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
initTopbar();
initRefreshLayout();
initStickyLayout();
initRecycleScrollListener();
mActivity.queryAreas(null);
mActivity.queryTables(null);
mActivity.initGetTableTimer();
cb_all_select.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
for (int i = 0; i < mTableList.size(); i++) {
TableItem tableItem = mTableList.get(i);
if (tableItem.getStatus() == 0) {
mTableList.get(i).setChecked(isChecked);
}
}
mAdapter.notifyDataSetChanged();
}
});
}
@Override
public void onResume() {
super.onResume();
hideSoftInput();
//開始刷新餐檯數據
mActivity.onStartRefreshTableData();
}
@Override
public void onPause() {
super.onPause();
//停止刷新餐檯數據
mActivity.onPauseRefreshTableData();
}
@Override
public void setData(@Nullable Object data) {
}
private void initTopbar() {
......@@ -176,20 +204,30 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
mTopBar.addLeftBackImageButton().setOnClickListener(v -> killMyself());
mTopBar.setTitle("餐檯管理").setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
Button rightButton = mTopBar.addRightTextButton("編輯", R.id.qmui_dialog_edit_right_icon);
rightButton = mTopBar.addRightTextButton("編輯", R.id.qmui_dialog_edit_right_icon);
rightButton.setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
rightButton.setOnClickListener(v -> {
clickEdit(rightButton);
});
}
private void clickEdit(Button rightButton) {
isRadioEdit = !isRadioEdit;
if (isRadioEdit) {
initCheckedStatus();
if (rightButton != null) {
rightButton.setText("取消");
}
mActivity.onPauseRefreshTableData();
} else {
if (rightButton != null) {
rightButton.setText("編輯");
}
mActivity.onStartRefreshTableData();
}
showRadioEdit();
mAdapter.setRadioEdit(isRadioEdit);
mAdapter.notifyDataSetChanged();
});
}
private void initRefreshLayout() {
......@@ -223,13 +261,17 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
TableManageSectiontAdapter.ViewHolder viewHolder = (TableManageSectiontAdapter.ViewHolder) holder;
if (viewHolder.getTvName().getText() != null) {
TableItem item = viewHolder.getTableItem(position);
if(isRadioEdit){
if (item.getLayoutType() == 1) {
start(AddTableFragment.newInstance(item));
} else {
if (isRadioEdit) {
item.setChecked(!item.isChecked());
mAdapter.notifyDataSetChanged();
}else {
} else {
start(AddTableFragment.newInstance(item));
}
}
}
} else {
//點擊的頭部,折疊
}
......@@ -247,7 +289,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
int margin = QMUIDisplayHelper.dp2px(getContext(), 10);
outRect.set(margin, margin, margin, margin);
} else {
outRect.set(0, 0, 0, 0);
outRect.set(5, 5, 5, 5);
}
}
});
......@@ -260,17 +302,22 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
@Override
public void onItemClick(RecyclerView.ViewHolder viewHolder) {
QMUIStickySectionAdapter.ViewHolder viewHolder1 = (QMUIStickySectionAdapter.ViewHolder) viewHolder;
Toast.makeText(mActivity, "點擊了:" + viewHolder1.getAdapterPosition(), Toast.LENGTH_SHORT).show();
}
@Override
public void onLongClick(RecyclerView.ViewHolder viewHolder) {
QMUIStickySectionAdapter.ViewHolder viewHolder1 = (QMUIStickySectionAdapter.ViewHolder) viewHolder;
Toast.makeText(mActivity, "長按:" + viewHolder1.getAdapterPosition(), Toast.LENGTH_SHORT).show();
if (viewHolder.getLayoutPosition() != 0) {
itemTouchHelper.startDrag(viewHolder);
// QMUIStickySectionAdapter.ViewHolder viewHolder1 = (QMUIStickySectionAdapter.ViewHolder) viewHolder;
// Toast.makeText(mActivity, "長按:" + viewHolder1.getAdapterPosition(), Toast.LENGTH_SHORT).show();
// if (viewHolder.getLayoutPosition() != 0) {
// itemTouchHelper.startDrag(viewHolder);
// }
}
});
itemTouchHelperCallback.setOnMoveListener(new RecyItemTouchHelperCallback.onMoveListener() {
@Override
public void onMoveFinish(String ids) {
mActivity.changeTableSort(ids);
}
});
......@@ -278,7 +325,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
}
private RecyclerView.LayoutManager createLayoutManager() {
final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
final GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4, LinearLayoutManager.VERTICAL, false);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int i) {
......@@ -295,7 +342,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
mAreaList.addAll(tableAreaList);
}
public void updateTableData(List<TableItem> tableItemList) {
public void updateTableData(List<TableArea> tableAreaList, List<TableItem> tableItemList) {
initParms();
......@@ -306,13 +353,24 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
item.setRegionId(-1);
}
}
mTableAreaSectionList.addAll(mPresenter.tableAreaTransformToSection(mPresenter.assembleTableArea(mPresenter.assembleAreaList(mTableList), mTableList)));
mTableAreaSectionList.addAll(mPresenter.tableAreaTransformToSection(mPresenter.assembleTableArea(mPresenter.assembleAreaList(tableAreaList, mTableList), mTableList)));
// if (!initLoad) {
mAdapter.setData(mTableAreaSectionList);
// } else {
// mAdapter.getCurrentData().clear();
// mAdapter.getCurrentData().addAll(mTableAreaSectionList);
// mAdapter.notifyDataSetChanged();
// }
mEmptyView.hide();
mSectionLayout.setVisibility(View.VISIBLE);
initLoad = true;
}
private void initParms() {
if (mTableList.size() > 0) {
mTableList.clear();
......@@ -325,12 +383,11 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
}
}
@Override
public void setData(@Nullable Object data) {
public void backEdit() {
clickEdit(rightButton);
}
private void initCheckedStatus(){
private void initCheckedStatus() {
for (int i = 0; i < mTableAreaSectionList.size(); i++) {
for (int j = 0; j < mTableAreaSectionList.get(i).getItemCount(); j++) {
mTableAreaSectionList.get(i).getItemAt(j).setChecked(false);
......@@ -339,40 +396,25 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
mAdapter.setData(mTableAreaSectionList);
}
@OnClick(R2.id.tv_area)
void onClickToArea() {
startForResult(AreaListFragment.newInstance(), ADD_AREA_RESULT_SUCCESS);
}
@OnClick(R2.id.fl_add_table)
void onClickAddTable() {
startForResult(AddTableFragment.newInstance(null), ADD_TABLE_RESULT_SUCCESS);
}
@OnClick(R2.id.btn_all_select)
void onClickAddSelect() {
for (int i = 0; i < mTableAreaSectionList.size(); i++) {
for (int j = 0; j < mTableAreaSectionList.get(i).getItemCount(); j++) {
mTableAreaSectionList.get(i).getItemAt(j).setChecked(true);
}
}
mAdapter.setData(mTableAreaSectionList);
startForResult(AreaListFragment.newInstance(), ADD_AREA_RESULT_SUCCESS);
}
@OnClick(R2.id.btn_anti_select)
void onClickAntiSelect() {
for (int i = 0; i < mTableAreaSectionList.size(); i++) {
for (int j = 0; j < mTableAreaSectionList.get(i).getItemCount(); j++) {
TableItem tableItem = mTableAreaSectionList.get(i).getItemAt(j);
tableItem.setChecked(!tableItem.isChecked());
}
@OnClick(R2.id.btn_modify_serviceCharge)
void onClickModifyServiceCharge() {
String ids = getSelectedIds();
if (TextUtils.isEmpty(ids)) {
showMessage("請選擇餐檯");
return;
}
mAdapter.setData(mTableAreaSectionList);
showEditTextDialog(mActivity, "批量修改服務費", "請輸入服務費");
}
@OnClick(R2.id.btn_sure)
@OnClick(R2.id.btn_delete)
void onClickSure() {
String ids = getDeleteIds();
String ids = getSelectedIds();
if (TextUtils.isEmpty(ids)) {
showMessage("請選擇餐檯");
return;
......@@ -382,8 +424,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
CommonTipDialog.showSurpisedDialog(mActivity, "是否刪除所選餐檯", TableManageActivity.class, mActivity, "deleteTable", parameterTypes, parameters);
}
private String getDeleteIds() {
private String getSelectedIds() {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < mTableAreaSectionList.size(); i++) {
for (int j = 0; j < mTableAreaSectionList.get(i).getItemCount(); j++) {
......@@ -401,6 +442,37 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
return str;
}
private List<TableRequest.UpdateServiceCharge> getModifyServiceChargeList(double modifyServiceCharge) {
List<TableRequest.UpdateServiceCharge> updateServiceCharges = new ArrayList<>();
for (int i = 0; i < mTableList.size(); i++) {
TableItem tableItem = mTableList.get(i);
if (tableItem.isChecked()) {
TableRequest.UpdateServiceCharge updateServiceCharge = new TableRequest.UpdateServiceCharge();
updateServiceCharge.setId(tableItem.getId());
updateServiceCharge.setServiceCharge(modifyServiceCharge);
updateServiceCharges.add(updateServiceCharge);
}
}
return updateServiceCharges;
}
public void showEditTextDialog(Activity context, String title, String placeholder) {
final QMUIDialog.EditTextDialogBuilder dialogBuilder = new QMUIDialog.EditTextDialogBuilder(context);
dialogBuilder.setTitle(title);
dialogBuilder.setPlaceholder(placeholder);
dialogBuilder.setInputType(InputType.TYPE_CLASS_NUMBER);
dialogBuilder.addAction("取消", (dialog, index) -> dialog.dismiss());
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
dialog.dismiss();
CharSequence text = dialogBuilder.getEditText().getText();
if (text != null && text.length() > 0) {
mActivity.updateTableServiceCharge(getModifyServiceChargeList(Double.parseDouble(text.toString())));
} else {
showMessage("請輸入服務費比例");
}
});
dialogBuilder.create(R.style.MyDialogTheme2).show();
}
@Override
public void showLoading(String message) {
......@@ -474,15 +546,64 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
mSectionLayout.setVisibility(View.VISIBLE);
}
private void initRecycleScrollListener() {
mSectionLayout.getRecyclerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
switch (newState) {
case SCROLL_STATE_IDLE://停止滚动
if (mActivity != null) {
mActivity.onStartRefreshTableData();
}
break;
case SCROLL_STATE_DRAGGING://正在被外部拖拽,一般为用户正在用手指滚动
case SCROLL_STATE_SETTLING://自动滚动开始
if (mActivity != null) {
mActivity.onPauseRefreshTableData();
}
break;
}
}
});
mSectionLayout.getRecyclerView().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: //用户滑动 先停止刷新餐台数据
if (mActivity != null) {
mActivity.onPauseRefreshTableData();
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mActivity != null) {
mActivity.onStartRefreshTableData();
}
//用户手抬起是 继续刷新餐台数据
break;
}
return false;
}
});
}
private void showRadioEdit() {
if (isRadioEdit) {
fl_add_table.setVisibility(View.GONE);
tv_area.setVisibility(View.GONE);
ll_bottom_operat.setVisibility(View.VISIBLE);
} else {
fl_add_table.setVisibility(View.VISIBLE);
tv_area.setVisibility(View.VISIBLE);
ll_bottom_operat.setVisibility(View.GONE);
}
}
@Override
public List<TableItem> getTableList() {
return mTableList;
}
}
......@@ -5,6 +5,6 @@
android:thicknessRatio="20"
android:useLevel="false">
<solid android:color="#FF3333" />
<solid android:color="#1196DB" />
</shape>
\ No newline at end of file
......@@ -5,57 +5,3 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!--<?xml version="1.0" encoding="utf-8"?>-->
<!--<RelativeLayout 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">-->
<!-- <com.qmuiteam.qmui.widget.QMUITopBar-->
<!-- android:id="@+id/topbar"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="?attr/qmui_topbar_height"-->
<!-- app:qmui_topbar_title_color="@color/theme_white_color" />-->
<!-- <com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout-->
<!-- android:id="@+id/section_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="?attr/qmui_topbar_height"/>-->
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaTextView-->
<!-- android:id="@+id/tv_area_list"-->
<!-- android:layout_width="@dimen/dp_65"-->
<!-- android:layout_height="@dimen/dp_65"-->
<!-- android:layout_toLeftOf="@+id/tv_add_table"-->
<!-- android:layout_marginRight="@dimen/dp_15"-->
<!-- android:layout_marginBottom="@dimen/dp_20"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:text="@string/manager_area"-->
<!-- android:textSize="@dimen/sp_14"-->
<!-- android:textColor="@color/theme_white_color"-->
<!-- android:gravity="center"-->
<!-- android:background="@drawable/ui_shape_theme_oval"/>-->
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaTextView-->
<!-- android:id="@+id/tv_add_table"-->
<!-- android:layout_width="@dimen/dp_65"-->
<!-- android:layout_height="@dimen/dp_65"-->
<!-- android:layout_marginBottom="@dimen/dp_20"-->
<!-- android:layout_marginRight="@dimen/dp_20"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:text="@string/manager_add"-->
<!-- android:textColor="@color/theme_white_color"-->
<!-- android:textSize="@dimen/sp_14"-->
<!-- android:gravity="center"-->
<!-- android:background="@drawable/manage_shape_add_btn_oval"/>-->
<!-- <FrameLayout-->
<!-- android:id="@+id/frameLayout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="?attr/qmui_topbar_height" />-->
<!--</RelativeLayout>-->
......@@ -10,90 +10,127 @@
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height">
<com.qmuiteam.qmui.widget.QMUIEmptyView
android:id="@+id/emptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" />
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlEnableLoadMore="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/theme_white_color">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:spanCount="1" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<com.qmuiteam.qmui.widget.QMUIEmptyView
android:id="@+id/emptyView"
<LinearLayout
android:id="@+id/ll_add_area_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" />
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<EditText
android:id="@+id/ed_area_name"
android:layout_width="0dp"
android:layout_height="@dimen/dp_48"
android:layout_weight="1"
android:background="@null"
android:hint="請輸入打區域名稱"
android:maxLength="20"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:singleLine="true"
android:textColor="@color/normal_color"
android:textColorHint="@color/hint_color"
android:textSize="@dimen/sp_16"
android:visibility="visible"/>
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/btn_save_area"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_38"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_gravity="right|center_vertical"
android:background="@color/theme_red_color"
android:text="保存"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14"
app:qmui_backgroundColor="@color/theme_color"
app:qmui_radius="@dimen/dp_5" />
</LinearLayout>
</LinearLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/ll_bottom_operat"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_height="@dimen/dp_45"
android:layout_gravity="bottom"
android:background="@color/theme_white_color"
android:orientation="horizontal"
android:visibility="gone"
android:weightSum="3">
android:paddingLeft="@dimen/dp_15"
android:paddingRight="@dimen/dp_15"
android:visibility="gone">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_all_select"
android:layout_width="@dimen/dp_0"
<CheckBox
android:id="@+id/cb_all_select"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/theme_color"
android:text="全選"
android:textColor="@color/theme_white_color"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_14" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_anti_select"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_1"
android:layout_weight="1"
android:background="@color/theme_color"
android:text="反選"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/btn_sure"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_1"
android:layout_weight="1"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_38"
android:layout_gravity="right|center_vertical"
android:background="@color/theme_red_color"
android:text="刪除"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14" />
android:textSize="@dimen/sp_14"
app:qmui_backgroundColor="@color/theme_color"
app:qmui_radius="@dimen/dp_5" />
</LinearLayout>
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaTextView-->
<!-- android:id="@+id/tv_add_area"-->
<!-- android:layout_width="@dimen/dp_65"-->
<!-- android:layout_height="@dimen/dp_65"-->
<!-- android:layout_gravity="bottom|right"-->
<!-- android:layout_marginBottom="@dimen/dp_20"-->
<!-- android:layout_marginRight="@dimen/dp_20"-->
<!-- android:background="@drawable/manage_shape_add_btn_oval"-->
<!-- android:gravity="center"-->
<!-- android:text="+"-->
<!-- android:textColor="@color/theme_white_color"-->
<!-- android:textSize="@dimen/sp_14" />-->
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaTextView-->
<!-- android:id="@+id/tv_add_area"-->
<!-- android:layout_width="@dimen/dp_65"-->
<!-- android:layout_height="@dimen/dp_65"-->
<!-- android:layout_gravity="bottom|right"-->
<!-- android:layout_marginBottom="@dimen/dp_20"-->
<!-- android:layout_marginRight="@dimen/dp_20"-->
<!-- android:background="@drawable/manage_shape_add_btn_oval"-->
<!-- android:gravity="center"-->
<!-- android:text="+"-->
<!-- android:textColor="@color/theme_white_color"-->
<!-- android:textSize="@dimen/sp_14" />-->
<com.qmuiteam.qmui.alpha.QMUIAlphaFrameLayout
android:id="@+id/fl_add_area"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_65"
android:layout_gravity="bottom|right"
android:layout_marginBottom="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_45"
android:layout_marginRight="@dimen/dp_20"
android:background="@drawable/manage_shape_add_btn_oval">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -23,13 +23,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlEnableLoadMore="false"
app:srlEnableRefresh="false"
android:layout_marginBottom="@dimen/dp_10">
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/section_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/dp_10"/>
android:layout_height="wrap_content" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
......@@ -48,6 +48,7 @@
android:layout_marginBottom="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_20"
android:background="@drawable/manage_shape_add_btn_oval">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -55,60 +56,53 @@
android:src="@drawable/add_white" />
</com.qmuiteam.qmui.alpha.QMUIAlphaFrameLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_area"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_65"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_15"
android:layout_toLeftOf="@+id/fl_add_table"
android:background="@drawable/ui_shape_theme_oval"
android:gravity="center"
android:text="@string/manager_area"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14" />
<LinearLayout
android:id="@+id/ll_bottom_operat"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:weightSum="3"
android:layout_height="@dimen/dp_45"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:visibility="gone">
android:gravity="center_vertical"
android:paddingLeft="@dimen/dp_15"
android:paddingRight="@dimen/dp_15"
android:visibility="gone"
android:background="@color/theme_white_color">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_all_select"
android:layout_width="@dimen/dp_0"
<CheckBox
android:id="@+id/cb_all_select"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14"
android:text="全選"
android:background="@color/theme_color"/>
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_14" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_anti_select"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="@dimen/dp_1"
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/btn_modify_serviceCharge"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_38"
android:layout_gravity="right|center_vertical"
android:background="@color/theme_red_color"
android:text="批量修改服務費"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14"
android:background="@color/theme_color"
android:text="反選"/>
android:layout_marginRight="@dimen/dp_10"
android:paddingRight="@dimen/dp_8"
android:paddingLeft="@dimen/dp_8"
app:qmui_backgroundColor="@color/theme_color"
app:qmui_radius="@dimen/dp_5" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_sure"
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="@dimen/dp_1"
<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/btn_delete"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_38"
android:layout_gravity="right|center_vertical"
android:background="@color/theme_red_color"
android:text="刪除"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14"
android:background="@color/theme_red_color"
android:text="刪除"/>
app:qmui_backgroundColor="@color/theme_color"
app:qmui_radius="@dimen/dp_5" />
</LinearLayout>
</RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
<!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical"-->
<!--&gt;-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_48"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10">
<TextView
android:id="@+id/tv_name"
<EditText
android:id="@+id/ed_name"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:maxLength="20"
android:singleLine="true"
android:text="大廳"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_14"
android:text="大廳"/>
android:textSize="@dimen/sp_16" />
<CheckBox
android:id="@+id/cb_checked"
......@@ -22,13 +32,33 @@
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_20"
android:visibility="gone" />
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaTextView-->
<!-- android:id="@+id/tv_edit"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="編輯"-->
<!-- android:textColor="@color/theme_color"-->
<!-- android:textSize="@dimen/sp_14"-->
<!-- android:text="編輯"/>-->
<!-- android:textSize="@dimen/sp_14" />-->
</LinearLayout>
<!-- <View-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_1"-->
<!-- android:background="@color/theme_hint_color"/>-->
</LinearLayout>
\ No newline at end of file
<!-- <EditText-->
<!-- android:id="@+id/ed_input_name"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_48"-->
<!-- android:paddingLeft="@dimen/dp_10"-->
<!-- android:paddingRight="@dimen/dp_10"-->
<!-- android:background="@null"-->
<!-- android:hint="請輸入打區域名稱"-->
<!-- android:maxLength="20"-->
<!-- android:singleLine="true"-->
<!-- android:textColor="@color/normal_color"-->
<!-- android:textColorHint="@color/hint_color"-->
<!-- android:textSize="@dimen/sp_16"-->
<!-- android:visibility="gone">-->
<!-- </EditText>-->
<!--</LinearLayout>-->
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.layout.QMUIRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/theme_background_color">
<LinearLayout
android:layout_width="@dimen/dp_100"
android:layout_height="wrap_content"
android:background="@drawable/ui_selector_item_background"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/dp_10"
android:layout_margin="@dimen/dp_10">
android:background="@color/theme_white_color">
<com.qmuiteam.qmui.alpha.QMUIAlphaRelativeLayout
android:id="@+id/rl_table"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_name"
android:id="@+id/tv_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ellipsize="end"
android:maxLines="1"
android:text="Button"
android:textColor="#FF000000"
android:textSize="@dimen/dp_22" />
<TextView
android:id="@+id/tv_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_table"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_3"
android:text=""
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_16" />
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="visible" />
<TextView
android:id="@+id/tv_service_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_2"
android:layout_below="@+id/tv_people"
android:text=""
android:textColor="@color/theme_text_pice_color"
android:textSize="@dimen/sp_16" />
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_13" />
<!-- <com.qmuiteam.qmui.alpha.QMUIAlphaButton-->
<!-- android:id="@+id/btn_showMain"-->
<!-- style="@style/ButtonBorderless"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="96dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:layout_alignParentBottom="true"-->
<!-- android:layout_marginLeft="0dp"-->
<!-- android:layout_marginTop="0dp"-->
<!-- android:text="Button"-->
<!-- android:textSize="@dimen/dp_16"-->
<!-- android:visibility="gone" />-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_vip"-->
<!-- android:layout_width="50dp"-->
<!-- android:layout_height="50dp"-->
<!-- android:layout_alignParentLeft="true"-->
<!-- android:layout_alignParentTop="true"-->
<!-- android:scaleType="fitXY"-->
<!-- android:src="@drawable/qmui_icon_tip_new"-->
<!-- android:visibility="gone" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_scan_flag"-->
<!-- android:layout_width="25dp"-->
<!-- android:layout_height="25dp"-->
<!-- android:layout_alignParentTop="true"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:text="S"-->
<!-- android:background="@color/orange_700"-->
<!-- android:textColor="@color/theme_white_color"-->
<!-- android:gravity="center"-->
<!-- android:visibility="gone"-->
<!-- android:textSize="@dimen/font_normal2" />-->
<CheckBox
android:id="@+id/cb_checked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_2"
android:visibility="gone" />
</LinearLayout>
</FrameLayout>
android:layout_centerHorizontal="true"
android:layout_below="@+id/tv_service_fee"
android:visibility="invisible" />
</com.qmuiteam.qmui.alpha.QMUIAlphaRelativeLayout>
<FrameLayout
android:id="@+id/fl_table_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:visibility="gone">
<com.gingersoft.gsa.cloud.ui.view.TriangleLabelView
android:id="@+id/tlv_table_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundColor="@color/theme_white_color"
app:corner="rightBottom"
app:primaryText="堂"
app:primaryTextColor="#249B65"
app:primaryTextSize="10sp" />
<TextView
android:id="@+id/tv_type_labe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:text="堂"
android:textColor="#249B65"
android:textSize="10sp"
android:padding="@dimen/dp_5"/>
</FrameLayout>
<FrameLayout
android:id="@+id/fl_add_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="+"
android:textColor="#ff3c3c3c"
android:textSize="31sp"/>
</FrameLayout>
</com.qmuiteam.qmui.layout.QMUIRelativeLayout>
......@@ -145,6 +145,14 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network.getCancelReason(requestBody)
}
suspend fun getCancelReason(restaurantId: String, type: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.add("type", type)//取消原因類型,1食品取消,2,物流取消,3,訂單取消
.build()
network.getCancelReason(requestBody)
}
fun getBody(vararg pair: Pair1<String, String>): RequestBody {
val requestBody = FormBody.Builder()
......
......@@ -10,12 +10,12 @@ data class CancelReason(
val content: String,
val content2: String,
val content3: String,
val createTime: Long,
val createTime: Int,
val id: Int,
val restaurantId: Int,
val sort: Int,
val type: Int,
val uid: Int,
val updateTime: Long
val updateTime: Int
)
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.cloud.constans.PrintConstans
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
......@@ -32,16 +31,21 @@ import kotlinx.coroutines.withContext
class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
private fun showLoading(context: Context, message: String? = null) {
if (message != null)
LoadingDialog.showDialogForLoading(context, message, true)
else
LoadingDialog.showDialogForLoading(context)
}
fun cancelDialogForLoading() {
LoadingDialog.cancelDialogForLoading()
}
companion object {
var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var fragmentType = arrayOf("0", "0", "0", "2", "7")
val PrintCode = 1001//打印
val SendCode = 1002//指派送貨
val OrderDelivery = 1003//訂單配送
val Closing = 1004//結賬
val CancelOrder = 1005//取消訂單
val CancelLogistics = 1006//取消物流
val ProductionComplete = 1007//製作完成
}
var mOrderNum = arrayListOf<MutableLiveData<Int>>()
......@@ -60,6 +64,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//派送員信息
var deliveryBean: DeliveryBean? = null
var deliveryConfig: DeliveryConfig? = null
/**
* 獲取訂單數量
* status
......@@ -243,23 +249,16 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
// }
fun getShipanyAndOrderInfo(restaurantId: String, orderId: String, listener: (OrderDetails?) -> Unit) {
fun getShipanyAndOrderInfo(curStat: Int, restaurantId: String, orderId: String, listener: (OrderDetails?) -> Unit) {
launch({
withContext(Dispatchers.IO) {
val orderDetail = withContext(Dispatchers.Default) { repository.getOrderInfo(orderId) }
if (orderDetail.data != null && orderDetail.data!!.isNotEmpty()) {
//訂單詳情不為空
if (orderDetail.data!![0].isDelete != 0) {
//如果不是第三方物流單
withContext(Dispatchers.Main) {
listener.invoke(orderDetail)
}
} else {
if (orderDetail.data!![0].curStat != 0) {
if (curStat != 0) {
val data = orderDetail.data!![0]
val type: Int
val estimatedTime: String
when (orderDetail.data!![0].curStat) {
when (curStat) {
1 -> {
type = 2
estimatedTime = "預計配送員接單時間:"
......@@ -278,7 +277,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
val estimatedBean = withContext(Dispatchers.Default) { repository.getShipanyOrderTime(restaurantId, orderId, type) }//1、预计整张订单完成时间2、預計配送員接單時間3、預計配送員到店時間4、配送員預計送達時間
if (estimatedBean?.data != null && estimatedBean.data.estimated_time > 0) {
if (estimatedBean.data.estimated_time > 0) {
data.estimatedTime = estimatedTime + ("${estimatedBean.data.estimated_time}分鐘後")
} else {
data.estimatedTime = ""
......@@ -287,7 +286,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
withContext(Dispatchers.Main) {
listener.invoke(orderDetail)
}
}
} else {
withContext(Dispatchers.Main) {
listener.invoke(null)
......@@ -301,220 +299,168 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
fun updateOrderStatusByBtn(btnId: Int, dataBean: OrderDetails.DataBean, restaurantId: String, listener: (Int, Boolean) -> Unit) {
/**
* 待確認 --- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬
* 更新訂單信息,自取或是外賣
* status 0,1待確認
* 2 已確認,外賣是指派送單,自取是製作完成
*/
fun updateOrderStatus(context: Context, data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, listener: (Boolean) -> Unit) {
launch({
when (btnId) {
BtnBuilder.sureBtn -> {
// 確認訂單
// 1、如果是外賣,指派到第三方物流
// 2、如果是自取,狀態改為製作中
repository.getDeliveryConfigDTO(restaurantId).apply {
var third = false
//獲取配送設置,查看當前單是否是第三方物流
for (i in 0 until data.list.size) {
if (data.list[i].distributionType == dataBean.deliveryMode) {
third = data.list[i].type == 1
break
}
val status = when (data.STATUS) {//如果以前的狀態是0,則修改為2。。。。
0 -> 2
1 -> 2
2 -> 3
3 -> 4
else -> 0
}
val isPush = when (status) {
2 -> 2
3 -> 1
4 -> 0
else -> 2
}
if (third) {
// 如果是第三方物流,調用第三方接口
thirdSend(dataBean, 2, listener)
// if (data.order_type == 2) {
// 是外賣
if (status == 3) {
//指派送貨,自取是製作完成
if (data.order_type == 2) {
if (orderDetails.data!![0].isDelete != 0) {
if (deliveryBean != null && deliveryBean!!.data.isNotEmpty()) {
selectorDelivery(listener, context, data, status, isPush)
} else {
updateOrderAndPrint(dataBean, 2, listener)
ToastUtils.show(context, "沒有送貨員信息")
}
} else {
//第三方的單,執行重印功能
printOrder(orderDetails, data, context, listener)
}
}
BtnBuilder.printBtn -> {
//打印
printOrder(dataBean, listener)
}
BtnBuilder.ProductionCompletedBtn -> {
//製作完成
repository.gsUpdateOrderStatus(dataBean.ID.toString(), 3, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
listener.invoke(ProductionComplete, code == "1")
} else {
//自取
repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 1, "", "", "", "0", "", 1, 0).apply {
listener.invoke(code == "1")
}
}
} else if (status == 4) {
//結賬,彈窗確認是否結賬
if (orderDetails.data!![0].isDelete == 0) {
//第三方物流單,沒有結賬,重印
printOrder(orderDetails, data, context, listener)
} else {
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 {
dialog.dismiss()
launch({
// updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
// listener.invoke(success)
// }
repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 3, "", "", "", "0", "", 1, 0).apply {
listener.invoke(code == "1")
}
}, {
})
}
fun gsUpdateOrderStatus(orderId: String, orderType: Int, listener: (Int, Boolean) -> Unit) {
launch({
repository.gsUpdateOrderStatus(orderId, 4, orderType, 3, "", "", "", "0", "", 1, 0).apply {
listener.invoke(OrderDelivery, code == "1")
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss()
listener.invoke(false)
}
}
}.createDialogView().show()
}
} else {
showLoading(context)
// 確認訂單
var third = false
if (deliveryConfig != null) {
for (i in 0 until deliveryConfig!!.data.list.size) {
if (deliveryConfig!!.data.list[i].distributionType == data.deliveryMode) {
third = deliveryConfig!!.data.list[i].type == 1
break
}
}
}
if (third) {
// 如果是第三方物流,調用第三方接口
thirdSend(data, orderDetails, status, context, listener)
} else {
updateOrderAndPrint(data, status, context, listener)
}
}, {
listener.invoke(OrderDelivery, false)
})
}
/**
* 待確認 --- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬
* 更新訂單信息,自取或是外賣
* 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。。。。
// 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 (data.order_type == 2) {
// if (orderDetails.data!![0].isDelete != 0) {
// if (deliveryBean != null && deliveryBean!!.data.isNotEmpty()) {
// selectorDelivery(listener, context, data, status, isPush)
// } else {
// ToastUtils.show(context, "沒有送貨員信息")
// }
// } else {
// //第三方的單,執行重印功能
// printOrder(orderDetails, data, context, listener)
// }
// } else {
// //自取
// repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 1, "", "", "", "0", "", 1, 0).apply {
// listener.invoke(code == "1")
// }
// }
// } else if (status == 4) {
// //結賬,彈窗確認是否結賬
// if (orderDetails.data!![0].isDelete == 0) {
// //第三方物流單,沒有結賬,重印
// printOrder(orderDetails, data, context, listener)
// } else {
// 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 {
// dialog.dismiss()
// launch({
// // updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
//// listener.invoke(success)
//// }
// repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 3, "", "", "", "0", "", 1, 0).apply {
// listener.invoke(code == "1")
// }
// }, {
//
// })
// }
// hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
// dialog.dismiss()
// listener.invoke(false)
// }
// }
// }.createDialogView().show()
// }
// } else {
// showLoading(context)
// // 確認訂單
// var third = false
// if (deliveryConfig != null) {
// for (i in 0 until deliveryConfig!!.data.list.size) {
// if (deliveryConfig!!.data.list[i].distributionType == data.deliveryMode) {
// third = deliveryConfig!!.data.list[i].type == 1
// break
// }
// }
// }
// if (third) {
// // 如果是第三方物流,調用第三方接口
// thirdSend(data, orderDetails, status, context, listener)
// } else {
// updateOrderAndPrint(data, status, context, listener)
// // 自取的確認訂單
// repository.updateSelfOrderStatus(data.Id.toString(), status.toString(), GsaCloudApplication.getRestaurantId(context).toString()).apply {
// listener.invoke(success)
// }
// }
//// } else {
//// // 自取的確認訂單
//// repository.updateSelfOrderStatus(data.Id.toString(), status.toString(), GsaCloudApplication.getRestaurantId(context).toString()).apply {
//// listener.invoke(success)
//// }
//// }
// }, {
//
// })
}, {
})
}
/**
* 修改訂單狀態並打印
*/
private suspend fun updateOrderAndPrint(dataBean: OrderDetails.DataBean, status: Int, listener: (Int, Boolean) -> Unit) {
repository.gsUpdateOrderStatus(dataBean.ID.toString(), status, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
private suspend fun updateOrderAndPrint(data: OrderList.DataBeanX.DataBean, status: Int, context: Context, listener: (Boolean) -> Unit) {
// updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
//
// }
repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 1, "", "", "", "0", "", 1, 0).apply {
if (status == 0 || status == 1 || status == 2) {
//確認送單
if (this.code == "1") {
listener.invoke(OrderDelivery, true)
// 打印
// 初始化用於打印的view
// 送單成功後,再調用接口獲取取餐碼
getOrderInfo(dataBean.ID.toString()) {
showLoading(context)
getOrderInfo(data.Id.toString()) {
if (it != null) {
printOrder(dataBean, listener)
printOrder(it, data, context, listener)
}
cancelDialogForLoading()
}
} else {
listener.invoke(OrderDelivery, false)
ToastUtils.show(context, "送單失敗")
}
}
cancelDialogForLoading()
}
}
/**
* 打印訂單
*/
private fun printOrder(dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) {
private fun printOrder(orderDetails: OrderDetails, data: OrderList.DataBeanX.DataBean, context: Context, listener: (Boolean) -> Unit) {
if (orderDetails.data != null) {
//訂單信息和廚房單
MyOrderManage.setDataBean(dataBean)
orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType
MyOrderManage.setDataBean(orderDetails.data!![0])
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
MyOrderManage.setDataBean(null)
listener.invoke(PrintCode, result.isSuccess)
Log.e("error", "是否成功打印:" + result.isSuccess)
if (!result.isSuccess) {
ToastUtils.show(context, "打印失敗")
}
MyOrderManage.setDataBean(null)
}
/**
* 打開錢箱
*/
fun openCashBox() {
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 6)
.addParam(PrintConstans.PRINT_LOADING, false)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
}
listener.invoke(true)
}
/**
* 第三方派送
*/
private suspend fun thirdSend(dataBean: OrderDetails.DataBean, status: Int, listener: (Int, Boolean) -> Unit) {
private suspend fun thirdSend(data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, status: Int, context: Context, listener: (Boolean) -> Unit) {
val third = ThirdItem()
//將食品數據轉為第三方需要的數據
dataBean.PRODUCT_NAME?.let {
orderDetails.data?.get(0)?.PRODUCT_NAME?.let {
for (i in it) {
val price = ThirdItem.ThirdItemItem.UntPrice(`val` = i.PRICE!!.toDouble())
val thirdItem = if (i.PRODUCT_NAME != null) {
......@@ -525,29 +471,27 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
third.add(thirdItem)
}
}
//調用第三方物流接口
repository.thirdDelivery(dataBean.ID.toString(), third).apply {
repository.thirdDelivery(data.Id.toString(), third).apply {
cancelDialogForLoading()
if (success) {
listener.invoke(OrderDelivery, true)
updateOrderAndPrint(dataBean, status, listener)
ToastUtils.show(context, "訂單派送成功")
updateOrderAndPrint(data, status, context, listener)
} else {
listener.invoke(OrderDelivery, false)
ToastUtils.show(context, "訂單派送失敗")
}
}
}
// suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int): UpdateOrderBean {
// return repository.updateOrderStatus(orderId, selfOrderId, status, mobile, sender, isPush, orderType)
// }
/**
* 選擇派送員
*/
fun selectorDelivery(context: Context, dataBean: OrderDetails.DataBean, status: Int, listener: (Int, Boolean) -> Unit) {
launch({
repository.getDeliveryInfo(GsaCloudApplication.getRestaurantId(context).toString(), GsaCloudApplication.getMemberId(context).toString()).apply {
deliveryBean = this
if (this.data.isEmpty()) {
ToastUtils.show(context, "沒有配置配送員信息")
return@apply
}
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 {
......@@ -572,11 +516,21 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
confirmBtn.setOnClickListener {
if (selectIndex != -1) {
launch({
repository.gsUpdateOrderStatus(dataBean.ID.toString(), status, dataBean.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply {
// 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, "訂單派送失敗")
// }
// }
repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply {
if (code == "1") {
dialog?.dismiss()
//回調
listener.invoke(OrderDelivery, code == "1")//刷新頁面
listener.invoke(code == "1")//刷新頁面
ToastUtils.show(context, "訂單開始派送")
} else {
ToastUtils.show(context, "訂單派送失敗")
......@@ -596,63 +550,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
.setGravity(Gravity.BOTTOM)
.show()
}
}, {
})
}
/**
* 選擇取消原因
*/
fun selectorCancelReason(context: Context, cancelReason: CancelReason, title: String, listener: (Int) -> Unit) {
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()
}
hepler.getView<TextView>(R.id.tv_title).text = title
val confirmBtn: TextView = hepler.getView(R.id.tv_delivery_confirm)
var selectIndex = -1
val recycler = hepler.getView<RecyclerView>(R.id.rv_delivery)
if (cancelReason.data.isNotEmpty() && cancelReason.data.size < 3) {
recycler.layoutManager = GridLayoutManager(context, cancelReason.data.size)
} else {
recycler.layoutManager = GridLayoutManager(context, 3)
}
val cancelReasons = ArrayList<DeliveryBean.Data>()
for (bean in cancelReason.data) {
val data = DeliveryBean.Data(bean.id, "", bean.content)
cancelReasons.add(data)
}
val deliveryAdapter = DeliveryAdapter(context, cancelReasons)
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) {
listener.invoke(selectIndex)
} else {
ToastUtils.show(context, "請選擇一個取消原因")
}
}
}
}.setWidth(WindowManager.LayoutParams.MATCH_PARENT)
.setHeight((ArmsUtils.getScreenHeidth(context) * 0.5).toInt())
.createDialogView()
.setGravity(Gravity.BOTTOM)
.show()
}
/**
* 獲取配送員信息
......@@ -670,10 +567,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 獲取餐廳第三方物流信息
*/
fun getDeliveryConfigDTO(restaurantId: String, listener: (DeliveryConfig?) -> Unit) {
fun getDeliveryConfigDTO(context: Context) {
launch({
repository.getDeliveryConfigDTO(restaurantId).apply {
listener.invoke(this)
repository.getDeliveryConfigDTO(GsaCloudApplication.getRestaurantId(context).toString()).apply {
deliveryConfig = this
}
}, {
......@@ -683,9 +580,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 取消物流
*/
fun cancelLogistics(shopId: String, orderId: String, reasonId: String, reasonDesc: String, listener: (String) -> Unit) {
fun cancelLogistics(shopId: String, orderId: String, listener: (String) -> Unit) {
launch({
repository.cancelLogistics(shopId, orderId, reasonId, reasonDesc).apply {
repository.cancelLogistics(shopId, orderId).apply {
if (success) {
listener.invoke("已取消物流")
} else {
......@@ -698,11 +595,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
/**
* 取消訂單
* 取消訂單,如果有物流需要先提示取消物流
*/
fun cancelOrder(context: Context, orderId: String, reasonId: String, reasonDesc: String, listener: (Boolean) -> Unit) {
fun cancelOrder(context: Context, orderId: String, listener: (Boolean) -> Unit) {
launch({
repository.updateOrderStates(GsaCloudApplication.getMemberId(context).toString(), orderId, "6", GsaCloudApplication.getMemberName(context), reasonId, reasonDesc).apply {
showLoading(context)
repository.updateOrderStates(GsaCloudApplication.getMemberId(context).toString(), orderId, "6", GsaCloudApplication.getMemberName(context)).apply {
listener.invoke(code == "1")
}
}, {
......@@ -710,16 +608,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
/**
* 獲取餐廳配置的取消原因
*/
fun getCancelReason(restaurantId: String, type: String, listener: (CancelReason?) -> Unit) {
fun getCancelReason(restaurantId: String, type: String) {
launch({
repository.getCancelReason(restaurantId, type).apply {
listener.invoke(this)
}
}, {
listener.invoke(null)
})
}
......@@ -733,4 +628,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
override fun onCleared() {
super.onCleared()
cancelDialogForLoading()
}
}
\ No newline at end of file
......@@ -102,6 +102,7 @@ class OtherOrderActivity : BaseActivity() {
btnHeight = btn_open_or_close_info.height.toFloat()
}
pageViewModel.getDeliveryInfo(this)
pageViewModel.getDeliveryConfigDTO(this)
}
/**
......@@ -256,14 +257,13 @@ class OtherOrderActivity : BaseActivity() {
private fun initWebsocket() {
//開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java)
startService(intent)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
}
// override fun onDestroy() {
// super.onDestroy()
// unbindService(serviceConnection)
// }
override fun onDestroy() {
super.onDestroy()
unbindService(serviceConnection)
}
private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
......@@ -274,12 +274,12 @@ class OtherOrderActivity : BaseActivity() {
Log.e("message", "消息類型$type")
if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) {
// if (type == 6 || type == 7) {
//
// } else {
// //播放提示音
// initSoundPool()
// }
if (type == 6 || type == 7) {
} else {
//播放提示音
initSoundPool()
}
pageViewModel.refreshState.postValue(selectPosition)
}
}
......@@ -420,11 +420,6 @@ class OtherOrderActivity : BaseActivity() {
startActivity(Intent(this, HistoryOrderActivity::class.java))
pop!!.dismiss()
}
view.findViewById<QMUIAlphaTextView>(R.id.tv_open_cash_box).setOnClickListener {
//開錢箱
pageViewModel.openCashBox()
pop!!.dismiss()
}
} else {
pop!!.show(it)
}
......
......@@ -5,7 +5,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
......@@ -19,6 +18,7 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryListAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseFragment
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.fragment_delivery_list.*
import kotlin.math.max
class DeliveryFragment : BaseFragment() {
......@@ -30,21 +30,15 @@ class DeliveryFragment : BaseFragment() {
private lateinit var viewModel: DeliveryViewModel
private lateinit var contentView:View
private lateinit var addBtn: Button
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
contentView = inflater.inflate(R.layout.fragment_delivery_list, container, false)
addBtn = contentView.findViewById(R.id.btn_default)
return contentView
return inflater.inflate(R.layout.fragment_delivery_list, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getDeliveryFactory())[DeliveryViewModel::class.java]
addBtn.text = "+添加配送方式"
addBtn.setOnClickListener{
tv_add_delivery.setOnClickListener{
(activity as DeliverySettingActivity).editDelivery(null)
}
viewModel.otherInfo.observe(viewLifecycleOwner, Observer { it ->
......@@ -59,7 +53,7 @@ class DeliveryFragment : BaseFragment() {
deliveryListAdapter!!.setOnItemChildClickListener { adapter, view, position ->
when (view.id) {
R.id.iv_delete -> {
AppDialog().showWaringDialog(context, "是否確認刪除") { _, dialog ->
AppDialog.showWaringDialog(context, "是否確認刪除") { _, dialog ->
showLoading()
it.data.list[position].apply {
viewModel.updateDeliveryConfig(distributionFeeMin.toString(), distributionFeeMax.toString(), distributionFee.toString(), deliveryCost.toString(), distributionType, type, desc, id, GsaCloudApplication.getRestaurantId(context), GsaCloudApplication.getMemberId(context), lackPrice.toString(), 1) {
......
......@@ -39,7 +39,6 @@ class HistoryFragment : BaseFragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(activity!!.viewModelStore, InjectorUtil.getHistoryModelFactory())[HistoryOrderViewModel::class.java].apply {
historyData.observe(viewLifecycleOwner, Observer{ it ->
cancelDialogForLoading()
refresh_layout.finishRefresh()
......@@ -48,7 +47,7 @@ class HistoryFragment : BaseFragment() {
it?.let { _ ->
refresh_layout.setEnableLoadMore((it.data != null && it.data!!.size > 0))
if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.data.let { it1 -> context?.let { it2 -> HistoryOrderAdapter(status.value, it2, it1) } }
mHistoryOrderAdapter = it.data.let { it1 -> context?.let { it2 -> HistoryOrderAdapter(it2, it1) } }
rv_other_order.layoutManager = LinearLayoutManager(context)
rv_other_order.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter { it ->
......@@ -78,7 +77,6 @@ class HistoryFragment : BaseFragment() {
}
} else {
mHistoryOrderAdapter!!.data = it.data
mHistoryOrderAdapter!!.stauts = status.value
mHistoryOrderAdapter!!.notifyDataSetChanged()
}
}
......
package com.gingersoft.gsa.other_order_mode.ui.fragment
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
......@@ -15,7 +14,6 @@ import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.ui.activity.OrderDetailsActivity
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
......@@ -37,8 +35,18 @@ class PlaceholderFragment : BaseFragment() {
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一致
//如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
// if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
// page = 1
// getOrderList(this, false)
// }
Log.e("eee", "$it 當前:" + arguments?.getInt(INDEX))
if (arguments?.getInt(INDEX) == it) {
page = 1
getOrderList(this, false)
......@@ -52,71 +60,63 @@ class PlaceholderFragment : BaseFragment() {
adapter.setOnItemClickListenter { data ->
// 點擊查詢食品詳情
val intent = Intent(activity, OrderDetailsActivity::class.java)
intent.putExtra("orderId", data.Id.toString())
intent.putExtra("orderType", data.order_type)
intent.putExtra("orderStatus", data.STATUS)
intent.putExtra("orderPayType", data.orderPayType)
startActivity(intent)
// showLoading()
// pageViewModel.getShipanyAndOrderInfo(data.curStat, GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) { it1 ->
// cancelDialogForLoading()
// //顯示彈窗
// if (this@PlaceholderFragment.context != null && it1 != null) {
// OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { view, _, dialog ->
// when (view.id) {
// R.id.btn_assign_shipping -> {
// //修改訂單狀態
// pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
// dialog.dismiss()
// if (it) {
// // 關閉彈窗,並刷新當前頁面
// refresh()
// }
// }
// }
// R.id.btn_cancel_order -> {
// //取消訂單,先判斷有沒有物流
// if (it1.data!![0].isDelete == 0) {
// //第三方物流單
// //彈出彈窗詢問是否確認取消
// AppDialog.showWaringDialog(context, "是否確認取消第三方派送?") { v, dialog ->
// when (v.id) {
// R.id.tv_dialog_confirm -> {
// //取消物流
// showLoading()
// pageViewModel.cancelLogistics(GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) {
// ToastUtils.show(context, it)
// cancelDialogForLoading()
// refresh()//刷新當前頁面
// }
// dialog.dismiss()
// }
// R.id.tv_dialog_cancel -> dialog.dismiss()
// }
// }
// } else {
// //本店配送的單
// pageViewModel.cancelOrder(context!!, data.Id.toString()) {
// ToastUtils.show(context, if (it) {
// "取消訂單成功"
// } else {
// "取消訂單失敗"
// })
// cancelDialogForLoading()
// refresh()//刷新當前頁面
// }
// }
// dialog.dismiss()
// }
// }
// }
// } else {
// ToastUtils.show(context, "獲取訂單詳情失敗")
// }
// }
showLoading()
pageViewModel.getShipanyAndOrderInfo(data.curStat, GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) { it1 ->
cancelDialogForLoading()
//顯示彈窗
if (this@PlaceholderFragment.context != null && it1 != null) {
OtherOrderUtils.showOrderDetailsDialog(this@PlaceholderFragment.context!!, it1, data.STATUS, data.order_type) { view, _, dialog ->
when (view.id) {
R.id.btn_assign_shipping -> {
//修改訂單狀態
pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
dialog.dismiss()
if (it) {
// 關閉彈窗,並刷新當前頁面
refresh()
}
}
}
R.id.btn_cancel_order -> {
//取消訂單,先判斷有沒有物流
if (it1.data!![0].isDelete == 0) {
//第三方物流單
//彈出彈窗詢問是否確認取消
AppDialog.showWaringDialog(context, "是否確認取消第三方派送?") { v, dialog ->
when (v.id) {
R.id.tv_dialog_confirm -> {
//取消物流
showLoading()
pageViewModel.cancelLogistics(GsaCloudApplication.getRestaurantId(context).toString(), data.Id.toString()) {
ToastUtils.show(context, it)
cancelDialogForLoading()
refresh()//刷新當前頁面
}
dialog.dismiss()
}
R.id.tv_dialog_cancel -> dialog.dismiss()
}
}
} else {
//本店配送的單
pageViewModel.cancelOrder(context!!, data.Id.toString()) {
ToastUtils.show(context, if (it) {
"取消訂單成功"
} else {
"取消訂單失敗"
})
cancelDialogForLoading()
refresh()//刷新當前頁面
}
}
dialog.dismiss()
}
}
}
} else {
ToastUtils.show(context, "獲取訂單詳情失敗")
}
}
}
rv_other_order.adapter = adapter
......@@ -136,6 +136,7 @@ class PlaceholderFragment : BaseFragment() {
refresh()
//重新拉取一遍送貨員和第三方派送信息
pageViewModel.getDeliveryInfo(context!!)
pageViewModel.getDeliveryConfigDTO(context!!)
}
refresh_layout.setOnLoadMoreListener {
page++
......
<?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/black" />
</shape>
\ No newline at end of file
......@@ -10,5 +10,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/layout_default" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/tv_add_delivery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_border_bg"
android:text="添加配送方式"
android:padding="@dimen/dp_10"
android:textColor="@color/theme_color" />
</LinearLayout>
\ No newline at end of file
......@@ -155,7 +155,7 @@
<ImageView
android:id="@+id/iv_edit"
android:layout_width="@dimen/dp_30"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginRight="@dimen/dp_10"
android:gravity="center"
......@@ -169,15 +169,15 @@
app:layout_constraintRight_toLeftOf="@id/iv_delete"
app:layout_constraintTop_toTopOf="parent" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
<ImageView
android:id="@+id/iv_delete"
android:layout_width="@dimen/dp_30"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginRight="@dimen/dp_10"
android:gravity="center"
android:paddingLeft="@dimen/dp_5"
android:paddingRight="@dimen/dp_5"
android:src="@drawable/ic_delete"
android:src="@drawable/ic_delete_bill_method"
android:text="刪除"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12"
......
......@@ -95,14 +95,4 @@
<style name="otherOrder_delivery_setting_layout_style">
<item name="android:paddingRight">@dimen/dp_20</item>
</style>
<style name="otherOrder_details_sixteen_text_Style">
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item>
</style>
<style name="otherOrder_details_twelve_text_Style">
<item name="android:textSize">@dimen/dp_12</item>
<item name="android:textColor">@color/color_3c</item>
</style>
</resources>
......@@ -31,6 +31,13 @@ public class IpPrintMaker implements PrintDataMaker {
this.bitmaps = new ArrayList<>();
this.bitmaps.add(bitmap);
}
public IpPrintMaker(Context context, int width, Bitmap bitmap) {
this.mContext = context;
this.width = width;
this.bitmaps = new ArrayList<>();
this.bitmaps.add(bitmap);
}
@Override
public List<byte[]> getPrintData() {
......
......@@ -59,7 +59,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public final static int PRINT_KITCHEN = 3;//送單,廚房單
public final static int PRINT_CLEAN_MACHINE = 4;//清機報表
public final static int PRINT_OTHER_ORDER = 5;//接單內容打印
public final static int PRINT_INSTRUCTION = 6;//開錢箱
private final static int SUNMI_PAPER_WIDTH = 360;//商米打印機紙張寬度
private final static int N5_PAPER_WIDTH = 500;//N5打印機紙張寬度
......@@ -87,8 +86,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return new PrintCleanMachine();
} else if (type == PRINT_OTHER_ORDER) {
return new PrintOtherOrder();
} else if (type == PRINT_INSTRUCTION) {
return new PrintInstruction();
}
return null;
}
......@@ -137,11 +134,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public abstract int getPrintCount(Context context);
public void print(List<PrinterDeviceBean> deviceBeans) {
if (this instanceof PrintInstruction) {
//開錢箱
PrintExecutor executor = new PrintExecutor(getDefaultPrintInList(deviceBeans));
executor.doPrinterRequestAsync(new OpenCashBoxMaker());
} else {
listMap = getPrintBitmap(mContext);
printSize = listMap.size();
printCount = getPrintCount(mContext);
......@@ -149,6 +141,13 @@ public abstract class PrinterRoot 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,則是走默認打印機流程
......@@ -162,7 +161,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}
}
}
}
/**
......@@ -345,7 +343,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}
private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
//獲取默認打印方式,本機、IP
String deftultPrint = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_METHOD, "");
if (deftultPrint.equals("")) {
// 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印
......@@ -404,30 +401,25 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
});
} else if (deftultPrint.equals(PrintConstans.IP_PRINT)) {
// 默認打印方式為ip打印,調用ip打印方法
// 獲取默認ip打印機
// 獲取默認ip打印機
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
ipDevicePrint(getDefaultPrintInList(printerDeviceBeans), bitmaps);
} else {
//有默認打印機
for (PrinterDeviceBean printerDeviceBean : printerDeviceBeans) {
if (printerDeviceBean.getStatus() == 2) {
//默認打印機
ipDevicePrint(printerDeviceBeans.get(0), bitmaps);
return;
}
}
//沒有默認打印機,彈出彈窗,讓用戶選擇ip打印機
showIpPrintDeviceList(printerDeviceBeans, bitmaps);
}
} else {
//沒有打印機,讓用戶去添加
setPrintState(PrintActivity.ADD_PRINT_DEVICE);
}
}
private PrinterDeviceBean getDefaultPrintInList(List<PrinterDeviceBean> printerDeviceBeans) {
for (PrinterDeviceBean printerDeviceBean : printerDeviceBeans) {
if (printerDeviceBean.getStatus() == 2) {
//默認打印機
return printerDeviceBean;
}
}
return null;
}
private void showIpPrintDeviceList
(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
......@@ -473,26 +465,32 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public void ipDevicePrint(PrinterDeviceBean
printerDeviceBean, List<Bitmap> bitmaps, PrintSocketHolder.OnStateChangedListener
stateChangedListener, PrintExecutor.OnPrintResultListener resultListener) {
int paperType = printerDeviceBean.getType();//打印紙類型 1:58mm,2::80mm
int printWidth;//打印出來的內容寬度
if (printerDeviceBean.getPaperSpecification() != null) {
printWidth = Double.valueOf(printerDeviceBean.getPaperSpecification()).intValue();
if (paperType == 1) {
paperType = PrinterWriter58mm.TYPE_58;
printWidth = 580 - 20;//兩邊留20的空隙
} else {
printWidth = 540;
paperType = PrinterWriter80mm.TYPE_80;
printWidth = 800 - 20;//兩邊留20的空隙
}
PrintExecutor executor = new PrintExecutor(printerDeviceBean);
PrintExecutor executor = new PrintExecutor(printerDeviceBean, paperType);
executor.setOnStateChangedListener(stateChangedListener);
executor.setOnPrintResultListener(resultListener);
// List<Bitmap> zoomBitmaps = new ArrayList<>();
if (bitmaps != null) {
for (int j = 0; j < printCount; j++) {
for (int i = 0; i < bitmaps.size(); i++) {
// zoomBitmaps.add(ImageUtils.zoomDrawable(bitmaps.get(i), printWidth));
IpPrintMaker maker = new IpPrintMaker(mContext, printWidth, ImageUtils.zoomDrawable(bitmaps.get(i), printWidth));
executor.doPrinterRequestAsync(maker);
}
}
}
// IpPrintMaker maker = new IpPrintMaker(mContext, printWidth, zoomBitmaps);
// executor.doPrinterRequestAsync(maker);
}
/**
* view轉bitmap
*
......
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.R;
import java.util.ArrayList;
import java.util.List;
/**
* 打印測試
* 測試數據生成
*/
public class TestPrintDataMaker implements PrintDataMaker {
private Context context;
// private String qr;
private int width;
private int height;
public TestPrintDataMaker(Context context, int width, int height) {
this.context = context;
// this.qr = qr;
this.width = width;
this.height = height;
}
@Override
public List<byte[]> getPrintData(int type) {
ArrayList<byte[]> data = new ArrayList<>();
try {
PrinterWriter printer;
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(height, width) : new PrinterWriter80mm(height, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
ArrayList<byte[]> image = printer.getImageByte(context.getResources(), R.mipmap.ic_launcher);
data.addAll(image);
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(context, -1, width);//根據打印類型獲得不同的bitmap
if (bitmaps.size() <= 0) {
ToastUtils.show(context, "打印失敗");
return null;
}
for (int i = 0; i < bitmaps.size(); i++) {
ArrayList<byte[]> image1 = printer.getImageByte(bitmaps.get(i));
data.addAll(image1);//draw2PxPoint2(bitmaps.get(i)
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.feedPaperCutPartial();
}
data.add(printer.getDataAndReset());
// printer.setAlignLeft();
// printer.printLine();
// printer.printLineFeed();
//
// printer.printLineFeed();
// printer.setAlignCenter();
// printer.setEmphasizedOn();
// printer.setFontSize(1);
// printer.print("Selftest");
// printer.printLineFeed();
// printer.setFontSize(0);
// printer.setEmphasizedOff();
// printer.printLineFeed();
//
// printer.print("Gingersoft");
// printer.printLineFeed();
// printer.print("客服电话:××××××××");
// printer.printLineFeed();
//
// printer.setAlignLeft();
// printer.printLineFeed();
//
// printer.print("订单号:88888888888888888");
// printer.printLineFeed();
//
// printer.print("预计送达:" +
// new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.getDefault())
// .format(new Date(System.currentTimeMillis())));
// printer.printLineFeed();
//
// printer.setEmphasizedOn();
// printer.print("#8(已付款)");
// printer.printLineFeed();
// printer.print("××区××路×××大厦××楼×××室");
// printer.printLineFeed();
// printer.setEmphasizedOff();
// printer.printLineFeed();
// printer.print("备注:多加点辣椒,多加点香菜,多加点酸萝卜,多送点一次性手套");
// printer.printLineFeed();
//
// printer.printLine();
// printer.printLineFeed();
// printer.printLineFeed();
// printer.printLineFeed();
data.add(printer.getDataAndClose());
return data;
} catch (Exception e) {
return new ArrayList<>();
}
}
}
package com.joe.print.mvp.ui.activity;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.R;
import com.joe.print.mvp.print.SendPrint;
import com.joe.print.mvp.print.TestPrintDataMaker;
import static com.billy.cc.core.component.CCUtil.EXTRA_KEY_CALL_ID;
/**
* Created by Wyh on 2020/1/7.
*/
public class IpPrintActivity extends Activity implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener, DialogInterface.OnDismissListener {
private Context mContext;
private PrintExecutor executor;
private SendPrint maker;
private String callId;
/**
* -
* 是否打印成功 true:成功
*/
private boolean printStatus = false;
private String ip;
private Integer port;
private int paperType = 1;//打印紙類型 1:58mm,2::80mm
private int printWidth = 560;//打印出來的內容寬度
/**
* -1:打印測試
* 0:上菜紙
* 1:印單
* 2:結賬單
* 3:廚房單
*/
private int type = -1;
private TextView mTvLoadingTip;
private Dialog mLoadingDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
super.onCreate(savedInstanceState);
mContext = this;
getWindow().setBackgroundDrawable(null);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
initDialog();
initIntent();
callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID);
printOrder(this);
}
private void initDialog() {
try {
View view = LayoutInflater.from(mContext).inflate(R.layout.ui_dialog_loading, null);
mTvLoadingTip = view.findViewById(R.id.tv_loading_dialog_text);
mLoadingDialog = new Dialog(mContext, R.style.ui_loading_dialog);
mLoadingDialog.setCancelable(true);
mLoadingDialog.setCanceledOnTouchOutside(false);
Window window = mLoadingDialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// window.getDecorView().setBackgroundResource(android.R.color.transparent);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
mLoadingDialog.show();
mLoadingDialog.setOnDismissListener(dialog -> dismiss());
setLoadingText("加載中...");
} catch (Exception e) {
e.printStackTrace();
}
}
private void setLoadingText(String tip) {
if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
mTvLoadingTip.setText(tip);
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
//點擊當前頁面任意地方自動關閉
finish();
return true;
}
private void initIntent() {
Intent intent = getIntent();
ip = intent.getStringExtra("ip");
port = intent.getIntExtra("port", 0);
paperType = intent.getIntExtra("paperType", 1);
type = intent.getIntExtra(PrintConstans.PRINT_TYPE, -1);
if (ip == null || ip.equals("")) {
ip = "192.168.1.217";
}
if (paperType == 1) {
paperType = PrinterWriter58mm.TYPE_58;
printWidth = 580 - 20;//兩邊留20的空隙
} else {
paperType = PrinterWriter80mm.TYPE_80;
printWidth = 800 - 20;//兩邊留20的空隙
}
}
public void printOrder(Context context) {
PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean("", null, ip, port, type);
if (executor == null) {
executor = new PrintExecutor(printerDeviceBean, paperType);
executor.setOnStateChangedListener(this);
executor.setOnPrintResultListener(this);
}
if (maker == null) {
maker = new SendPrint(context, 255, printWidth, type);
}
executor.setIp(printerDeviceBean);
if (type == -1) {
executor.doPrinterRequestAsync(new TestPrintDataMaker(context, 380, 255));
} else {
executor.doPrinterRequestAsync(maker);
}
}
@Override
public void onResult(int errorCode, PrinterDeviceBean printerDeviceBean) {
String tip;
switch (errorCode) {
case PrintSocketHolder.ERROR_0:
tip = "打印成功";
printStatus = true;
setLoadingText(tip);
dismiss();
break;
case PrintSocketHolder.ERROR_1:
tip = "生成打印數據失敗";
printStatus = false;
setLoadingText(tip);
dismiss();
break;
case PrintSocketHolder.ERROR_2:
case PrintSocketHolder.ERROR_3:
tip = "連接打印機失敗";
printStatus = false;
setLoadingText(tip);
dismiss();
break;
case PrintSocketHolder.ERROR_4:
tip = "寫入測試頁面數據失敗";
setLoadingText(tip);
break;
case PrintSocketHolder.ERROR_5:
tip = "必要的參數不能為空";
setLoadingText(tip);
break;
}
}
@Override
public void onStateChanged(int state, PrinterDeviceBean printerDeviceBean) {
String tip = "打印中...";
switch (state) {
case PrintSocketHolder.STATE_0:
case PrintSocketHolder.STATE_1:
tip = "開始創建連接";
break;
case PrintSocketHolder.STATE_2:
tip = "創建連接成功,開始發送數據";
break;
case PrintSocketHolder.STATE_3:
tip = "開始寫入數據";
break;
case PrintSocketHolder.STATE_4:
tip = "關閉中";
break;
}
setLoadingText(tip);
}
private void dismiss() {
//延遲一秒
new Handler().postDelayed(() -> {
if (mLoadingDialog != null) {
mLoadingDialog.dismiss();
//判断是否为CC调用打开本页面
if (callId != null) {
CCResult result;
if (printStatus) {
result = CCResult.success();
} else {
result = CCResult.error("print error");
}
//为确保不管登录成功与否都会调用CC.sendCCResult,在onDestroy方法中调用
CC.sendCCResult(callId, result);
}
}
finish();
}, 1500);
}
@Override
public void onDismiss(DialogInterface dialog) {
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (executor != null)
executor.closeSocket();
}
}
......@@ -113,7 +113,7 @@ public abstract class QMUIStickySectionAdapter<H extends QMUISection.Model<H>, T
* @param newData new section list
*/
protected void beforeDiffInSet(List<QMUISection<H, T>> oldData, List<QMUISection<H, T>> newData) {
notifyDataSetChanged();
}
/**
......
......@@ -382,6 +382,8 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
openTableBean = new TableBean.DataBean(dataBean);
}
OpenTableManage.getDefault().setPeopleNumber(dataBean.getSeatCount());
OrderBean orderBean = respose.getData();
if (orderBean != null && respose.getData().getOrderDetails() != null) {
if (respose.getData().getCreateTime() != null && openTableBean != null) {
......
package com.gingersoft.gsa.cloud.table.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.text.TextUtils;
......@@ -16,21 +17,28 @@ import android.widget.TextView;
import com.gingersoft.gsa.cloud.aspectj.SingleClick;
import com.gingersoft.gsa.cloud.aspectj.XClickUtil;
import com.gingersoft.gsa.cloud.base.common.bean.TableItem;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.ui.view.TriangleLabelView;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout;
import com.qmuiteam.qmui.alpha.QMUIAlphaRelativeLayout;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.layout.QMUILinearLayout;
import com.qmuiteam.qmui.layout.QMUIRelativeLayout;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
/**
......@@ -60,12 +68,17 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
private int style;
private int mRadius;
private float mShadowAlpha = 0.25f;
private int mShadowElevationDp = 14;
public TableAdapter(Context context, List<TableBean.DataBean> infos, float diaplayScreenHeight, int function) {
super(infos);
this.mContext = context;
this.mFunction = function;
this.mDiaplayScreenHeight = diaplayScreenHeight;
this.mTableTextSize = 20;
this.mRadius = QMUIDisplayHelper.dp2px(context, 5);
initItemDispalyHeight();
}
......@@ -94,13 +107,15 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
class TableItemHolder extends BaseHolder<TableBean.DataBean> {
@BindView(R2.id.ll_container)
LinearLayout ll_container;
QMUIRelativeLayout ll_container;
@BindView(R2.id.rl_table)
QMUIAlphaRelativeLayout rl_table;
@BindView(R2.id.btn_table)
TextView btn_table;
@BindView(R2.id.tv_people)
TextView tv_people;
@BindView(R2.id.tv_service_fee)
TextView tv_service_fee;
@BindView(R2.id.tv_open_duration)
TextView tv_open_duration;
// @BindView(R2.id.btn_showMain)
......@@ -109,6 +124,12 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
// ImageView iv_vip;
// @BindView(R2.id.tv_scan_flag)
// TextView tv_scan_flag;
@BindView(R2.id.fl_table_type)
FrameLayout fl_table_type;
@BindView(R2.id.tlv_table_type)
TriangleLabelView tlv_table_type;
@BindView(R2.id.tv_type_labe)
TextView tv_type_labe;
public TableItemHolder(View itemView) {
super(itemView);
......@@ -121,17 +142,31 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
initItemDispalyMetrics();
initItemTableClick(item, position);
initTableBackground(item);
ll_container.setRadiusAndShadow(mRadius, QMUIDisplayHelper.dp2px(mContext, mShadowElevationDp), mShadowAlpha);
}
private void initItemData(TableBean.DataBean item) {
btn_table.setText(item.getTableName());
// if (item.getServiceCharge() > 0) {
// tv_service_fee.setText(item.getServiceCharge() + "%");
// tv_service_fee.setVisibility(View.VISIBLE);
// } else {
tv_service_fee.setVisibility(View.GONE);
// }
if (item.getStatus() != 0) {
int person = 0;
if (item.getPerson() != 0) {
person = item.getPerson();
} else {
person = item.getSeatCount();
}
tv_people.setVisibility(View.VISIBLE);
tv_people.setText(item.getPerson() + "人");
tv_people.setText(person + "人");
String createDate = item.getCreateTime();
if(!TextUtils.isEmpty(createDate)) {
if (!TextUtils.isEmpty(createDate)) {
String createTime = TimeUtil.getStringByFormat(new Date(createDate), TimeUtil.dateFormatYMDHMS);
String currentTime = TimeUtil.getStringByFormat(System.currentTimeMillis(), TimeUtil.dateFormatYMDHMS);
long[] difference = TimeUtil.getDistanceTimes2(createTime, currentTime);
......@@ -151,6 +186,26 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
tv_people.setVisibility(View.GONE);
tv_open_duration.setVisibility(View.GONE);
}
if (item.getStatus() != 0) {
switch (item.getType()) {
case TableItem.TABLE_TYPE_CANTEEN:
tv_type_labe.setText("堂");
tv_type_labe.setTextColor(Color.parseColor("#249B65"));
break;
case TableItem.TABLE_TYPE_TAKEAWAY:
tv_type_labe.setText("外");
tv_type_labe.setTextColor(Color.parseColor("#FF720A"));
break;
case TableItem.TABLE_TYPE_SELF_FETCHING:
tv_type_labe.setText("自");
tv_type_labe.setTextColor(Color.parseColor("#00479D"));
break;
}
fl_table_type.setVisibility(View.VISIBLE);
} else {
fl_table_type.setVisibility(View.GONE);
}
}
private void initTableBackground(TableBean.DataBean item) {
......@@ -158,29 +213,50 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
// if (item.getSplitStatus() != 0) {
// setBackGroundWork(item, "888", R.drawable.tablebutton_splite, R.drawable.tablebutton_splite_new, R.color.black);
// } else {
ll_container.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
if (item.getUseStatus() == 1) {
setBackGroundWork(item, "999", R.drawable.table_shape_table_use, R.drawable.tablebutton_red_new, R.color.theme_white_color);
setBackGroundWork(item, Color.parseColor("#FFD14141"), R.color.theme_white_color,R.color.theme_black);
} else {
// switch (item.getStatus()) {
// case 0:
// setBackGroundWork(item, Color.parseColor("#FFFFFFFF"), R.color.black);
// break;
// case 1:
//// setBackGroundWork(item, "2", R.drawable.table_shape_table_send, R.drawable.tablebutton_glassgreen_new, R.color.theme_white_color); break;
// case 2:
// setBackGroundWork(item, Color.parseColor("#FF249B65"), R.color.theme_white_color);
// break;
// case 3:
// setBackGroundWork(item, Color.parseColor("#FFE5AC00"), R.color.theme_white_color);
// break;
// case 4:
// setBackGroundWork(item, ContextCompat.getColor(mContext, R.color.Violet), R.color.theme_white_color);
// break;
// case 5:
// setBackGroundWork(item, ContextCompat.getColor(mContext, R.color.Violet), R.color.theme_white_color);
// break;
// case 6:
// setBackGroundWork(item, ContextCompat.getColor(mContext, R.color.Violet), R.color.theme_white_color);
// break;
// }
switch (item.getStatus()) {
case 0:
setBackGroundWork(item, "0", R.drawable.table_shape_table_nomal, R.drawable.tablebutton_skyblue_new, R.color.black);
setBackGroundWork(item, Color.parseColor("#FFFFFFFF"), R.color.black,R.color.theme_black);
break;
case 1:
// setBackGroundWork(item, "2", R.drawable.table_shape_table_send, R.drawable.tablebutton_glassgreen_new, R.color.theme_white_color); break;
case 2:
setBackGroundWork(item, "2", R.drawable.table_shape_table_send, R.drawable.tablebutton_glassgreen_new, R.color.theme_white_color);
setBackGroundWork(item, Color.parseColor("#FF249B65"), R.color.theme_white_color,R.color.theme_white_color);
break;
case 3:
setBackGroundWork(item, "3", R.drawable.table_shape_table_print, R.drawable.tablebutton_yellow_new, R.color.theme_white_color);
setBackGroundWork(item, Color.parseColor("#FFE5AC00"), R.color.theme_white_color,R.color.theme_white_color);
break;
case 4:
setBackGroundWork(item, "4", R.drawable.tablebutton_violet, R.drawable.tablebutton_violet_new, R.color.theme_white_color);
break;
case 5:
setBackGroundWork(item, "5", R.drawable.tablebutton_default, R.drawable.tablebutton_default_new, R.color.theme_white_color);
break;
case 6:
setBackGroundWork(item, "6", R.drawable.tablebutton_default, R.drawable.tablebutton_default_new, R.color.theme_white_color);
setBackGroundWork(item, ContextCompat.getColor(mContext, R.color.Violet), R.color.theme_white_color,R.color.theme_white_color);
break;
}
}
......@@ -204,166 +280,38 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
private void initItemDispalyMetrics() {
if (btn_table.getGravity() != Gravity.CENTER) {
rl_table.setGravity(Gravity.CENTER);
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) rl_table.getLayoutParams();
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rl_table.getLayoutParams();
lp.height = ItemColHeight;
rl_table.setLayoutParams(lp);
}
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) rl_table.getLayoutParams();
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rl_table.getLayoutParams();
rl_table.setLayoutParams(lp);
rl_table.setMinimumHeight(ItemColHeight);
LinearLayout.LayoutParams relativeLayout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
relativeLayout.height = ItemColHeight;
rl_table.setLayoutParams(relativeLayout);
}
private void setBackGroundWork(TableBean.DataBean item, String workstatu, int defaultMainback, int defaultChildBack, int defaultFontColor) {
// private void setBackGroundWork(TableBean.DataBean item, String workstatu, int defaultMainback, int defaultChildBack, int defaultFontColor) {
// if (defaultMainback != -1) {
// ll_container.setBackground(mContext.getResources().getDrawable(defaultMainback));
// }
//// if (defaultChildBack != -1) {
//// btn_table.setBackground(mContext.getResources().getDrawable(defaultMainback));
//// btn_showMain.setBackground(mContext.getResources().getDrawable(defaultMainback));
//// }
// btn_table.setTextColor(mContext.getResources().getColor(defaultFontColor));
//// btn_showMain.setTextColor(mContext.getResources().getColor(defaultFontColor));
// }
private void setBackGroundWork(TableBean.DataBean item, int defaultMainback, int defaultFontColor,int serviceFeeFontColor) {
if (defaultMainback != -1) {
ll_container.setBackground(mContext.getResources().getDrawable(defaultMainback));
ll_container.setBackgroundColor(defaultMainback);
}
// if (defaultChildBack != -1) {
// btn_table.setBackground(mContext.getResources().getDrawable(defaultMainback));
// btn_showMain.setBackground(mContext.getResources().getDrawable(defaultMainback));
// }
btn_table.setTextColor(mContext.getResources().getColor(defaultFontColor));
// btn_showMain.setTextColor(mContext.getResources().getColor(defaultFontColor));
/**
* 可使用 0
* 操作中 1
* 已開台 2
* 已印單 3
* 已結賬 4
* 連台 6
*/
// StateListDrawable bgShape = (StateListDrawable) btn_table.getBackground();
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// switch (workstatu) {
// case "0":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_normal));
// break;
// case "1":
// case "2":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_send));
// break;
// case "3":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_print));
// break;
// case "4":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_normal));
// break;
// case "5":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_normal));
// break;
// case "6":
// d.setColor(ArmsUtils.getColor(mContext, R.color.Violet));
// break;
// case "999":
// d.setColor(ArmsUtils.getColor(mContext, R.color.table_use));
// break;
//
// }
// com.elegant.bin.gsa.mvp.main.model.bean.Color.DatasBean cs;
//
// for (TableWorkStatusColor tws : GSAApplication.androidSetting.getTableWorkStatusColors()) {
// if (tws.getWorkstatu().equalsIgnoreCase(workstatu)) {
// cs = AndroidSettingUtils.getColorById(tws.getColorid());
// if (cs != null) {
// StateListDrawable bgShape = (StateListDrawable) btn_table.getBackground();
// int[] states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// if (!TextUtils.isEmpty(cs.getAndroidColor())) {
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// } else {
// d.setColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
// }
// }
// }
// bgShape = (StateListDrawable) btn_showMain.getBackground();
// states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// if (!TextUtils.isEmpty(cs.getAndroidColor())) {
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// } else {
//// d.setColor(Color.parseColor(""));
// }
// }
// }
// if (!TextUtils.isEmpty(cs.getAndroidfontcolor())) {
// btn_table.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// btn_showMain.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// }
// }
// break;
// }
// }
// if (item.getSplitStatus() == 1 || item.isUsing()) {
// return;
// }
// switch (item.getStatus()) {
// case 2://开台状态下要增加随时时间增加,改变色的功能
// for (TableStatusOpenedOverTime tws : GSAApplication.androidSetting.getTableStatusOpenedOverTimeColors()) {
// if (item.getOropentime_diff() >= tws.times) {
// cs = AndroidSettingUtils.getColorById(tws.getColorid());
// if (cs != null) {
// StateListDrawable bgShape = (StateListDrawable) btn_table.getBackground();
// int[] states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// }
// }
// bgShape = (StateListDrawable) btn_showMain.getBackground();
// states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// }
// }
// btn_table.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// btn_showMain.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// }
// //break;
// }
// }
// break;
// case 3://印单状态下要增加随时间增加,改变色的功能
// for (TableStatusPrintedOverTime tws : GSAApplication.androidSetting.getTableStatusPrintedOverTimeColors()) {
// if (item.getOropentime_diff() >= tws.times) {
// cs = AndroidSettingUtils.getColorById(tws.getColorid());
// if (cs != null) {
// StateListDrawable bgShape = (StateListDrawable) btn_table.getBackground();
// int[] states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// }
// }
// bgShape = (StateListDrawable) btn_showMain.getBackground();
// states = bgShape.getState();
// for (int i = 0; i < states.length; i++) {
// if (states[i] == android.R.attr.state_focused || states[i] == android.R.attr.state_enabled) {
// GradientDrawable d = (GradientDrawable) bgShape.getCurrent();
// d.setColor(Color.parseColor(cs.getAndroidColor()));
// }
// }
// btn_table.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// btn_showMain.setTextColor(Color.parseColor(cs.getAndroidfontcolor()));
// }
// //break;
// }
// }
// break;
// }
// }
tv_service_fee.setTextColor(mContext.getResources().getColor(serviceFeeFontColor));
}
}
......
......@@ -93,7 +93,6 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem
} else if(mContext instanceof OrderContentActivity){
mOrderContentActivity = (OrderContentActivity) mContext;
}
initRecycleScrollListener();
}
......
......@@ -12,11 +12,9 @@
android:id="@+id/recycle_all_table"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/theme_background_color"
android:overScrollMode="never" />
android:background="@color/theme_background_color" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<com.qmuiteam.qmui.widget.QMUIEmptyView
android:id="@+id/emptyView"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.layout.QMUIRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_margin="@dimen/dp_2">
android:layout_margin="@dimen/dp_2"
android:background="@color/theme_white_color">
<com.qmuiteam.qmui.alpha.QMUIAlphaRelativeLayout
android:id="@+id/rl_table"
......@@ -36,11 +38,22 @@
android:visibility="gone"/>
<TextView
android:id="@+id/tv_service_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_2"
android:layout_below="@+id/tv_people"
android:text=""
android:textColor="@color/theme_text_pice_color"
android:textSize="@dimen/sp_13" />
<TextView
android:id="@+id/tv_open_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30:00"
android:layout_below="@+id/tv_people"
android:layout_below="@+id/tv_service_fee"
android:textSize="@dimen/sp_12"
android:layout_centerHorizontal="true"
android:drawableLeft="@mipmap/ic_table_open_time"
......@@ -64,6 +77,34 @@
<!-- android:visibility="gone" />-->
</com.qmuiteam.qmui.alpha.QMUIAlphaRelativeLayout>
<FrameLayout
android:id="@+id/fl_table_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:visibility="gone">
<com.gingersoft.gsa.cloud.ui.view.TriangleLabelView
android:id="@+id/tlv_table_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:backgroundColor="@color/theme_white_color"
app:corner="rightBottom"
app:primaryText="堂"
app:primaryTextColor="#249B65"
app:primaryTextSize="10sp" />
<TextView
android:id="@+id/tv_type_labe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:text="堂"
android:textColor="#249B65"
android:textSize="10sp"
android:padding="@dimen/dp_5"/>
</FrameLayout>
<!-- <ImageView-->
<!-- android:id="@+id/iv_vip"-->
<!-- android:layout_width="50dp"-->
......@@ -86,4 +127,4 @@
<!-- android:gravity="center"-->
<!-- android:visibility="gone"-->
<!-- android:textSize="@dimen/font_normal2" />-->
</LinearLayout>
</com.qmuiteam.qmui.layout.QMUIRelativeLayout>
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