Commit c07bddb7 by Wyh

6.13 完成接單詳情UI,打印機型,其他BUG

parent 6d6f9c24
......@@ -43,7 +43,7 @@ android {
/**
* 版本号
*/
schemaVersion 7
schemaVersion 8
/**
* greendao输出dao的数据库操作实体类文件夹(相对路径 包名+自定义路径名称,包将创建于包名的直接路径下)
*/
......
......@@ -141,7 +141,8 @@ public class TimeUtils {
return sf.format(endDate);
}
/**@param beginTime 開始時間
/**
* @param beginTime 開始時間
* @param distance 差距: 昨天天傳負一,今天傳零,明天傳一
* @param type 類型: 1、天 Calendar.DATE 2、年Calendar.YEAR 3、月Calendar.MONTH
* @param sf {@link #DEFAULT_DATE_MD}
......@@ -473,14 +474,13 @@ public class TimeUtils {
}
/**
*
* @param time
* @param dateFormat
* @return
*/
public static String parseTimeRepeat(String time, SimpleDateFormat dateFormat) {
Date date = null;
if(TextUtils.isEmpty(time)){
if (TextUtils.isEmpty(time)) {
return "";
}
try {
......@@ -498,4 +498,28 @@ public class TimeUtils {
}
return time;
}
/**
* 计算两个日期的相隔天数
*/
public static int daysBetween(Date date1, Date date2) {
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
long time1 = cal.getTimeInMillis();
cal.setTime(date2);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
/**
* 计算两个日期的相隔天数
*/
public static int daysBetween(Calendar startCal, Calendar endCal) {
long time1 = startCal.getTimeInMillis();
long time2 = endCal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
}
......@@ -23,6 +23,7 @@ public class PrintConstans {
* 2:結賬單
* 3:廚房單
* 4:打印view
* 5:外賣接單打印
*/
public static final String PRINT_TYPE = "type";//打印類型
public static final String PRINT_LOADING = "is_show_loading";//是否顯示加載框
......
package com.gingersoft.gsa.cloud.database.bean;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import java.io.Serializable;
@Entity
public class PrintModelBean implements Serializable {
private static final long serialVersionUID = 1705321642319997541L;
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long dbid;
private int id;
private String paperSpecification;//紙張規格
private String printerName;//名稱
private String model;//型號
@Generated(hash = 1820550615)
public PrintModelBean() {
}
@Generated(hash = 1803312003)
public PrintModelBean(Long dbid, int id, String paperSpecification, String printerName, String model) {
this.dbid = dbid;
this.id = id;
this.paperSpecification = paperSpecification;
this.printerName = printerName;
this.model = model;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPaperSpecification() {
return paperSpecification;
}
public void setPaperSpecification(String paperSpecification) {
this.paperSpecification = paperSpecification;
}
public String getPrinterName() {
return printerName;
}
public void setPrinterName(String printerName) {
this.printerName = printerName;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public Long getDbid() {
return this.dbid;
}
public void setDbid(Long dbid) {
this.dbid = dbid;
}
}
......@@ -25,10 +25,14 @@ public class PrinterDeviceBean implements Serializable {
private Integer restaurantId;
private String ip;//ip
private Integer port;//端口
private int type;//打印機紙張類型 為1時是58mm,否則是88mm
// private int type;//打印機紙張類型 為1時是58mm,否則是88mm
private Integer status;//2為默認打印機,1為普通打印機
private int printerModelId;//打印機機型id
private String paperSpecification;//紙張規格
private String printerName;//打印機機型名稱
private String model;//打印機型號
/**
* 飛單1打印機id
*/
......@@ -37,6 +41,7 @@ public class PrinterDeviceBean implements Serializable {
* 飛單2 打印機id
*/
private Long defaultPrinterDeviceId;
@Generated(hash = 626885316)
public PrinterDeviceBean() {
}
......@@ -46,30 +51,32 @@ public class PrinterDeviceBean implements Serializable {
this.id = id;
this.restaurantId = restaurantId;
this.ip = ip;
this.port = port;
this.type = type;
// this.type = type;
}
public PrinterDeviceBean(String name, Integer restaurantId, String ip, Integer port, int type) {
this.name = name;
this.restaurantId = restaurantId;
this.ip = ip;
this.port = port;
this.type = type;
// this.type = type;
}
@Generated(hash = 1104327416)
public PrinterDeviceBean(int id, Long dbid, String name, Integer restaurantId, String ip, Integer port,
int type, Integer status, Long printerDeviceId, Long defaultPrinterDeviceId) {
@Generated(hash = 157623255)
public PrinterDeviceBean(int id, Long dbid, String name, Integer restaurantId, String ip, Integer port, Integer status, int printerModelId, String paperSpecification, String printerName, String model, Long printerDeviceId, Long defaultPrinterDeviceId) {
this.id = id;
this.dbid = dbid;
this.name = name;
this.restaurantId = restaurantId;
this.ip = ip;
this.port = port;
this.type = type;
this.status = status;
this.printerModelId = printerModelId;
this.paperSpecification = paperSpecification;
this.printerName = printerName;
this.model = model;
this.printerDeviceId = printerDeviceId;
this.defaultPrinterDeviceId = defaultPrinterDeviceId;
}
......@@ -118,13 +125,13 @@ public class PrinterDeviceBean implements Serializable {
this.port = port;
}
public int getType() {
return this.type;
}
public void setType(int type) {
this.type = type;
}
// public int getType() {
// return this.type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
public void setRestaurantId(Integer restaurantId) {
this.restaurantId = restaurantId;
......@@ -153,4 +160,36 @@ public class PrinterDeviceBean implements Serializable {
public void setDefaultPrinterDeviceId(Long defaultPrinterDeviceId) {
this.defaultPrinterDeviceId = defaultPrinterDeviceId;
}
public int getPrinterModelId() {
return printerModelId;
}
public void setPrinterModelId(int printerModelId) {
this.printerModelId = printerModelId;
}
public String getPaperSpecification() {
return paperSpecification;
}
public void setPaperSpecification(String paperSpecification) {
this.paperSpecification = paperSpecification;
}
public String getPrinterName() {
return printerName;
}
public void setPrinterName(String printerName) {
this.printerName = printerName;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
}
......@@ -14,10 +14,10 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 7): knows all DAOs.
* Master of DAO (schema version 8): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 7;
public static final int SCHEMA_VERSION = 8;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
......@@ -30,6 +30,7 @@ public class DaoMaster extends AbstractDaoMaster {
FunctionDao.createTable(db, ifNotExists);
ModifierDao.createTable(db, ifNotExists);
PrinterDeviceBeanDao.createTable(db, ifNotExists);
PrintModelBeanDao.createTable(db, ifNotExists);
}
/** Drops underlying database table using DAOs. */
......@@ -43,6 +44,7 @@ public class DaoMaster extends AbstractDaoMaster {
FunctionDao.dropTable(db, ifExists);
ModifierDao.dropTable(db, ifExists);
PrinterDeviceBeanDao.dropTable(db, ifExists);
PrintModelBeanDao.dropTable(db, ifExists);
}
/**
......@@ -70,6 +72,7 @@ public class DaoMaster extends AbstractDaoMaster {
registerDaoClass(FunctionDao.class);
registerDaoClass(ModifierDao.class);
registerDaoClass(PrinterDeviceBeanDao.class);
registerDaoClass(PrintModelBeanDao.class);
}
public DaoSession newSession() {
......
......@@ -17,6 +17,7 @@ import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao;
import com.gingersoft.gsa.cloud.database.greendao.DiscountDao;
......@@ -27,6 +28,7 @@ import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.FunctionDao;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.PrinterDeviceBeanDao;
import com.gingersoft.gsa.cloud.database.greendao.PrintModelBeanDao;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
......@@ -46,6 +48,7 @@ public class DaoSession extends AbstractDaoSession {
private final DaoConfig functionDaoConfig;
private final DaoConfig modifierDaoConfig;
private final DaoConfig printerDeviceBeanDaoConfig;
private final DaoConfig printModelBeanDaoConfig;
private final ComboItemDao comboItemDao;
private final DiscountDao discountDao;
......@@ -56,6 +59,7 @@ public class DaoSession extends AbstractDaoSession {
private final FunctionDao functionDao;
private final ModifierDao modifierDao;
private final PrinterDeviceBeanDao printerDeviceBeanDao;
private final PrintModelBeanDao printModelBeanDao;
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
......@@ -88,6 +92,9 @@ public class DaoSession extends AbstractDaoSession {
printerDeviceBeanDaoConfig = daoConfigMap.get(PrinterDeviceBeanDao.class).clone();
printerDeviceBeanDaoConfig.initIdentityScope(type);
printModelBeanDaoConfig = daoConfigMap.get(PrintModelBeanDao.class).clone();
printModelBeanDaoConfig.initIdentityScope(type);
comboItemDao = new ComboItemDao(comboItemDaoConfig, this);
discountDao = new DiscountDao(discountDaoConfig, this);
expandInfoDao = new ExpandInfoDao(expandInfoDaoConfig, this);
......@@ -97,6 +104,7 @@ public class DaoSession extends AbstractDaoSession {
functionDao = new FunctionDao(functionDaoConfig, this);
modifierDao = new ModifierDao(modifierDaoConfig, this);
printerDeviceBeanDao = new PrinterDeviceBeanDao(printerDeviceBeanDaoConfig, this);
printModelBeanDao = new PrintModelBeanDao(printModelBeanDaoConfig, this);
registerDao(ComboItem.class, comboItemDao);
registerDao(Discount.class, discountDao);
......@@ -107,6 +115,7 @@ public class DaoSession extends AbstractDaoSession {
registerDao(Function.class, functionDao);
registerDao(Modifier.class, modifierDao);
registerDao(PrinterDeviceBean.class, printerDeviceBeanDao);
registerDao(PrintModelBean.class, printModelBeanDao);
}
public void clear() {
......@@ -119,6 +128,7 @@ public class DaoSession extends AbstractDaoSession {
functionDaoConfig.clearIdentityScope();
modifierDaoConfig.clearIdentityScope();
printerDeviceBeanDaoConfig.clearIdentityScope();
printModelBeanDaoConfig.clearIdentityScope();
}
public ComboItemDao getComboItemDao() {
......@@ -157,4 +167,8 @@ public class DaoSession extends AbstractDaoSession {
return printerDeviceBeanDao;
}
public PrintModelBeanDao getPrintModelBeanDao() {
return printModelBeanDao;
}
}
package com.gingersoft.gsa.cloud.database.greendao;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "PRINT_MODEL_BEAN".
*/
public class PrintModelBeanDao extends AbstractDao<PrintModelBean, Long> {
public static final String TABLENAME = "PRINT_MODEL_BEAN";
/**
* Properties of entity PrintModelBean.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Dbid = new Property(0, Long.class, "dbid", true, "_id");
public final static Property Id = new Property(1, int.class, "id", false, "ID");
public final static Property PaperSpecification = new Property(2, String.class, "paperSpecification", false, "PAPER_SPECIFICATION");
public final static Property PrinterName = new Property(3, String.class, "printerName", false, "PRINTER_NAME");
public final static Property Model = new Property(4, String.class, "model", false, "MODEL");
}
public PrintModelBeanDao(DaoConfig config) {
super(config);
}
public PrintModelBeanDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"PRINT_MODEL_BEAN\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: dbid
"\"ID\" INTEGER NOT NULL ," + // 1: id
"\"PAPER_SPECIFICATION\" TEXT," + // 2: paperSpecification
"\"PRINTER_NAME\" TEXT," + // 3: printerName
"\"MODEL\" TEXT);"); // 4: model
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PRINT_MODEL_BEAN\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, PrintModelBean entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
}
stmt.bindLong(2, entity.getId());
String paperSpecification = entity.getPaperSpecification();
if (paperSpecification != null) {
stmt.bindString(3, paperSpecification);
}
String printerName = entity.getPrinterName();
if (printerName != null) {
stmt.bindString(4, printerName);
}
String model = entity.getModel();
if (model != null) {
stmt.bindString(5, model);
}
}
@Override
protected final void bindValues(SQLiteStatement stmt, PrintModelBean entity) {
stmt.clearBindings();
Long dbid = entity.getDbid();
if (dbid != null) {
stmt.bindLong(1, dbid);
}
stmt.bindLong(2, entity.getId());
String paperSpecification = entity.getPaperSpecification();
if (paperSpecification != null) {
stmt.bindString(3, paperSpecification);
}
String printerName = entity.getPrinterName();
if (printerName != null) {
stmt.bindString(4, printerName);
}
String model = entity.getModel();
if (model != null) {
stmt.bindString(5, model);
}
}
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public PrintModelBean readEntity(Cursor cursor, int offset) {
PrintModelBean entity = new PrintModelBean( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // dbid
cursor.getInt(offset + 1), // id
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // paperSpecification
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // printerName
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // model
);
return entity;
}
@Override
public void readEntity(Cursor cursor, PrintModelBean entity, int offset) {
entity.setDbid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setId(cursor.getInt(offset + 1));
entity.setPaperSpecification(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setPrinterName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setModel(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
}
@Override
protected final Long updateKeyAfterInsert(PrintModelBean entity, long rowId) {
entity.setDbid(rowId);
return rowId;
}
@Override
public Long getKey(PrintModelBean entity) {
if(entity != null) {
return entity.getDbid();
} else {
return null;
}
}
@Override
public boolean hasKey(PrintModelBean entity) {
return entity.getDbid() != null;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}
......@@ -30,10 +30,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
public final static Property RestaurantId = new Property(3, Integer.class, "restaurantId", false, "RESTAURANT_ID");
public final static Property Ip = new Property(4, String.class, "ip", false, "IP");
public final static Property Port = new Property(5, Integer.class, "port", false, "PORT");
public final static Property Type = new Property(6, int.class, "type", false, "TYPE");
public final static Property Status = new Property(7, Integer.class, "status", false, "STATUS");
public final static Property PrinterDeviceId = new Property(8, Long.class, "printerDeviceId", false, "PRINTER_DEVICE_ID");
public final static Property DefaultPrinterDeviceId = new Property(9, Long.class, "defaultPrinterDeviceId", false, "DEFAULT_PRINTER_DEVICE_ID");
public final static Property Status = new Property(6, Integer.class, "status", false, "STATUS");
public final static Property PrinterModelId = new Property(7, int.class, "printerModelId", false, "PRINTER_MODEL_ID");
public final static Property PaperSpecification = new Property(8, String.class, "paperSpecification", false, "PAPER_SPECIFICATION");
public final static Property PrinterName = new Property(9, String.class, "printerName", false, "PRINTER_NAME");
public final static Property Model = new Property(10, String.class, "model", false, "MODEL");
public final static Property PrinterDeviceId = new Property(11, Long.class, "printerDeviceId", false, "PRINTER_DEVICE_ID");
public final static Property DefaultPrinterDeviceId = new Property(12, Long.class, "defaultPrinterDeviceId", false, "DEFAULT_PRINTER_DEVICE_ID");
}
......@@ -55,10 +58,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
"\"RESTAURANT_ID\" INTEGER," + // 3: restaurantId
"\"IP\" TEXT," + // 4: ip
"\"PORT\" INTEGER," + // 5: port
"\"TYPE\" INTEGER NOT NULL ," + // 6: type
"\"STATUS\" INTEGER," + // 7: status
"\"PRINTER_DEVICE_ID\" INTEGER," + // 8: printerDeviceId
"\"DEFAULT_PRINTER_DEVICE_ID\" INTEGER);"); // 9: defaultPrinterDeviceId
"\"STATUS\" INTEGER," + // 6: status
"\"PRINTER_MODEL_ID\" INTEGER NOT NULL ," + // 7: printerModelId
"\"PAPER_SPECIFICATION\" TEXT," + // 8: paperSpecification
"\"PRINTER_NAME\" TEXT," + // 9: printerName
"\"MODEL\" TEXT," + // 10: model
"\"PRINTER_DEVICE_ID\" INTEGER," + // 11: printerDeviceId
"\"DEFAULT_PRINTER_DEVICE_ID\" INTEGER);"); // 12: defaultPrinterDeviceId
}
/** Drops the underlying database table. */
......@@ -96,21 +102,36 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (port != null) {
stmt.bindLong(6, port);
}
stmt.bindLong(7, entity.getType());
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(8, status);
stmt.bindLong(7, status);
}
stmt.bindLong(8, entity.getPrinterModelId());
String paperSpecification = entity.getPaperSpecification();
if (paperSpecification != null) {
stmt.bindString(9, paperSpecification);
}
String printerName = entity.getPrinterName();
if (printerName != null) {
stmt.bindString(10, printerName);
}
String model = entity.getModel();
if (model != null) {
stmt.bindString(11, model);
}
Long printerDeviceId = entity.getPrinterDeviceId();
if (printerDeviceId != null) {
stmt.bindLong(9, printerDeviceId);
stmt.bindLong(12, printerDeviceId);
}
Long defaultPrinterDeviceId = entity.getDefaultPrinterDeviceId();
if (defaultPrinterDeviceId != null) {
stmt.bindLong(10, defaultPrinterDeviceId);
stmt.bindLong(13, defaultPrinterDeviceId);
}
}
......@@ -143,21 +164,36 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (port != null) {
stmt.bindLong(6, port);
}
stmt.bindLong(7, entity.getType());
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(8, status);
stmt.bindLong(7, status);
}
stmt.bindLong(8, entity.getPrinterModelId());
String paperSpecification = entity.getPaperSpecification();
if (paperSpecification != null) {
stmt.bindString(9, paperSpecification);
}
String printerName = entity.getPrinterName();
if (printerName != null) {
stmt.bindString(10, printerName);
}
String model = entity.getModel();
if (model != null) {
stmt.bindString(11, model);
}
Long printerDeviceId = entity.getPrinterDeviceId();
if (printerDeviceId != null) {
stmt.bindLong(9, printerDeviceId);
stmt.bindLong(12, printerDeviceId);
}
Long defaultPrinterDeviceId = entity.getDefaultPrinterDeviceId();
if (defaultPrinterDeviceId != null) {
stmt.bindLong(10, defaultPrinterDeviceId);
stmt.bindLong(13, defaultPrinterDeviceId);
}
}
......@@ -175,10 +211,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // restaurantId
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // ip
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // port
cursor.getInt(offset + 6), // type
cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7), // status
cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8), // printerDeviceId
cursor.isNull(offset + 9) ? null : cursor.getLong(offset + 9) // defaultPrinterDeviceId
cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // status
cursor.getInt(offset + 7), // printerModelId
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // paperSpecification
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // printerName
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // model
cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11), // printerDeviceId
cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12) // defaultPrinterDeviceId
);
return entity;
}
......@@ -191,10 +230,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
entity.setRestaurantId(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
entity.setIp(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setPort(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setType(cursor.getInt(offset + 6));
entity.setStatus(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7));
entity.setPrinterDeviceId(cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8));
entity.setDefaultPrinterDeviceId(cursor.isNull(offset + 9) ? null : cursor.getLong(offset + 9));
entity.setStatus(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6));
entity.setPrinterModelId(cursor.getInt(offset + 7));
entity.setPaperSpecification(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setPrinterName(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setModel(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setPrinterDeviceId(cursor.isNull(offset + 11) ? null : cursor.getLong(offset + 11));
entity.setDefaultPrinterDeviceId(cursor.isNull(offset + 12) ? null : cursor.getLong(offset + 12));
}
@Override
......
package com.gingersoft.gsa.cloud.database.utils;//package com.gingersoft.gsa.cloud.database.utils;
import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.greendao.PrintModelBeanDao;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.List;
/**
* Created by Wyh on 2020/1/17.
*/
public class PrintModelDaoUtil {
private static final String TAG = PrintModelDaoUtil.class.getSimpleName();
private DaoManager mManager;
public PrintModelDaoUtil(Context context) {
mManager = DaoManager.getInstance();
mManager.init(context);
}
/**
* 完成PrintModelBeanDao记录的插入,如果表未创建,先创建PrintModelBeanDao表
* @return
*/
public boolean insertPrintModelBeanDao(PrintModelBean printerDevice){
boolean flag = false;
flag = mManager.getDaoSession().getPrintModelBeanDao().insert(printerDevice) != -1;
Log.i(TAG, "insert printerDevice :" + flag + "-->" + printerDevice.toString());
return flag;
}
/**
* 插入多条数据,在子线程操作
* @param printerDeviceList
* @return
*/
public boolean insertMultPrintModelBeanDao(final List<PrintModelBeanDao> printerDeviceList) {
boolean flag = false;
try {
mManager.getDaoSession().runInTx(new Runnable() {
@Override
public void run() {
for (PrintModelBeanDao PrintModelBeanDao : printerDeviceList) {
mManager.getDaoSession().insertOrReplace(PrintModelBeanDao);
}
}
});
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 修改一条数据
* @param printerDevice
* @return
*/
public boolean updatePrintModelBeanDao(PrintModelBeanDao printerDevice){
boolean flag = false;
try {
mManager.getDaoSession().update(printerDevice);
flag = true;
}catch (Exception e){
e.printStackTrace();
}
return flag;
}
/**
* 删除单条记录
* @param printerDevice
* @return
*/
public boolean deletePrintModelBeanDao(PrintModelBeanDao printerDevice){
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().delete(printerDevice);
flag = true;
}catch (Exception e){
e.printStackTrace();
}
return flag;
}
/**
* 删除所有记录
* @return
*/
public boolean deleteAll(){
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().deleteAll(PrintModelBeanDao.class);
flag = true;
}catch (Exception e){
e.printStackTrace();
}
return flag;
}
/**
* 查询所有记录
* @return
*/
public List<PrintModelBeanDao> queryAllPrintModelBeanDao(){
return mManager.getDaoSession().loadAll(PrintModelBeanDao.class);
}
/**
* 根据主键id查询记录
* @param key
* @return
*/
public PrintModelBeanDao queryPrintModelBeanDaoById(long key){
return mManager.getDaoSession().load(PrintModelBeanDao.class, key);
}
/**
* 使用native sql进行查询操作
*/
public List<PrintModelBeanDao> queryPrintModelBeanDaoByNativeSql(String sql, String[] conditions){
return mManager.getDaoSession().queryRaw(PrintModelBeanDao.class, sql, conditions);
}
/**
* 使用queryBuilder进行查询
* @return
*/
public List<PrintModelBeanDao> queryPrintModelBeanDaoByQueryBuilder(long PrintModelBeanDaoId){
QueryBuilder<PrintModelBeanDao> queryBuilder = mManager.getDaoSession().queryBuilder(PrintModelBeanDao.class);
return queryBuilder.where(PrintModelBeanDao.Properties.Id.eq(PrintModelBeanDaoId)).list();
}
}
......@@ -18,11 +18,6 @@ package com.gingersoft.gsa.cloud.print;
import java.util.List;
/**
* Print
* Created by Alex on 2016/11/10.
*/
public interface PrintDataMaker {
List<byte[]> getPrintData(int type);
List<byte[]> getPrintData();
}
......@@ -28,21 +28,18 @@ import java.util.List;
* Created by Alex on 2016/11/10.
*/
public class PrintExecutor {
private int type;
private PrintSocketHolder holder;
private int mReconnectTimes = 0;
private int time = 0;
private PrintSocketHolder.OnStateChangedListener listener;
private OnPrintResultListener mListener;
public PrintExecutor(BluetoothDevice device, int type) {
public PrintExecutor(BluetoothDevice device) {
holder = new PrintSocketHolder(device);
setType(type);
}
public PrintExecutor(PrinterDeviceBean printerDeviceBean, int type) {
public PrintExecutor(PrinterDeviceBean printerDeviceBean) {
holder = new PrintSocketHolder(printerDeviceBean);
setType(type);
}
/**
......@@ -53,7 +50,7 @@ public class PrintExecutor {
private int doRequest(PrintDataMaker maker) {
if (mReconnectTimes == 0) {
holder.onPrinterStateChanged(PrintSocketHolder.STATE_0);
List<byte[]> data = maker.getPrintData(type);
List<byte[]> data = maker.getPrintData();
if (!holder.isSocketPrepared()) {
int prepare = holder.prepareSocket();
if (prepare != PrintSocketHolder.ERROR_0)
......@@ -62,7 +59,7 @@ public class PrintExecutor {
return holder.sendData(data);
} else {
holder.onPrinterStateChanged(PrintSocketHolder.STATE_0);
List<byte[]> data = maker.getPrintData(type);
List<byte[]> data = maker.getPrintData();
if (holder.isSocketPrepared()) {
if (sendData(data))
return PrintSocketHolder.ERROR_0;
......@@ -138,9 +135,9 @@ public class PrintExecutor {
*
* @param type 打印类型
*/
public void setType(int type) {
this.type = type;
}
// public void setType(int type) {
// this.type = type;
// }
/**
* 设置状态监听
......
......@@ -130,6 +130,18 @@ public abstract class PrinterWriter {
}
/**
* 打开钱箱
*/
public void openCashBox() throws IOException {
bos.write(0x1B);
bos.write(0x70);
bos.write(0);
bos.write(100);
bos.write(80);
bos.flush();
}
/**
* 设置居中
*
* @throws IOException 异常
......
......@@ -20,7 +20,6 @@ import java.io.IOException;
/**
* 纸宽58mm的打印机
* Created by Alex on 2016/6/17.
*/
@SuppressWarnings("unused")
public class PrinterWriter58mm extends PrinterWriter {
......
......@@ -20,7 +20,6 @@ import java.io.IOException;
/**
* 纸宽80mm的打印机
* Created by Alex on 2016/6/17.
*/
@SuppressWarnings("unused")
public class PrinterWriter80mm extends PrinterWriter {
......
/*
* Copyright (C) 2015 AlexMofer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.print;
import java.io.IOException;
/**
* 纸宽58mm的打印机
*/
@SuppressWarnings("unused")
public class PrinterWriterExecutor extends PrinterWriter {
public int width = 380;
public PrinterWriterExecutor() throws IOException {
}
public PrinterWriterExecutor(int parting) throws IOException {
super(parting);
}
public PrinterWriterExecutor(int parting, int width) throws IOException {
super(parting);
this.width = width;
}
@Override
protected int getLineWidth() {
return 16;
}
@Override
protected int getLineStringWidth(int textSize) {
switch (textSize) {
default:
case 0:
return 31;
case 1:
return 15;
}
}
@Override
protected int getDrawableMaxWidth() {
return width;
}
}
......@@ -58,6 +58,7 @@ class OrderDetails {
var DELIVERY_CHARGE: Double = 0.toDouble()
var order_from: Int = 0
var sender: String? = null
var sendMobile: String? = null
var SEND_TIME: String? = null
var PAY_AMOUNT: Double = 0.toDouble()
var ID: Int = 0
......@@ -76,6 +77,18 @@ class OrderDetails {
var estimatedTime: String? = null
var orderStatus: Int = 0
var curStat: Int = 0//訂單已創建 1
// * * Order Assigned To Delivery Man - 配送員已接單 2
// * * Delivery Man Reached Pickup Point Nearby - 配送員已到達店鋪附近 3
// * * Delivery Man Reached Pickup Point - 配送员已到店 4
// * * Delivery In Progress - 訂單正在配送中 5
// * * Delivery Man Reached Destination Nearby - 配送員已到達目的地附近 6
// * * Order Delivered - 訂單已完成 7
// * * Order Cancelled Before Collection - 訂單已取消 - 取餐前 8
// * * Order Cancelled After Collection - 訂單已取消 - 取餐后 9
// * * Order Assigned To Another Delivery Man - 已指派另一位配送員 10
class PRODUCTNAMEBean {
/**
* odsId : 1654481
......
......@@ -9,7 +9,7 @@ import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
public class AppDialog {
public static void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
public void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
showWaringDialog(context, title, null, null, sureOnclickListenter, null);
}
......@@ -17,7 +17,7 @@ public class AppDialog {
// showWaringDialog(context, title, null, null, sureOnclickListenter, null);
// }
private static void showWaringDialog(Context context, String title, String confimText, String cancelText, DialogOnClickListenter sureOnclickListenter, DialogOnClickListenter cancelOnclickListenter) {
private void showWaringDialog(Context context, String title, String confimText, String cancelText, DialogOnClickListenter sureOnclickListenter, DialogOnClickListenter cancelOnclickListenter) {
//暫停接單,彈窗向用戶確認是否關閉
new DialogUtils(context, R.layout.other_order_pause_orders) {
@Override
......
......@@ -86,11 +86,18 @@ public class LoadingDialog {
if (mLoadingDialog == null) {
mLoadingDialog = new Dialog(context, R.style.ui_loading_dialog);
} else if(mLoadingDialog.isShowing()){
mLoadingDialog.dismiss();
mLoadingDialog = new Dialog(context, R.style.ui_loading_dialog);
}
mLoadingDialog.setCancelable(true);
mLoadingDialog.setCanceledOnTouchOutside(false);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
try {
mLoadingDialog.show();
} catch (Exception e) {
e.printStackTrace();
}
return mLoadingDialog;
}
......
......@@ -11,5 +11,4 @@
android:layout_height="match_parent"
android:background="@drawable/shape_white_eight_corners_bg" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:background="@color/grey_200" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_item_print_model_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="@color/grey_200" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_50"
android:src="@drawable/ic_default"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/btn_default"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_default_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="暫無數據"
android:textColor="@color/color_ccc"
android:layout_marginTop="@dimen/dp_10"
android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_default" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_20"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:padding="@dimen/dp_10"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -485,4 +485,14 @@
<color name="restaurant_color_open">#6FBE8E</color>
<color name="restaurant_color_busy_close">#F56C6C</color>
<color name="restaurant_color_busy_open">#E6A23C</color>
<!-- 確認訂單按鈕背景色-->
<color name="other_order_details_sure_btn_color">#1196DB</color>
<!-- 取消訂單按鈕背景色-->
<color name="other_order_details_cancel_btn_color">#E74E40</color>
<!-- 打印訂單按鈕背景色-->
<color name="other_order_details_print_btn_color">#FFA827</color>
<!-- 取消物流按鈕背景色-->
<color name="other_order_details_cancel_logistics_btn_color">#E74E40</color>
</resources>
......@@ -36,5 +36,8 @@ public interface NewMainContract {
Observable<CheckVersionRequest> checkAppVersion(RequestBody requestBody);
Observable<Object> loginOut(RequestBody requestBody);
Observable<Object> clearHeartbeat(RequestBody requestBody);
}
}
......@@ -61,4 +61,10 @@ public class NewMainModel extends BaseModel implements NewMainContract.Model {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.loginOut(requestBody);
}
@Override
public Observable<Object> clearHeartbeat(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.clearHeartbeat(requestBody);
}
}
\ No newline at end of file
......@@ -18,6 +18,10 @@ 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);
}
......@@ -120,8 +120,9 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
public void loginOut() {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) +"")
.build();
mModel.loginOut(requestBody)
mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
......@@ -132,25 +133,37 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
@Override
public void onNext(@NonNull Object info) {
mModel.loginOut(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) {
mRootView.loginOut();
//清空用戶信息
GsaCloudApplication.clearMemberInfo();
}
});
}
});
}
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");
......
......@@ -61,11 +61,11 @@ public class PaymentMethodReportPresenter extends BasePresenter<PaymentMethodRep
this.mApplication = null;
}
public void getPaymentInfo(String restaurandId, String startTime) {
public void getPaymentInfo(String restaurandId, String startTime, String endTime) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", restaurandId)
.add("startTime", startTime)//TimeUtils.getYesterdayTime(TimeUtils.DATE_FORMAT_DATE)
.add("endTime", TimeUtils.getOldDate(1))//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
.add("endTime", endTime)//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
.build();
mModel.getPaymentInfo(requestBody)
.subscribeOn(Schedulers.io())
......
......@@ -62,11 +62,11 @@ public class SalesPresenter extends BasePresenter<SalesContract.Model, SalesCont
this.mApplication = null;
}
public void getSalesReportInfo(String restaurantId, String startTime) {
public void getSalesReportInfo(String restaurantId, String startTime,String endTime) {
Map<String, Object> map = new HashMap<>();
map.put("restaurantId", restaurantId);
map.put("startTime", startTime);
map.put("endTime", TimeUtils.getOldDate(1));
map.put("endTime", endTime);
mModel.getSalesReportInfo(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
......
......@@ -130,7 +130,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPresenter.checkAppVersion();
}
@Override
protected void onResume() {
super.onResume();
// mPresenter.checkAppVersion();
}
@Override
......@@ -235,7 +240,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
// }
List<Function> functions = new ArrayList<>();
if (!BuildConfig.DEBUG) {
// 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));
......@@ -258,11 +263,11 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record_close, 1));
} else {
functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.order, "order"));
functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.manager, "manager"));
functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.employee, "employee"));
}
// } else {
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.order, "order"));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.manager, "manager"));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.main.class, ComponentMain.main.employee, "employee"));
// }
//將功能列表數據分組
SparseArray<String> parents = new SparseArray<>();
......@@ -303,14 +308,14 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private void functionClick(String name, int status) {
switch (status){
case STATUS_NONACTIVATED:
ToastUtils.show(mContext, "服務暫未開通,請前往開通");
return;
case STATUS_TIME_LIMIT:
ToastUtils.show(mContext, "服務已到期,請前往續費");
return;
}
// switch (status){
// case STATUS_NONACTIVATED:
// ToastUtils.show(mContext, "服務暫未開通,敬請期待");
// return;
// case STATUS_TIME_LIMIT:
// ToastUtils.show(mContext, "服務已到期,請前往續費");
// return;
// }
if (name.equals("餐檯模式")) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
......
......@@ -38,6 +38,7 @@ 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;
......@@ -75,6 +76,8 @@ 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)
......@@ -85,7 +88,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
private BusinessInfoAdapter businessInfoAdapter;
//查詢多少天的數據
private int manyDay = 6;
private int manyDay = 7;
public static BusinessReportFragment newInstance() {
BusinessReportFragment fragment = new BusinessReportFragment();
......@@ -111,14 +114,15 @@ 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();
}
/**
......@@ -195,7 +199,6 @@ 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];
......@@ -339,29 +342,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
} else {
mTvEndTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
}
// 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());
getBetweenInfo();
}).setOnDismissListener(o -> {
if (triangleView.isOpen()) {
triangleView.toggle();
......@@ -373,4 +354,24 @@ 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());
}
}
......@@ -80,6 +80,9 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
@BindView(R2.id.iv_payment_time_triangle)
TriangleView triangleView;
@BindView(R2.id.iv_end_time_triangle)
TriangleView endTimeTriangleView;
public static PaymentMethodReportFragment newInstance() {
PaymentMethodReportFragment fragment = new PaymentMethodReportFragment();
return fragment;
......@@ -102,11 +105,14 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-2);
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime);
mTvStartTime.setText(TimeUtils.getOldDate(-7));
mTvEndTime.setText(TimeUtils.getOldDate(0));
getPayMenthInfo();
}
private void getPayMenthInfo() {
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
}
/**
......@@ -279,23 +285,51 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
chart.invalidate();
}
@OnClick({R2.id.tv_start_time, R2.id.iv_payment_time_triangle})
@OnClick({R2.id.tv_start_time, R2.id.iv_payment_time_triangle, R2.id.tv_end_time, R2.id.iv_end_time_triangle})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_start_time || v.getId() == R.id.iv_payment_time_triangle) {
int viewId = v.getId();
try {
String time = null;
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.DAY_OF_YEAR, startTime.getActualMinimum(Calendar.DAY_OF_YEAR));//今年第一天
Calendar endTime = Calendar.getInstance();
if (viewId == R.id.tv_start_time || viewId == R.id.iv_start_time_triangle) {
triangleView.toggle();
time = mTvStartTime.getText().toString();
endTime.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvEndTime.getText().toString()));
} else if (viewId == R.id.tv_end_time || viewId == R.id.iv_end_time_triangle) {
endTimeTriangleView.toggle();
time = mTvEndTime.getText().toString();
startTime.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvStartTime.getText().toString()));
}
Calendar cal = Calendar.getInstance();
try {
//設置默認時間為當前的起止時間
cal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvStartTime.getText().toString()));
cal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(time));
} catch (ParseException e) {
e.printStackTrace();
}
//打開時間選擇器
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) -> {
TimePickerUtils.showReportTimePicker(mContext, startTime, endTime, cal, (date, v1) ->
{
if (viewId == R.id.tv_start_time || viewId == R.id.iv_start_time_triangle) {
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
}).setOnDismissListener(o -> triangleView.toggle());
} else {
mTvEndTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
}
getPayMenthInfo();
}).setOnDismissListener(o -> {
if (triangleView.isOpen()) {
triangleView.toggle();
} else if (endTimeTriangleView.isOpen()) {
endTimeTriangleView.toggle();
}
});
} catch (ParseException e) {
e.printStackTrace();
}
}
}
......@@ -84,6 +84,10 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
TextView mTvEndTime;
@BindView(R2.id.iv_sale_time_triangle)
TriangleView triangleView;
@BindView(R2.id.iv_end_time_triangle)
TriangleView endTimeTriangleView;
public static SalesFragment newInstance() {
SalesFragment fragment = new SalesFragment();
return fragment;
......@@ -106,10 +110,9 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-2);
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime);
mTvStartTime.setText(TimeUtils.getOldDate(-7));
mTvEndTime.setText(TimeUtils.getOldDate(0));
getSaleReprot();
}
/**
......@@ -352,24 +355,58 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
salesChart.invalidate();
}
@OnClick({R2.id.tv_start_time, R2.id.iv_sale_time_triangle})
@OnClick({R2.id.tv_start_time, R2.id.iv_sale_time_triangle, R2.id.tv_end_time, R2.id.iv_end_time_triangle})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_start_time || v.getId() == R.id.iv_sale_time_triangle) {
int viewId = v.getId();
try {
String time = null;
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.DAY_OF_YEAR, startTime.getActualMinimum(Calendar.DAY_OF_YEAR));//今年第一天
Calendar endTime = Calendar.getInstance();
if (viewId == R.id.tv_start_time || viewId == R.id.iv_start_time_triangle) {
triangleView.toggle();
//打開時間選擇器
time = mTvStartTime.getText().toString();
endTime.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvEndTime.getText().toString()));
} else if (viewId == R.id.tv_end_time || viewId == R.id.iv_end_time_triangle) {
endTimeTriangleView.toggle();
time = mTvEndTime.getText().toString();
startTime.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvStartTime.getText().toString()));
}
Calendar cal = Calendar.getInstance();
try {
//設置默認時間為當前的起止時間
cal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(mTvStartTime.getText().toString()));
cal.setTime(TimeUtils.DATE_FORMAT_DATE.parse(time));
} catch (ParseException e) {
e.printStackTrace();
}
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) -> {
//打開時間選擇器
TimePickerUtils.showReportTimePicker(mContext, startTime, endTime, cal, (date, v1) ->
{
if (viewId == R.id.tv_start_time || viewId == R.id.iv_start_time_triangle) {
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
}).setOnDismissListener(o -> triangleView.toggle());
} else {
mTvEndTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
}
getSaleReprot();
}).setOnDismissListener(o -> {
if (triangleView.isOpen()) {
triangleView.toggle();
} else if (endTimeTriangleView.isOpen()) {
endTimeTriangleView.toggle();
}
});
} catch (ParseException e) {
e.printStackTrace();
}
}
private void getSaleReprot() {
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), mTvEndTime.getText().toString());
}
......
......@@ -55,10 +55,10 @@
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_payment_time_triangle"
android:layout_marginLeft="@dimen/dp_2"
android:layout_width="@dimen/dp_8"
app:trv_direction="bottom"
android:layout_height="@dimen/dp_5" />
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
app:trv_direction="bottom" />
<TextView
android:layout_width="wrap_content"
......@@ -75,6 +75,13 @@
android:layout_marginLeft="@dimen/dp_7"
android:textColor="#181818"
android:textSize="@dimen/dp_10" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_end_time_triangle"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
app:trv_direction="bottom" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
......
......@@ -57,10 +57,10 @@
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_sale_time_triangle"
android:layout_marginLeft="@dimen/dp_2"
android:layout_width="@dimen/dp_8"
app:trv_direction="bottom"
android:layout_height="@dimen/dp_5"/>
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
app:trv_direction="bottom" />
<TextView
android:layout_width="wrap_content"
......@@ -77,6 +77,14 @@
android:layout_marginLeft="@dimen/dp_7"
android:textColor="#181818"
android:textSize="@dimen/sp_10" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_end_time_triangle"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_2"
app:trv_direction="bottom" />
</LinearLayout>
<com.github.mikephil.charting.charts.PieChart
......
......@@ -14,6 +14,7 @@
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<activity android:name=".ui.activity.DeliverySettingActivity"/>
<activity android:name=".ui.activity.OrderDetailsActivity"/>
</application>
</manifest>
\ No newline at end of file
......@@ -3,6 +3,7 @@
package="com.gingersoft.gsa.other_order_mode">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
......@@ -11,6 +12,7 @@
android:networkSecurityConfig="@xml/network_android"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.activity.OrderDetailsActivity"></activity>
<activity
android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name">
......@@ -23,9 +25,11 @@
</activity>
<service android:name=".service.GetInfoUpdateService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<activity android:name=".ui.activity.HistoryOrderActivity" />
</application>
......
......@@ -129,12 +129,12 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
network.getDeliveryConfigDTO(requestBody)
}
suspend fun cancelLogistics(shopId: String, orderId: String) = withContext(Dispatchers.IO) {
network.cancelLogistics(getBody("restaurantId" to shopId, "orderId" to orderId))
suspend fun cancelLogistics(shopId: String, orderId: String, reasonId: String, reasonDesc: String) = withContext(Dispatchers.IO) {
network.cancelLogistics(getBody("restaurantId" to shopId, "orderId" to orderId, "reasonId" to reasonId, "reasonDesc" to reasonDesc))
}
suspend fun updateOrderStates(memberId: String, orderId: String, status: String, updateBy: String) = withContext(Dispatchers.IO) {
network.cancelOrder(getBody("memberId" to memberId, "orderId" to orderId, "status" to status, "type" to "2", "updateBy" to updateBy))
suspend fun updateOrderStates(memberId: String, orderId: String, status: String, updateBy: String, reasonId: String, reasonDesc: String) = withContext(Dispatchers.IO) {
network.cancelOrder(getBody("memberId" to memberId, "orderId" to orderId, "status" to status, "type" to "2", "updateBy" to updateBy, "reasonId" to reasonId, "reasonDesc" to reasonDesc))
}
suspend fun getCancelReason(restaurantId: String, type: String) = withContext(Dispatchers.IO) {
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
import com.gingersoft.gsa.other_order_mode.R
class BtnBuilder {
companion object {
val sureBtn = 0
val cancelBtn = 1
val printBtn = 2
val logisticsBtn = 3
val assignDeliveryBtn = 4
val closingBtn = 5
val ProductionCompletedBtn = 6
}
class BtnBean(val type: Int, val btnContent: String, val btnColor: Int, val btnImg: Int)
fun getSureBtn(): BtnBean {
return BtnBean(sureBtn, "確認訂單", R.color.other_order_details_sure_btn_color, R.drawable.ic_sure)
}
fun getProductionCompletedBtn(): BtnBean {
return BtnBean(ProductionCompletedBtn, "製作完成", R.color.other_order_details_sure_btn_color, R.drawable.ic_sure)
}
fun getCancelBtn(): BtnBean {
return BtnBean(cancelBtn, "取消訂單", R.color.other_order_details_cancel_btn_color, R.drawable.ic_cancel)
}
fun getPrintBtn(): BtnBean {
return BtnBean(printBtn, "打印訂單", R.color.other_order_details_print_btn_color, R.drawable.ic_print)
}
fun getLogisticsBtn(): BtnBean {
return BtnBean(logisticsBtn, "取消物流", R.color.other_order_details_cancel_logistics_btn_color, R.drawable.ic_logistics)
}
fun getAssignDeliveryBtn(): BtnBean {
return BtnBean(assignDeliveryBtn, "指派送貨", R.color.other_order_details_sure_btn_color, R.drawable.ic_deliveryman)
}
fun getClosingBtn(): BtnBean {
return BtnBean(closingBtn, "結賬", R.color.other_order_details_cancel_btn_color, R.drawable.ic_closing)
}
}
......@@ -10,12 +10,12 @@ data class CancelReason(
val content: String,
val content2: String,
val content3: String,
val createTime: Int,
val createTime: Long,
val id: Int,
val restaurantId: Int,
val sort: Int,
val type: Int,
val uid: Int,
val updateTime: Int
val updateTime: Long
)
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ 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
......@@ -31,21 +32,16 @@ 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>>()
......@@ -64,8 +60,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//派送員信息
var deliveryBean: DeliveryBean? = null
var deliveryConfig: DeliveryConfig? = null
/**
* 獲取訂單數量
* status
......@@ -249,16 +243,23 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
// }
fun getShipanyAndOrderInfo(curStat: Int, restaurantId: String, orderId: String, listener: (OrderDetails?) -> Unit) {
fun getShipanyAndOrderInfo(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 (curStat != 0) {
//訂單詳情不為空
if (orderDetail.data!![0].isDelete != 0) {
//如果不是第三方物流單
withContext(Dispatchers.Main) {
listener.invoke(orderDetail)
}
} else {
if (orderDetail.data!![0].curStat != 0) {
val data = orderDetail.data!![0]
val type: Int
val estimatedTime: String
when (curStat) {
when (orderDetail.data!![0].curStat) {
1 -> {
type = 2
estimatedTime = "預計配送員接單時間:"
......@@ -277,7 +278,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.estimated_time > 0) {
if (estimatedBean?.data != null && estimatedBean.data.estimated_time > 0) {
data.estimatedTime = estimatedTime + ("${estimatedBean.data.estimated_time}分鐘後")
} else {
data.estimatedTime = ""
......@@ -286,6 +287,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
withContext(Dispatchers.Main) {
listener.invoke(orderDetail)
}
}
} else {
withContext(Dispatchers.Main) {
listener.invoke(null)
......@@ -299,168 +301,220 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
/**
* 待確認 --- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬
* 更新訂單信息,自取或是外賣
* status 0,1待確認
* 2 已確認,外賣是指派送單,自取是製作完成
*/
fun updateOrderStatus(context: Context, data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, listener: (Boolean) -> Unit) {
fun updateOrderStatusByBtn(btnId: Int, dataBean: OrderDetails.DataBean, restaurantId: String, listener: (Int, 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")
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
}
}
} else if (status == 4) {
//結賬,彈窗確認是否結賬
if (orderDetails.data!![0].isDelete == 0) {
//第三方物流單,沒有結賬,重印
printOrder(orderDetails, data, context, listener)
if (third) {
// 如果是第三方物流,調用第三方接口
thirdSend(dataBean, 2, 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")
updateOrderAndPrint(dataBean, 2, listener)
}
}, {
})
}
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss()
listener.invoke(false)
}
BtnBuilder.printBtn -> {
//打印
printOrder(dataBean, listener)
}
}.createDialogView().show()
BtnBuilder.ProductionCompletedBtn -> {
//製作完成
repository.gsUpdateOrderStatus(dataBean.ID.toString(), 3, dataBean.order_type, 1, "", "", "", "0", "", 1, 0).apply {
listener.invoke(ProductionComplete, code == "1")
}
} 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)
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")
}
}, {
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 {
// // 自取的確認訂單
// repository.updateSelfOrderStatus(data.Id.toString(), status.toString(), GsaCloudApplication.getRestaurantId(context).toString()).apply {
// listener.invoke(success)
// 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)
// }
// }
//// } else {
//// // 自取的確認訂單
//// repository.updateSelfOrderStatus(data.Id.toString(), status.toString(), GsaCloudApplication.getRestaurantId(context).toString()).apply {
//// listener.invoke(success)
//// }
//// }
// }, {
//
// })
}
/**
* 修改訂單狀態並打印
*/
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 {
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 {
if (status == 0 || status == 1 || status == 2) {
//確認送單
if (this.code == "1") {
listener.invoke(OrderDelivery, true)
// 打印
// 初始化用於打印的view
// 送單成功後,再調用接口獲取取餐碼
showLoading(context)
getOrderInfo(data.Id.toString()) {
getOrderInfo(dataBean.ID.toString()) {
if (it != null) {
printOrder(it, data, context, listener)
printOrder(dataBean, listener)
}
cancelDialogForLoading()
}
} else {
ToastUtils.show(context, "送單失敗")
listener.invoke(OrderDelivery, false)
}
}
cancelDialogForLoading()
}
}
/**
* 打印訂單
*/
private fun printOrder(orderDetails: OrderDetails, data: OrderList.DataBeanX.DataBean, context: Context, listener: (Boolean) -> Unit) {
if (orderDetails.data != null) {
private fun printOrder(dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) {
//訂單信息和廚房單
orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType
MyOrderManage.setDataBean(orderDetails.data!![0])
MyOrderManage.setDataBean(dataBean)
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
Log.e("error", "是否成功打印:" + result.isSuccess)
if (!result.isSuccess) {
ToastUtils.show(context, "打印失敗")
}
MyOrderManage.setDataBean(null)
listener.invoke(PrintCode, result.isSuccess)
}
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
}
listener.invoke(true)
/**
* 打開錢箱
*/
fun openCashBox(){
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 6)
.addParam(PrintConstans.PRINT_LOADING, false)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
}
}
/**
* 第三方派送
*/
private suspend fun thirdSend(data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, status: Int, context: Context, listener: (Boolean) -> Unit) {
private suspend fun thirdSend(dataBean: OrderDetails.DataBean, status: Int, listener: (Int, Boolean) -> Unit) {
val third = ThirdItem()
orderDetails.data?.get(0)?.PRODUCT_NAME?.let {
//將食品數據轉為第三方需要的數據
dataBean.PRODUCT_NAME?.let {
for (i in it) {
val price = ThirdItem.ThirdItemItem.UntPrice(`val` = i.PRICE!!.toDouble())
val thirdItem = if (i.PRODUCT_NAME != null) {
......@@ -471,27 +525,25 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
third.add(thirdItem)
}
}
repository.thirdDelivery(data.Id.toString(), third).apply {
cancelDialogForLoading()
//調用第三方物流接口
repository.thirdDelivery(dataBean.ID.toString(), third).apply {
if (success) {
ToastUtils.show(context, "訂單派送成功")
updateOrderAndPrint(data, status, context, listener)
listener.invoke(OrderDelivery, true)
updateOrderAndPrint(dataBean, status, listener)
} else {
ToastUtils.show(context, "訂單派送失敗")
listener.invoke(OrderDelivery, false)
}
}
}
// suspend fun updateOrderStatus(orderId: String, selfOrderId: String?, status: Int, mobile: String?, sender: String?, isPush: Int, orderType: Int): UpdateOrderBean {
// return repository.updateOrderStatus(orderId, selfOrderId, status, mobile, sender, isPush, orderType)
// }
/**
* 選擇派送員
*/
private fun selectorDelivery(listener: (Boolean) -> Unit, context: Context, data: OrderList.DataBeanX.DataBean, status: Int, isPush: Int) {
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
//顯示選擇派送員
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 {
......@@ -516,21 +568,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
confirmBtn.setOnClickListener {
if (selectIndex != -1) {
launch({
// updateOrderStatus(data.Id.toString(), "", status, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, deliveryBean!!.data[deliveryAdapter.selectIndex].userName, isPush, data.order_type).apply {
// if (this.success) {
// dialog?.dismiss()
// //回調
// listener.invoke(success)//刷新頁面
// ToastUtils.show(context, "訂單開始派送")
// } else {
// ToastUtils.show(context, "訂單派送失敗")
// }
// }
repository.gsUpdateOrderStatus(data.Id.toString(), status, data.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply {
repository.gsUpdateOrderStatus(dataBean.ID.toString(), status, dataBean.order_type, 1, "", deliveryBean!!.data[deliveryAdapter.selectIndex].userName, deliveryBean!!.data[deliveryAdapter.selectIndex].mobile, "0", "", 1, 0).apply {
if (code == "1") {
dialog?.dismiss()
//回調
listener.invoke(code == "1")//刷新頁面
listener.invoke(OrderDelivery, code == "1")//刷新頁面
ToastUtils.show(context, "訂單開始派送")
} else {
ToastUtils.show(context, "訂單派送失敗")
......@@ -550,6 +592,63 @@ 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()
}
/**
* 獲取配送員信息
......@@ -567,10 +666,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 獲取餐廳第三方物流信息
*/
fun getDeliveryConfigDTO(context: Context) {
fun getDeliveryConfigDTO(restaurantId: String, listener: (DeliveryConfig?) -> Unit) {
launch({
repository.getDeliveryConfigDTO(GsaCloudApplication.getRestaurantId(context).toString()).apply {
deliveryConfig = this
repository.getDeliveryConfigDTO(restaurantId).apply {
listener.invoke(this)
}
}, {
......@@ -580,9 +679,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 取消物流
*/
fun cancelLogistics(shopId: String, orderId: String, listener: (String) -> Unit) {
fun cancelLogistics(shopId: String, orderId: String, reasonId: String, reasonDesc: String, listener: (String) -> Unit) {
launch({
repository.cancelLogistics(shopId, orderId).apply {
repository.cancelLogistics(shopId, orderId, reasonId, reasonDesc).apply {
if (success) {
listener.invoke("已取消物流")
} else {
......@@ -595,12 +694,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
/**
* 取消訂單,如果有物流需要先提示取消物流
* 取消訂單
*/
fun cancelOrder(context: Context, orderId: String, listener: (Boolean) -> Unit) {
fun cancelOrder(context: Context, orderId: String, reasonId: String, reasonDesc: String, listener: (Boolean) -> Unit) {
launch({
showLoading(context)
repository.updateOrderStates(GsaCloudApplication.getMemberId(context).toString(), orderId, "6", GsaCloudApplication.getMemberName(context)).apply {
repository.updateOrderStates(GsaCloudApplication.getMemberId(context).toString(), orderId, "6", GsaCloudApplication.getMemberName(context), reasonId, reasonDesc).apply {
listener.invoke(code == "1")
}
}, {
......@@ -608,13 +706,16 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
})
}
fun getCancelReason(restaurantId: String, type: String) {
/**
* 獲取餐廳配置的取消原因
*/
fun getCancelReason(restaurantId: String, type: String, listener: (CancelReason?) -> Unit) {
launch({
repository.getCancelReason(restaurantId, type).apply {
listener.invoke(this)
}
}, {
listener.invoke(null)
})
}
......@@ -628,10 +729,4 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
}
override fun onCleared() {
super.onCleared()
cancelDialogForLoading()
}
}
\ No newline at end of file
......@@ -2,13 +2,19 @@ package com.gingersoft.gsa.other_order_mode.service
import android.app.Service
import android.content.Intent
import android.media.AudioAttributes
import android.media.AudioManager
import android.media.SoundPool
import android.os.Binder
import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.util.Log
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import com.google.gson.Gson
import io.reactivex.Observable
import okhttp3.*
import okio.ByteString
import org.json.JSONObject
......@@ -22,7 +28,7 @@ class GetInfoUpdateService : Service() {
/**
* 心跳检测时间
*/
private val HEART_BEAT_RATE = (15 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测
private val HEART_BEAT_RATE = (60 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private var mWebSocket: WebSocket? = null
......@@ -64,10 +70,13 @@ class GetInfoUpdateService : Service() {
// 初始化socket
private fun initSocket() {
// Observable.interval(5, 10, TimeUnit.SECONDS)
// .subscribe(Observer())
val client = OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).build()
val request = Request.Builder()
.url(WEBSOCKET_HOST_AND_PORT)
.build()
client.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket?, response: Response?) {//开启长连接成功的回调
super.onOpen(webSocket, response)
......@@ -82,8 +91,19 @@ class GetInfoUpdateService : Service() {
override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调
super.onMessage(webSocket, text)
val json = JSONObject(text)
val type = json.optInt("type");
if (postCallBack != null) {
postCallBack!!.callBack(json.optInt("type"))
postCallBack!!.callBack(type)
}
if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) {
if (type == 6 || type == 7) {
} else {
//播放提示音
initSoundPool()
}
}
//收到服务器端传过来的消息text
Log.e(TAG, "onMessage:" + text!!)
......@@ -124,7 +144,59 @@ class GetInfoUpdateService : Service() {
}
})
client.dispatcher().executorService().shutdown()
// mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测
}
private var soundPool: SoundPool? = null
fun initSoundPool() {
//实例化SoundPool
//sdk版本21是SoundPool 的一个分水岭
if (soundPool == null) {
if (Build.VERSION.SDK_INT >= 21) {
val builder = SoundPool.Builder()
//传入最多播放音频数量,
builder.setMaxStreams(1)
//AudioAttributes是一个封装音频各种属性的方法
val attrBuilder = AudioAttributes.Builder()
//设置音频流的合适的属性
attrBuilder.setLegacyStreamType(AudioManager.STREAM_MUSIC)
//加载一个AudioAttributes
builder.setAudioAttributes(attrBuilder.build())
soundPool = builder.build()
} else {
/**
* 第一个参数:int maxStreams:SoundPool对象的最大并发流数
* 第二个参数:int streamType:AudioManager中描述的音频流类型
*第三个参数:int srcQuality:采样率转换器的质量。 目前没有效果。 使用0作为默认值。
*/
soundPool = SoundPool(1, AudioManager.STREAM_MUSIC, 0)
}
}
//可以通过四种途径来记载一个音频资源:
//1.通过一个AssetFileDescriptor对象
//int load(AssetFileDescriptor afd, int priority)
//2.通过一个资源ID
//int load(Context context, int resId, int priority)
//3.通过指定的路径加载
//int load(String path, int priority)
//4.通过FileDescriptor加载
//int load(FileDescriptor fd, long offset, long length, int priority)
//声音ID 加载音频资源,这里用的是第二种,第三个参数为priority,声音的优先级*API中指出,priority参数目前没有效果,建议设置为1。
val voiceId = soundPool!!.load(this, R.raw.newordervocal, 1)
//异步需要等待加载完成,音频才能播放成功
soundPool!!.setOnLoadCompleteListener { soundPool, sampleId, status ->
if (status == 0) {
//第一个参数soundID
//第二个参数leftVolume为左侧音量值(范围= 0.0到1.0)
//第三个参数rightVolume为右的音量值(范围= 0.0到1.0)
//第四个参数priority 为流的优先级,值越大优先级高,影响当同时播放数量超出了最大支持数时SoundPool对该流的处理
//第五个参数loop 为音频重复播放次数,0为值播放一次,-1为无限循环,其他值为播放loop+1次
//第六个参数 rate为播放的速率,范围0.5-2.0(0.5为一半速率,1.0为正常速率,2.0为两倍速率)
soundPool.play(voiceId, 1f, 1f, 1, 0, 1f)
}
}
}
/*获取一条随机字符串*/
......@@ -149,16 +221,16 @@ class GetInfoUpdateService : Service() {
if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态
Log.e(TAG, "連接狀態:$isSuccess")
if (isSuccess != null && !isSuccess) {//长连接已断开
// if (isSuccess != null && !isSuccess) {//长连接已断开
mHandler.removeCallbacks(this)
mWebSocket?.cancel()//取消掉以前的长连接
InitSocketThread().start()//创建一个新的连接
} else {//长连接处于连接状态
}
// } else {//长连接处于连接状态
//
// }
sendTime = System.currentTimeMillis()
}
mHandler.postDelayed(this, HEART_BEAT_RATE)//每隔一定的时间,对长连接进行一次心跳检测
// mHandler.postDelayed(this, HEART_BEAT_RATE)//每隔一定的时间,对长连接进行一次心跳检测
}
}
}
......
package com.gingersoft.gsa.other_order_mode.ui.activity
import android.app.Dialog
import android.os.Bundle
import android.widget.TextView
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.base.widget.DialogUtils
import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.BtnBuilder
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOrderDetailsBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.Closing
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.OrderDelivery
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.PrintCode
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.SendCode
import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.activity_order_details.*
class OrderDetailsActivity : BaseActivity() {
private lateinit var pageViewModel: PageViewModel
private lateinit var binding: ActivityOrderDetailsBinding
private lateinit var orderId: String
private var orderType: Int = 0
private var orderPayType: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_order_details)
orderId = intent.getStringExtra("orderId")//訂單id
orderType = intent.getIntExtra("orderType", 0)//訂單類型
orderPayType = intent.getIntExtra("orderPayType", 0)//訂單支付方式
pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
getOrderDetails(orderId, binding)
}
qm_order_details_bar.setTitle(GsaCloudApplication.getRestaurantName(this))
qm_order_details_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
qm_order_details_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
}
private fun PageViewModel.getOrderDetails(orderId: String, binding: ActivityOrderDetailsBinding) {
showLoading()
getShipanyAndOrderInfo(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), orderId) { it ->
cancelDialogForLoading()
if (it?.data != null && it.data!!.isNotEmpty()) {
val orderDetails = it.data!![0]
orderDetails.order_type = orderType
orderDetails.orderPayType = orderPayType
binding.data = orderDetails
binding.totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble()
binding.isSelf = orderDetails.order_type == 7
val btnList = ArrayList<BtnBuilder.BtnBean>()
val orderStatusText: String
val type = if (orderDetails.order_type == 7) "自取" else "外送"
when (orderDetails.orderStatus) {
2 -> {//製作中
btnList.add(BtnBuilder().getPrintBtn())
if (orderDetails.order_type == 7) {
//製作中的自取,應該製作完成、打印、取消訂單
btnList.add(BtnBuilder().getProductionCompletedBtn())
tv_order_state.setTextColor(resources.getColor(R.color.order_state0_color))
} else {
//製作中的外賣,應該有打印、取消物流、取消訂單
if (orderDetails.isDelete == 0) {
btnList.add(BtnBuilder().getLogisticsBtn())
} else {
btnList.add(BtnBuilder().getAssignDeliveryBtn())
}
tv_order_state.setTextColor(resources.getColor(R.color.order_state1_color))
}
orderStatusText = "製作中"
btnList.add(BtnBuilder().getCancelBtn())
}
3 -> {//外賣是送貨中,自取是待取餐
btnList.add(BtnBuilder().getPrintBtn())
if (orderDetails.order_type == 7) {
//自取待取餐,有打印和結賬
orderStatusText = "待取餐"
btnList.add(BtnBuilder().getClosingBtn())
tv_order_state.setTextColor(resources.getColor(R.color.order_state3_color))
} else {
// 外賣有打印
// 如果是第三方物流,不顯示結賬
// 如果是本店配送,有結賬按鈕
if (orderDetails.isDelete == 0) {
//如果是第三方物流,不顯示結賬按鈕
} else {
btnList.add(BtnBuilder().getClosingBtn())
}
orderStatusText = "派送中"
tv_order_state.setTextColor(resources.getColor(R.color.order_state2_color))
}
}
else -> {//待確認訂單
btnList.add(BtnBuilder().getSureBtn())
btnList.add(BtnBuilder().getCancelBtn())
orderStatusText = "待確認"
tv_order_state.setTextColor(resources.getColor(R.color.order_state0_color))
}
}
binding.patMethod = when (orderDetails.payType) {
1 -> "積分支付"
2 -> "支付寶"
3 -> "财付通"
4 -> "微信支付"
5 -> "貨到付款"
6 -> "其他支付"
else -> ""
}
binding.orderStatus = type + orderStatusText
binding.estimatedTime = orderDetails.estimatedTime
rv_food.layoutManager = LinearLayoutManager(this@OrderDetailsActivity)
rv_food.adapter = FoodListAdapter(this@OrderDetailsActivity, orderDetails.PRODUCT_NAME!!)
if (btnList.size <= 3) {
rv_order_details_btn.layoutManager = GridLayoutManager(this@OrderDetailsActivity, btnList.size)
} else {
rv_order_details_btn.layoutManager = GridLayoutManager(this@OrderDetailsActivity, 3)
}
val orderBtnAdapter = OrderDetailsAdapter(btnList)
rv_order_details_btn.adapter = orderBtnAdapter
orderBtnAdapter.setOnItemClickListener { adapter, view, position ->
when (btnList[position].type) {
BtnBuilder.logisticsBtn ->
//取消第三方物流 彈出彈窗詢問是否確認取消
cancelLogistics(orderDetails)
BtnBuilder.assignDeliveryBtn ->
//指派送貨
selectorDelivery(this@OrderDetailsActivity, orderDetails, 3) { status, isSuccess -> getOrderDetails(orderId, binding) }
BtnBuilder.cancelBtn ->
//取消訂單
cancelOrder(orderDetails)
BtnBuilder.closingBtn ->
//結賬,彈窗確認是否結賬
// 自取結賬,外賣結賬,第三方物流沒有結賬
object : DialogUtils(this@OrderDetailsActivity, 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()
showLoading()
gsUpdateOrderStatus(orderDetails.ID.toString(), orderDetails.order_type) { status, isSuccess ->
cancelDialogForLoading()
finish()
}
}
hepler.getView<TextView>(R.id.tv_dialog_cancel).setOnClickListener {
dialog.dismiss()
}
}
}.createDialogView().show()
else -> {
showLoading()
updateOrderStatusByBtn(btnList[position].type, orderDetails, GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString()) { status, isSuccess ->
cancelDialogForLoading()
when (status) {
PrintCode -> {
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"打印成功"
} else {
"打印失敗"
})
}
SendCode -> {
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"成功"
} else {
"失敗"
})
}
OrderDelivery -> {
//已確認訂單,重新刷新當前頁面
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"訂單已確認"
} else {
"訂單確認失敗"
})
getOrderDetails(orderId, binding)
}
Closing -> {
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"結賬成功"
} else {
"結賬失敗"
})
}
PageViewModel.ProductionComplete -> {
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"製作完成"
} else {
"修改訂單狀態失敗"
})
getOrderDetails(orderId, binding)
}
}
}
}
}
}
} else {
ToastUtils.show(this@OrderDetailsActivity, "獲取訂單詳情失敗")
finish()
}
}
}
/**
* 取消訂單,獲取取消原因
*/
private fun PageViewModel.cancelOrder(orderDetails: OrderDetails.DataBean) {
//獲取取消原因讓用戶選擇
showLoading()
getCancelReason(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), "3") { cancelReson ->
cancelDialogForLoading()
if (cancelReson != null && cancelReson.data.isNotEmpty()) {
//如果有配置取消原因
//彈出彈窗讓用戶選擇取消原因
selectorCancelReason(this@OrderDetailsActivity, cancelReson, "選擇取消原因") {
isSureCancelOrder(orderDetails.ID.toString(), cancelReson.data[it].id.toString(), cancelReson.data[it].content)
}
} else {
//後台沒有配置取消原因,彈出彈窗詢問是否取消
isSureCancelOrder(orderDetails.ID.toString(), "", "")
}
}
}
/**
* 是否確認取消訂單
*/
private fun PageViewModel.isSureCancelOrder(orderId: String, reasonId: String, reasonDesc: String) {
AppDialog().showWaringDialog(this@OrderDetailsActivity, "是否確認取消訂單?") { v, dialog ->
when (v.id) {
R.id.tv_dialog_confirm -> {
dialog.dismiss()
showLoading()
cancelOrder(this@OrderDetailsActivity, orderId, reasonId, reasonDesc) {
cancelDialogForLoading()
ToastUtils.show(this@OrderDetailsActivity, if (it) {
"取消訂單成功"
} else {
"取消訂單失敗"
})
finish()
}
}
R.id.tv_dialog_cancel -> dialog.dismiss()
}
}
}
/**
* 取消物流,獲取取消原因
*/
private fun PageViewModel.cancelLogistics(orderDetails: OrderDetails.DataBean) {
//獲取取消原因讓用戶選擇
showLoading()
getCancelReason(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), "2") { cancelReson ->
cancelDialogForLoading()
if (cancelReson != null && cancelReson.data.isNotEmpty()) {
//如果有配置取消原因
//彈出彈窗讓用戶選擇取消原因
selectorCancelReason(this@OrderDetailsActivity, cancelReson, "選擇取消原因") {
confirmCancelLogistics(orderDetails.ID.toString(), cancelReson.data[it].id.toString(), cancelReson.data[it].content)
}
} else {
//後台沒有配置取消原因,彈出讓用戶選擇是否取消
confirmCancelLogistics(orderDetails.ID.toString(), "", "")
}
}
}
/**
* 是否確認取消物流
*/
private fun PageViewModel.confirmCancelLogistics(orderId: String, reasonId: String, reasonDesc: String) {
AppDialog().showWaringDialog(this@OrderDetailsActivity, "是否確認取消第三方派送?") { v, dialog ->
when (v.id) {
R.id.tv_dialog_confirm -> {
dialog.dismiss()
showLoading()
cancelLogistics(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), orderId, reasonId, reasonDesc) {
cancelDialogForLoading()
ToastUtils.show(this@OrderDetailsActivity, it)
finish()
}
}
R.id.tv_dialog_cancel -> dialog.dismiss()
}
}
}
}
......@@ -102,7 +102,6 @@ class OtherOrderActivity : BaseActivity() {
btnHeight = btn_open_or_close_info.height.toFloat()
}
pageViewModel.getDeliveryInfo(this)
pageViewModel.getDeliveryConfigDTO(this)
}
/**
......@@ -257,6 +256,7 @@ class OtherOrderActivity : BaseActivity() {
private fun initWebsocket() {
//開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java)
startService(intent)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
}
......@@ -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,6 +420,11 @@ 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,6 +5,7 @@ import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.other_order_mode.R
......@@ -13,7 +14,7 @@ import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutHistoryOrderItemBinding
import com.scwang.smartrefresh.layout.util.SmartUtil
class HistoryOrderAdapter(private val context: Context, var data: List<DataBean>?) : RecyclerView.Adapter<HistoryOrderAdapter.ViewHolder>() {
class HistoryOrderAdapter(var stauts: String?, private val context: Context, var data: List<DataBean>?) : RecyclerView.Adapter<HistoryOrderAdapter.ViewHolder>() {
//item點擊事件
private var listenter: ((item: DataBean) -> Unit)? = null
......@@ -72,6 +73,18 @@ class HistoryOrderAdapter(private val context: Context, var data: List<DataBean>
holder.itemView.setOnClickListener {
listenter?.invoke(data)
}
if (stauts != null) {
if (stauts.equals("4")) {
//已完成訂單
holder.iv_end.setImageResource(R.drawable.ic_has_end)
} else if (stauts.equals("6")) {
//已取消訂單
holder.iv_end.setImageResource(R.drawable.img_cancelled)
}
} else {
holder.iv_end.setImageResource(R.drawable.ic_has_end)
}
}
private fun getColor(color: Int): Int {
......@@ -80,6 +93,7 @@ class HistoryOrderAdapter(private val context: Context, var data: List<DataBean>
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutHistoryOrderItemBinding = DataBindingUtil.bind(itemView)!!
var iv_end = itemView.findViewById<ImageView>(R.id.iv_end)
}
fun setOnItemClickListenter(listenter: (item: DataBean) -> Unit) {
......
package com.gingersoft.gsa.other_order_mode.ui.adapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.BtnBuilder
class OrderDetailsAdapter(list: List<BtnBuilder.BtnBean>) : BaseQuickAdapter<BtnBuilder.BtnBean, BaseViewHolder>(R.layout.item_btn, list) {
override fun convert(helper: BaseViewHolder, item: BtnBuilder.BtnBean) {
helper.setText(R.id.tv_btn_content, item.btnContent)
helper.setBackgroundRes(R.id.layout_btn_item, item.btnColor)
helper.setImageResource(R.id.iv_btn_mark, item.btnImg)
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ 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
......@@ -18,7 +19,6 @@ 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,15 +30,21 @@ 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? {
return inflater.inflate(R.layout.fragment_delivery_list, container, false)
contentView = inflater.inflate(R.layout.fragment_delivery_list, container, false)
addBtn = contentView.findViewById(R.id.btn_default)
return contentView
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getDeliveryFactory())[DeliveryViewModel::class.java]
tv_add_delivery.setOnClickListener{
addBtn.text = "+添加配送方式"
addBtn.setOnClickListener{
(activity as DeliverySettingActivity).editDelivery(null)
}
viewModel.otherInfo.observe(viewLifecycleOwner, Observer { it ->
......@@ -53,7 +59,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,6 +39,7 @@ 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()
......@@ -47,7 +48,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(it2, it1) } }
mHistoryOrderAdapter = it.data.let { it1 -> context?.let { it2 -> HistoryOrderAdapter(status.value, it2, it1) } }
rv_other_order.layoutManager = LinearLayoutManager(context)
rv_other_order.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter { it ->
......@@ -77,6 +78,7 @@ 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
......@@ -14,6 +15,7 @@ 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
......@@ -35,18 +37,8 @@ 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)
......@@ -60,63 +52,71 @@ class PlaceholderFragment : BaseFragment() {
adapter.setOnItemClickListenter { data ->
// 點擊查詢食品詳情
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, "獲取訂單詳情失敗")
}
}
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, "獲取訂單詳情失敗")
// }
// }
}
rv_other_order.adapter = adapter
......@@ -136,7 +136,6 @@ class PlaceholderFragment : BaseFragment() {
refresh()
//重新拉取一遍送貨員和第三方派送信息
pageViewModel.getDeliveryInfo(context!!)
pageViewModel.getDeliveryConfigDTO(context!!)
}
refresh_layout.setOnLoadMoreListener {
page++
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.gingersoft.gsa.cloud.base.utils.time.TimeUtils" />
<import type="com.gingersoft.gsa.cloud.base.utils.MoneyUtil" />
<import type="android.view.View" />
<variable
name="totalAmount"
type="Double" />
<variable
name="data"
type="com.gingersoft.gsa.cloud.print.bean.OrderDetails.DataBean" />
<!-- 是否自取-->
<variable
name="isSelf"
type="Boolean" />
<variable
name="btnContent"
type="String" />
<variable
name="cancelBtnContent"
type="String" />
<variable
name="orderStatus"
type="String" />
<variable
name="patMethod"
type="String" />
<variable
name="estimatedTime"
type="String" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_f0">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/qm_order_details_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_details_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_order_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/rv_order_details_btn"
android:layout_below="@id/qm_order_details_bar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_dialog_bg"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/otherOrder_details_sixteen_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
android:text="@{data.order_from==2?@string/ricepon_order:@string/h5_order}"
android:textSize="@dimen/dp_16"
android:textStyle="normal" />
<TextView
android:id="@+id/tv_order_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{orderStatus}"
android:textColor="#009788"
android:textSize="@dimen/dp_15"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<!-- 訂單編號-->
<TextView
android:id="@+id/tv_order_no"
style="@style/otherOrder_details_twelve_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:text="@{@string/order_no + data.oRDER_NO}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_num" />
<TextView
android:id="@+id/tv_create_time"
style="@style/otherOrder_details_twelve_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_no" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_dialog_bg"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10">
<TextView
style="@style/otherOrder_details_sixteen_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
android:text="訂單詳情" />
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14"
android:visibility="@{isSelf?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_receiver_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="收貨人:" />
<TextView
android:id="@+id/tv_receiver"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_receiver_text"
android:gravity="right"
android:text="@{data.rECEIVER}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14">
<TextView
android:id="@+id/tv_receive_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}" />
<TextView
android:id="@+id/tv_receive_phone"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_receive_phone_text"
android:gravity="right"
android:text="@{data.pHONE}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14">
<TextView
android:id="@+id/tv_receive_time_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}" />
<TextView
android:id="@+id/tv_receive_time"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_receive_time_text"
android:gravity="right"
android:text="@{isSelf?data.takeTime:data.sEND_TIME}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14">
<TextView
android:id="@+id/tv_receive_address_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{isSelf?@string/meal_code:@string/receiving_address}" />
<TextView
android:id="@+id/tv_receive_address"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_receive_address_text"
android:gravity="right"
android:text="@{isSelf?data.takeFoodCode:data.addressDetail}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14"
android:visibility="@{data.remark==null||data.remark.length() == 0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_remark_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="備註:" />
<TextView
android:id="@+id/tv_remark"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_remark_text"
android:gravity="right"
android:text="@{data.remark}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14"
android:visibility="@{(data.delivery_man_name==null || data.delivery_man_name.length()==0) ? View.GONE : View.VISIBLE}">
<TextView
android:id="@+id/tv_delivery_man_name_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/deliveryman" />
<TextView
android:id="@+id/tv_delivery_man_name"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_delivery_man_name_text"
android:gravity="right"
android:text="@{data.delivery_man_name}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14"
android:visibility="@{(data.delivery_man_phone_num==null || data.delivery_man_phone_num.length()==0) ? View.GONE : View.VISIBLE}">
<TextView
android:id="@+id/tv_delivery_man_phone_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/deliveryman_phone" />
<TextView
android:id="@+id/tv_delivery_man_phone"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_delivery_man_phone_text"
android:gravity="right"
android:text="@{data.delivery_man_phone_num}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:paddingLeft="@dimen/dp_7"
android:paddingRight="@dimen/dp_14"
android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_delivery_num_text"
style="@style/otherOrderReceiving_title_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/logistics_number" />
<TextView
android:id="@+id/tv_delivery_num"
style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_delivery_num_text"
android:gravity="right"
android:text="@{data.trkNo}" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_dialog_bg"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10">
<TextView
android:id="@+id/tv_food_details_text"
style="@style/otherOrder_details_sixteen_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="商品詳情" />
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:layout_marginBottom="@dimen/dp_10"
app:layout_constraintTop_toBottomOf="@id/line_food_top" />
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">
<TextView
android:id="@+id/tv_total_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="合計:" />
<TextView
android:id="@+id/tv_total"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_total_text"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(MoneyUtil.sub(totalAmount, data.lunchbox),data.dELIVERY_CHARGE)}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_lunchbox_cost_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="餐盒費:" />
<TextView
android:id="@+id/tv_lunchbox_cost"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_lunchbox_cost_text"
android:gravity="right"
android:text="@{@string/amount_unit + data.lunchbox}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_delivery_fee_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送貨費:" />
<TextView
android:id="@+id/tv_delivery_fee"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_delivery_fee_text"
android:gravity="right"
android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_discount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣:" />
<TextView
android:id="@+id/tv_discount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_discount_text"
android:gravity="right"
android:text="@{@string/minus_amount_unit + data.discount_amount}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">
<TextView
android:id="@+id/tv_total_amount_text2"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="總金額:" />
<TextView
android:id="@+id/tv_total_amount2"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_total_amount_text2"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">
<TextView
android:id="@+id/tv_pay_amount_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="支付金額:" />
<TextView
android:id="@+id/tv_pay_amount"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_pay_amount_text"
android:gravity="right"
android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}"
android:textColor="#FF0000" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
android:visibility="@{patMethod.length()==0?View.GONE:View.VISIBLE}">
<TextView
android:id="@+id/tv_pay_method_text"
style="@style/otherOrder_bill_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="支付方式:" />
<TextView
android:id="@+id/tv_pay_method"
style="@style/otherOrder_bill_info_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/tv_pay_method_text"
android:gravity="right"
android:text="@{patMethod}" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</layout>
\ No newline at end of file
......@@ -10,12 +10,5 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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" />
<include layout="@layout/layout_default" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/layout_btn_item"
android:layout_height="@dimen/dp_40"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_btn_mark"
android:layout_width="@dimen/dp_19"
android:layout_height="@dimen/dp_19"/>
<TextView
android:id="@+id/tv_btn_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout>
\ No newline at end of file
......@@ -153,9 +153,9 @@
app:layout_constraintRight_toLeftOf="@id/iv_edit"
app:layout_constraintTop_toTopOf="@id/tv_difference_text" />
<ImageView
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/iv_edit"
android:layout_width="wrap_content"
android:layout_width="@dimen/dp_30"
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" />
<ImageView
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/iv_delete"
android:layout_width="wrap_content"
android:layout_width="@dimen/dp_30"
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_bill_method"
android:src="@drawable/ic_delete"
android:text="刪除"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_12"
......
......@@ -32,5 +32,19 @@
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_open_cash_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10"
android:text="打開錢箱"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</LinearLayout>
......@@ -14,6 +14,8 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:paddingLeft="@dimen/dp_5"
android:paddingRight="@dimen/dp_5"
android:textColor="@color/color_c8"
android:textSize="@dimen/dp_17" />
......
......@@ -19,6 +19,7 @@
android:padding="@dimen/dp_10">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
......
......@@ -95,4 +95,14 @@
<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>
......@@ -4,11 +4,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<application>
<activity
android:name=".mvp.ui.activity.IpPrintActivity"
android:launchMode="singleTop"
android:theme="@style/print_TranslucentTheme" />
<activity
android:name=".mvp.ui.activity.PrintActivity"
android:launchMode="singleTop"
android:theme="@style/print_TranslucentTheme" />
......
......@@ -23,9 +23,6 @@
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.PrintActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<activity
android:name=".mvp.ui.activity.IpPrintActivity"
android:theme="@style/print_TranslucentTheme" />
<activity android:name=".mvp.ui.activity.PrinterListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
package com.joe.print;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.joe.print.mvp.print.service.PrjService;
import com.joe.print.mvp.ui.activity.IpPrintActivity;
import com.joe.print.mvp.ui.activity.PrintActivity;
import com.joe.print.mvp.ui.activity.PrinterListActivity;
import static com.billy.cc.core.component.CCUtil.EXTRA_KEY_CALL_ID;
public class PrintComponent implements IComponent {
......@@ -54,8 +47,6 @@ public class PrintComponent implements IComponent {
case "getInfo":
getInfo(cc);
break;
case "print_order":
return printOrderInfo(cc);
case "printActivity":
return print(cc);
case "openPrintService":
......@@ -104,20 +95,6 @@ public class PrintComponent implements IComponent {
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
private boolean printOrderInfo(CC cc) {
Context context = cc.getContext();
Intent intent = new Intent(context, IpPrintActivity.class);
if (!(context instanceof Activity)) {
//调用方没有设置context或app间组件跳转,context为application
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
//将cc的callId传给Activity,登录完成后通过这个callId来回传结果
intent.putExtra(EXTRA_KEY_CALL_ID, cc.getCallId());
context.startActivity(intent);
//返回true,不立即调用CC.sendCCResult
return true;
}
private boolean print(CC cc) {
// Context context = cc.getContext();
// Intent intent = new Intent(context, PrintActivity.class);
......
......@@ -24,5 +24,7 @@ public interface IpPrintListActivityContract {
Observable<BaseResult> getPrinterList(int restaurantId);
Observable<BaseResult> deletePrinter(RequestBody requestBody);
Observable<BaseResult> getPrintModel(int restaurantId);
}
}
......@@ -34,5 +34,7 @@ public interface PrinterAddContract {
Observable<BaseResult> addPrinter(RequestBody requestBody);
Observable<BaseResult> updatePrinter(RequestBody requestBody);
Observable<BaseResult> getPrintModel(int restaurantId);
}
}
......@@ -46,4 +46,10 @@ public class IpPrintListActivityModel extends BaseModel implements IpPrintListAc
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class)
.deletePrinterList(requestBody);
}
@Override
public Observable<BaseResult> getPrintModel(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class)
.getPrinterModelList(restaurantId);
}
}
\ No newline at end of file
......@@ -58,4 +58,10 @@ public class PrinterAddModel extends BaseModel implements PrinterAddContract.Mod
.updatePrinter(requestBody);
}
@Override
public Observable<BaseResult> getPrintModel(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class)
.getPrinterModelList(restaurantId);
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ import retrofit2.http.Query;
* Created by Wyh on 2019/12/20.
*/
public interface PrintInfoService {
// @Headers({"Domain-Name: yc_location"})
@POST("PrinterDevice/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addPrinter(@Body RequestBody requestBody);
......@@ -30,4 +30,10 @@ public interface PrintInfoService {
// @Headers({"Domain-Name: yc_location"})
@POST("PrinterDevice/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updatePrinter(@Body RequestBody requestBody);
// @Headers({"Domain-Name: yc_location"})
@GET("printerModel/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getPrinterModelList(@Query("restaurantId") int restaurantId);
}
......@@ -12,6 +12,7 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.IpPrintListActivityContract;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import java.util.List;
......@@ -106,4 +107,30 @@ public class IpPrintListActivityPresenter extends BasePresenter<IpPrintListActiv
});
}
private List<PrintModelBean> printModelBeans;
public List<PrintModelBean> getPrintModelBeans() {
return printModelBeans;
}
/**
* 獲取打印機機型列表
*/
public void getModelList(int restaurantId) {
mModel.getPrintModel(restaurantId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult.isSuccess()) {
printModelBeans = JsonUtils.parseArray(baseResult.getData(), PrintModelBean.class);
}
}
});
}
}
......@@ -49,4 +49,6 @@ public class PrintListPresenter extends BasePresenter<PrintListContract.Model, P
this.mImageLoader = null;
this.mApplication = null;
}
}
......@@ -11,7 +11,10 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.PrinterAddContract;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
......@@ -47,6 +50,28 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model,
@Inject
AppManager mAppManager;
// private List<PrintModelBean> printModelBeans;
// private List<String> printModelLabels = new ArrayList<>();
//
// private int modelPosition = -1;
//
// public List<String> getPrintModelLabels() {
// return printModelLabels;
// }
//
// public List<PrintModelBean> getPrintModelBeans() {
// return printModelBeans;
// }
//
// public int getModelPosition() {
// return modelPosition;
// }
//
// public void setModelPosition(int modelPosition) {
// this.modelPosition = modelPosition;
// }
@Inject
public PrinterAddPresenter(PrinterAddContract.Model model, PrinterAddContract.View rootView) {
super(model, rootView);
......@@ -61,6 +86,7 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model,
this.mApplication = null;
}
/**
* 添加打印機
*/
......@@ -110,4 +136,30 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model,
}
/**
* 獲取打印機機型列表
*/
// public void getModelList(int restaurantId) {
// mModel.getPrintModel(restaurantId)
// .subscribeOn(Schedulers.io())
// .doOnSubscribe(disposable -> mRootView.showLoading(""))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .doAfterTerminate(() -> mRootView.hideLoading())
// .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
// .subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
// @Override
// public void onNext(BaseResult baseResult) {
// if (baseResult.isSuccess()) {
// printModelBeans = JsonUtils.parseArray(baseResult.getData(), PrintModelBean.class);
// if (printModelBeans != null && printModelBeans.size() > 0) {
// for (int i = 0; i < printModelBeans.size(); i++) {
// printModelLabels.add(printModelBeans.get(i).getPrinterName() + "\u3000" + printModelBeans.get(i).getModel());
// }
// }
// }
// }
// });
// }
}
......@@ -7,11 +7,9 @@ import android.graphics.Matrix;
import android.graphics.Rect;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
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.gingersoft.gsa.cloud.print.PrinterWriterExecutor;
import java.io.IOException;
import java.util.ArrayList;
......@@ -27,11 +25,6 @@ public class IpPrintMaker implements PrintDataMaker {
private int width; // 打印的圖片寬度,紙張寬度
private List<Bitmap> bitmaps;
public IpPrintMaker(Context context, int width, List<Bitmap> bitmaps) {
this.mContext = context;
this.width = width;
this.bitmaps = bitmaps;
}
public IpPrintMaker(Context context, int width, Bitmap bitmap) {
this.mContext = context;
this.width = width;
......@@ -39,14 +32,12 @@ public class IpPrintMaker implements PrintDataMaker {
this.bitmaps.add(bitmap);
}
@Override
public List<byte[]> getPrintData(int type) {
public List<byte[]> getPrintData() {
ArrayList<byte[]> data = new ArrayList<>();
try {
PrinterWriter printer;
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(255, width) : new PrinterWriter80mm(255, width);
printer = new PrinterWriterExecutor(255, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
if (bitmaps.size() <= 0) {
......@@ -64,6 +55,7 @@ public class IpPrintMaker implements PrintDataMaker {
printer.feedPaperCutPartial();
data.add(printer.getDataAndReset());
}
// printer.openCashBox();
data.add(printer.getDataAndClose());
return data;
} catch (Exception e) {
......
package com.joe.print.mvp.print;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriterExecutor;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Wyh on 2020/1/9.
* ip打印類
*/
public class OpenCashBoxMaker implements PrintDataMaker {
@Override
public List<byte[]> getPrintData() {
ArrayList<byte[]> data = new ArrayList<>();
try {
PrinterWriter printer;
printer = new PrinterWriterExecutor(255, 0);
printer.openCashBox();
data.add(printer.getDataAndClose());
return data;
} catch (Exception e) {
return new ArrayList<>();
}
}
}
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import java.util.List;
import java.util.Map;
/**
* 指令打印
*/
public class PrintInstruction extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
return null;
}
@Override
public int getPrintCount(Context context) {
return 0;
}
}
......@@ -59,6 +59,7 @@ 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打印機紙張寬度
......@@ -86,6 +87,8 @@ 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;
}
......@@ -134,6 +137,11 @@ 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);
......@@ -141,13 +149,6 @@ 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,則是走默認打印機流程
......@@ -161,6 +162,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}
}
}
}
/**
......@@ -343,6 +345,7 @@ 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打印
......@@ -401,25 +404,30 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
});
} else if (deftultPrint.equals(PrintConstans.IP_PRINT)) {
// 默認打印方式為ip打印,調用ip打印方法
// 獲取默認ip打印機
// 獲取默認ip打印機
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
//有默認打印機
for (PrinterDeviceBean printerDeviceBean : printerDeviceBeans) {
if (printerDeviceBean.getStatus() == 2) {
//默認打印機
ipDevicePrint(printerDeviceBeans.get(0), bitmaps);
return;
}
}
ipDevicePrint(getDefaultPrintInList(printerDeviceBeans), bitmaps);
} else {
//沒有默認打印機,彈出彈窗,讓用戶選擇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) {
......@@ -465,32 +473,26 @@ 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 (paperType == 1) {
paperType = PrinterWriter58mm.TYPE_58;
printWidth = 580 - 20;//兩邊留20的空隙
if (printerDeviceBean.getPaperSpecification() != null) {
printWidth = Double.valueOf(printerDeviceBean.getPaperSpecification()).intValue();
} else {
paperType = PrinterWriter80mm.TYPE_80;
printWidth = 800 - 20;//兩邊留20的空隙
printWidth = 540;
}
PrintExecutor executor = new PrintExecutor(printerDeviceBean, paperType);
PrintExecutor executor = new PrintExecutor(printerDeviceBean);
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.os.Message;
import android.util.Log;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
public class PrinterUtil {
//定义编码方式
private static String encoding = null;
private String ip;
private Socket sock = null;
// 通过socket流进行读写
private OutputStream socketOut = null;
private OutputStreamWriter writer = null;
/**
* 初始化Pos实例
*
* @param ip 打印机IP
* @param port 打印机端口号
* @param encoding 编码
*/
public PrinterUtil(String ip, int port, String encoding) {
try {
this.ip = ip;
boolean isSocketConnect = false;
if (sock != null) {
closeIOAndSocket();
} else {
sock = new Socket(ip, port);
}
sock.setSoTimeout(1000 * 3);
socketOut = new DataOutputStream(sock.getOutputStream());
PrinterUtil.encoding = encoding;
writer = new OutputStreamWriter(socketOut, encoding);
isSocketConnect = true;
} catch (Exception e) {
Log.e("king", e.toString());
}
}
/**
* 获取打印机状态
*
* @return
*/
public String getPosStatus() {
try {
Socket sock = new Socket(ip, 4000); // ip and port of printer
sock.setSoTimeout(1000);
OutputStream outStream = sock.getOutputStream();
outStream.write(new byte[]{0x1B, 0x76});
outStream.flush();
InputStream stream = sock.getInputStream();
byte[] bytes = new byte[4];
stream.read(bytes);
Message msg = new Message();
stream.close();
outStream.close();
sock.close();
return bytes[0] + "," + bytes[1] + "," + bytes[2] + "," + bytes[3] + ",";
} catch (IOException e) {
Message msg = new Message();
e.printStackTrace();
}
return "error";
}
/**
* 关闭IO流和Socket
*
* @throws IOException
*/
public void closeIOAndSocket() {
try {
writer.close();
socketOut.close();
sock.close();
} catch (Exception e) {
}
}
/**
* 判断socket连接状态
*/
public boolean isSocketConnect() throws IOException {
boolean connected = sock.isConnected();
return connected;
}
/**
* 打印二维码
*
* @param qrData 二维码的内容
* @throws IOException
*/
public void qrCode(String qrData) throws IOException {
int moduleSize = 8;
int length = qrData.getBytes(encoding).length;
//打印二维码矩阵
writer.write(0x1D);// init
writer.write("(k");// adjust height of barcode
writer.write(length + 3); // pl
writer.write(0); // ph
writer.write(49); // cn
writer.write(80); // fn
writer.write(48); //
writer.write(qrData);
writer.write(0x1D);
writer.write("(k");
writer.write(3);
writer.write(0);
writer.write(49);
writer.write(69);
writer.write(48);
writer.write(0x1D);
writer.write("(k");
writer.write(3);
writer.write(0);
writer.write(49);
writer.write(67);
writer.write(moduleSize);
writer.write(0x1D);
writer.write("(k");
writer.write(3); // pl
writer.write(0); // ph
writer.write(49); // cn
writer.write(81); // fn
writer.write(48); // m
writer.flush();
}
/**
* 进纸并全部切割
*
* @throws IOException
*/
public void feedAndCut() throws IOException {
writer.write(0x1D);
writer.write(86);
writer.write(65);
// writer.write(0);
//切纸前走纸多少
writer.write(100);
writer.flush();
//另外一种切纸的方式
// byte[] bytes = {29, 86, 0};
// socketOut.write(bytes);
}
/**
* 打印换行
*
* @return length 需要打印的空行数
* @throws IOException
*/
public void printLine(int lineNum) throws IOException {
for (int i = 0; i < lineNum; i++) {
writer.write("\n");
}
writer.flush();
}
/**
* 打印换行(只换一行)
*
* @throws IOException
*/
public void printLine() throws IOException {
writer.write("\n");
writer.flush();
}
/**
* 打印空白(一个Tab的位置,约4个汉字)
*
* @param length 需要打印空白的长度,
* @throws IOException
*/
public void printTabSpace(int length) throws IOException {
for (int i = 0; i < length; i++) {
writer.write("\t");
}
writer.flush();
}
/**
* 打印空白(一个汉字的位置)
*
* @param length 需要打印空白的长度,
* @throws IOException
*/
public void printWordSpace(int length) throws IOException {
for (int i = 0; i < length; i++) {
writer.write(" ");
}
writer.flush();
}
/**
* 打印位置调整
*
* @param position 打印位置 0:居左(默认) 1:居中 2:居右
* @throws IOException
*/
public void printLocation(int position) throws IOException {
writer.write((char) 27);
writer.write((char) 97);
writer.write((char) position);
writer.flush();
}
/**
* 绝对打印位置
*
* @throws IOException
*/
public void printLocation(int light, int weight) throws IOException {
writer.write(0x1B);
writer.write(0x24);
writer.write(light);
writer.write(weight);
writer.flush();
}
/**
* 打印文字
*
* @param text
* @throws IOException
*/
public void printText(String text) throws IOException {
String s = text;
byte[] content = s.getBytes("gbk");
socketOut.write(content);
socketOut.flush();
}
/**
* 新起一行,打印文字
*
* @param text
* @throws IOException
*/
public void printTextNewLine(String text) throws IOException {
//换行
writer.write("\n");
writer.flush();
String s = text;
byte[] content = s.getBytes("gbk");
socketOut.write(content);
socketOut.flush();
}
/**
* 初始化打印机
*
* @throws IOException
*/
public void initPos() throws IOException {
writer.write(0x1B);
writer.write(0x40);
writer.flush();
}
/**
* 加粗
*
* @param flag false为不加粗
* @return
* @throws IOException
*/
public void bold(boolean flag) throws IOException {
if (flag) {
//常规粗细
writer.write(0x1B);
writer.write(69);
writer.write(0xF);
writer.flush();
} else {
//加粗
writer.write(0x1B);
writer.write(69);
writer.write(0);
writer.flush();
}
}
public void fontSize(int size) throws IOException {
writer.write(CMD_FontSize(size));
writer.flush();
}
/**
* 睡几秒
*/
private void sleep(int time) throws InterruptedException {
Thread.sleep(time);
}
/**
* 打开钱箱
*/
public void openCashBox() throws IOException {
writer.write(0x1B);
writer.write(0x70);
writer.write(0);
writer.write(100);
writer.write(80);
writer.flush();
}
/// <summary>
/// 字体的大小
/// </summary>
/// <param name="nfontsize">0:正常大小 1:两倍高 2:两倍宽 3:两倍大小 4:三倍高 5:三倍宽 6:三倍大小 7:四倍高 8:四倍宽 9:四倍大小 10:五倍高 11:五倍宽 12:五倍大小</param>
/// <returns></returns>
public String CMD_FontSize(int nfontsize) {
String _cmdstr = "";
//设置字体大小
switch (nfontsize) {
case -1:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 0).toString();//29 33
break;
case 0:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 0).toString();//29 33
break;
case 1:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 1).toString();
break;
case 2:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 16).toString();
break;
case 3:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 17).toString();
break;
case 4:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 2).toString();
break;
case 5:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 32).toString();
break;
case 6:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 34).toString();
break;
case 7:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 3).toString();
break;
case 8:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 48).toString();
break;
case 9:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 51).toString();
break;
case 10:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 4).toString();
break;
case 11:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 64).toString();
break;
case 12:
_cmdstr = new StringBuffer().append((char) 29).append((char) 33).append((char) 68).toString();
break;
}
return _cmdstr;
}
}
......@@ -35,12 +35,12 @@ public class SendPrint implements PrintDataMaker {
}
@Override
public List<byte[]> getPrintData(int type) {
public List<byte[]> getPrintData() {
ArrayList<byte[]> data = new ArrayList<>();
try {
PrinterWriter printer;
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(parting, width) : new PrinterWriter80mm(parting, width);
printer = new PrinterWriter58mm(parting, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(mContext, printType, width);//根據打印類型獲得不同的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();
}
}
......@@ -105,6 +105,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
* 2:結賬單
* 3:廚房單
* 4:打印view
* 5:打印外賣接單
* 6:其他指令
*/
int type = CCUtil.getNavigateParam(this, PRINT_TYPE, -1);
boolean isShowDialog = CCUtil.getNavigateParam(this, PrintConstans.PRINT_LOADING, true);
......
......@@ -6,10 +6,11 @@ import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView;
......@@ -24,6 +25,7 @@ import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
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.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
......@@ -35,8 +37,10 @@ import com.joe.print.mvp.contract.PrinterAddContract;
import com.joe.print.mvp.presenter.PrinterAddPresenter;
import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.ui.adapter.SelectPrintAdapter;
import com.joe.print.mvp.ui.view.WheelView;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
......@@ -60,20 +64,25 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
QMUITopBar topBar;
@BindView(R2.id.add_printer_ed_port)
EditText etPort;
@BindView(R2.id.printer_type)
RadioGroup rgPaperType;
@BindView(R2.id.switch_set_default)
Switch mSwitchDefalute;
@BindView(R2.id.tv_print_fail_one)
TextView mTvFailNameOne;
@BindView(R2.id.tv_print_fail_two)
TextView mTvFailNameTwo;
@BindView(R2.id.print_device_name)
TextView mTvModel;
private List<PrinterDeviceBean> devicess;
private PrinterDeviceBean printerDeviceBean;
private boolean isEditPrinter = false;//是否是編輯打印機
private int oneFailPosition = -1, twoFailPosition = -1;
private List<PrintModelBean> printModelBeans;
private List<String> printModelLabels;
private int modelPosition = -1;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -92,16 +101,20 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String[] ips = new String[4];
//如果不為空,則是編輯打印機,初始化信息
if (printerDeviceBean != null) {
mEdPrintName.setText(String.valueOf(printerDeviceBean.getName()));
ips = printerDeviceBean.getIp().split("[.]");
etPort.setText(printerDeviceBean.getPort() + "");
if (printerDeviceBean.getType() == 1) {
rgPaperType.check(R.id.print_paper_size_58);
} else {
rgPaperType.check(R.id.print_paper_size_88);
if (printerDeviceBean.getPrinterName() != null) {
mTvModel.setTextColor(getResources().getColor(R.color.color_3c));
mTvModel.setText(printerDeviceBean.getPrinterName());
if (printerDeviceBean.getModel() != null) {
mTvModel.setText(printerDeviceBean.getPrinterName() + "\u3000" + printerDeviceBean.getModel());
}
}
mSwitchDefalute.setChecked(printerDeviceBean.getStatus() == 2);
if (devicess != null && devicess.size() > 0) {
......@@ -141,6 +154,8 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
public void initIntent() {
int position = getIntent().getIntExtra("printer_position", -1);
devicess = (List<PrinterDeviceBean>) getIntent().getSerializableExtra("printList");
printModelBeans = (List<PrintModelBean>) getIntent().getSerializableExtra("printModelList");
if (devicess != null && position != -1) {
printerDeviceBean = devicess.get(position);
if (printerDeviceBean != null) {
......@@ -148,6 +163,16 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
}
}
isEditPrinter = printerDeviceBean != null;
if (printModelBeans != null) {
printModelLabels = new ArrayList<>();
for (int i = 0; i < printModelBeans.size(); i++) {
printModelLabels.add(printModelBeans.get(i).getPrinterName() + "\u3000" + printModelBeans.get(i).getModel());
if (printerDeviceBean != null && printerDeviceBean.getPrinterModelId() == printModelBeans.get(i).getId()) {
modelPosition = i;
}
}
}
}
@Override
......@@ -205,7 +230,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
finish();
}
@OnClick({R2.id.printer_add, R2.id.layout_select_fail_one, R2.id.layout_select_fail_two})
@OnClick({R2.id.printer_add, R2.id.layout_select_fail_one, R2.id.layout_select_fail_two, R2.id.layout_print_device})
@Override
public void onClick(View v) {
int id = v.getId();
......@@ -217,6 +242,36 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
return;
}
selectFailPrint(id);
} else if (id == R.id.layout_print_device) {
if (printModelBeans == null || printModelBeans.size() <= 0) {
ToastUtils.show(mContext, "請先添加打印機機型");
return;
}
//選擇打印機機型
new DialogUtils(this, R.layout.dialog_select_print_device) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
WheelView wheelView = hepler.getView(R.id.wv_model);
wheelView.setOffset(1);
if (modelPosition >= 0) {
wheelView.setSeletion(modelPosition);
}
wheelView.setItems(printModelLabels);
hepler.getView(R.id.btn_cancel).setOnClickListener(v -> dialog.dismiss());
hepler.getView(R.id.btn_confirm).setOnClickListener(v -> {
modelPosition = wheelView.getSeletedIndex();
mTvModel.setText(wheelView.getSeletedItem());
mTvModel.setTextColor(getResources().getColor(R.color.color_3c));
dialog.dismiss();
});
}
}
.setWidth(WindowManager.LayoutParams.MATCH_PARENT)
.createDialogView()
.setGravity(Gravity.BOTTOM)
.show();
}
}
......@@ -281,12 +336,13 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
ipAddress.append(editText.getText());
ipAddress.append(".");
}
hideKeyBoard();
int paperType = 1;//打印紙類型
if (rgPaperType.getCheckedRadioButtonId() != R.id.print_paper_size_58) {
paperType = 2;
}
// if (rgPaperType.getCheckedRadioButtonId() != R.id.print_paper_size_58) {
// paperType = 2;
// }
String port = etPort.getText().toString();
PrinterDeviceBean deviceBean;
......@@ -302,6 +358,18 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
deviceBean.setDefaultPrinterDeviceId((long) devicess.get(twoFailPosition).getId());
}
deviceBean.setStatus(mSwitchDefalute.isChecked() ? 2 : 1);
//打印機機型ID
if (modelPosition < 0) {
if (printerDeviceBean != null) {
deviceBean.setPrinterModelId(printerDeviceBean.getPrinterModelId());
deviceBean.setPaperSpecification(printerDeviceBean.getPaperSpecification());
}
} else {
if (printModelBeans != null && printModelBeans.size() > modelPosition) {
deviceBean.setPrinterModelId(printModelBeans.get(modelPosition).getId());
deviceBean.setPaperSpecification(printModelBeans.get(modelPosition).getPaperSpecification());
}
}
//添加打印機
if (v.getId() == R.id.printer_add) {
if (isEditPrinter && printerDeviceBean != null) {
......
package com.joe.print.mvp.ui.activity;
class aaa {
public static void main(String[] age) {
int[] arr = new int[]{4, 1, 8, 5, 3, 2, 9, 10, 6, 7};
int[] brr = new int[]{5, 1, 2, 3, 8, 4, 9, 10, 6, 7};
partition(arr, 0, 9);
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + ",");
}
}
public static void quickSort(int[] arr, int startIndex, int endIndex) {
if (arr != null && arr.length > 0) {
int start = startIndex, end = endIndex;
int target = arr[startIndex];
while (start < end) {
while (start < end) {
if (arr[end] < target) {
swap(arr, start, end);
break;
} else {
end--;
}
}
while (start < end) {
if (arr[start] > target) {
swap(arr, start, end);
break;
} else {
start++;
}
}
}
}
}
public static void swap(int[] arr, int index1, int index2) {
int a = arr[index1];
arr[index1] = arr[index2];
arr[index2] = a;
}
// public static int[] getLeastNumbers(int[] arr, int k) {
// if (k == 0 || arr.length == 0) {
// return new int[0];
// }
// // 最后一个参数表示我们要找的是下标为k-1的数
// return quickSearch(arr, 0, arr.length - 1, k - 1);
// }
//
// private static int[] quickSearch(int[] nums, int lo, int hi, int k) {
// // 每快排切分1次,找到排序后下标为j的元素,如果j恰好等于k就返回j以及j左边所有的数;
// int j = partition(nums, lo, hi);
// if (j == k) {
// return Arrays.copyOf(nums, j + 1);
// }
// // 否则根据下标j与k的大小关系来决定继续切分左段还是右段。
// return j > k ? quickSearch(nums, lo, j - 1, k) : quickSearch(nums, j + 1, hi, k);
// }
//
// // 快排切分,返回下标j,使得比nums[j]小的数都在j的左边,比nums[j]大的数都在j的右边。
private static void partition(int[] nums, int lo, int hi) {
int k = nums[lo];
int i = lo, j = hi + 1;
while (true) {
while (++i <= hi && nums[i] < k);
while (--j >= lo && nums[j] > k);
if (i >= j) {
break;
}
// int t = nums[j];最近更新
// nums[j] = nums[i];
// nums[i] = t;
swap(nums, i, j);
}
nums[lo] = nums[j];
nums[j] = k;
swap(nums, i, j);
}
}
\ No newline at end of file
package com.joe.print.mvp.ui.adapter;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.joe.print.R;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import java.util.List;
public class PrintModelAdapter extends BaseQuickAdapter<PrintModelBean, BaseViewHolder> {
public PrintModelAdapter(@Nullable List<PrintModelBean> data) {
super(R.layout.item_dialog_select_print_model, data);
}
@Override
protected void convert(BaseViewHolder helper, PrintModelBean item) {
helper.setText(R.id.tv_item_print_model_name, item.getPrinterName() + "\u3000" + item.getModel());
}
}
......@@ -31,6 +31,7 @@ import com.joe.print.mvp.contract.IpPrintListActivityContract;
import com.joe.print.mvp.presenter.IpPrintListActivityPresenter;
import com.joe.print.mvp.ui.activity.PrinterAddActivity;
import com.joe.print.mvp.ui.adapter.PrinterListAdapter;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.yanzhenjie.recyclerview.touch.OnItemMoveListener;
......@@ -51,8 +52,8 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
@BindView(R2.id.rc_ip_print)
SwipeRecyclerView mRvPrintList;
private PrinterListAdapter printListAdapter;
@BindView(R2.id.tv_add_print)
TextView mTvAddPrint;
@BindView(R2.id.btn_default)
QMUIAlphaButton mTvAddPrint;
public static IpPrintListActivityFragment newInstance() {
IpPrintListActivityFragment fragment = new IpPrintListActivityFragment();
......@@ -76,7 +77,8 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mTvAddPrint.setText("+添加打印機");
mPresenter.getModelList(GsaCloudApplication.getRestaurantId(mContext));
}
@Override
......@@ -85,6 +87,12 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
}
@Override
public void onStart() {
super.onStart();
}
/**
* 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法,
* 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {#setData(Object)}
......@@ -262,7 +270,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
});// 监听拖拽和侧滑删除,更新UI和数据源。
printListAdapter = new PrinterListAdapter(devicess, mContext);
printListAdapter.setOnItemChildClickListener((adapter, view, position) -> AppDialog.showWaringDialog(mContext, "是否刪除打印機", (view1, dialog) -> {
printListAdapter.setOnItemChildClickListener((adapter, view, position) -> new AppDialog().showWaringDialog(mContext, "是否刪除打印機", (view1, dialog) -> {
//調用刪除接口
mPresenter.deletePrinter(devicess.get(position).getId() + "");
devicess.remove(position);
......@@ -289,6 +297,9 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
Intent intent = new Intent(mContext, PrinterAddActivity.class);
intent.putExtra("printer_position", adapterPosition);
intent.putExtra("printList", (Serializable) devicess);
if(mPresenter.getPrintModelBeans() != null){
intent.putExtra("printModelList", (Serializable) mPresenter.getPrintModelBeans());
}
startActivity(intent);
}
......@@ -298,10 +309,10 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
mTvAddPrint.setVisibility(View.VISIBLE);
}
@OnClick(R2.id.tv_add_print)
@OnClick(R2.id.btn_default)
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_add_print) {
if (v.getId() == R.id.btn_default) {
startToEditPrint(-1);
}
}
......
package com.joe.print.mvp.ui.view;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
*/
public class WheelView extends ScrollView {
public static final String TAG = WheelView.class.getSimpleName();
private int textSize = 16;
public static class OnWheelViewListener {
public void onSelected(int selectedIndex, String item) {
}
}
private Context context;
// private ScrollView scrollView;
private LinearLayout views;
public WheelView(Context context) {
super(context);
init(context);
}
public WheelView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public WheelView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
// String[] items;
List<String> items;
private List<String> getItems() {
return items;
}
public void setItems(List<String> list) {
if (null == items) {
items = new ArrayList<String>();
}
items.clear();
items.addAll(list);
// 前面和后面补全
for (int i = 0; i < offset; i++) {
items.add(0, "");
items.add("");
}
initData();
}
public void setTextSize(int textSize) {
this.textSize = textSize;
}
public static final int OFF_SET_DEFAULT = 1;
int offset = OFF_SET_DEFAULT; // 偏移量(需要在最前面和最后面补全)
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
int displayItemCount; // 每页显示的数量
int selectedIndex = 1;
private void init(Context context) {
this.context = context;
// scrollView = ((ScrollView)this.getParent());
// Log.d(TAG, "scrollview: " + scrollView);
Log.d(TAG, "parent: " + this.getParent());
// this.setOrientation(VERTICAL);
this.setVerticalScrollBarEnabled(false);
views = new LinearLayout(context);
views.setOrientation(LinearLayout.VERTICAL);
this.addView(views);
scrollerTask = new Runnable() {
public void run() {
int newY = getScrollY();
if (initialY - newY == 0) { // stopped
final int remainder = initialY % itemHeight;
final int divided = initialY / itemHeight;
// Log.d(TAG, "initialY: " + initialY);
// Log.d(TAG, "remainder: " + remainder + ", divided: " + divided);
if (remainder == 0) {
selectedIndex = divided + offset;
onSeletedCallBack();
} else {
if (remainder > itemHeight / 2) {
WheelView.this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, initialY - remainder + itemHeight);
selectedIndex = divided + offset + 1;
onSeletedCallBack();
}
});
} else {
WheelView.this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, initialY - remainder);
selectedIndex = divided + offset;
onSeletedCallBack();
}
});
}
}
} else {
initialY = getScrollY();
WheelView.this.postDelayed(scrollerTask, newCheck);
}
}
};
}
int initialY;
Runnable scrollerTask;
int newCheck = 50;
public void startScrollerTask() {
initialY = getScrollY();
this.postDelayed(scrollerTask, newCheck);
}
private void initData() {
displayItemCount = offset * 2 + 1;
for (String item : items) {
views.addView(createView(item));
}
refreshItemView(0);
}
int itemHeight = 0;
private TextView createView(String item) {
TextView tv = new TextView(context);
tv.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
tv.setSingleLine(true);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
tv.setText(item);
tv.setGravity(Gravity.CENTER);
int padding = dip2px(15);
tv.setPadding(padding, padding, padding, padding);
if (0 == itemHeight) {
itemHeight = getViewMeasuredHeight(tv);
Log.d(TAG, "itemHeight: " + itemHeight);
views.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight * displayItemCount));
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) this.getLayoutParams();
this.setLayoutParams(new LinearLayout.LayoutParams(lp.width, itemHeight * displayItemCount));
}
return tv;
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
// Log.d(TAG, "l: " + l + ", t: " + t + ", oldl: " + oldl + ", oldt: " + oldt);
// try {
// Field field = ScrollView.class.getDeclaredField("mScroller");
// field.setAccessible(true);
// OverScroller mScroller = (OverScroller) field.get(this);
//
//
// if(mScroller.isFinished()){
// Log.d(TAG, "isFinished...");
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// }
refreshItemView(t);
if (t > oldt) {
// Log.d(TAG, "向下滚动");
scrollDirection = SCROLL_DIRECTION_DOWN;
} else {
// Log.d(TAG, "向上滚动");
scrollDirection = SCROLL_DIRECTION_UP;
}
}
private void refreshItemView(int y) {
int position = y / itemHeight + offset;
int remainder = y % itemHeight;
int divided = y / itemHeight;
if (remainder == 0) {
position = divided + offset;
} else {
if (remainder > itemHeight / 2) {
position = divided + offset + 1;
}
// if(remainder > itemHeight / 2){
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// Log.d(TAG, ">down...position: " + position);
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
// Log.d(TAG, ">up...position: " + position);
// }
// }else{
//// position = y / itemHeight + offset;
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// Log.d(TAG, "<down...position: " + position);
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
// Log.d(TAG, "<up...position: " + position);
// }
// }
// }
// if(scrollDirection == SCROLL_DIRECTION_DOWN){
// position = divided + offset;
// }else if(scrollDirection == SCROLL_DIRECTION_UP){
// position = divided + offset + 1;
}
int childSize = views.getChildCount();
for (int i = 0; i < childSize; i++) {
TextView itemView = (TextView) views.getChildAt(i);
if (null == itemView) {
return;
}
if (position == i) {
itemView.setTextColor(Color.parseColor("#0288ce"));
} else {
itemView.setTextColor(Color.parseColor("#bbbbbb"));
}
}
}
/**
* 获取选中区域的边界
*/
int[] selectedAreaBorder;
private int[] obtainSelectedAreaBorder() {
if (null == selectedAreaBorder) {
selectedAreaBorder = new int[2];
selectedAreaBorder[0] = itemHeight * offset;
selectedAreaBorder[1] = itemHeight * (offset + 1);
}
return selectedAreaBorder;
}
private int scrollDirection = -1;
private static final int SCROLL_DIRECTION_UP = 0;
private static final int SCROLL_DIRECTION_DOWN = 1;
Paint paint;
int viewWidth;
@Override
public void setBackgroundDrawable(Drawable background) {
if (viewWidth == 0) {
viewWidth = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
Log.d(TAG, "viewWidth: " + viewWidth);
}
if (null == paint) {
paint = new Paint();
paint.setColor(Color.parseColor("#83cde6"));
paint.setStrokeWidth(dip2px(1f));
}
background = new Drawable() {
@Override
public void draw(Canvas canvas) {
canvas.drawLine(viewWidth * 1 / 6, obtainSelectedAreaBorder()[0], viewWidth * 5 / 6, obtainSelectedAreaBorder()[0], paint);
canvas.drawLine(viewWidth * 1 / 6, obtainSelectedAreaBorder()[1], viewWidth * 5 / 6, obtainSelectedAreaBorder()[1], paint);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return PixelFormat.UNKNOWN;
}
};
super.setBackgroundDrawable(background);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
Log.d(TAG, "w: " + w + ", h: " + h + ", oldw: " + oldw + ", oldh: " + oldh);
viewWidth = w;
setBackgroundDrawable(null);
}
/**
* 选中回调
*/
private void onSeletedCallBack() {
if (null != onWheelViewListener) {
onWheelViewListener.onSelected(selectedIndex, items.get(selectedIndex));
}
}
public void setSeletion(int position) {
final int p = position;
selectedIndex = p + offset;
this.post(new Runnable() {
@Override
public void run() {
WheelView.this.smoothScrollTo(0, p * itemHeight);
}
});
}
public String getSeletedItem() {
return items.get(selectedIndex);
}
public int getSeletedIndex() {
return selectedIndex - offset;
}
@Override
public void fling(int velocityY) {
super.fling(velocityY / 3);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
startScrollerTask();
}
return super.onTouchEvent(ev);
}
private OnWheelViewListener onWheelViewListener;
public OnWheelViewListener getOnWheelViewListener() {
return onWheelViewListener;
}
public void setOnWheelViewListener(OnWheelViewListener onWheelViewListener) {
this.onWheelViewListener = onWheelViewListener;
}
private int dip2px(float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
private int getViewMeasuredHeight(View view) {
int width = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int expandSpec = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, View.MeasureSpec.AT_MOST);
view.measure(width, expandSpec);
return view.getMeasuredHeight();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/dp_10"
android:text="打印機型號"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16" />
<com.joe.print.mvp.ui.view.WheelView
android:id="@+id/wv_model"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10">
<Button
android:id="@+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@drawable/shape_black_border"
android:text="取消"
android:textColor="@color/theme_333_color" />
<Button
android:id="@+id/btn_confirm"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="@dimen/dp_10"
android:layout_weight="1"
android:background="@color/theme_color"
android:text="確定"
android:textColor="@color/white" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -10,12 +10,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/tv_add_print"
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" />
<include layout="@layout/layout_default" />
</LinearLayout>
\ No newline at end of file
......@@ -190,44 +190,43 @@
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
<RelativeLayout
android:id="@+id/layout_print_device"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_device_model_text"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="紙張規格" />
android:layout_centerVertical="true"
android:text="打印機型號" />
<RadioGroup
android:id="@+id/printer_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:checkedButton="@id/print_paper_size_58"
android:orientation="horizontal">
<RadioButton
android:id="@+id/print_paper_size_58"
<ImageView
android:id="@+id/iv_device_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="58mm"
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" />
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_black_next_arrow" />
<RadioButton
android:id="@+id/print_paper_size_88"
<TextView
android:id="@+id/print_device_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:text="80mm"
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" />
</RadioGroup>
</LinearLayout>
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginRight="@dimen/dp_7"
android:layout_toLeftOf="@id/iv_device_arrow"
android:layout_toRightOf="@id/tv_device_model_text"
android:gravity="right"
android:text="請選擇"
android:textColor="@color/color_c9"
android:textSize="@dimen/dp_16" />
</RelativeLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
......@@ -256,7 +255,7 @@
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
<RelativeLayout
android:id="@+id/layout_select_fail_one"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
......@@ -264,32 +263,43 @@
android:orientation="horizontal">
<TextView
android:id="@+id/tv_fail_one_text"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="1"
android:text="打印失敗由此打印" />
<ImageView
android:id="@+id/iv_fail_one_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_black_next_arrow" />
<TextView
android:id="@+id/tv_print_fail_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginRight="@dimen/dp_7"
android:layout_toLeftOf="@id/iv_fail_one_arrow"
android:layout_toRightOf="@id/tv_fail_one_text"
android:gravity="right"
android:text="請選擇"
android:textColor="@color/color_c9"
android:textSize="@dimen/dp_16"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_black_next_arrow" />
</LinearLayout>
</RelativeLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
<RelativeLayout
android:id="@+id/layout_select_fail_two"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
......@@ -297,28 +307,39 @@
android:orientation="horizontal">
<TextView
android:id="@+id/tv_fail_two_text"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerVertical="true"
android:text="打印失敗由此打印" />
<ImageView
android:id="@+id/iv_fail_two_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_black_next_arrow" />
<TextView
android:id="@+id/tv_print_fail_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginRight="@dimen/dp_7"
android:layout_toLeftOf="@id/iv_fail_two_arrow"
android:layout_toRightOf="@id/tv_fail_two_text"
android:gravity="right"
android:text="請選擇"
android:textColor="@color/color_c9"
android:textSize="@dimen/dp_16"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_black_next_arrow" />
</LinearLayout>
</RelativeLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
......@@ -327,7 +348,7 @@
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/printer_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
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