Commit 2229211e by 宁斌

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	print-module/src/main/java/com/joe/print/mvp/ui/fragment/IpPrintListActivityFragment.java
parents 082ce5f0 43817993
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.billy.android.android_internal" /> package="com.billy.android.android_internal">
<meta-data
android:name="design_width_in_dp"
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="640" />
</manifest>
...@@ -106,13 +106,13 @@ dependencies { ...@@ -106,13 +106,13 @@ dependencies {
exclude module: 'okhttp' exclude module: 'okhttp'
exclude module: 'okio' exclude module: 'okio'
} }
implementation(rootProject.ext.dependencies["retrofit-converter-gson"]) { api(rootProject.ext.dependencies["retrofit-converter-gson"]) {
exclude module: 'gson' exclude module: 'gson'
exclude module: 'okhttp' exclude module: 'okhttp'
exclude module: 'okio' exclude module: 'okio'
exclude module: 'retrofit' exclude module: 'retrofit'
} }
implementation(rootProject.ext.dependencies["retrofit-adapter-rxjava2"]) { api(rootProject.ext.dependencies["retrofit-adapter-rxjava2"]) {
exclude module: 'rxjava' exclude module: 'rxjava'
exclude module: 'okhttp' exclude module: 'okhttp'
exclude module: 'retrofit' exclude module: 'retrofit'
......
...@@ -63,7 +63,7 @@ dependencies { ...@@ -63,7 +63,7 @@ dependencies {
implementation files('libs/sun.misc.BASE64Decoder.jar') implementation files('libs/sun.misc.BASE64Decoder.jar')
api files('libs/nexgon5lib.jar') api files('libs/nexgon5lib.jar')
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03' api 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] releaseImplementation rootProject.ext.dependencies["canary-release"]
......
...@@ -4,9 +4,9 @@ import android.app.Dialog; ...@@ -4,9 +4,9 @@ import android.app.Dialog;
import android.view.View; import android.view.View;
import com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils; import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
...@@ -48,11 +48,11 @@ public class SwitchPrintAspect { ...@@ -48,11 +48,11 @@ public class SwitchPrintAspect {
@Override @Override
public void initLayout(ViewHepler hepler, Dialog dialog) { public void initLayout(ViewHepler hepler, Dialog dialog) {
hepler.setViewClick(R.id.local_print, v -> { hepler.setViewClick(R.id.local_print, v -> {
SPUtils.put(dialog.getContext(), Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT); SPUtils.put(dialog.getContext(), PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT);
dialog.dismiss(); dialog.dismiss();
}); });
hepler.setViewClick(R.id.internet_print, v -> { hepler.setViewClick(R.id.internet_print, v -> {
SPUtils.put(dialog.getContext(), Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT); SPUtils.put(dialog.getContext(), PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
dialog.dismiss(); dialog.dismiss();
}); });
} }
......
...@@ -20,8 +20,8 @@ import com.gingersoft.gsa.cloud.base.BuildConfig; ...@@ -20,8 +20,8 @@ import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.function.FunctionStyleUtils; import com.gingersoft.gsa.cloud.function.FunctionStyleUtils;
import com.gingersoft.gsa.cloud.base.utils.AidlUtil; import com.gingersoft.gsa.cloud.base.utils.AidlUtil;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.constans.HttpsConstans; import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.constans.UserConstans; import com.gingersoft.gsa.cloud.constans.UserConstans;
import com.gingersoft.gsa.cloud.base.utils.crash.AppCrashHandler; import com.gingersoft.gsa.cloud.base.utils.crash.AppCrashHandler;
import com.gingersoft.gsa.cloud.base.utils.file.FileUtils; import com.gingersoft.gsa.cloud.base.utils.file.FileUtils;
...@@ -166,6 +166,8 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -166,6 +166,8 @@ public class GsaCloudApplication extends BaseApplication {
RetrofitUrlManager.getInstance().putDomain("wechat_report", HttpsConstans.WECHAR_REPORT_SERVER_ADDRESS); RetrofitUrlManager.getInstance().putDomain("wechat_report", HttpsConstans.WECHAR_REPORT_SERVER_ADDRESS);
//沽清控制請求地址 //沽清控制請求地址
RetrofitUrlManager.getInstance().putDomain("soldoutctrl", HttpsConstans._SERVER_ADDRESS); RetrofitUrlManager.getInstance().putDomain("soldoutctrl", HttpsConstans._SERVER_ADDRESS);
//友常本地請求地址
RetrofitUrlManager.getInstance().putDomain("yc_location", HttpsConstans.ROOT_SERVER_YOU_CHANG_HK);
} }
private void initPrint() { private void initPrint() {
...@@ -181,7 +183,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -181,7 +183,7 @@ public class GsaCloudApplication extends BaseApplication {
} }
} else { } else {
//如果當前機型不是上面兩種,那麼設置默認打印為ip打印 //如果當前機型不是上面兩種,那麼設置默認打印為ip打印
SPUtils.put(this, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT); SPUtils.put(this, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
} }
} }
...@@ -216,7 +218,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -216,7 +218,7 @@ public class GsaCloudApplication extends BaseApplication {
} }
private void initAutoSize(){ private void initAutoSize() {
//当 App 中出现多进程, 并且您需要适配所有的进程, 就需要在 App 初始化时调用 initCompatMultiProcess() //当 App 中出现多进程, 并且您需要适配所有的进程, 就需要在 App 初始化时调用 initCompatMultiProcess()
//在 Demo 中跳转的三方库中的 DefaultErrorActivity 就是在另外一个进程中, 所以要想适配这个 Activity 就需要调用 initCompatMultiProcess() //在 Demo 中跳转的三方库中的 DefaultErrorActivity 就是在另外一个进程中, 所以要想适配这个 Activity 就需要调用 initCompatMultiProcess()
AutoSize.initCompatMultiProcess(this); AutoSize.initCompatMultiProcess(this);
......
...@@ -3,7 +3,6 @@ package com.gingersoft.gsa.cloud.base.utils; ...@@ -3,7 +3,6 @@ package com.gingersoft.gsa.cloud.base.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.List; import java.util.List;
/** /**
......
package com.gingersoft.gsa.cloud.base.utils.okhttpUtils; package com.gingersoft.gsa.cloud.base.utils.okhttpUtils;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.constans.AppConstans; import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
...@@ -10,6 +12,7 @@ import java.io.IOException; ...@@ -10,6 +12,7 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.ObservableEmitter; import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe; import io.reactivex.ObservableOnSubscribe;
...@@ -139,7 +142,7 @@ public class OkHttp3Utils { ...@@ -139,7 +142,7 @@ public class OkHttp3Utils {
//遍历paths中所有图片绝对路径到builder,并约定key如“upload”作为后台接受多张图片的key //遍历paths中所有图片绝对路径到builder,并约定key如“upload”作为后台接受多张图片的key
if (files != null) { if (files != null) {
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
multipartBodyBuilder.addFormDataPart(file_key , files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i))); multipartBodyBuilder.addFormDataPart(file_key, files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i)));
} }
} }
//构建请求体 //构建请求体
...@@ -233,29 +236,31 @@ public class OkHttp3Utils { ...@@ -233,29 +236,31 @@ public class OkHttp3Utils {
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
Request request2 = chain.request(); Request request = chain.request();
Headers headers = request.headers();
String token = ""; Headers.Builder builder = new Headers.Builder();
if (GsaCloudApplication.isLogin) { for (int i = 0; i < headers.size(); i++) {
int memberId = GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext()); builder.set(headers.name(i), headers.value(i));
String loginToken = GsaCloudApplication.getLoginToken(GsaCloudApplication.getAppContext());
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
token = token.replaceAll("\r|\n", "");
} }
Headers.Builder builder = new Headers.Builder();
builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);//set表示name1是唯一的,会覆盖掉已经存在的,add不会覆盖已经存在的头,可以存在多个 builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);//set表示name1是唯一的,会覆盖掉已经存在的,add不会覆盖已经存在的头,可以存在多个
builder.set("mobielModel", android.os.Build.MODEL); builder.set("mobielModel", android.os.Build.MODEL);
builder.set("apptype", AppConstans.APP_TYPE); builder.set("apptype", AppConstans.APP_TYPE);
builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext())); builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext()));
builder.set("mobileId", "1"); builder.set("mobileId", "1");
if (GsaCloudApplication.isLogin)
builder.set("token", token);
builder.set("Domain-Name", "common");
request2.newBuilder().headers(builder.build()).build();
return chain.proceed(request2); if (GsaCloudApplication.isLogin) {
String token;
int memberId = GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext());
String loginToken = GsaCloudApplication.getLoginToken(GsaCloudApplication.getAppContext());
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
token = token.replaceAll("\r|\n", "");
builder.set("token", token);
Log.e("eee", "TOKEN:" + token);
}
Request request1 = chain.request().newBuilder().headers(builder.build()).build();
return chain.proceed(request1);
} }
} }
......
...@@ -387,6 +387,22 @@ public class TimeUtils { ...@@ -387,6 +387,22 @@ public class TimeUtils {
} }
/** /**
* 描述:获取表示当前日期时间的字符串.
*
* @return String String类型的当前日期时间
*/
public static String getCurrentDate(SimpleDateFormat format) {
String curDateTime = null;
try {
Calendar c = new GregorianCalendar();
curDateTime = format.format(c.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return curDateTime;
}
/**
* 区分白天还是夜晚 * 区分白天还是夜晚
* *
* @param time * @param time
......
package com.gingersoft.gsa.cloud.constans;
/**
* Created by Wyh on 2019/12/21.
*/
public class Constans {
//默認打印方式
public final static String DEFAULT_PRINT_METHOD = "default_print";
public final static String LOCAL_PRINT = "local_print";
public final static String IP_PRINT = "ip_print";
public final static String SETTLEMENT_REPORT = "settlement_report";
}
...@@ -7,4 +7,24 @@ public class PrintConstans { ...@@ -7,4 +7,24 @@ public class PrintConstans {
public static final String DEFAULT_PRINT_PAPER = "default_print_paper"; public static final String DEFAULT_PRINT_PAPER = "default_print_paper";
public static final int SO_TIMEOUT = 10000;//讀取/輸入io流數據超時的時間 public static final int SO_TIMEOUT = 10000;//讀取/輸入io流數據超時的時間
public static final int PRINT_TIMEOUT = 5000;//打印機連接超時時間 public static final int PRINT_TIMEOUT = 5000;//打印機連接超時時間
//默認打印方式
public final static String DEFAULT_PRINT_METHOD = "default_print";
public final static String LOCAL_PRINT = "local_print";
public final static String IP_PRINT = "ip_print";
public final static String SETTLEMENT_REPORT = "settlement_report";
/**
* 0:上菜紙
* 1:印單
* 2:結賬單
* 3:廚房單
* 4:打印view
*/
public static final String PRINT_TYPE = "type";//打印類型
public static final String PRINT_LOADING = "is_show_loading";//是否顯示加載框
} }
...@@ -28,6 +28,15 @@ public class PrinterDeviceBean implements Serializable { ...@@ -28,6 +28,15 @@ public class PrinterDeviceBean implements Serializable {
private int type;//打印機紙張類型 為1時是58mm,否則是88mm private int type;//打印機紙張類型 為1時是58mm,否則是88mm
private Integer status;//2為默認打印機,1為普通打印機 private Integer status;//2為默認打印機,1為普通打印機
/**
* 飛單1打印機id
*/
private Long printerDeviceId;
/**
* 飛單2 打印機id
*/
private Long defaultPrinterDeviceId;
@Generated(hash = 626885316) @Generated(hash = 626885316)
public PrinterDeviceBean() { public PrinterDeviceBean() {
} }
...@@ -50,9 +59,9 @@ public class PrinterDeviceBean implements Serializable { ...@@ -50,9 +59,9 @@ public class PrinterDeviceBean implements Serializable {
this.type = type; this.type = type;
} }
@Generated(hash = 422399868) @Generated(hash = 1104327416)
public PrinterDeviceBean(int id, Long dbid, String name, Integer restaurantId, String ip, Integer port, public PrinterDeviceBean(int id, Long dbid, String name, Integer restaurantId, String ip, Integer port,
int type, Integer status) { int type, Integer status, Long printerDeviceId, Long defaultPrinterDeviceId) {
this.id = id; this.id = id;
this.dbid = dbid; this.dbid = dbid;
this.name = name; this.name = name;
...@@ -61,6 +70,8 @@ public class PrinterDeviceBean implements Serializable { ...@@ -61,6 +70,8 @@ public class PrinterDeviceBean implements Serializable {
this.port = port; this.port = port;
this.type = type; this.type = type;
this.status = status; this.status = status;
this.printerDeviceId = printerDeviceId;
this.defaultPrinterDeviceId = defaultPrinterDeviceId;
} }
public String getName() { public String getName() {
...@@ -126,4 +137,20 @@ public class PrinterDeviceBean implements Serializable { ...@@ -126,4 +137,20 @@ public class PrinterDeviceBean implements Serializable {
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public Long getPrinterDeviceId() {
return this.printerDeviceId;
}
public void setPrinterDeviceId(Long printerDeviceId) {
this.printerDeviceId = printerDeviceId;
}
public Long getDefaultPrinterDeviceId() {
return this.defaultPrinterDeviceId;
}
public void setDefaultPrinterDeviceId(Long defaultPrinterDeviceId) {
this.defaultPrinterDeviceId = defaultPrinterDeviceId;
}
} }
...@@ -32,6 +32,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -32,6 +32,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
public final static Property Port = new Property(5, Integer.class, "port", false, "PORT"); 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 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 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");
} }
...@@ -54,7 +56,9 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -54,7 +56,9 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
"\"IP\" TEXT," + // 4: ip "\"IP\" TEXT," + // 4: ip
"\"PORT\" INTEGER," + // 5: port "\"PORT\" INTEGER," + // 5: port
"\"TYPE\" INTEGER NOT NULL ," + // 6: type "\"TYPE\" INTEGER NOT NULL ," + // 6: type
"\"STATUS\" INTEGER);"); // 7: status "\"STATUS\" INTEGER," + // 7: status
"\"PRINTER_DEVICE_ID\" INTEGER," + // 8: printerDeviceId
"\"DEFAULT_PRINTER_DEVICE_ID\" INTEGER);"); // 9: defaultPrinterDeviceId
} }
/** Drops the underlying database table. */ /** Drops the underlying database table. */
...@@ -98,6 +102,16 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -98,6 +102,16 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (status != null) { if (status != null) {
stmt.bindLong(8, status); stmt.bindLong(8, status);
} }
Long printerDeviceId = entity.getPrinterDeviceId();
if (printerDeviceId != null) {
stmt.bindLong(9, printerDeviceId);
}
Long defaultPrinterDeviceId = entity.getDefaultPrinterDeviceId();
if (defaultPrinterDeviceId != null) {
stmt.bindLong(10, defaultPrinterDeviceId);
}
} }
@Override @Override
...@@ -135,6 +149,16 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -135,6 +149,16 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (status != null) { if (status != null) {
stmt.bindLong(8, status); stmt.bindLong(8, status);
} }
Long printerDeviceId = entity.getPrinterDeviceId();
if (printerDeviceId != null) {
stmt.bindLong(9, printerDeviceId);
}
Long defaultPrinterDeviceId = entity.getDefaultPrinterDeviceId();
if (defaultPrinterDeviceId != null) {
stmt.bindLong(10, defaultPrinterDeviceId);
}
} }
@Override @Override
...@@ -152,7 +176,9 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -152,7 +176,9 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // ip cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // ip
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // port cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // port
cursor.getInt(offset + 6), // type cursor.getInt(offset + 6), // type
cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7) // status 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
); );
return entity; return entity;
} }
...@@ -167,6 +193,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -167,6 +193,8 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
entity.setPort(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5)); entity.setPort(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setType(cursor.getInt(offset + 6)); entity.setType(cursor.getInt(offset + 6));
entity.setStatus(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7)); 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));
} }
@Override @Override
......
package com.gingersoft.gsa.cloud.globalconfig.applyOptions; package com.gingersoft.gsa.cloud.globalconfig.applyOptions;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.constans.AppConstans; import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
...@@ -27,7 +29,6 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler { ...@@ -27,7 +29,6 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler {
// 统一处理http请求。eg:给request统一添加token或者header以及参数加密等操作 // 统一处理http请求。eg:给request统一添加token或者header以及参数加密等操作
String requestBody = request.toString(); String requestBody = request.toString();
e(requestBody); e(requestBody);
String url = chain.request().url().url().toString();
String token = ""; String token = "";
if (GsaCloudApplication.isLogin) { if (GsaCloudApplication.isLogin) {
...@@ -43,15 +44,15 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler { ...@@ -43,15 +44,15 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler {
builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext())); builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext()));
builder.set("mobileId", "1"); builder.set("mobileId", "1");
Headers headers = request.headers(); Headers headers = request.headers();
if (headers != null) { for (int i = 0; i < headers.size(); i++) {
for (int i = 0; i < headers.size(); i++) { builder.set(headers.name(i), headers.value(i));
builder.set(headers.name(i), headers.value(i));
}
} }
if (GsaCloudApplication.isLogin) if (GsaCloudApplication.isLogin)
builder.set("token", token); builder.set("token", token);
// builder.set("Domain-Name", "common");
Log.e("eee", token + "統一請求onHttpRequestBefore" + chain.request().url());
// builder.set("Domain-Name", "common");
return chain.request().newBuilder() return chain.request().newBuilder()
.headers(builder.build()) .headers(builder.build())
.build(); .build();
......
...@@ -21,12 +21,10 @@ import android.content.Context; ...@@ -21,12 +21,10 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.widget.Adapter;
import com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils; import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
...@@ -470,7 +468,7 @@ public class PrinterUtils { ...@@ -470,7 +468,7 @@ public class PrinterUtils {
function.setLable("本機"); function.setLable("本機");
orderTopFunctionAdapter.notifyDataSetChanged(); orderTopFunctionAdapter.notifyDataSetChanged();
} }
SPUtils.put(dialog.getContext(), Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT); SPUtils.put(dialog.getContext(), PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT);
dialog.dismiss(); dialog.dismiss();
}); });
hepler.setViewClick(R.id.internet_print, v -> { hepler.setViewClick(R.id.internet_print, v -> {
...@@ -479,7 +477,7 @@ public class PrinterUtils { ...@@ -479,7 +477,7 @@ public class PrinterUtils {
function.setLable("網絡"); function.setLable("網絡");
orderTopFunctionAdapter.notifyDataSetChanged(); orderTopFunctionAdapter.notifyDataSetChanged();
} }
SPUtils.put(dialog.getContext(), Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT); SPUtils.put(dialog.getContext(), PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
dialog.dismiss(); dialog.dismiss();
}); });
} }
......
...@@ -68,6 +68,7 @@ class OrderDetails { ...@@ -68,6 +68,7 @@ class OrderDetails {
//後台不會返回 //後台不會返回
var order_type: Int = 0 var order_type: Int = 0
var orderPayType: Int = 0 var orderPayType: Int = 0
var isDelete: Int = 1 //默認為1,為1時是本店配送,為0是第三方物流
var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null var PRODUCT_NAME: List<PRODUCTNAMEBean>? = null
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_track_on" android:state_checked="true" />
<item android:drawable="@drawable/shape_track_off" android:state_checked="false" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<stroke
android:width="@dimen/dp_2"
android:color="@color/order_state0_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="@dimen/dp_19"
android:height="@dimen/dp_19" />
<stroke
android:width="3dp"
android:color="#00000000" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/color_aaa" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/theme_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_select_print"
android:layout_width="match_parent"
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"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_8">
<TextView
android:id="@+id/tv_item_print_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_25"
android:text="K1"
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" />
<RadioButton
android:id="@+id/rb_item_print"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_24"
android:layout_gravity="center_vertical"
android:gravity="center"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:padding="@dimen/dp_5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_8"
android:background="@color/grey_200"
app:layout_constraintTop_toBottomOf="@id/rb_item_print" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_nodata"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/png_no_record" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:text="暫無數據"
android:textColor="@color/color_66"
android:textSize="@dimen/dp_16" />
</LinearLayout>
...@@ -23,4 +23,6 @@ ...@@ -23,4 +23,6 @@
android:textColor="@color/theme_white_color" android:textColor="@color/theme_white_color"
android:textSize="@dimen/load_dialog_text_size" /> android:textSize="@dimen/load_dialog_text_size" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -458,6 +458,8 @@ ...@@ -458,6 +458,8 @@
<color name="color_86">#868686</color> <color name="color_86">#868686</color>
<color name="color_ef">#efefef</color> <color name="color_ef">#efefef</color>
<color name="color_50">#505050</color> <color name="color_50">#505050</color>
<color name="color_c9">#C9C9C9</color>
<color name="color_aaa">#AAA</color>
<color name="tran_fifty_order_state0_color">#7F009788</color> <color name="tran_fifty_order_state0_color">#7F009788</color>
<!-- 待確認背景色--> <!-- 待確認背景色-->
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<item name="shadow_bottom">@drawable/shadow_bottom</item> <item name="shadow_bottom">@drawable/shadow_bottom</item>
</style> </style>
<style name="PhotoDialog" parent="@android:style/Theme.Light"> <style name="PhotoDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--边框--> <item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上--> <item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
<item name="android:windowNoTitle">true</item><!--无标题--> <item name="android:windowNoTitle">true</item><!--无标题-->
......
...@@ -10,7 +10,7 @@ buildscript { ...@@ -10,7 +10,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.2' classpath 'com.android.tools.build:gradle:3.5.3'
// classpath 'com.android.tools.build:gradle:3.0.1' // classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
...@@ -25,7 +25,8 @@ buildscript { ...@@ -25,7 +25,8 @@ buildscript {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8' // classpath 'org.aspectj:aspectjtools:1.8.13' // add
// classpath 'org.aspectj:aspectjrt:1.8.13' // add
classpath fileTree(dir: 'plugins', include: ['*.jar']) classpath fileTree(dir: 'plugins', include: ['*.jar'])
} }
} }
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.billy.cc.core.component"> package="com.billy.cc.core.component">
<application > <application>
<provider <provider
android:authorities="${applicationId}.com.billy.cc.core.remote"
android:name=".remote.RemoteProvider" android:name=".remote.RemoteProvider"
android:exported="true" android:authorities="${applicationId}.com.billy.cc.core.remote"
/> android:exported="true" />
<activity android:name=".remote.RemoteConnectionActivity" <activity
android:taskAffinity="com.billy.cc.connection" android:name=".remote.RemoteConnectionActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:exported="true" android:exported="true"
> android:taskAffinity="com.billy.cc.connection"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter> <intent-filter>
<action android:name="action.com.billy.cc.connection" /> <action android:name="action.com.billy.cc.connection" />
</intent-filter> </intent-filter>
</activity> </activity>
<meta-data
android:name="design_width_in_dp"
android:value="360" />
<meta-data
android:name="design_height_in_dp"
android:value="640" />
</application> </application>
</manifest> </manifest>
...@@ -86,6 +86,5 @@ dependencies { ...@@ -86,6 +86,5 @@ dependencies {
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03' implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
implementation rootProject.ext.dependencies["autosize"] implementation rootProject.ext.dependencies["autosize"]
implementation rootProject.ext.dependencies["fastjson"]
} }
...@@ -5,11 +5,12 @@ import android.content.Intent; ...@@ -5,11 +5,12 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSON; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.login.R; import com.gingersoft.gsa.cloud.login.R;
import com.gingersoft.gsa.cloud.login.mvp.bean.TestLoginBean; import com.gingersoft.gsa.cloud.login.mvp.bean.TestLoginBean;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.google.gson.Gson;
import java.io.IOException; import java.io.IOException;
...@@ -35,7 +36,7 @@ public class LoginOutActivity extends Activity { ...@@ -35,7 +36,7 @@ public class LoginOutActivity extends Activity {
TextView tv_json = findViewById(R.id.tv_json); TextView tv_json = findViewById(R.id.tv_json);
String json = getIntent().getStringExtra("json"); String json = getIntent().getStringExtra("json");
loginBean = JSON.parseObject(json, TestLoginBean.class); loginBean = JsonUtils.parseObject(json, TestLoginBean.class);
tv_json.setText(json); tv_json.setText(json);
findViewById(R.id.tv_gsa_user_loginout).setOnClickListener(v -> { findViewById(R.id.tv_gsa_user_loginout).setOnClickListener(v -> {
......
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
android:text="找回密碼" android:text="找回密碼"
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16" android:textSize="@dimen/dp_16"
android:visibility="visible" android:visibility="gone"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="@id/rb_auto_login" app:layout_constraintBottom_toBottomOf="@id/rb_auto_login"
app:layout_constraintTop_toBottomOf="@id/rb_auto_login" app:layout_constraintTop_toBottomOf="@id/rb_auto_login"
......
package com.gingersoft.gsa.cloud.main.mvp.ui.activity; package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
...@@ -22,6 +25,7 @@ import com.billy.cc.core.component.CC; ...@@ -22,6 +25,7 @@ import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils; import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
...@@ -166,6 +170,10 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -166,6 +170,10 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
private void initSideMenu() { private void initSideMenu() {
mRvSideMenu.setLayoutManager(new LinearLayoutManager(mContext)); mRvSideMenu.setLayoutManager(new LinearLayoutManager(mContext));
List<MainSideMenuBean> mainSideMenuBeans = new ArrayList<>(); List<MainSideMenuBean> mainSideMenuBeans = new ArrayList<>();
if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
}
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_mall_center, "商城中心"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_about_us, "關於我們"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_password, "修改密碼"));
...@@ -186,6 +194,18 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -186,6 +194,18 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
.call(); .call();
finish(); finish();
break; break;
case "複製Token":
String token;
int memberId = GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext());
String loginToken = GsaCloudApplication.getLoginToken(GsaCloudApplication.getAppContext());
token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
token = token.replaceAll("\r|\n", "");
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData label = ClipData.newPlainText("Label", token);
cm.setPrimaryClip(label);
ToastUtils.show(mContext, "已複製");
break;
case "清機": case "清機":
launchActivity(new Intent(mContext, SettlementActivity.class)); launchActivity(new Intent(mContext, SettlementActivity.class));
break; break;
...@@ -215,14 +235,13 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -215,14 +235,13 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.Function.class, ComponentMain.Function.manager,"manager")); // functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.Function.class, ComponentMain.Function.manager,"manager"));
functions.add(new Function((long) 151, 0, 5, "管理", 0, 0)); functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
// functions.add(new Function((long) 142, 151, 5, "餐牌管理", R.drawable.ic_meals_menu_management)); // functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "外賣接單", R.drawable.ic_takeaway_orders, 0)); functions.add(new Function((long) 142, 151, 5, "外賣接單", R.drawable.ic_takeaway_orders, 0));
functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 0)); // functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 0));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0)); functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1)); // functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1)); // functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1));
functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0)); // functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
// functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.Function.class, ComponentMain.Function.employee,"employee")); // functions.addAll(FunctionManager.getDefault().getFunctionByResModule(this, ComponentMain.Function.class, ComponentMain.Function.employee,"employee"));
functions.add(new Function((long) 152, 0, 5, "員工", 0, 0)); functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
......
...@@ -22,10 +22,10 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils; ...@@ -22,10 +22,10 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils; import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.PrintTransitUtils; import com.gingersoft.gsa.cloud.base.utils.PrintTransitUtils;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.main.R; import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2; import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerSettlementReportComponent; import com.gingersoft.gsa.cloud.main.di.component.DaggerSettlementReportComponent;
...@@ -142,7 +142,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese ...@@ -142,7 +142,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese
Button rightBtn = mTopBar.addRightTextButton("打印", R.id.tv_right); Button rightBtn = mTopBar.addRightTextButton("打印", R.id.tv_right);
rightBtn.setTextColor(ArmsUtils.getColor(this, R.color.theme_white_color)); rightBtn.setTextColor(ArmsUtils.getColor(this, R.color.theme_white_color));
rightBtn.setOnClickListener(v -> { rightBtn.setOnClickListener(v -> {
String settlementReportJson = (String) SPUtils.get(mContext, Constans.SETTLEMENT_REPORT, ""); String settlementReportJson = (String) SPUtils.get(mContext, PrintConstans.SETTLEMENT_REPORT, "");
if (!TextUtils.isEmpty(settlementReportJson)) { if (!TextUtils.isEmpty(settlementReportJson)) {
SettlementReport.DataBean datasBean = JsonUtils.parseObject(settlementReportJson, SettlementReport.DataBean.class); SettlementReport.DataBean datasBean = JsonUtils.parseObject(settlementReportJson, SettlementReport.DataBean.class);
if(datasBean != null){ if(datasBean != null){
...@@ -238,7 +238,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese ...@@ -238,7 +238,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese
public void returnSettlementData(SettlementReport.DataBean datasBean) { public void returnSettlementData(SettlementReport.DataBean datasBean) {
if (datasBean.getVo() != null && datasBean.getVo().getPrices() > 0) { if (datasBean.getVo() != null && datasBean.getVo().getPrices() > 0) {
//保存下次重印數據 //保存下次重印數據
SPUtils.put(mContext, Constans.SETTLEMENT_REPORT, JsonUtils.toJson(datasBean)); SPUtils.put(mContext, PrintConstans.SETTLEMENT_REPORT, JsonUtils.toJson(datasBean));
} }
List<SectionTextItem3> settlementReportItems = new ArrayList<>(); List<SectionTextItem3> settlementReportItems = new ArrayList<>();
...@@ -427,7 +427,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese ...@@ -427,7 +427,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese
//清機成功,打印 //清機成功,打印
PrintTransitUtils.getInstance().setPrintView(view); PrintTransitUtils.getInstance().setPrintView(view);
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.addParam("type", 4)//清機打印 .addParam(PrintConstans.PRINT_TYPE, 4)//清機打印
.setActionName("printActivity") .setActionName("printActivity")
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
......
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_20" android:layout_marginTop="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20"
android:layout_weight="1" /> android:layout_weight="1"
android:visibility="invisible" />
<LinearLayout <LinearLayout
android:id="@+id/layout_login_out" android:id="@+id/layout_login_out"
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
android:layout_width="@dimen/dp_24" android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_26" android:layout_height="@dimen/dp_26"
android:src="@drawable/ic_msg" android:src="@drawable/ic_msg"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
...@@ -146,6 +148,7 @@ ...@@ -146,6 +148,7 @@
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:paddingBottom="@dimen/dp_10"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<fragment <fragment
...@@ -159,7 +162,7 @@ ...@@ -159,7 +162,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/layout_ordering_meals" android:layout_below="@id/layout_ordering_meals"
android:layout_marginLeft="@dimen/dp_13" android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="-4dp" android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_13" android:layout_marginRight="@dimen/dp_13"
app:hl_cornerRadius="@dimen/dp_4" app:hl_cornerRadius="@dimen/dp_4"
app:hl_shadowBackColor="@color/white" app:hl_shadowBackColor="@color/white"
...@@ -199,6 +202,7 @@ ...@@ -199,6 +202,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15" android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_20" android:layout_marginTop="@dimen/dp_20"
android:visibility="gone"
android:textColor="#181818" android:textColor="#181818"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
...@@ -206,12 +210,13 @@ ...@@ -206,12 +210,13 @@
android:id="@+id/rv_staff_management" android:id="@+id/rv_staff_management"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:visibility="gone"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft" android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" /> android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout> </LinearLayout>
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
<!-- 點餐模塊-->
<com.lihang.ShadowLayout <com.lihang.ShadowLayout
android:id="@+id/layout_ordering_meals" android:id="@+id/layout_ordering_meals"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -221,6 +226,7 @@ ...@@ -221,6 +226,7 @@
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4" app:hl_cornerRadius="@dimen/dp_4"
app:hl_dy="@dimen/main_shadow_dy" app:hl_dy="@dimen/main_shadow_dy"
android:visibility="gone"
app:hl_shadowBackColor="@color/white" app:hl_shadowBackColor="@color/white"
app:hl_shadowColor="@color/shadow_color" app:hl_shadowColor="@color/shadow_color"
app:hl_shadowLimit="@dimen/main_shadow_limit"> app:hl_shadowLimit="@dimen/main_shadow_limit">
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
package="com.gingersoft.gsa.cloud.manager"> package="com.gingersoft.gsa.cloud.manager">
<application> <application>
<activity android:name=".mvp.ui.activity.TableManageActivity"></activity> <activity android:name=".mvp.ui.activity.TableManageActivity"/>
<!-- arms配置 --> <!-- arms配置 -->
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
......
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"2020-05-15_GSA-Cloud_1.0_debug_.apk","fullName":"debug","baseName":"debug"},"path":"2020-05-15_GSA-Cloud_1.0_debug_.apk","properties":{}}]
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
package="com.gingersoft.gsa.other_order_mode"> package="com.gingersoft.gsa.other_order_mode">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application> <application>
<activity <activity
android:name=".ui.activity.OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
......
...@@ -23,6 +23,13 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw ...@@ -23,6 +23,13 @@ class WeatherRepository private constructor(private val network: CoolWeatherNetw
heWeather heWeather
} }
suspend fun getOrderGroup(restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restId", restaurantId)
.build()
network.getOrderGroupNum(requestBody)
}
suspend fun updateRestOpenStatus(state: Boolean, restaurantId: String) = withContext(Dispatchers.IO) { suspend fun updateRestOpenStatus(state: Boolean, restaurantId: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder() val requestBody = FormBody.Builder()
.add("restId", restaurantId) .add("restId", restaurantId)
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
data class OrderGoupNumBean(
val `data`: Data,
val success: Boolean,
val sysTime: Long) {
data class Data(
val self: List<SelfTakeaway>,
val selfTakeaway: List<SelfTakeaway>,
val takeaway: List<SelfTakeaway>) {
data class SelfTakeaway(
val STATUS: Int,
val SumNum: Int
)
}
}
\ No newline at end of file
...@@ -64,7 +64,7 @@ class OrderList { ...@@ -64,7 +64,7 @@ class OrderList {
var deliveryMode: String? = null var deliveryMode: String? = null
var trkNo: String? = null var trkNo: String? = null
var isDelete: Int = 0 var isDelete: Int = 0
var STATUS: Int = 0//0,1為待確認,2為製作中,3待取餐或送貨中 var STATUS: Int = 0//0貨到付款的待確認,1為在線支付的待確認,2為製作中,3待取餐或送貨中
var MEMBER_NAME: String? = null var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null var ADDRESS_DETAIL: String? = null
var PAY_AMOUNT: Double = 0.toDouble() var PAY_AMOUNT: Double = 0.toDouble()
......
...@@ -21,6 +21,8 @@ class CoolWeatherNetwork { ...@@ -21,6 +21,8 @@ class CoolWeatherNetwork {
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await() suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
suspend fun getOrderGroupNum(requestBody: RequestBody) = orderService.getOrderGroupNum(requestBody).await()
suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await() suspend fun getOrderInfo(requestBody: RequestBody) = orderService.getOrderDesc(requestBody).await()
suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await() suspend fun updateOrderStatus(requestBody: RequestBody) = orderService.updateOrderStatus(requestBody).await()
......
...@@ -15,6 +15,9 @@ interface WeatherService { ...@@ -15,6 +15,9 @@ interface WeatherService {
@POST("wx/updateRestOpenStatus") @POST("wx/updateRestOpenStatus")
fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean> fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean>
@POST("wechat/findOrderGroup")
fun getOrderGroupNum(@Body requestBody: RequestBody): Call<OrderGoupNumBean>
@POST("wechat/findOrderDetails") @POST("wechat/findOrderDetails")
fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails> fun getOrderDesc(@Body requestBody: RequestBody): Call<OrderDetails>
......
...@@ -29,7 +29,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo ...@@ -29,7 +29,7 @@ class HistoryOrderViewModel(private val historyOrderRepository: HistoryOrderRepo
historyOrderRepository.getHistoryOrderList(GsaCloudApplication.getRestaurantId(context).toString(), "4", pageIndex, "10", orderNumber, phone).apply { historyOrderRepository.getHistoryOrderList(GsaCloudApplication.getRestaurantId(context).toString(), "4", pageIndex, "10", orderNumber, phone).apply {
this.getData()?.let { this.getData()?.let {
if (it.size > 0) { if (it.size > 0) {
it.removeAt(it.size - 1) it.removeAt(it.size - 1)//移除最後一個,最後一個是顯示總條數的
} }
if (pageIndex != "1") { if (pageIndex != "1") {
data.value!!.getData()!!.addAll(it) data.value!!.getData()!!.addAll(it)
......
...@@ -16,6 +16,7 @@ import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication ...@@ -16,6 +16,7 @@ import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.base.widget.DialogUtils 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.print.bean.OrderDetails
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
...@@ -45,6 +46,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -45,6 +46,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
var fragmentType = arrayOf("0", "0", "0", "2", "7") var fragmentType = arrayOf("0", "0", "0", "2", "7")
} }
var mOrderNum = arrayListOf<MutableLiveData<Int>>()
var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>() var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>()
//其他的所有數據 //其他的所有數據
...@@ -61,13 +64,65 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -61,13 +64,65 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
var deliveryConfig: DeliveryConfig? = null var deliveryConfig: DeliveryConfig? = null
/**
* 獲取訂單數量
* status 0,1待確認
* 2 已確認,外賣是指派送單,自取是製作完成
*/
fun getOrderGroupNum(restaurantId: String) {
launch({
repository.getOrderGroup(restaurantId).apply {
//先把所有置0
for(i in mOrderNum){
i.value = 0
}
//遍歷獲得外賣自取的 待確認和製作中的總單數
for (i in data.selfTakeaway) {
when {
i.STATUS == 0 -> //貨到付款的待確認
mOrderNum[1].value = mOrderNum[1].value?.plus(i.SumNum)
i.STATUS == 1 -> //在線支付的待確認
mOrderNum[1].value = mOrderNum[1].value?.plus(i.SumNum)
i.STATUS == 2 -> //製作中
mOrderNum[2].value = i.SumNum
}
}
//狀態為三時,下標為3(送貨中)的值為外賣的數量,下標為4(待取餐)的值為自取的數量
for (i in data.takeaway) {
if (i.STATUS == 3) {
mOrderNum[3].value = i.SumNum
}
}
for (i in data.self) {
if (i.STATUS == 3) {
mOrderNum[4].value = i.SumNum
}
}
//下標為0時是全部,把集合所有值加起來
var num = 0
for (i in mOrderNum) {
//五個模塊
if (i.value != null) {
num += i.value!!
}
}
mOrderNum[0].value = num
}
}, {
})
}
/** /**
* 獲取訂單 * 獲取訂單
*/ */
fun getOrderList(context: Context, position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) { fun getOrderList(context: Context, position: Int, page: String, isLoadMore: Boolean, listener: (Int) -> Unit) {
launch({ launch({
repository.requestOrderList(GsaCloudApplication.getRestaurantId(context).toString(), fragmentStatus[position], fragmentType[position], page, orderNo, phone).apply { val restId = GsaCloudApplication.getRestaurantId(context).toString()
repository.requestOrderList(restId, fragmentStatus[position], fragmentType[position], page, orderNo, phone).apply {
getOrderGroupNum(restId)
loadInfo(listener, isLoadMore, position) loadInfo(listener, isLoadMore, position)
} }
}, { }, {
...@@ -76,8 +131,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -76,8 +131,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}) })
} }
private fun OrderList.loadInfo(listener: (String) -> Unit, isLoadMore: Boolean, position: Int) { private fun OrderList.loadInfo(listener: (Int) -> Unit, isLoadMore: Boolean, position: Int) {
listener.invoke("加載完成")
if (getData() != null && getData()?.data != null) { if (getData() != null && getData()?.data != null) {
val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean> val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean>
if (myData.isNotEmpty()) { if (myData.isNotEmpty()) {
...@@ -88,8 +142,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -88,8 +142,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
if (myData.size == 1) { if (myData.size == 1) {
otherInfo.value = myData[0] otherInfo.value = myData[0]
listener.invoke(0)
} else { } else {
otherInfo.value = myData[myData.size - 1] otherInfo.value = myData[myData.size - 1]
listener.invoke(myData.size - 1)
} }
//移除掉最後一個對象 //移除掉最後一個對象
myData.removeAt(myData.size - 1) myData.removeAt(myData.size - 1)
...@@ -104,8 +160,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -104,8 +160,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
mOrderList[position].value = myData mOrderList[position].value = myData
} }
} else { } else {
listener.invoke(0)
} }
} else {
listener.invoke(0)
} }
} }
...@@ -179,7 +237,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -179,7 +237,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
*/ */
fun updateOrderStatus(context: Context, data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, listener: (Boolean) -> Unit) { fun updateOrderStatus(context: Context, data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, listener: (Boolean) -> Unit) {
launch({ launch({
val status = when (data.STATUS) { val status = when (data.STATUS) {//如果以前的狀態是0,則修改為2。。。。
0 -> 2 0 -> 2
1 -> 2 1 -> 2
2 -> 3 2 -> 3
...@@ -193,13 +251,18 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -193,13 +251,18 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
else -> 2 else -> 2
} }
if (data.order_type == 2) { if (data.order_type == 2) {
// 外賣 // 外賣
if (status == 3) { if (status == 3) {
//指派送貨,選擇派送員 if (orderDetails.data!![0].isDelete == 1) {
if (deliveryBean != null && deliveryBean!!.data.isNotEmpty()) { if (deliveryBean != null && deliveryBean!!.data.isNotEmpty()) {
selectorDelivery(listener, context, data, status, isPush) selectorDelivery(listener, context, data, status, isPush)
} else {
ToastUtils.show(context, "沒有送貨員信息")
}
} else { } else {
ToastUtils.show(context, "沒有送貨員信息") //第三方的單,執行重印功能
printOrder(orderDetails, data, context, listener)
} }
} else if (status == 4) { } else if (status == 4) {
//結賬,彈窗確認是否結賬 //結賬,彈窗確認是否結賬
...@@ -228,12 +291,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -228,12 +291,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
var third = false var third = false
if (deliveryConfig != null) { if (deliveryConfig != null) {
for (i in 0 until deliveryConfig!!.data.list.size) { for (i in 0 until deliveryConfig!!.data.list.size) {
third = deliveryConfig!!.data.list[i].let { if (deliveryConfig!!.data.list[i].distributionType == data.deliveryMode) {
(it.distributionType == data.deliveryMode && deliveryConfig!!.data.list[i].type == 1) third = deliveryConfig!!.data.list[i].type == 1
break
} }
} }
} }
Log.e("eee", "是否是第三方配送:$third")
if (third) { if (third) {
// 如果是第三方物流,調用第三方接口 // 如果是第三方物流,調用第三方接口
thirdSend(data, orderDetails, status, isPush, data.order_type, context, listener) thirdSend(data, orderDetails, status, isPush, data.order_type, context, listener)
...@@ -259,23 +322,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -259,23 +322,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
if (this.success) { if (this.success) {
//打印 //打印
//初始化用於打印的view //初始化用於打印的view
if (orderDetails.data != null) { //送單成功後,再調用接口獲取取餐碼
//訂單信息和廚房單 getOrderInfo(data.Id.toString()){
orderDetails.data!![0].order_type = data.order_type if(it != null){
orderDetails.data!![0].orderPayType = data.orderPayType printOrder(it, data, context, listener)
MyOrderManage.setDataBean(orderDetails.data!![0]) }
CC.obtainBuilder("Component.Print")
.addParam("type", 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
Log.e("error", "是否成功打印:" + result.isSuccess)
MyOrderManage.setDataBean(null)
}
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
} }
listener.invoke(true)
} else { } else {
ToastUtils.show(context, "送單失敗") ToastUtils.show(context, "送單失敗")
} }
...@@ -283,6 +335,29 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -283,6 +335,29 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
private fun printOrder(orderDetails: OrderDetails, data: OrderList.DataBeanX.DataBean, context: Context, listener: (Boolean) -> Unit) {
if (orderDetails.data != null) {
//訂單信息和廚房單
orderDetails.data!![0].order_type = data.order_type
orderDetails.data!![0].orderPayType = data.orderPayType
MyOrderManage.setDataBean(orderDetails.data!![0])
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 5)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread { _, result ->
Log.e("error", "是否成功打印:" + result.isSuccess)
if (!result.isSuccess) {
ToastUtils.show(context, "打印失敗")
}
MyOrderManage.setDataBean(null)
}
} else {
ToastUtils.show(context, "沒有訂單內容,打印失敗")
}
listener.invoke(true)
}
/** /**
* 第三方派送 * 第三方派送
*/ */
......
package com.gingersoft.gsa.other_order_mode.ui.activity package com.gingersoft.gsa.other_order_mode.ui.activity
import android.os.Bundle import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.R2
import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.HistoryOrderViewModel
import com.gingersoft.gsa.other_order_mode.ui.adapter.HistoryOrderAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.HistoryOrderAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.gingersoft.gsa.other_order_mode.util.setState
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import kotlinx.android.synthetic.main.activity_history_order.* import kotlinx.android.synthetic.main.activity_history_order.*
class HistoryOrderActivity : BaseActivity() { class HistoryOrderActivity : BaseActivity() {
...@@ -18,11 +24,19 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -18,11 +24,19 @@ class HistoryOrderActivity : BaseActivity() {
private var mHistoryOrderAdapter: HistoryOrderAdapter? = null private var mHistoryOrderAdapter: HistoryOrderAdapter? = null
private var pageIndex = 1 private var pageIndex = 1
lateinit var refreshLayout: SmartRefreshLayout
lateinit var rvOrderList: RecyclerView
lateinit var layoutNoData: View
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_history_order) setContentView(R.layout.activity_history_order)
refreshLayout = findViewById(R.id.refresh_layout)
rvOrderList = findViewById(R.id.rv_other_order)
layoutNoData = findViewById(R.id.layout_nodata)
initAppTop() initAppTop()
rv_history_order.layoutManager = LinearLayoutManager(this) rvOrderList.layoutManager = LinearLayoutManager(this)
initViewModel() initViewModel()
getHistoryInfo() getHistoryInfo()
initSearch() initSearch()
...@@ -33,12 +47,12 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -33,12 +47,12 @@ class HistoryOrderActivity : BaseActivity() {
showLoading() showLoading()
mViewModel.getHistoryOrderList(this, page.toString(), orderNum) { mViewModel.getHistoryOrderList(this, page.toString(), orderNum) {
cancelDialogForLoading() cancelDialogForLoading()
refresh_layout.setEnableLoadMore(it.getData() != null) refreshLayout.setEnableLoadMore(it.getData() != null)
refresh_layout.finishRefresh() refreshLayout.finishRefresh()
refresh_layout.finishLoadMore() refreshLayout.finishLoadMore()
if (mHistoryOrderAdapter == null) { if (mHistoryOrderAdapter == null) {
mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) } mHistoryOrderAdapter = it.getData()?.let { it1 -> HistoryOrderAdapter(this@HistoryOrderActivity, it1) }
rv_history_order.adapter = mHistoryOrderAdapter rvOrderList.adapter = mHistoryOrderAdapter
mHistoryOrderAdapter!!.setOnItemClickListenter { mHistoryOrderAdapter!!.setOnItemClickListenter {
showLoading() showLoading()
mViewModel.getOrderInfo(it.Id.toString()) { it2 -> mViewModel.getOrderInfo(it.Id.toString()) { it2 ->
...@@ -57,6 +71,7 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -57,6 +71,7 @@ class HistoryOrderActivity : BaseActivity() {
mHistoryOrderAdapter!!.data = it.getData() mHistoryOrderAdapter!!.data = it.getData()
mHistoryOrderAdapter!!.notifyDataSetChanged() mHistoryOrderAdapter!!.notifyDataSetChanged()
} }
layoutNoData.setState(it.getData() == null || it.getData()!!.size <= 0)
} }
} }
...@@ -77,13 +92,13 @@ class HistoryOrderActivity : BaseActivity() { ...@@ -77,13 +92,13 @@ class HistoryOrderActivity : BaseActivity() {
private fun initRefresh() { private fun initRefresh() {
//设置 Header 顏色 //设置 Header 顏色
refresh_layout.setPrimaryColorsId(R.color.color_f0, R.color.color_66) refreshLayout.setPrimaryColorsId(R.color.color_f0, R.color.color_66)
//下拉刷新,加載更多 //下拉刷新,加載更多
refresh_layout.setOnRefreshListener { refreshLayout.setOnRefreshListener {
pageIndex = 1 pageIndex = 1
getHistoryInfo() getHistoryInfo()
} }
refresh_layout.setOnLoadMoreListener { refreshLayout.setOnLoadMoreListener {
pageIndex++ pageIndex++
getHistoryInfo() getHistoryInfo()
} }
......
...@@ -5,19 +5,24 @@ import android.content.ComponentName ...@@ -5,19 +5,24 @@ import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.media.AudioAttributes import android.media.AudioAttributes
import android.media.AudioManager import android.media.AudioManager
import android.media.SoundPool import android.media.SoundPool
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log
import android.view.View import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.core.animation.doOnEnd
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.ui.view.SwitchButton import com.gingersoft.gsa.cloud.ui.view.SwitchButton
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
...@@ -53,6 +58,8 @@ class OtherOrderActivity : BaseActivity() { ...@@ -53,6 +58,8 @@ class OtherOrderActivity : BaseActivity() {
private var titles: ArrayList<TextView> = ArrayList() private var titles: ArrayList<TextView> = ArrayList()
private var layoutHeight: Float = 0F private var layoutHeight: Float = 0F
private var btnHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -72,8 +79,11 @@ class OtherOrderActivity : BaseActivity() { ...@@ -72,8 +79,11 @@ class OtherOrderActivity : BaseActivity() {
//餐廳營業信息 //餐廳營業信息
loadRestaurantInfo(binding) loadRestaurantInfo(binding)
layout_today_order_info.post { cl_order_info.post {
layoutHeight = layout_today_order_info.height.toFloat() layoutHeight = cl_order_info.height.toFloat()
}
btn_open_or_close_info.post {
btnHeight = btn_open_or_close_info.height.toFloat()
} }
pageViewModel.getDeliveryInfo(this) pageViewModel.getDeliveryInfo(this)
pageViewModel.getDeliveryConfigDTO(this) pageViewModel.getDeliveryConfigDTO(this)
...@@ -122,11 +132,11 @@ class OtherOrderActivity : BaseActivity() { ...@@ -122,11 +132,11 @@ class OtherOrderActivity : BaseActivity() {
mNumber.text = "0" mNumber.text = "0"
mNumber.setTextColor(this@OtherOrderActivity.resources.getColor(colors[i])) mNumber.setTextColor(this@OtherOrderActivity.resources.getColor(colors[i]))
while (pageViewModel.mOrderList.size <= i) { while (pageViewModel.mOrderNum.size <= i) {
pageViewModel.mOrderList.add(MutableLiveData()) pageViewModel.mOrderNum.add(MutableLiveData())
} }
pageViewModel.mOrderList[i].observe(instance, Observer { pageViewModel.mOrderNum[i].observe(instance, Observer {
mNumber.text = it.size.toString() mNumber.text = it.toString()
}) })
} }
} }
...@@ -140,7 +150,9 @@ class OtherOrderActivity : BaseActivity() { ...@@ -140,7 +150,9 @@ class OtherOrderActivity : BaseActivity() {
//搜索 //搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) { if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
pageViewModel.phone = ed_order_num_search.text.toString() pageViewModel.phone = ed_order_num_search.text.toString()
pageViewModel.getOrderList(this, viewPager.currentItem, "0", false) {} pageViewModel.getOrderList(this, viewPager.currentItem, "0", false) {
ToastUtils.show(this@OtherOrderActivity, "搜索到$it" + "條數據")
}
} else { } else {
ToastUtils.show(this@OtherOrderActivity, "請輸入手機號或訂單號") ToastUtils.show(this@OtherOrderActivity, "請輸入手機號或訂單號")
} }
...@@ -151,6 +163,9 @@ class OtherOrderActivity : BaseActivity() { ...@@ -151,6 +163,9 @@ class OtherOrderActivity : BaseActivity() {
* 切換餐廳狀態按鈕 * 切換餐廳狀態按鈕
*/ */
private fun initSwitchRestStatus() { private fun initSwitchRestStatus() {
btnOpenBg = resources.getDrawable(R.drawable.shape_white_bottom_border)
btnCloseBg = resources.getDrawable(R.drawable.shape_dialog_bg)
btn_switch_restaurant_state.setOnClickListener { btn_switch_restaurant_state.setOnClickListener {
pageViewModel.setRestaurantState(this, !(it as SwitchButton).statusBasedOnPos) pageViewModel.setRestaurantState(this, !(it as SwitchButton).statusBasedOnPos)
} }
...@@ -168,7 +183,6 @@ class OtherOrderActivity : BaseActivity() { ...@@ -168,7 +183,6 @@ class OtherOrderActivity : BaseActivity() {
//開啟websocket //開啟websocket
val intent = Intent(this, GetInfoUpdateService::class.java) val intent = Intent(this, GetInfoUpdateService::class.java)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
} }
override fun onDestroy() { override fun onDestroy() {
...@@ -185,7 +199,12 @@ class OtherOrderActivity : BaseActivity() { ...@@ -185,7 +199,12 @@ class OtherOrderActivity : BaseActivity() {
if (type == 3 || type == 4 || type == 5 if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) { || type == 6 || type == 7) {
//播放提示音 //播放提示音
pageViewModel.refreshState.postValue(type) if (type == 5) {
pageViewModel.refreshState.postValue(1)
} else {
pageViewModel.refreshState.postValue(type)
// pageViewModel.getOrderGroupNum(GsaCloudApplication.getRestaurantId(this))
}
initSoundPool() initSoundPool()
} }
} }
...@@ -248,6 +267,8 @@ class OtherOrderActivity : BaseActivity() { ...@@ -248,6 +267,8 @@ class OtherOrderActivity : BaseActivity() {
} }
private var isOpen: Boolean = true private var isOpen: Boolean = true
private lateinit var btnOpenBg: Drawable
private lateinit var btnCloseBg: Drawable
/** /**
* 顯示或收起餐廳營業信息 * 顯示或收起餐廳營業信息
*/ */
...@@ -256,18 +277,31 @@ class OtherOrderActivity : BaseActivity() { ...@@ -256,18 +277,31 @@ class OtherOrderActivity : BaseActivity() {
isOpen = !isOpen isOpen = !isOpen
//如果是打開的,則關閉 //如果是打開的,則關閉
val heightAnimation = if (isOpen) val heightAnimation = if (isOpen)
ValueAnimator.ofFloat(1f, layoutHeight) ValueAnimator.ofFloat(btnHeight, layoutHeight)
else else
ValueAnimator.ofFloat(layoutHeight, 1f) ValueAnimator.ofFloat(layoutHeight, btnHeight)
heightAnimation.duration = 200 heightAnimation.duration = 200
heightAnimation.addUpdateListener { animation -> heightAnimation.addUpdateListener { animation ->
val height = animation.animatedValue as Float val height = animation.animatedValue as Float
setViewHeight(layout_today_order_info, height.toInt())
btn_open_or_close_info.text = if (isOpen) setViewHeight(cl_order_info, height.toInt())
"點擊收起"
else if (height >= layoutHeight * 0.8) {
"查看詳情" btn_open_or_close_info.apply {
btn_open_or_close_info.isClickable = true if (isOpen) {
text = "點擊收起"
background = btnOpenBg
layout_search_info.visibility = View.VISIBLE
layout_today_order_info.visibility = View.VISIBLE
} else {
text = "查看詳情"
background = btnCloseBg
layout_search_info.visibility = View.GONE
layout_today_order_info.visibility = View.GONE
}
}
btn_open_or_close_info.isClickable = true
}
} }
heightAnimation.start() heightAnimation.start()
} }
......
package com.gingersoft.gsa.other_order_mode.ui.adapter package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator.ofFloat
import android.animation.ValueAnimator
import android.content.Context import android.content.Context
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.util.Log import android.support.v4.media.session.PlaybackStateCompat
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.FrameLayout
import androidx.databinding.BindingAdapter
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter import androidx.recyclerview.widget.RecyclerView.Adapter
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding
...@@ -54,10 +55,10 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -54,10 +55,10 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
5 -> "配送中" 5 -> "配送中"
6 -> "到達目的地附近" 6 -> "到達目的地附近"
7 -> "訂單已完成" 7 -> "訂單已完成"
8 -> "訂單已取消"//取餐前 8 -> "物流已取消"//取餐前
9 -> "訂單已取消"//取餐後 9 -> "物流已取消"//取餐後
10 -> "已指派另一位配送員" 10 -> "已指派另一位配送員"
else -> "訂單已創建" else -> ""
} }
} }
} }
...@@ -65,14 +66,21 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -65,14 +66,21 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
var state: String? = null var state: String? = null
val bg = GradientDrawable() val bg = GradientDrawable()
bg.cornerRadius = dp2px(5f).toFloat() bg.cornerRadius = dp2px(5f).toFloat()
holder.flBorder.visibility = View.GONE//隱藏邊框
when { when {
data.STATUS == 0 -> { data.STATUS == 0 -> {
state = "待確認" state = "待確認"
bg.setColor(getColor(R.color.order_state0_color)) bg.setColor(getColor(R.color.order_state0_color))
holder.flBorder.visibility = View.VISIBLE//顯示邊框
//執行動畫
alphaAnimator(holder.flBorder)
} }
data.STATUS == 1 -> { data.STATUS == 1 -> {
state = "待確認" state = "待確認"
bg.setColor(getColor(R.color.order_state0_color)) bg.setColor(getColor(R.color.order_state0_color))
holder.flBorder.visibility = View.VISIBLE//顯示邊框
//執行動畫
alphaAnimator(holder.flBorder)
} }
data.STATUS == 2 -> { data.STATUS == 2 -> {
state = "製作中" state = "製作中"
...@@ -130,8 +138,27 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -130,8 +138,27 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
holder.itemView.setOnClickListener { holder.itemView.setOnClickListener {
listenter?.invoke(data) listenter?.invoke(data)
} }
}
private fun alphaAnimator(view: View) {
val animatorSet = AnimatorSet()
val ofFloat = ofFloat(view, "alpha", 0f, 1f)
ofFloat.duration = 200
ofFloat.repeatCount = -1
ofFloat.repeatMode = ValueAnimator.REVERSE
val ofFloat1 = ofFloat(view, "alpha", 1f, 0f)
ofFloat1.duration = 200
ofFloat1.repeatCount = -1
ofFloat1.repeatMode = ValueAnimator.REVERSE
animatorSet.play(ofFloat).with(ofFloat1)
animatorSet.duration = 400
animatorSet.start()
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return if (databeans == null) { return if (databeans == null) {
0 0
...@@ -146,17 +173,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View ...@@ -146,17 +173,7 @@ class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.View
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutOtherOrderItemBinding = DataBindingUtil.bind(itemView)!! var binding: LayoutOtherOrderItemBinding = DataBindingUtil.bind(itemView)!!
// var flBorder: FrameLayout = itemView.findViewById(R.id.fl_border)
// @BindingAdapter("imageUrl")
// fun bindImageUrl(view: ImageView, imageUrl: String) {
// val options: RequestOptions = RequestOptions()
// .centerCrop()
// .dontAnimate()
//
// Glide.with(view)
// .load(imageUrl)
// .apply(options)
// .into(view)
// }
} }
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.OtherOrdersAdapter ...@@ -15,6 +15,7 @@ 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.ui.base.BaseFragment
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils import com.gingersoft.gsa.other_order_mode.util.OtherOrderUtils
import com.gingersoft.gsa.other_order_mode.util.setState
import kotlinx.android.synthetic.main.fragment_other_order.* import kotlinx.android.synthetic.main.fragment_other_order.*
/** /**
...@@ -29,17 +30,17 @@ class PlaceholderFragment : BaseFragment() { ...@@ -29,17 +30,17 @@ class PlaceholderFragment : BaseFragment() {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply { pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
// 第一次進入獲取數據 // 第一次進入獲取數據
getOrderList(this, false) // getOrderList(this, false)
// 綁定狀態,如果這個值發生變化 // 綁定狀態,如果這個值發生變化
refreshState.observe(viewLifecycleOwner, Observer { refreshState.observe(viewLifecycleOwner, Observer {
// 觸發刷新,判斷是否更新 // 觸發刷新,判斷是否更新
// 並且type一致 // 並且type一致
//如果當前fragment的狀態中包含需要刷新的狀態,獲取數據 //如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
Log.e("eee", "$it,當前fragment的" + PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!]) Log.e("eee", "$it,當前fragment的" + PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!])
// if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) { if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
page = 1 page = 1
getOrderList(this, false) getOrderList(this, false)
// } }
}) })
} }
...@@ -58,8 +59,9 @@ class PlaceholderFragment : BaseFragment() { ...@@ -58,8 +59,9 @@ class PlaceholderFragment : BaseFragment() {
pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) { pageViewModel.updateOrderStatus(this@PlaceholderFragment.context!!, data, it1) {
dialog.dismiss() dialog.dismiss()
if (it) { if (it) {
// 關閉彈窗,並刷新頁面 // 關閉彈窗,並刷新當前頁面
refresh() refresh()
// pageViewModel.refreshState.postValue(pageViewModel.refreshState.value!! + 1)
} }
} }
} }
...@@ -88,6 +90,11 @@ class PlaceholderFragment : BaseFragment() { ...@@ -88,6 +90,11 @@ class PlaceholderFragment : BaseFragment() {
} }
} }
override fun onResume() {
super.onResume()
refresh()
}
private fun refresh() { private fun refresh() {
page = 1 page = 1
pageViewModel.orderNo = "" pageViewModel.orderNo = ""
...@@ -102,6 +109,9 @@ class PlaceholderFragment : BaseFragment() { ...@@ -102,6 +109,9 @@ class PlaceholderFragment : BaseFragment() {
private fun getOrderList(pageViewModel: PageViewModel, isLoadMore: Boolean) { private fun getOrderList(pageViewModel: PageViewModel, isLoadMore: Boolean) {
pageViewModel.getOrderList(activity!!, arguments?.getInt(INDEX) pageViewModel.getOrderList(activity!!, arguments?.getInt(INDEX)
?: 0, page.toString(), isLoadMore) { ?: 0, page.toString(), isLoadMore) {
if (!isLoadMore) {
layout_nodata.setState(it <= 0)
}
refresh_layout.finishRefresh() refresh_layout.finishRefresh()
refresh_layout.finishLoadMore() refresh_layout.finishLoadMore()
} }
......
...@@ -28,12 +28,7 @@ object OtherOrderUtils { ...@@ -28,12 +28,7 @@ object OtherOrderUtils {
layoutOrderInfoDialogBinding.isSelf = orderType == 7 layoutOrderInfoDialogBinding.isSelf = orderType == 7
layoutOrderInfoDialogBinding.totalAmount = orderData.TOTAL_AMOUNT!!.toDouble() layoutOrderInfoDialogBinding.totalAmount = orderData.TOTAL_AMOUNT!!.toDouble()
//如果有物流號,就不顯示指派送貨按鈕 //如果有物流號,就不顯示指派送貨按鈕
// if (orderData.trkNo != null && orderData.trkNo!!.isNotEmpty() && orderStuats == 2) { layoutOrderInfoDialogBinding.showBtn = showBtn
// layoutOrderInfoDialogBinding.showBtn = false
// } else {
layoutOrderInfoDialogBinding.showBtn = showBtn
// }
val btnContent: String val btnContent: String
val type = if (orderType == 7) "自取" else "外賣" val type = if (orderType == 7) "自取" else "外賣"
val orderStatus: String val orderStatus: String
...@@ -45,7 +40,11 @@ object OtherOrderUtils { ...@@ -45,7 +40,11 @@ object OtherOrderUtils {
btnContent = "製作完成" btnContent = "製作完成"
tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color)) tvStatus.setTextColor(context.resources.getColor(R.color.order_state0_color))
} else { } else {
btnContent = "指派送貨" btnContent = if (orderData.isDelete == 1) {
"指派送貨"
} else {
"重印"
}
tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color)) tvStatus.setTextColor(context.resources.getColor(R.color.order_state1_color))
} }
orderStatus = "製作中" orderStatus = "製作中"
...@@ -80,7 +79,7 @@ object OtherOrderUtils { ...@@ -80,7 +79,7 @@ object OtherOrderUtils {
listenter?.invoke(data.data!![0], dialog) listenter?.invoke(data.data!![0], dialog)
} }
hepler.getView<ImageView>(R.id.iv_close).setOnClickListener{ hepler.getView<ImageView>(R.id.iv_close).setOnClickListener {
dialog.dismiss() dialog.dismiss()
} }
} }
......
package com.gingersoft.gsa.other_order_mode.util
import android.view.View
fun View.setState(state: Boolean) {
visibility = if (state) {
View.VISIBLE
} else {
View.GONE
}
}
\ No newline at end of file
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
android:paddingRight="@dimen/dp_50" android:paddingRight="@dimen/dp_50"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc" android:textColorHint="@color/color_ccc"
android:inputType="number"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_14"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
...@@ -57,14 +58,5 @@ ...@@ -57,14 +58,5 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout <include layout="@layout/fragment_other_order"/>
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_history_order"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<variable <variable
name="data" name="data"
type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" /> type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" />
· </data> </data>
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -47,17 +47,17 @@ ...@@ -47,17 +47,17 @@
android:id="@+id/cl_order_info" android:id="@+id/cl_order_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" 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:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true">
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_search_info" android:id="@+id/layout_search_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/shape_white_top_border"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:padding="@dimen/dp_10" android:padding="@dimen/dp_10"
...@@ -100,7 +100,6 @@ ...@@ -100,7 +100,6 @@
app:layout_constraintRight_toRightOf="@id/sb_takeaway" app:layout_constraintRight_toRightOf="@id/sb_takeaway"
app:layout_constraintTop_toTopOf="@id/tv_month_takeaway_num_text" /> app:layout_constraintTop_toTopOf="@id/tv_month_takeaway_num_text" />
<View <View
android:id="@+id/dividing_line" android:id="@+id/dividing_line"
android:layout_width="@dimen/dp_1" android:layout_width="@dimen/dp_1"
...@@ -160,6 +159,7 @@ ...@@ -160,6 +159,7 @@
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textColorHint="@color/color_ccc" android:textColorHint="@color/color_ccc"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_14"
android:inputType="number"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_switch_restaurant_state" app:layout_constraintRight_toLeftOf="@id/btn_switch_restaurant_state"
app:layout_constraintTop_toBottomOf="@id/tv_month_takeaway_num_text" /> app:layout_constraintTop_toBottomOf="@id/tv_month_takeaway_num_text" />
...@@ -181,13 +181,13 @@ ...@@ -181,13 +181,13 @@
android:layout_height="@dimen/dp_40" android:layout_height="@dimen/dp_40"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_12" android:textSize="@dimen/dp_12"
app:kswThumbColor="@color/white"
app:kswBackRadius="@dimen/dp_20"
app:kswThumbMarginTop="@dimen/dp_4"
app:kswBackColor="@color/selector_switch_button" app:kswBackColor="@color/selector_switch_button"
app:kswThumbMarginBottom="@dimen/dp_4" app:kswBackRadius="@dimen/dp_20"
app:kswTextOff="@string/resting" app:kswTextOff="@string/resting"
app:kswTextOn="@string/open" app:kswTextOn="@string/open"
app:kswThumbColor="@color/white"
app:kswThumbMarginBottom="@dimen/dp_4"
app:kswThumbMarginTop="@dimen/dp_4"
app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search" app:layout_constraintBottom_toBottomOf="@id/ed_order_num_search"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/ed_order_num_search" /> app:layout_constraintTop_toTopOf="@id/ed_order_num_search" />
...@@ -377,20 +377,19 @@ ...@@ -377,20 +377,19 @@
app:layout_constraintTop_toBottomOf="@id/tv_self_amount_text" /> app:layout_constraintTop_toBottomOf="@id/tv_self_amount_text" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/btn_open_or_close_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_5"
android:background="@drawable/shape_white_bottom_border"
android:gravity="center"
android:text="點擊收起"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12"
app:layout_constraintTop_toBottomOf="@id/layout_today_order_info" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/btn_open_or_close_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_5"
android:background="@drawable/shape_white_bottom_border"
android:gravity="center"
android:text="點擊收起"
android:textColor="@color/color_a9"
android:textSize="@dimen/dp_12" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<data> <FrameLayout
<variable
name="viewModel"
type="com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel" />
</data>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -18,5 +12,9 @@ ...@@ -18,5 +12,9 @@
android:id="@+id/rv_other_order" android:id="@+id/rv_other_order"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</layout> <include
\ No newline at end of file android:id="@+id/layout_nodata"
layout="@layout/layout_no_data" />
</FrameLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
...@@ -290,6 +290,7 @@ ...@@ -290,6 +290,7 @@
style="@style/otherOrderReceiving_information_textStyle" style="@style/otherOrderReceiving_information_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight" android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{data.delivery_man_phone_num}" android:text="@{data.delivery_man_phone_num}"
app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_phone_text" app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_phone_text"
...@@ -459,7 +460,7 @@ ...@@ -459,7 +460,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight" android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
android:text="@{@string/amount_unit + data.discount_amount}" android:text="@{@string/minus_amount_unit + data.discount_amount}"
android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}" android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_discount_text" /> app:layout_constraintTop_toTopOf="@id/tv_discount_text" />
......
...@@ -136,7 +136,6 @@ ...@@ -136,7 +136,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:text="手機號:" android:text="手機號:"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_user_name" /> app:layout_constraintTop_toBottomOf="@id/tv_order_user_name" />
...@@ -165,8 +164,9 @@ ...@@ -165,8 +164,9 @@
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num"
style="@style/otherOrder_item_info_textStyle" style="@style/otherOrder_item_info_textStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textStyle="bold"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{data.takeFoodCode}" android:text='@{data.takeFoodCode.equals("0")? @string/take_food_code_omit:data.takeFoodCode}'
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num" app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintTop_toTopOf="@id/tv_order_num_text" /> app:layout_constraintTop_toTopOf="@id/tv_order_num_text" />
...@@ -218,5 +218,12 @@ ...@@ -218,5 +218,12 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_address" /> app:layout_constraintTop_toTopOf="@id/tv_address" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:id="@+id/fl_border"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_order_border"
android:visibility="gone" />
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
</layout> </layout>
\ No newline at end of file
...@@ -40,4 +40,5 @@ ...@@ -40,4 +40,5 @@
<string name="deliveryman">送貨員:</string> <string name="deliveryman">送貨員:</string>
<string name="deliveryman_phone">送貨員手機號:</string> <string name="deliveryman_phone">送貨員手機號:</string>
<string name="logistics_number">物流號:</string> <string name="logistics_number">物流號:</string>
<string name="take_food_code_omit">----</string>
</resources> </resources>
package com.joe.print.mvp.model.bean;
/**
* @author LYC
* @version 1.0
* @date 2020/4/28 11:42
*/
public class Prg {
private Long id;
private Long orderId;
private Long restaurantId;
private Long orderDetailsId;
private Long printerDeviceId;
private Long requests;
private Byte status;
private Byte printerType;
private Long createTime;
private Long updateTime;
private Long printerTime;
/**
* 狀態,1不切紙 2切紙
*/
public static final byte STATUS_FALSE = 1;
public static final byte STATUS_TRUE = 2;
/**
* 打印狀態 1未打印 2打印中 3已打印
*/
public static final byte PRINTER_FALSE = 1;
public static final byte PRINTER_TRUE = 2;
}
package com.joe.print.mvp.model.bean;
import java.util.List;
import java.util.Map;
public class PrjBean {
/**
* success : true
* sysTime : 1589177793623
* data : {"-1":[{"id":1,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827589,"productName":"炸鸡翅","parentId":0,"type":3},{"id":2,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827590,"productName":"鮮茄汁藍青口","parentId":0,"type":3}],"k1":[{"id":77,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828004,"productName":"走青檸測試","parentId":48827589,"type":4},{"id":78,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828005,"productName":"走豆測試","parentId":48827590,"type":4},{"id":79,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828006,"productName":"精選牛肉","parentId":0,"type":3},{"id":80,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828007,"productName":"走豆測試","parentId":48828006,"type":4},{"id":81,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828008,"productName":"雞飯(四客)","parentId":48828006,"type":3},{"id":82,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828009,"productName":"精選牛肉","parentId":48828006,"type":3}]}
*/
private boolean success;
private long sysTime;
private String data;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public long getSysTime() {
return sysTime;
}
public void setSysTime(long sysTime) {
this.sysTime = sysTime;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public static class DataBean {
public Map<String, List<Bean>> prjMap;
public static class Bean {
/**
* id : 77
* printerDeviceId : 1
* status : 1
* tableName : 51536
* orderNo : gs201351936242891
* orderTime : 2020
* person : 2
* orderDetailsTime : May 11, 2020 11:41:41 AM
* orderDetailsId : 48828004
* productName : 走青檸測試
* parentId : 48827589
* type : 4
*/
private int id;
private int printerDeviceId;
private int status;
private String tableName;
private String orderNo;
private int orderTime;
private int person;
private String orderDetailsTime;
private int orderDetailsId;
private String productName;
private int parentId;
private int type;
private int printerType;
private Long printerTime;
/***
* 層級
* 1:主食品
* 2:子項or細項
* 3:細項
*/
private int itemType;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPrinterDeviceId() {
return printerDeviceId;
}
public void setPrinterDeviceId(int printerDeviceId) {
this.printerDeviceId = printerDeviceId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public int getOrderTime() {
return orderTime;
}
public void setOrderTime(int orderTime) {
this.orderTime = orderTime;
}
public int getPerson() {
return person;
}
public void setPerson(int person) {
this.person = person;
}
public String getOrderDetailsTime() {
return orderDetailsTime;
}
public void setOrderDetailsTime(String orderDetailsTime) {
this.orderDetailsTime = orderDetailsTime;
}
public int getOrderDetailsId() {
return orderDetailsId;
}
public void setOrderDetailsId(int orderDetailsId) {
this.orderDetailsId = orderDetailsId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public int getParentId() {
return parentId;
}
public void setParentId(int parentId) {
this.parentId = parentId;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getItemType() {
return itemType;
}
public void setItemType(int itemType) {
this.itemType = itemType;
}
public int getPrinterType() {
return printerType;
}
public void setPrinterType(int printerType) {
this.printerType = printerType;
}
public Long getPrinterTime() {
return printerTime;
}
public void setPrinterTime(Long printerTime) {
this.printerTime = printerTime;
}
}
public Map<String, List<Bean>> getPrjMap() {
return prjMap;
}
public void setPrjMap(Map<String, List<Bean>> prjMap) {
this.prjMap = prjMap;
}
}
}
...@@ -9,5 +9,5 @@ import retrofit2.http.Query; ...@@ -9,5 +9,5 @@ import retrofit2.http.Query;
public interface GetPrintInfoService { public interface GetPrintInfoService {
@GET("prg/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("prg/get" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<LoginBean> getPrintInfo(@Query("restaurantId") String restaurantId); Observable<Object> getPrintInfo(@Query("restaurantId") String restaurantId);
} }
...@@ -8,6 +8,7 @@ import me.jessyan.retrofiturlmanager.RetrofitUrlManager; ...@@ -8,6 +8,7 @@ import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.Query; import retrofit2.http.Query;
...@@ -19,12 +20,14 @@ public interface PrintInfoService { ...@@ -19,12 +20,14 @@ public interface PrintInfoService {
@POST("PrinterDevice/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @POST("PrinterDevice/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addPrinter(@Body RequestBody requestBody); Observable<BaseResult> addPrinter(@Body RequestBody requestBody);
// @Headers({"Domain-Name: yc_location"})
@GET("PrinterDevice/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("PrinterDevice/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getPrinterList(@Query("restaurantId") int restaurantId); Observable<BaseResult> getPrinterList(@Query("restaurantId") int restaurantId);
@POST("PrinterDevice/deletes" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @POST("PrinterDevice/deletes" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> deletePrinterList(@Body RequestBody requestBody); Observable<BaseResult> deletePrinterList(@Body RequestBody requestBody);
// @Headers({"Domain-Name: yc_location"})
@POST("PrinterDevice/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @POST("PrinterDevice/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updatePrinter(@Body RequestBody requestBody); Observable<BaseResult> updatePrinter(@Body RequestBody requestBody);
} }
package com.joe.print.mvp.presenter; package com.joe.print.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult; import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager; import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager;
...@@ -85,6 +86,12 @@ public class PrintPresenter extends BasePresenter<PrintContract.Model, PrintCont ...@@ -85,6 +86,12 @@ public class PrintPresenter extends BasePresenter<PrintContract.Model, PrintCont
mRootView.showPrinterList(null); mRootView.showPrinterList(null);
} }
} }
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.showPrinterList(null);
}
}); });
} }
} }
...@@ -29,8 +29,6 @@ import java.util.Objects; ...@@ -29,8 +29,6 @@ import java.util.Objects;
*/ */
public class PrintKitchen extends PrinterRoot { public class PrintKitchen extends PrinterRoot {
// String[] printLocation = new String[]{"k1", "k2"};
@Override @Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) { public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>(); Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
...@@ -170,7 +168,7 @@ public class PrintKitchen extends PrinterRoot { ...@@ -170,7 +168,7 @@ public class PrintKitchen extends PrinterRoot {
} }
} }
if (OpenTableManage.getDefault().getTableBean() != null) { if (OpenTableManage.getDefault().getTableBean() != null) {
// 台號 //台號
tvTableNumber.setText(OpenTableManage.getDefault().getTableBean().getTableName() + ""); tvTableNumber.setText(OpenTableManage.getDefault().getTableBean().getTableName() + "");
tvTableNumber2.setText(OpenTableManage.getDefault().getTableBean().getTableName() + ""); tvTableNumber2.setText(OpenTableManage.getDefault().getTableBean().getTableName() + "");
//人數 //人數
...@@ -187,4 +185,9 @@ public class PrintKitchen extends PrinterRoot { ...@@ -187,4 +185,9 @@ public class PrintKitchen extends PrinterRoot {
return viewToBitmap(context, view); return viewToBitmap(context, view);
} }
} }
...@@ -149,11 +149,17 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -149,11 +149,17 @@ public class PrintOtherOrder extends PrinterRoot {
TextView tvSendTime = view.findViewById(R.id.tv_order_send_time); TextView tvSendTime = view.findViewById(R.id.tv_order_send_time);
TextView tvOrderNum = view.findViewById(R.id.tv_order_number); TextView tvOrderNum = view.findViewById(R.id.tv_order_number);
RecyclerView rvFood = view.findViewById(R.id.rv_order_food); RecyclerView rvFood = view.findViewById(R.id.rv_order_food);
TextView tvTakeCode = view.findViewById(R.id.tv_order_take_code);
if (dataBean.getOrder_type() == 2) { if (dataBean.getOrder_type() == 2) {
tvOrderType.setText("外賣"); tvOrderType.setText("外賣");
} else { } else {
tvOrderType.setText("自取"); tvOrderType.setText("自取");
} }
if (dataBean.getTakeFoodCode() != null && !dataBean.getTakeFoodCode().equals("0")) {
tvTakeCode.setText("取餐碼:#" + dataBean.getTakeFoodCode());
} else {
view.findViewById(R.id.tv_order_take_code).setVisibility(View.GONE);
}
//送貨時間 //送貨時間
if (!TextUtil.isEmptyOrNullOrUndefined(dataBean.getSEND_TIME())) { if (!TextUtil.isEmptyOrNullOrUndefined(dataBean.getSEND_TIME())) {
tvSendTime.setVisibility(View.VISIBLE); tvSendTime.setVisibility(View.VISIBLE);
...@@ -170,6 +176,7 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -170,6 +176,7 @@ public class PrintOtherOrder extends PrinterRoot {
rvFood.setLayoutManager(new LinearLayoutManager(context)); rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(new OtherOrderAdapter(context, orderDetail, false)); rvFood.setAdapter(new OtherOrderAdapter(context, orderDetail, false));
return viewToBitmap(context, view); return viewToBitmap(context, view);
} }
...@@ -180,6 +187,11 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -180,6 +187,11 @@ public class PrintOtherOrder extends PrinterRoot {
setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外賣" : "自取"); setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外賣" : "自取");
// 訂單號 // 訂單號
setText(view, R.id.tv_order_number, "訂單號:" + data.getORDER_NO()); setText(view, R.id.tv_order_number, "訂單號:" + data.getORDER_NO());
if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) {
setText(view, R.id.tv_order_take_food_code, "#" + data.getTakeFoodCode());
} else {
view.findViewById(R.id.tv_order_take_food_code).setVisibility(View.GONE);
}
//訂單創建時間 //訂單創建時間
setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT)); setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
String amountUnit = context.getString(R.string.amount_unit); String amountUnit = context.getString(R.string.amount_unit);
...@@ -198,6 +210,8 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -198,6 +210,8 @@ public class PrintOtherOrder extends PrinterRoot {
setText(view, R.id.tv_pay_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())); setText(view, R.id.tv_pay_amount, amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
//支付類型:貨到付款,在線支付 //支付類型:貨到付款,在線支付
setText(view, R.id.tv_pay_type, data.getOrderPayType() == 1 ? "貨到付款" : "在線支付"); setText(view, R.id.tv_pay_type, data.getOrderPayType() == 1 ? "貨到付款" : "在線支付");
//收貨時間
setText(view, R.id.tv_delivery_time, data.getOrder_type() == 2 ? data.getTakeTime() : data.getSEND_TIME());
//收貨地址 //收貨地址
setText(view, R.id.tv_address, context.getString(R.string.address) + data.getAddressDetail()); setText(view, R.id.tv_address, context.getString(R.string.address) + data.getAddressDetail());
//收貨人 //收貨人
......
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.adapter.print.KitChenPrintFoodAdapter;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrjBean;
import com.joe.print.mvp.ui.adapter.KitChenPrjPrintFoodAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static com.gingersoft.gsa.cloud.base.common.bean.OrderDetail.DISCOUNT_TYPE;
import static com.gingersoft.gsa.cloud.base.common.bean.OrderDetail.FOOD_TYPE;
import static com.gingersoft.gsa.cloud.base.common.bean.OrderDetail.MODIFIER_TYPE;
/**
* 廚房單打印
*/
public class PrintPrjKitchen extends PrinterRoot {
private static Map<String, List<PrjBean.DataBean.Bean>> prjMap;
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
//通過打印位置生成多張用於打印的bitmap
for (Map.Entry<String, List<PrjBean.DataBean.Bean>> entry : prjMap.entrySet()) {
String key = entry.getKey();
List<Bitmap> bitmaps = new ArrayList<>();
Bitmap bitmap = getKitChenPrintBitmap(mContext, key, entry.getValue());
//不帶*號,所有同樣廚房位置的食品都在一張紙上
bitmaps.add(bitmap);
bitmapMaps.put(key, bitmaps);
}
prjMap.clear();
return bitmapMaps;
}
/**
* 獲取"廚房單"圖片
*
* @param context
* @return
*/
private Bitmap getKitChenPrintBitmap(Context context, String key, List<PrjBean.DataBean.Bean> data) {
if (data == null || data.size() <= 0) {
return null;
}
for (PrjBean.DataBean.Bean bean : data) {
if (bean.getParentId() == 0) {
//沒有父級id,則是第一級食品
bean.setItemType(1);
}
//如果父級id不為0,是細項
if (bean.getParentId() != 0) {
bean.setItemType(2);//先設置為細項,再通過下面的遍歷確定是否是第三級細項
//循環遍歷查找父級食品
for (PrjBean.DataBean.Bean itembean : data) {
if (bean.getParentId() == itembean.getOrderDetailsId()) {
//如果父級是細項,則當前食品就是二級細項
bean.setItemType(bean.getItemType() + 1);
break;
}
}
}
}
View view = LinearLayout.inflate(context, R.layout.print_kitchen, null);
TextView tvTableNumber = view.findViewById(R.id.tv_kitchen_print_table_number);
TextView tvOrderNumber = view.findViewById(R.id.tv_order_num);
TextView tvOpeningTime = view.findViewById(R.id.tv_opening_time);
TextView tvOrderTime = view.findViewById(R.id.tv_order_time);
TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location);
TextView tvPeople = view.findViewById(R.id.tv_people);
TextView tvOperator = view.findViewById(R.id.tv_operator);
RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food);
TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number2);
if (data.size() > 0 && data.get(0) != null) {
KitChenPrjPrintFoodAdapter foodAdapter = new KitChenPrjPrintFoodAdapter(data);
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(foodAdapter);
//廚房位置
if (!TextUtil.isEmptyOrNullOrUndefined(key) && !key.equals("-1")) {
tvKitChenLocation.setText(key);//.replace("*", "")
tvKitChenLocation.setVisibility(View.VISIBLE);
} else {
tvKitChenLocation.setVisibility(View.GONE);
}
}
if (OpenTableManage.getDefault().getTableBean() != null) {
//台號
tvTableNumber.setText(data.get(0).getTableName());
tvTableNumber2.setText(data.get(0).getTableName());
//人數
tvPeople.setText(data.get(0).getPerson() + "");
//訂單號
tvOrderNumber.setText(data.get(0).getOrderNo());
//開台時間
tvOpeningTime.setText(TimeUtils.parseTimeRepeat(data.get(0).getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_FORMAT));
}
//落單時間,為當前時間
tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT));
//操作人員
tvOperator.setText("");
return viewToBitmap(context, view);
}
public static Map<String, List<PrjBean.DataBean.Bean>> getPrjMap() {
if (prjMap == null) {
prjMap = new HashMap<>();
}
return prjMap;
}
}
...@@ -21,7 +21,7 @@ import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; ...@@ -21,7 +21,7 @@ import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils; import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils; import com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils; import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.constans.Constans; import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
...@@ -74,7 +74,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -74,7 +74,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} else if (type == PRINT_BILL) { } else if (type == PRINT_BILL) {
return new PrintBill(); return new PrintBill();
} else if (type == PRINT_KITCHEN) { } else if (type == PRINT_KITCHEN) {
return new PrintKitchen(); return new PrintPrjKitchen();
} else if (type == PRINT_CLEAN_MACHINE) { } else if (type == PRINT_CLEAN_MACHINE) {
return new PrintCleanMachine(); return new PrintCleanMachine();
} else if (type == PRINT_OTHER_ORDER) { } else if (type == PRINT_OTHER_ORDER) {
...@@ -288,7 +288,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -288,7 +288,6 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
//在打印機列表中找到當前key, //在打印機列表中找到當前key,
boolean isPrint = false;//是否已經打印 boolean isPrint = false;//是否已經打印
for (int i = 0; i < printerDeviceBeans.size(); i++) { for (int i = 0; i < printerDeviceBeans.size(); i++) {
int lastIndex = key.lastIndexOf(DELIMITER); int lastIndex = key.lastIndexOf(DELIMITER);
key = key.substring(lastIndex + 1); key = key.substring(lastIndex + 1);
...@@ -332,7 +331,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -332,7 +331,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} }
private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) { private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
String deftultPrint = (String) SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, ""); String deftultPrint = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_METHOD, "");
if (deftultPrint.equals("")) { if (deftultPrint.equals("")) {
// 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印 // 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印
new DialogUtils(mContext, R.layout.print_dialog_select_device) { new DialogUtils(mContext, R.layout.print_dialog_select_device) {
...@@ -357,19 +356,19 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -357,19 +356,19 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} }
}); });
//修改默認打印方式為本地 //修改默認打印方式為本地
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT);
dialog.dismiss(); dialog.dismiss();
}); });
//ip打印 //ip打印
hepler.setViewClick(R.id.internet_print, v -> { hepler.setViewClick(R.id.internet_print, v -> {
//修改默認打印方式為IP打印 //修改默認打印方式為IP打印
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
//彈出彈窗,讓用戶選擇ip打印機 //彈出彈窗,讓用戶選擇ip打印機
showIpPrintDeviceList(printerDeviceBeans, bitmaps); showIpPrintDeviceList(printerDeviceBeans, bitmaps);
}); });
} }
}.createDialogView().show(); }.createDialogView().show();
} else if (deftultPrint.equals(Constans.LOCAL_PRINT)) { } else if (deftultPrint.equals(PrintConstans.LOCAL_PRINT)) {
// 默認打印方式為本地,進行本地打印 // 默認打印方式為本地,進行本地打印
locationPrint(bitmaps, new PrintListener() { locationPrint(bitmaps, new PrintListener() {
@Override @Override
...@@ -387,7 +386,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -387,7 +386,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
setPrintState(PrintActivity.FINISH); setPrintState(PrintActivity.FINISH);
} }
}); });
} else if (deftultPrint.equals(Constans.IP_PRINT)) { } else if (deftultPrint.equals(PrintConstans.IP_PRINT)) {
// 默認打印方式為ip打印,調用ip打印方法 // 默認打印方式為ip打印,調用ip打印方法
// 獲取默認ip打印機, // 獲取默認ip打印機,
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) { if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
...@@ -533,76 +532,78 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -533,76 +532,78 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
Log.e("eee", "個數:" + printSize); Log.e("eee", "個數:" + printSize);
printSize--; printSize--;
if (printSize <= 0) { if (printSize <= 0) {
Log.e("eee", "打印完了"); Log.e("eee", "打印完了" + printerFileDevices.size());
//全部打印完了 //全部打印完了
if (printerFileDevices != null && printerFileDevices.size() > 0) { if (printerFileDevices != null && printerFileDevices.size() > 0) {
//有打印失敗的.關閉activity中的加載框 //有打印失敗的.關閉activity中的加載框
setPrintState(PrintActivity.DIMISS_LOADING); setPrintState(PrintActivity.DIMISS_LOADING);
//显示彈窗,將失敗的打印機信息和食品組顯示出來。 // //显示彈窗,將失敗的打印機信息和食品組顯示出來。
new DialogUtils(mContext, R.layout.dialog_print_fail_list) { // new DialogUtils(mContext, R.layout.dialog_print_fail_list) {
@Override // @Override
public void initLayout(ViewHepler hepler, Dialog dialog) { // public void initLayout(ViewHepler hepler, Dialog dialog) {
hepler.getView(R.id.iv_close_dialog).setOnClickListener(v -> dialog.dismiss()); // hepler.getView(R.id.iv_close_dialog).setOnClickListener(v -> dialog.dismiss());
RecyclerView recyclerView = hepler.getView(R.id.rv_print_fail_list); // RecyclerView recyclerView = hepler.getView(R.id.rv_print_fail_list);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext)); // recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
PrintFailListAdapter adapter = new PrintFailListAdapter(printerFileDevices); // PrintFailListAdapter adapter = new PrintFailListAdapter(printerFileDevices);
recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color))); // recyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color)));
adapter.setOnItemClickListener((adapter12, view, position) -> { // adapter.setOnItemClickListener((adapter12, view, position) -> {
//顯示打印失敗的食品。 // //顯示打印失敗的食品。
if (printerFileDevices.get(position).getName() != null) { // if (printerFileDevices.get(position).getName() != null) {
PrintFileBitmapAdapter bitmapAdapter = new PrintFileBitmapAdapter(getPrintBitmapByPrintLocation(printerFileDevices.get(position).getName())); // PrintFileBitmapAdapter bitmapAdapter = new PrintFileBitmapAdapter(getPrintBitmapByPrintLocation(printerFileDevices.get(position).getName()));
recyclerView.setAdapter(bitmapAdapter); // recyclerView.setAdapter(bitmapAdapter);
} // }
}); // });
adapter.setSwitchPrintListenter(position -> { // adapter.setSwitchPrintListenter(position -> {
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) { // if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
//切換打印機打印。跳轉到選擇打印機列表 // //切換打印機打印。跳轉到選擇打印機列表
DialogPrinterListAdapter adapter1 = new DialogPrinterListAdapter(printerDeviceBeans, mContext); // DialogPrinterListAdapter adapter1 = new DialogPrinterListAdapter(printerDeviceBeans, mContext);
//分割线 // //分割线
recyclerView.setAdapter(adapter1); // recyclerView.setAdapter(adapter1);
adapter1.setOnItemClickListener((adapter2, view, position1) -> { // adapter1.setOnItemClickListener((adapter2, view, position1) -> {
printerFileDevices.set(position, printerDeviceBeans.get(position1)); // printerFileDevices.set(position, printerDeviceBeans.get(position1));
adapter.setData(position, printerDeviceBeans.get(position1)); // adapter.setData(position, printerDeviceBeans.get(position1));
recyclerView.setAdapter(adapter); // recyclerView.setAdapter(adapter);
}); // });
} else { // } else {
//沒有打印機,讓用戶去添加 // //沒有打印機,讓用戶去添加
setPrintState(PrintActivity.ADD_PRINT_DEVICE); // setPrintState(PrintActivity.ADD_PRINT_DEVICE);
} // }
}); // });
adapter.setTryAgainPrintListenter(position -> { // adapter.setTryAgainPrintListenter(position -> {
//重試打印。 // //重試打印。
ipDevicePrint(printerFileDevices.get(position), getPrintBitmapByPrintLocation(printerFileDevices.get(position).getName()), (state, printerDeviceBean) -> { // ipDevicePrint(printerFileDevices.get(position), getPrintBitmapByPrintLocation(printerFileDevices.get(position).getName()), (state, printerDeviceBean) -> {
//打印機打印狀態切換回調 // //打印機打印狀態切換回調
}, (errorCode, printerDeviceBean) -> { // }, (errorCode, printerDeviceBean) -> {
switch (errorCode) { // switch (errorCode) {
case PrintSocketHolder.ERROR_0: // case PrintSocketHolder.ERROR_0:
//打印成功 // //打印成功
adapter.remove(position); // adapter.remove(position);
Log.e("eee", "打印成功"); // Log.e("eee", "打印成功");
if (adapter.getItemCount() <= 0) { // if (adapter.getItemCount() <= 0) {
//所有都打印成功 // //所有都打印成功
printListener.printSuccess(); // printListener.printSuccess();
} // }
break; // break;
case PrintSocketHolder.ERROR_2: // case PrintSocketHolder.ERROR_2:
case PrintSocketHolder.ERROR_3: // case PrintSocketHolder.ERROR_3:
//打印失敗 // //打印失敗
adapter.setItemStatus(position, 0); // adapter.setItemStatus(position, 0);
Log.e("eee", "打印失敗"); // Log.e("eee", "打印失敗");
break; // break;
} // }
}); // });
}); // });
recyclerView.setAdapter(adapter); // recyclerView.setAdapter(adapter);
} // }
} // }
.setWidth((int) (ArmsUtils.getScreenWidth(mContext) * 0.66)) // .setWidth((int) (ArmsUtils.getScreenWidth(mContext) * 0.66))
.setHeight((int) (ArmsUtils.getScreenHeidth(mContext) * 0.66)) // .setHeight((int) (ArmsUtils.getScreenHeidth(mContext) * 0.66))
.createDialogView() // .createDialogView()
.setCanceledOnTouchOutside(false) // .setCanceledOnTouchOutside(false)
.setOnDismissListener(dialog -> setPrintState(PrintActivity.FINISH)) // .setOnDismissListener(dialog -> setPrintState(PrintActivity.FINISH));
.show(); // .show();
printListener.printFile();
// ToastUtils.show(mContext, "打印失敗");
} else { } else {
//都打印成功了 //都打印成功了
Log.e("eee", "打印成功"); Log.e("eee", "打印成功");
......
...@@ -2,94 +2,341 @@ package com.joe.print.mvp.print.service; ...@@ -2,94 +2,341 @@ package com.joe.print.mvp.print.service;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log; import android.util.Log;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.jess.arms.integration.RepositoryManager; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.joe.print.mvp.model.server.GetPrintInfoService; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.joe.print.mvp.model.bean.PrjBean;
import com.joe.print.mvp.print.PrintPrjKitchen;
import com.joe.print.mvp.print.PrinterRoot;
import java.util.concurrent.TimeUnit; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.Observer; import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import okhttp3.MediaType;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import okhttp3.RequestBody;
import static com.joe.print.mvp.print.PrinterRoot.PRINT_KITCHEN;
/** /**
* 在用戶登錄成功後,打開打印service,每隔3~5秒請求一次。請求到了數據就進行打印邏輯 * 在用戶登錄成功後,打開打印service,每隔3~5秒請求一次。請求到了數據就進行打印邏輯
*/ */
public class PrjService extends Service { public class PrjService extends Service implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener {
private Disposable disposable;
private Disposable wakeDisposable;
private List<PrinterDeviceBean> printerDeviceBeans;
private List<PrjBean.DataBean.Bean> printDatas = new ArrayList<>();
private final String TAG = "PrjService";
@Inject
RxErrorHandler mErrorHandler;
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Log.e("eee", "打開打印服務"); //讀取本地ip打印機
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
//開始請求 //開始請求
Observable.interval(0,3, TimeUnit.SECONDS) // startGetPrjInfo();
.doOnNext(aLong ->{ }
Log.d(TAG, "第" + aLong + "次輪詢");
/*
* 步骤3:通过Retrofit发送网络请求
*
**/
new RepositoryManager().obtainRetrofitService(GetPrintInfoService.class)
.getPrintInfo("26")
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> {})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> {})
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(Object o) {
Log.e("eee", "请求到:" + o);
}
@Override
public void onError(Throwable t) {
super.onError(t);
t.printStackTrace();
}
});
}).subscribe(new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
} @Nullable
@Override
public IBinder onBind(Intent intent) {
@Override return null;
public void onNext(Long aLong) { }
} /**
* 開啟輪詢查詢prj數據
*/
private void startGetPrjInfo() {
if (wakeDisposable != null && !wakeDisposable.isDisposed()) {
wakeDisposable.dispose();
}
Observable.interval(5, 10, TimeUnit.SECONDS)
.subscribe(new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
disposable = d;
}
@Override @Override
public void onError(Throwable e) { public void onNext(Long aLong) {
Log.d(TAG, "对Error事件作出响应" + e.getMessage()); getPrjInfo();
} cancel();
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
/**
* 請求prj數據
*/
private void getPrjInfo() {
OkHttp3Utils.get(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + "prg/get?restaurantId=" + GsaCloudApplication.getRestaurantId(this))
.subscribeOn(Schedulers.io())//切换到io线程進行網絡請求
.observeOn(AndroidSchedulers.mainThread())//切換到主線程處理請求結果
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String s) {
Log.e("eee", "數據" + s);
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
startPrint(s);
//開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。
Observable.timer(30, TimeUnit.SECONDS)
.subscribe(new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
wakeDisposable = d;
}
@Override
public void onNext(Long aLong) {
startGetPrjInfo();
}
@Override
public void onError(Throwable e) {
@Override }
public void onComplete() {
Log.d(TAG, "对onComplete事件作出响应"); @Override
public void onComplete() {
}
});
}
@Override
public void onError(Throwable e) {
Log.e("eee", "報錯:" + e.getMessage());
}
@Override
public void onComplete() {
}
});
}
/**
* 取消輪詢
*/
private void cancel() {
if (disposable != null) {
disposable.dispose();
}
}
private PrinterRoot printerInIt;
/**
* 開始打印
*/
private void startPrint(String json) {
printDatas.clear();
PrjBean prjBean = JsonUtils.parseObject(json, PrjBean.class);
Log.e("eee", "打開打印服務" + prjBean.getSysTime());
if (prjBean.getData() == null) {
return;
}
try {
JSONObject jsonObject = new JSONObject(prjBean.getData());
//通过迭代器获取这段json当中所有的key值
Iterator keys = jsonObject.keys();
//然后通过一个循环取出所有的key值
while (keys.hasNext()) {
String key = String.valueOf(keys.next());
//最后就可以通过刚刚得到的key值去解析后面的json了
JSONArray dataJson = (JSONArray) jsonObject.get(key);
List<PrjBean.DataBean.Bean> datas = JsonUtils.parseArray(dataJson.toString(), PrjBean.DataBean.Bean.class);
// if (key.equals("-1")) {
// PrintPrjKitchen.getPrjMap().put("", datas);
// } else {
PrintPrjKitchen.getPrjMap().put(key, datas);
// }
printDatas.addAll(datas);
Log.e("eee", "個數" + datas.size());
}
} catch (JSONException e) {
e.printStackTrace();
}
if (printerInIt == null) {
printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN);
}
if (printerInIt != null) {
printerInIt.setmContext(this);
for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this).entrySet()) {
//遍歷所有的需要打印的內容
for (int i = 0; i < printerDeviceBeans.size(); i++) {
//遍歷打印機列表,找到對應的打印機,沒找到的就不打印
if (entry.getKey().equalsIgnoreCase(printerDeviceBeans.get(i).getName())) {
Log.e("eee", "有打印機。。。");
printerInIt.ipDevicePrint(printerDeviceBeans.get(i), entry.getValue(), this, this);
break;
}
}
} }
}); }
} }
/**
* @param printState 打印狀態 1未打印 2打印中 3已打印
*/
private void updatePrjState(int printState) {
if (printDatas == null) {
return;
}
Long time = null;
if (printState == 3) {
time = TimeUtils.getCurrentTimeInLong();
}
for (int i = 0; i < printDatas.size(); i++) {
printDatas.get(i).setPrinterType(printState);
printDatas.get(i).setPrinterTime(time);
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(printDatas));
//打印過後,直接再讀數據,不用管是否已更新狀態。
startGetPrjInfo();
OkHttp3Utils.post(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + "prg/update", requestBody)
.subscribeOn(Schedulers.io())//切换到io线程進行網絡請求
.observeOn(AndroidSchedulers.mainThread())//切換到主線程處理請求結果
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String s) {
Log.e("eee", "數據" + s);
}
@Override
public void onError(Throwable e) {
Log.e("eee", "報錯:" + e.getMessage());
}
@Override
public void onComplete() {
}
});
}
@Nullable
@Override @Override
public IBinder onBind(Intent intent) { public void onStateChanged(int state, PrinterDeviceBean printerDeviceBean) {
String tip = "加載中";
switch (state) {
case PrintSocketHolder.ERROR_0:
Log.e("eee", "打印成功");
tip = "打印成功";
break;
case PrintSocketHolder.ERROR_1:
Log.e("eee", "生成測試頁面數據失敗");
tip = "生成打印數據失敗";
break;
case PrintSocketHolder.ERROR_2:
Log.e("eee", "連接打印機失敗" + System.currentTimeMillis());
case PrintSocketHolder.ERROR_3:
Log.e("eee", "獲取輸出流失敗");
tip = "連接打印機失敗";
break;
case PrintSocketHolder.ERROR_4:
Log.e("eee", "寫入測試頁面數據失敗");
tip = "寫入測試頁面數據失敗";
break;
case PrintSocketHolder.ERROR_5:
Log.e("eee", "必要的參數不能為空");
tip = "必要的參數不能為空";
break;
case PrintSocketHolder.STATE_0:
Log.e("eee", "生成測試頁數據");
case PrintSocketHolder.STATE_1:
Log.e("eee", "開始創建連接");
tip = "開始創建連接";
break;
case PrintSocketHolder.STATE_2:
Log.e("eee", "創建連接成功,開始發送數據");
tip = "創建連接成功,開始發送數據";
break;
case PrintSocketHolder.STATE_3:
Log.e("eee", "開始寫入數據");
tip = "開始寫入數據";
break;
case PrintSocketHolder.STATE_4:
Log.e("eee", "關閉中");
tip = "關閉中";
break;
}
Log.e("eee", "onStateChanged狀態:" + tip);
}
return null; @Override
public void onResult(int errorCode, PrinterDeviceBean printerDeviceBean) {
switch (errorCode) {
case PrintSocketHolder.ERROR_0:
Log.e("eee", "打印成功");
//更新狀態
updatePrjState(3);
break;
case PrintSocketHolder.ERROR_1:
Log.e("eee", "生成測試頁面數據失敗");
break;
case PrintSocketHolder.ERROR_2:
Log.e("eee", "連接打印機失敗");
//再次打開輪詢
updatePrjState(1);
case PrintSocketHolder.ERROR_3:
Log.e("eee", "獲取輸出流失敗");
break;
case PrintSocketHolder.ERROR_4:
Log.e("eee", "寫入測試頁面數據失敗");
break;
case PrintSocketHolder.ERROR_5:
Log.e("eee", "必要的參數不能為空");
break;
}
} }
} }
...@@ -22,6 +22,7 @@ import androidx.annotation.Nullable; ...@@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; 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.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
...@@ -119,7 +120,7 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta ...@@ -119,7 +120,7 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
ip = intent.getStringExtra("ip"); ip = intent.getStringExtra("ip");
port = intent.getIntExtra("port", 0); port = intent.getIntExtra("port", 0);
paperType = intent.getIntExtra("paperType", 1); paperType = intent.getIntExtra("paperType", 1);
type = intent.getIntExtra("type", -1); type = intent.getIntExtra(PrintConstans.PRINT_TYPE, -1);
if (ip == null || ip.equals("")) { if (ip == null || ip.equals("")) {
ip = "192.168.1.217"; ip = "192.168.1.217";
} }
......
...@@ -23,7 +23,9 @@ import com.billy.cc.core.component.CCResult; ...@@ -23,7 +23,9 @@ import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
...@@ -38,6 +40,7 @@ import com.joe.print.mvp.print.PrinterRoot; ...@@ -38,6 +40,7 @@ import com.joe.print.mvp.print.PrinterRoot;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.gingersoft.gsa.cloud.constans.PrintConstans.PRINT_TYPE;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -88,7 +91,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -88,7 +91,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
public int initView(@Nullable Bundle savedInstanceState) { public int initView(@Nullable Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
return 0; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0 return 0; //如果你不需要框架帮你设置 setContentView(id) 需要 自行设置,请返回 0
} }
...@@ -103,28 +106,28 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -103,28 +106,28 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
* 3:廚房單 * 3:廚房單
* 4:打印view * 4:打印view
*/ */
int type = CCUtil.getNavigateParam(this, "type", -1); int type = CCUtil.getNavigateParam(this, PRINT_TYPE, -1);
boolean isShowDialog = CCUtil.getNavigateParam(this, PrintConstans.PRINT_LOADING, true);
initDialog(); if (isShowDialog) {
initDialog();
}
PrinterDeviceBean deviceBean = (PrinterDeviceBean) getIntent().getSerializableExtra("deviceBean");
// if (type != PrinterRoot.PRINT_TEST) {
//不是测试才去获取打印机列表,获取到打印机列表之后就进行打印
// } PrinterDeviceBean deviceBean = CCUtil.getNavigateParam(this, "deviceBean", null);
printerInIt = PrinterRoot.getPrinterByType(type); printerInIt = PrinterRoot.getPrinterByType(type);
if (printerInIt != null) { if (printerInIt != null) {
printerInIt.setmContext(mContext).setPrintListener(this); printerInIt.setmContext(mContext).setPrintListener(this);
} }
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(mContext);
printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
if (type == PrinterRoot.PRINT_TEST) { if (type == PrinterRoot.PRINT_TEST) {
if (deviceBean != null) { if (deviceBean != null) {
printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get("")); printerInIt.ipDevicePrint(deviceBean, printerInIt.getPrintBitmap(mContext).get(""));
} else { } else {
ToastUtils.show(mContext, "测试失败"); ToastUtils.show(mContext, "测试失败");
finish();
} }
} else { } else {
if (printerDeviceBeans == null || printerDeviceBeans.size() <= 0) { if (printerDeviceBeans == null || printerDeviceBeans.size() <= 0) {
...@@ -224,9 +227,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -224,9 +227,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
tip = "關閉中"; tip = "關閉中";
break; break;
case DIMISS_LOADING: case DIMISS_LOADING:
if (mLoadingDialog != null) { disLoadingDialog();
mLoadingDialog.dismiss();
}
break; break;
case FINISH: case FINISH:
finish(); finish();
...@@ -245,6 +246,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -245,6 +246,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
public void printSuccess() { public void printSuccess() {
CC.sendCCResult(callId, CCResult.success()); CC.sendCCResult(callId, CCResult.success());
disLoadingDialog();
finish(); finish();
Log.e("eee", "打印成功,關閉頁面"); Log.e("eee", "打印成功,關閉頁面");
} }
...@@ -309,7 +311,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -309,7 +311,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
private void addPrintDevice() { private void addPrintDevice() {
ToastUtils.show(mContext, "沒有打印機,請添加"); ToastUtils.show(mContext, "沒有打印機,請添加");
startActivityForResult(new Intent(mContext, PrinterAddActivity.class), ADD_PRINT_CODE); // startActivityForResult(new Intent(mContext, PrinterAddActivity.class), ADD_PRINT_CODE);
} }
@Override @Override
...@@ -339,6 +341,10 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -339,6 +341,10 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
disLoadingDialog();
}
private void disLoadingDialog() {
if (mLoadingDialog != null) { if (mLoadingDialog != null) {
mLoadingDialog.dismiss(); mLoadingDialog.dismiss();
} }
......
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -7,18 +8,22 @@ import android.text.Editable; ...@@ -7,18 +8,22 @@ import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil; import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; 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.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
...@@ -28,9 +33,12 @@ import com.joe.print.R2; ...@@ -28,9 +33,12 @@ import com.joe.print.R2;
import com.joe.print.di.component.DaggerPrinterAddComponent; import com.joe.print.di.component.DaggerPrinterAddComponent;
import com.joe.print.mvp.contract.PrinterAddContract; import com.joe.print.mvp.contract.PrinterAddContract;
import com.joe.print.mvp.presenter.PrinterAddPresenter; import com.joe.print.mvp.presenter.PrinterAddPresenter;
import com.gingersoft.gsa.cloud.constans.PrintConstans; import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.ui.adapter.SelectPrintAdapter;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.BindViews; import butterknife.BindViews;
import butterknife.OnClick; import butterknife.OnClick;
...@@ -52,16 +60,20 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -52,16 +60,20 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
QMUITopBar topBar; QMUITopBar topBar;
@BindView(R2.id.add_printer_ed_port) @BindView(R2.id.add_printer_ed_port)
EditText etPort; EditText etPort;
@BindView(R2.id.print_test)
TextView printTest;
@BindView(R2.id.printer_type) @BindView(R2.id.printer_type)
RadioGroup rgPaperType; RadioGroup rgPaperType;
@BindView(R2.id.cb_set_default) @BindView(R2.id.switch_set_default)
CheckBox mCbDefalute; Switch mSwitchDefalute;
@BindView(R2.id.tv_print_fail_one)
TextView mTvFailNameOne;
@BindView(R2.id.tv_print_fail_two)
TextView mTvFailNameTwo;
private List<PrinterDeviceBean> devicess;
private PrinterDeviceBean printerDeviceBean; private PrinterDeviceBean printerDeviceBean;
private boolean isEditPrinter = false;//是否是編輯打印機 private boolean isEditPrinter = false;//是否是編輯打印機
private boolean isDefault = false;//是否是默認打印機
private int oneFailPosition = -1, twoFailPosition = -1;
@Override @Override
public void setupActivityComponent(@NonNull AppComponent appComponent) { public void setupActivityComponent(@NonNull AppComponent appComponent) {
...@@ -80,7 +92,6 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -80,7 +92,6 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
isDefault = getIntent().getBooleanExtra("isDefault", false);
String[] ips = new String[4]; String[] ips = new String[4];
//如果不為空,則是編輯打印機,初始化信息 //如果不為空,則是編輯打印機,初始化信息
if (printerDeviceBean != null) { if (printerDeviceBean != null) {
...@@ -92,6 +103,29 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -92,6 +103,29 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
} else { } else {
rgPaperType.check(R.id.print_paper_size_88); rgPaperType.check(R.id.print_paper_size_88);
} }
mSwitchDefalute.setChecked(printerDeviceBean.getStatus() == 2);
if (devicess != null && devicess.size() > 0) {
if (printerDeviceBean.getPrinterDeviceId() != null && printerDeviceBean.getPrinterDeviceId() != 0) {
//有飛單
for (int i = 0; i < devicess.size(); i++) {
if (devicess.get(i).getId() == printerDeviceBean.getPrinterDeviceId()) {
mTvFailNameOne.setText(devicess.get(i).getName());
oneFailPosition = i;
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
}
}
}
if (printerDeviceBean.getDefaultPrinterDeviceId() != null && printerDeviceBean.getDefaultPrinterDeviceId() != 0) {
//有飛單2222
for (int i = 0; i < devicess.size(); i++) {
if (devicess.get(i).getId() == printerDeviceBean.getDefaultPrinterDeviceId()) {
mTvFailNameTwo.setText(devicess.get(i).getName());
twoFailPosition = i;
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
}
}
}
}
} }
//添加監聽 //添加監聽
for (int i = 0; i < ipEdits.length; i++) { for (int i = 0; i < ipEdits.length; i++) {
...@@ -105,7 +139,14 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -105,7 +139,14 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override @Override
public void initIntent() { public void initIntent() {
printerDeviceBean = (PrinterDeviceBean) getIntent().getSerializableExtra("printerInfo"); int position = getIntent().getIntExtra("printer_position", 0);
devicess = (List<PrinterDeviceBean>) getIntent().getSerializableExtra("printList");
if (devicess != null) {
printerDeviceBean = devicess.get(position);
if (printerDeviceBean != null) {
devicess.remove(position);//從打印機列表中移除掉當前打印機,選擇飛單時不能選擇當前打印機
}
}
isEditPrinter = printerDeviceBean != null; isEditPrinter = printerDeviceBean != null;
} }
...@@ -118,7 +159,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -118,7 +159,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
topBar.setTitle(title); topBar.setTitle(title);
topBar.setBackgroundColor(getResources().getColor(R.color.theme_color)); topBar.setBackgroundColor(getResources().getColor(R.color.theme_color));
topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish()); topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish());
topBar.addRightTextButton("保存", R.id.printer_add).setOnClickListener(this); topBar.addRightTextButton("測試", R.id.print_test).setOnClickListener(this);
} }
@Override @Override
...@@ -164,54 +205,121 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -164,54 +205,121 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
finish(); finish();
} }
@OnClick({R2.id.print_test}) @OnClick({R2.id.printer_add, R2.id.layout_select_fail_one, R2.id.layout_select_fail_two})
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.printer_add || v.getId() == R.id.print_test) { int id = v.getId();
if (mEdPrintName.getText().toString().contains("/")) { if (id == R.id.printer_add || id == R.id.print_test) {
ToastUtils.show(mContext, "打印機名稱禁止帶/字符"); addOrTestPrint(v);
} else if (id == R.id.layout_select_fail_one || id == R.id.layout_select_fail_two) {
if (devicess == null || devicess.size() <= 0) {
showMessage("沒有其他打印機");
return; return;
} }
//保存打印機信息 selectFailPrint(id);
StringBuilder ipAddress = new StringBuilder(); }
for (EditText editText : ipEdits) { }
if (editText.getText() == null || editText.getText().toString().equals("")) {
showMessage("請輸入完整的IP地址"); private void selectFailPrint(int viewId) {
return; // 彈窗,顯示除當前打印機外所有打印機,
} new DialogUtils(this, R.layout.dialog_select_print) {
ipAddress.append(editText.getText()); @Override
ipAddress.append("."); public void initLayout(ViewHepler hepler, Dialog dialog) {
RecyclerView rv = hepler.getView(R.id.rv_select_print);
SelectPrintAdapter adapter = new SelectPrintAdapter(devicess);
adapter.setSelectPosion(viewId == R.id.layout_select_fail_one ? oneFailPosition : twoFailPosition);
adapter.setOnItemClickListener((adapter1, view, position1) -> {
if (viewId == R.id.layout_select_fail_one) {
oneFailPosition = position1;
} else {
twoFailPosition = position1;
}
adapter.setSelectPosion(position1);
dismiss();
});
rv.setLayoutManager(new LinearLayoutManager(mContext));
rv.setAdapter(adapter);
} }
hideKeyBoard(); }.setWidth((int) (ArmsUtils.getScreenWidth(this) * 0.6))
.setHeight((int) (ArmsUtils.getScreenHeidth(this) * 0.4))
.createDialogView()
.setOnDismissListener(dialog -> {
if (viewId == R.id.layout_select_fail_one) {
mTvFailNameOne.setText(devicess.get(oneFailPosition).getName());
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
} else {
mTvFailNameTwo.setText(devicess.get(twoFailPosition).getName());
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
}
})
.show();
}
int paperType = 1;//打印紙類型 /**
if (rgPaperType.getCheckedRadioButtonId() != R.id.print_paper_size_58) { * 添加或測試打印機
paperType = 2; */
private void addOrTestPrint(View v) {
if(mEdPrintName.getText() == null || mEdPrintName.getText().toString().isEmpty()){
ToastUtils.show(mContext, "請輸入打印機名稱");
return;
}
if (mEdPrintName.getText().toString().contains("%")) {
ToastUtils.show(mContext, "打印機名稱禁止輸入%字符");
return;
}
//保存打印機信息
StringBuilder ipAddress = new StringBuilder();
for (EditText editText : ipEdits) {
if (editText.getText() == null || editText.getText().toString().equals("")) {
showMessage("請輸入完整的IP地址");
return;
} }
ipAddress.append(editText.getText());
ipAddress.append(".");
}
hideKeyBoard();
int paperType = 1;//打印紙類型
if (rgPaperType.getCheckedRadioButtonId() != R.id.print_paper_size_58) {
paperType = 2;
}
String port = etPort.getText().toString(); String port = etPort.getText().toString();
PrinterDeviceBean deviceBean; PrinterDeviceBean deviceBean;
if (TextUtil.isEmptyOrNullOrUndefined(port)) { if (TextUtil.isEmptyOrNullOrUndefined(port)) {
deviceBean = new PrinterDeviceBean(mEdPrintName.getText().toString().trim(), 0, GsaCloudApplication.getRestaurantId(mContext), ipAddress.substring(0, ipAddress.lastIndexOf(".")), null, paperType); deviceBean = new PrinterDeviceBean(mEdPrintName.getText().toString().trim(), 0, GsaCloudApplication.getRestaurantId(mContext), ipAddress.substring(0, ipAddress.lastIndexOf(".")), 9100, paperType);
} else {
deviceBean = new PrinterDeviceBean(mEdPrintName.getText().toString().trim(), 0, GsaCloudApplication.getRestaurantId(mContext), ipAddress.substring(0, ipAddress.lastIndexOf(".")), Integer.parseInt(port), paperType);
}
if (oneFailPosition != -1) {
deviceBean.setPrinterDeviceId((long) devicess.get(oneFailPosition).getId());
}
if (twoFailPosition != -1) {
deviceBean.setDefaultPrinterDeviceId((long) devicess.get(twoFailPosition).getId());
}
deviceBean.setStatus(mSwitchDefalute.isChecked() ? 2 : 1);
//添加打印機
if (v.getId() == R.id.printer_add) {
if (isEditPrinter && printerDeviceBean != null) {
deviceBean.setId(printerDeviceBean.getId());
deviceBean.setRestaurantId(null);
mPresenter.updatePrinterInfo(deviceBean);
} else { } else {
deviceBean = new PrinterDeviceBean(mEdPrintName.getText().toString().trim(), 0, GsaCloudApplication.getRestaurantId(mContext), ipAddress.substring(0, ipAddress.lastIndexOf(".")), Integer.parseInt(port), paperType); mPresenter.addPrinter(deviceBean);
}
deviceBean.setStatus(mCbDefalute.isChecked() ? 2 : 1);
//添加打印機
if (v.getId() == R.id.printer_add) {
if (isEditPrinter && printerDeviceBean != null) {
deviceBean.setRestaurantId(null);
deviceBean.setId(printerDeviceBean.getId());
mPresenter.updatePrinterInfo(deviceBean);
} else {
mPresenter.addPrinter(deviceBean);
}
} else if (v.getId() == R.id.print_test) {
//打印測試
Intent intent = new Intent(mContext, PrintActivity.class);
intent.putExtra("deviceBean", deviceBean);
startActivity(intent);
} }
} else if (v.getId() == R.id.print_test) {
//打印測試
CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, PrinterRoot.PRINT_TEST)
.addParam("deviceBean", deviceBean)
.setActionName("printActivity")
.build()
.callAsyncCallbackOnMainThread((cc, result) -> {
//打印完之後
if (!result.isSuccess()) {
ToastUtils.show(this, "打印失敗");
}
});
} }
} }
...@@ -235,11 +343,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -235,11 +343,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
@Override @Override
public void updatePrinterSuccess(PrinterDeviceBean item) { public void updatePrinterSuccess(PrinterDeviceBean item) {
//修改打印機成功,如果這個打印機是用戶設置的默認打印機,則需要更新信息 //修改打印機成功,如果這個打印機是用戶設置的默認打印機,則需要更新信息
if (isDefault) {
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_IP, item.getIp());
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_PORT, item.getPort());
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_PAPER, item.getType());
}
} }
......
...@@ -48,6 +48,7 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -48,6 +48,7 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
@BindView(R2.id.printer_home_bar) @BindView(R2.id.printer_home_bar)
QMUITopBar topBar; QMUITopBar topBar;
@BindView(R2.id.print_table_layout) @BindView(R2.id.print_table_layout)
MyTableView mTabLayout; MyTableView mTabLayout;
@BindView(R2.id.print_viewpager) @BindView(R2.id.print_viewpager)
......
package com.joe.print.mvp.ui.adapter;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.joe.print.mvp.model.bean.PrjBean;
import java.math.BigDecimal;
import java.util.List;
/**
* Created by Wyh on 2020/2/20.
*/
public class KitChenPrjPrintFoodAdapter extends BaseQuickAdapter<PrjBean.DataBean.Bean, BaseViewHolder> {
private int indentation = 0;
public KitChenPrjPrintFoodAdapter(@Nullable List<PrjBean.DataBean.Bean> data) {
super(R.layout.print_kitchen_item_food, data);
}
@Override
protected void convert(BaseViewHolder helper, PrjBean.DataBean.Bean item) {
TextView textView = helper.getView(R.id.tv_food_name);
if (helper.getAdapterPosition() == 0) {
//只第一次測量一下
indentation = new BigDecimal(textView.getPaint().measureText("哈")).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
}
int paddingLeft;
if (item.getItemType() == 2) {
//細項,縮進
paddingLeft = indentation;
} else if (item.getItemType() == 3) {
//細項,縮進
paddingLeft = indentation * 2;
} else {
paddingLeft = 0;
}
textView.setPadding(paddingLeft, textView.getPaddingTop(), textView.getPaddingRight(), textView.getPaddingBottom());
helper.setText(R.id.tv_food_name, item.getProductName());
// helper.setText(R.id.tv_food_number, String.valueOf(item.getNumber()));
}
}
...@@ -8,7 +8,6 @@ import androidx.annotation.Nullable; ...@@ -8,7 +8,6 @@ import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder; import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
...@@ -23,43 +22,14 @@ import java.util.List; ...@@ -23,43 +22,14 @@ import java.util.List;
public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, BaseViewHolder> { public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, BaseViewHolder> {
private Context mContext; private Context mContext;
private int selectPosition = -1; private int selectPosition = -1;
private String selectPrintIp;//默認選中的打印機IP
private Integer selectPrintPort;//默認選中的打印機端口號
private int paperType;//默認選中的打印機紙張類型
public PrinterListAdapter(@Nullable List<PrinterDeviceBean> data, Context mContext) { public PrinterListAdapter(@Nullable List<PrinterDeviceBean> data, Context mContext) {
super(R.layout.printer_item, data); super(R.layout.printer_item, data);
this.mContext = mContext; this.mContext = mContext;
// selectPrintIp = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, "");
// if ((Integer) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, -1) != -1) {
// selectPrintPort = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, 0);
// }
// paperType = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PAPER, 0);
} }
@Override @Override
protected void convert(BaseViewHolder helper, PrinterDeviceBean item) { protected void convert(BaseViewHolder helper, PrinterDeviceBean item) {
// if (selectPosition == -1) {
// //ip、端口、紙張類型也要一致才是默認打印機
// if (selectPrintIp.equals(item.getIp()) && paperType == item.getType()) {
// if (selectPrintPort != null && item.getPort() != null) {
// if (selectPrintPort.equals(item.getPort())) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// selectPosition = helper.getAdapterPosition();
// }
// } else if (selectPrintPort == null && item.getPort() == null) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// selectPosition = helper.getAdapterPosition();
// }
// } else {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
// }
// } else if (selectPosition == helper.getAdapterPosition()) {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(true);
// } else {
// ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(false);
// }
helper.setText(R.id.tv_printer_name, item.getName() + ""); helper.setText(R.id.tv_printer_name, item.getName() + "");
helper.setText(R.id.tv_printer_ip, String.format(mContext.getString(R.string.print_ip), item.getIp())); helper.setText(R.id.tv_printer_ip, String.format(mContext.getString(R.string.print_ip), item.getIp()));
if (item.getPort() == null) { if (item.getPort() == null) {
...@@ -69,47 +39,8 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base ...@@ -69,47 +39,8 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
} }
((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(item.getStatus() == 2); ((RadioButton) helper.getView(R.id.cb_printer_item)).setChecked(item.getStatus() == 2);
helper.getView(R.id.tv_default_print).setVisibility(item.getStatus() == 2 ? View.VISIBLE : View.GONE); helper.getView(R.id.tv_default_print).setVisibility(item.getStatus() == 2 ? View.VISIBLE : View.GONE);
// helper.setOnCheckedChangeListener(R.id.cb_printer_item, (buttonView, isChecked) -> {
// if (getRecyclerView() != null) {
// if (getRecyclerView().isComputingLayout()) {//如果recyclerView在刷新時
// getRecyclerView().post(() -> setSelectPrint(helper, item, isChecked));
// } else {
// setSelectPrint(helper, item, isChecked);
// }
// }
// });
// helper.setOnClickListener(R.id.cb_printer_item, v -> {
// if (getRecyclerView() != null) {
// if (getRecyclerView().isComputingLayout()) {//如果recyclerView在刷新時
// getRecyclerView().post(() -> setSelectPrint(helper, item, true));
// } else {
// setSelectPrint(helper, item, true);
// }
// }
// });
} }
/**
* 設置默認選中打印機
*
* @param helper
* @param item
* @param isChecked
*/
private void setSelectPrint(BaseViewHolder helper, PrinterDeviceBean item, boolean isChecked) {
if (isChecked) {
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_IP, item.getIp());
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_PORT, item.getPort());
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_PAPER, item.getType());
if (selectPosition != -1) {
notifyItemChanged(selectPosition);
}
selectPosition = helper.getAdapterPosition();
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT);
ToastUtils.show(mContext, "已設置默認打印機");
}
}
public int getSelectPosition() { public int getSelectPosition() {
return selectPosition; return selectPosition;
...@@ -121,11 +52,6 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base ...@@ -121,11 +52,6 @@ public class PrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean, Base
public void notifyData(List<PrinterDeviceBean> data) { public void notifyData(List<PrinterDeviceBean> data) {
this.mData = data; this.mData = data;
selectPrintIp = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_IP, "");
if (SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, null) != null) {
selectPrintPort = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PORT, 0);
}
paperType = (int) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_PAPER, 0);
super.notifyDataSetChanged(); super.notifyDataSetChanged();
} }
} }
package com.joe.print.mvp.ui.adapter;
import android.widget.RadioButton;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.joe.print.R;
import java.util.List;
public class SelectPrintAdapter extends BaseQuickAdapter<PrinterDeviceBean, BaseViewHolder> {
private int selectPosion = 0;
public SelectPrintAdapter(@Nullable List<PrinterDeviceBean> data) {
super(R.layout.item_dialog_select_print, data);
}
@Override
protected void convert(BaseViewHolder helper, PrinterDeviceBean item) {
helper.setText(R.id.tv_item_print_name, item.getName() + "");
RadioButton rb = helper.getView(R.id.rb_item_print);
rb.setChecked(helper.getAdapterPosition() == selectPosion);
}
public int getSelectPosion() {
return selectPosion;
}
public void setSelectPosion(int selectPosion) {
this.selectPosion = selectPosion;
notifyDataSetChanged();
}
}
...@@ -8,16 +8,20 @@ import android.view.LayoutInflater; ...@@ -8,16 +8,20 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager; import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.jess.arms.base.BaseFragment; import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -36,10 +40,14 @@ import com.yanzhenjie.recyclerview.SwipeRecyclerView; ...@@ -36,10 +40,14 @@ import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.yanzhenjie.recyclerview.touch.OnItemMoveListener; import com.yanzhenjie.recyclerview.touch.OnItemMoveListener;
import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener; import com.yanzhenjie.recyclerview.touch.OnItemStateChangedListener;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration; import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -193,6 +201,12 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -193,6 +201,12 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
@Override @Override
public void loadPrinterList(List<PrinterDeviceBean> deviceBeans) { public void loadPrinterList(List<PrinterDeviceBean> deviceBeans) {
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(getActivity());
printerDeviceDaoUtils.deleteAll();
if (deviceBeans != null) {
printerDeviceDaoUtils.insertMultPrinterDeviceBean(deviceBeans);
}
mRvPrintList.setVisibility(View.VISIBLE); mRvPrintList.setVisibility(View.VISIBLE);
mTvAddPrint.setVisibility(View.GONE); mTvAddPrint.setVisibility(View.GONE);
...@@ -203,11 +217,8 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -203,11 +217,8 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
mRvPrintList.setOnItemClickListener((view, adapterPosition) -> { mRvPrintList.setOnItemClickListener((view, adapterPosition) -> {
//item點擊事件 打開打印機詳情 //item點擊事件 打開打印機詳情
Intent intent = new Intent(mContext, PrinterAddActivity.class); Intent intent = new Intent(mContext, PrinterAddActivity.class);
intent.putExtra("printerInfo", devicess.get(adapterPosition)); intent.putExtra("printer_position", adapterPosition);
if(printListAdapter.getSelectPosition() == adapterPosition){ intent.putExtra("printList", (Serializable) devicess);
//如果當前點擊的是默認打印機,那麼編輯後的信息需要保存
intent.putExtra("isDefault", true);
}
startActivity(intent); startActivity(intent);
}); });
//menu 右侧菜單點擊事件 //menu 右侧菜單點擊事件
...@@ -261,7 +272,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -261,7 +272,7 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
printListAdapter = new PrinterListAdapter(devicess, mContext); printListAdapter = new PrinterListAdapter(devicess, mContext);
mRvPrintList.setLayoutManager(new LinearLayoutManager(mContext)); mRvPrintList.setLayoutManager(new LinearLayoutManager(mContext));
//分割线 //分割线
mRvPrintList.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color))); // mRvPrintList.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mContext, R.color.line_color)));
mRvPrintList.setSwipeMenuCreator(mSwipeMenuCreator); // 菜单创建器。 mRvPrintList.setSwipeMenuCreator(mSwipeMenuCreator); // 菜单创建器。
// mRvPrintList.setAdapter(printListAdapter); // mRvPrintList.setAdapter(printListAdapter);
printListAdapter.bindToRecyclerView(mRvPrintList); printListAdapter.bindToRecyclerView(mRvPrintList);
......
...@@ -11,8 +11,8 @@ import android.widget.Switch; ...@@ -11,8 +11,8 @@ import android.widget.Switch;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.jess.arms.base.BaseFragment; import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -65,18 +65,18 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem ...@@ -65,18 +65,18 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem
ivSetLocationPrintBtn.setOnCheckedChangeListener((buttonView, isChecked) -> { ivSetLocationPrintBtn.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked){ if(isChecked){
//修改默認打印方式為本地 //修改默認打印方式為本地
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT);
ivSetLocationPrintBtn.setChecked(true); ivSetLocationPrintBtn.setChecked(true);
} else { } else {
//如果默認打印方式為IP,修改為IP打印 //如果默認打印方式為IP,修改為IP打印
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.IP_PRINT);
ivSetLocationPrintBtn.setChecked(false); ivSetLocationPrintBtn.setChecked(false);
} }
}); });
} }
private void initBtn() { private void initBtn() {
if (SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, "").equals(Constans.LOCAL_PRINT)) { if (SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_METHOD, "").equals(PrintConstans.LOCAL_PRINT)) {
//如果默認打印方式為本地 //如果默認打印方式為本地
ivSetLocationPrintBtn.setChecked(true); ivSetLocationPrintBtn.setChecked(true);
} else { } else {
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
<com.yanzhenjie.recyclerview.SwipeRecyclerView <com.yanzhenjie.recyclerview.SwipeRecyclerView
android:id="@+id/rc_ip_print" android:id="@+id/rc_ip_print"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10" />
<TextView <TextView
android:id="@+id/tv_add_print" android:id="@+id/tv_add_print"
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:text="在線支付:支付寶HK" android:text="在線支付:"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_26" android:textSize="@dimen/dp_26"
android:textStyle="bold" /> android:textStyle="bold" />
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:text="盡快送達:05-06 12:00"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_18" android:textSize="@dimen/dp_18"
android:textStyle="bold" /> android:textStyle="bold" />
...@@ -71,12 +70,27 @@ ...@@ -71,12 +70,27 @@
android:text="@string/print_split_line" android:text="@string/print_split_line"
android:textColor="@color/theme_333_color" /> android:textColor="@color/theme_333_color" />
<TextView <LinearLayout
android:id="@+id/tv_order_number" android:layout_width="match_parent"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text='訂單號:000001' /> android:orientation="horizontal">
<TextView
android:id="@+id/tv_order_number"
style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='訂單號:' />
<TextView
android:id="@+id/tv_order_take_food_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_22"
android:textStyle="bold"/>
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_order_create" android:id="@+id/tv_order_create"
...@@ -90,7 +104,7 @@ ...@@ -90,7 +104,7 @@
style="@style/printOtherOrderTextStyle_font_style_twenty" style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="備註:少油少鹽,微辣" android:text="備註:"
android:textSize="@dimen/dp_26" android:textSize="@dimen/dp_26"
android:textStyle="bold" /> android:textStyle="bold" />
...@@ -248,7 +262,7 @@ ...@@ -248,7 +262,7 @@
style="@style/printOtherOrderInfoPrintBoldTextStyle" style="@style/printOtherOrderInfoPrintBoldTextStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="$10000" android:text=""
android:textSize="@dimen/dp_26" android:textSize="@dimen/dp_26"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@id/tv_pay_amount_text" app:layout_constraintLeft_toRightOf="@id/tv_pay_amount_text"
...@@ -268,7 +282,7 @@ ...@@ -268,7 +282,7 @@
style="@style/printOtherOrderTextStyle_font_style_twenty" style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="地址:******" android:text="地址:"
android:textSize="@dimen/dp_26" /> android:textSize="@dimen/dp_26" />
<TextView <TextView
...@@ -277,15 +291,15 @@ ...@@ -277,15 +291,15 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:text="收貨人:******" /> android:text="收貨人:" />
<TextView <TextView
android:id="@+id/tv_phone" android:id="@+id/tv_phone"
style="@style/printOtherOrderTextStyle_font_style_twenty" style="@style/printOtherOrderTextStyle_font_style_twenty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="手機號:******" /> android:layout_marginTop="@dimen/dp_5"
android:text="手機號:" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -18,20 +18,28 @@ ...@@ -18,20 +18,28 @@
style="@style/print_other_order_eighteen_style" style="@style/print_other_order_eighteen_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="廚房時間:12346546" /> android:text="廚房時間:" />
<TextView
android:id="@+id/tv_order_take_code"
style="@style/print_other_order_eighteen_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取餐碼:"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_operator_name" android:id="@+id/tv_operator_name"
style="@style/print_other_order_eighteen_style" style="@style/print_other_order_eighteen_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="操作test" /> android:text="操作" />
<TextView <TextView
android:id="@+id/tv_order_send_time" android:id="@+id/tv_order_send_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="送貨時間:04-15" android:text="送貨時間:"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_22" /> android:textSize="@dimen/dp_22" />
...@@ -56,7 +64,7 @@ ...@@ -56,7 +64,7 @@
android:id="@+id/tv_order_number" android:id="@+id/tv_order_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="訂單號:000032" android:text="訂單號:"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_18" /> android:textSize="@dimen/dp_18" />
......
...@@ -16,17 +16,14 @@ ...@@ -16,17 +16,14 @@
<LinearLayout <LinearLayout
style="@style/print_add_printer_input_style" style="@style/print_add_printer_input_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.3" android:layout_weight="0.3"
android:text="名稱" android:text="名稱" />
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<EditText <EditText
android:id="@+id/add_printer_ed_name" android:id="@+id/add_printer_ed_name"
...@@ -51,17 +48,14 @@ ...@@ -51,17 +48,14 @@
<LinearLayout <LinearLayout
style="@style/print_add_printer_input_style" style="@style/print_add_printer_input_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.3" android:layout_weight="0.3"
android:text="打印機IP" android:text="打印機IP" />
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
...@@ -71,8 +65,9 @@ ...@@ -71,8 +65,9 @@
<EditText <EditText
android:id="@+id/ip_edit_1" android:id="@+id/ip_edit_1"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:hint="0" android:hint="0"
android:inputType="number" android:inputType="number"
...@@ -96,8 +91,9 @@ ...@@ -96,8 +91,9 @@
<EditText <EditText
android:id="@+id/ip_edit_2" android:id="@+id/ip_edit_2"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:hint="0" android:hint="0"
android:inputType="number" android:inputType="number"
...@@ -121,8 +117,9 @@ ...@@ -121,8 +117,9 @@
<EditText <EditText
android:id="@+id/ip_edit_3" android:id="@+id/ip_edit_3"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:hint="0" android:hint="0"
android:inputType="number" android:inputType="number"
...@@ -146,8 +143,9 @@ ...@@ -146,8 +143,9 @@
<EditText <EditText
android:id="@+id/ip_edit_4" android:id="@+id/ip_edit_4"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:hint="0" android:hint="0"
android:inputType="number" android:inputType="number"
...@@ -166,17 +164,14 @@ ...@@ -166,17 +164,14 @@
<LinearLayout <LinearLayout
style="@style/print_add_printer_input_style" style="@style/print_add_printer_input_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.3" android:layout_weight="0.3"
android:text="端口號" android:text="端口號" />
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<EditText <EditText
android:id="@+id/add_printer_ed_port" android:id="@+id/add_printer_ed_port"
...@@ -185,7 +180,7 @@ ...@@ -185,7 +180,7 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_weight="0.7" android:layout_weight="0.7"
android:background="@null" android:background="@null"
android:hint="請輸入端口號" android:hint="請輸入端口號,默認9100"
android:inputType="number" android:inputType="number"
android:maxLength="4" android:maxLength="4"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
...@@ -198,17 +193,14 @@ ...@@ -198,17 +193,14 @@
<LinearLayout <LinearLayout
style="@style/print_add_printer_input_style" style="@style/print_add_printer_input_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.3" android:layout_weight="0.3"
android:text="紙張規格" android:text="紙張規格" />
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
<RadioGroup <RadioGroup
android:id="@+id/printer_type" android:id="@+id/printer_type"
...@@ -231,7 +223,7 @@ ...@@ -231,7 +223,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:text="88mm" android:text="80mm"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
</RadioGroup> </RadioGroup>
...@@ -242,41 +234,112 @@ ...@@ -242,41 +234,112 @@
<LinearLayout <LinearLayout
style="@style/print_add_printer_input_style" style="@style/print_add_printer_input_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.3" android:layout_weight="1"
android:text="設為默認" android:text="設為默認" />
android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" <Switch
android:textStyle="bold" /> android:id="@+id/switch_set_default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/shape_thumb_on"
android:track="@drawable/selector_switch_track"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
android:id="@+id/layout_select_fail_one"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<CheckBox <TextView
android:id="@+id/cb_set_default" style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="打印失敗由此打印" />
<TextView
android:id="@+id/tv_print_fail_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_7"
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>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
android:id="@+id/layout_select_fail_two"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="打印失敗由此打印" />
<TextView
android:id="@+id/tv_print_fail_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_7"
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_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.7" /> android:src="@drawable/ic_black_next_arrow" />
</LinearLayout> </LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" /> <include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView <TextView
android:id="@+id/print_test" android:id="@+id/printer_add"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/printer_add_input_paddingLeft" android:layout_marginLeft="@dimen/printer_add_input_paddingLeft"
android:layout_marginTop="@dimen/dp_30" android:layout_marginTop="@dimen/dp_30"
android:layout_marginRight="@dimen/printer_add_input_paddingLeft" android:layout_marginRight="@dimen/printer_add_input_paddingLeft"
android:layout_marginBottom="@dimen/dp_20"
android:background="@drawable/shape_app_btn" android:background="@drawable/shape_app_btn"
android:gravity="center" android:gravity="center"
android:paddingTop="@dimen/dp_10" android:paddingTop="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10" android:paddingBottom="@dimen/dp_10"
android:text="打印測試" android:text="保存"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_16" /> android:textSize="@dimen/dp_16" />
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="@dimen/dp_10" android:paddingTop="@dimen/dp_10">
android:paddingBottom="@dimen/dp_10">
<RadioButton <RadioButton
android:id="@+id/cb_printer_item" android:id="@+id/cb_printer_item"
...@@ -20,11 +19,11 @@ ...@@ -20,11 +19,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_19"
android:gravity="center" android:gravity="center"
android:text="asdasda" android:text="asdasda"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:textSize="@dimen/dp_16" android:textSize="@dimen/dp_19"
app:layout_constraintLeft_toRightOf="@id/cb_printer_item" app:layout_constraintLeft_toRightOf="@id/cb_printer_item"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
...@@ -32,52 +31,61 @@ ...@@ -32,52 +31,61 @@
android:id="@+id/tv_default_print" android:id="@+id/tv_default_print"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_14"
android:background="@color/theme_color" android:background="@drawable/shape_theme_color_bg"
android:padding="@dimen/dp_1" android:padding="@dimen/dp_1"
android:paddingLeft="@dimen/dp_8"
android:paddingTop="@dimen/dp_3"
android:paddingRight="@dimen/dp_8"
android:paddingBottom="@dimen/dp_3"
android:text="默認" android:text="默認"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_10" android:textSize="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="@id/tv_printer_name"
app:layout_constraintLeft_toRightOf="@id/tv_printer_name" app:layout_constraintLeft_toRightOf="@id/tv_printer_name"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="@id/tv_printer_name" />
<TextView <TextView
android:id="@+id/tv_printer_ip" android:id="@+id/tv_printer_ip"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_13"
android:singleLine="true" android:singleLine="true"
android:text="IP:" android:text="IP:"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_12"
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintLeft_toLeftOf="@id/tv_printer_name" app:layout_constraintLeft_toLeftOf="@id/tv_printer_name"
app:layout_constraintRight_toLeftOf="@id/tv_printer_port"
app:layout_constraintTop_toBottomOf="@id/tv_printer_name" /> app:layout_constraintTop_toBottomOf="@id/tv_printer_name" />
<TextView <TextView
android:id="@+id/tv_printer_port" android:id="@+id/tv_printer_port"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:singleLine="true" android:singleLine="true"
android:text="端口號:" android:text="端口號:"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:textSize="@dimen/dp_14" android:textSize="@dimen/dp_12"
app:layout_constraintHorizontal_weight="0.5" app:layout_constraintLeft_toLeftOf="@id/tv_printer_ip"
app:layout_constraintLeft_toRightOf="@id/tv_printer_ip" app:layout_constraintTop_toBottomOf="@id/tv_printer_ip" />
app:layout_constraintRight_toRightOf="@id/tv_printer_edit"
app:layout_constraintTop_toTopOf="@id/tv_printer_ip" />
<TextView <ImageView
android:id="@+id/tv_printer_edit" android:id="@+id/tv_printer_edit"
android:layout_width="wrap_content" android:layout_width="@dimen/dp_17"
android:layout_height="wrap_content" android:layout_height="@dimen/dp_17"
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_19"
android:src="@drawable/ic_edit"
android:text="編輯" android:text="編輯"
android:textColor="@color/theme_color"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/horizontal_dividing_line"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:layout_marginTop="@dimen/dp_10"
android:background="@color/color_ccc"
app:layout_constraintTop_toBottomOf="@id/tv_printer_port" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<resources> <resources>
<!-- 添加打印機 輸入信息的間距--> <!-- 添加打印機 輸入信息的間距-->
<dimen name="printer_add_input_paddingLeft">@dimen/dp_10</dimen> <dimen name="printer_add_input_paddingLeft">@dimen/dp_20</dimen>
<dimen name="printer_add_input_paddingTop">@dimen/dp_20</dimen> <dimen name="printer_add_input_paddingTop">@dimen/dp_20</dimen>
<dimen name="printer_add_input_paddingBottom">@dimen/dp_10</dimen> <dimen name="printer_add_input_paddingBottom">@dimen/dp_10</dimen>
<dimen name="printer_add_input_height">@dimen/dp_50</dimen>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<item name="printer_add" type="id"/> <item name="print_test" type="id"/>
</resources> </resources>
\ No newline at end of file
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
<style name="print_add_printer_input_style"> <style name="print_add_printer_input_style">
<item name="android:gravity">center_vertical</item> <item name="android:gravity">center_vertical</item>
<item name="android:layout_height">@dimen/printer_add_input_height</item>
<item name="android:paddingLeft">@dimen/printer_add_input_paddingLeft</item> <item name="android:paddingLeft">@dimen/printer_add_input_paddingLeft</item>
<item name="android:paddingRight">@dimen/printer_add_input_paddingLeft</item> <item name="android:paddingRight">@dimen/printer_add_input_paddingLeft</item>
<item name="android:paddingTop">@dimen/printer_add_input_paddingTop</item> <!-- <item name="android:paddingTop">@dimen/printer_add_input_paddingTop</item>-->
<item name="android:paddingBottom">@dimen/printer_add_input_paddingBottom</item> <!-- <item name="android:paddingBottom">@dimen/printer_add_input_paddingBottom</item>-->
</style> </style>
<style name="print_other_order_eighteen_style"> <style name="print_other_order_eighteen_style">
...@@ -32,4 +33,9 @@ ...@@ -32,4 +33,9 @@
<item name="android:textColor">@color/theme_333_color</item> <item name="android:textColor">@color/theme_333_color</item>
<item name="android:textStyle">bold</item> <item name="android:textStyle">bold</item>
</style> </style>
<style name="print_add_title_textStyle">
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textColor">@color/normal_color</item>
</style>
</resources> </resources>
\ No newline at end of file
.idea
.DS_Store
local.properties
/*.iml
/build
ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle")
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
multiDexEnabled true
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug {
buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false
}
release {
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "boolean", "USE_CANARY", "false"
minifyEnabled false
zipAlignEnabled false
}
}
}
dependencies {
def lintVersion = '26.4.2'
// compileOnly "com.android.tools.lint:lint-api:$lintVersion"
// compileOnly "com.android.tools.lint:lint-checks:$lintVersion"
}
//jar {
// manifest {
// attributes("Lint-Registry-v2": 'com.qmuiteam.qmui.lint.QMUIIssueRegistry')
// }
//}
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.qmuiteam.lint">
</manifest>
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.tools.lint.client.api.JavaEvaluator;
import com.android.tools.lint.client.api.UElementHandler;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.JavaContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import com.google.common.collect.Lists;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.uast.UCallExpression;
import org.jetbrains.uast.UElement;
import org.jetbrains.uast.UExpression;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
/**
* 检测 QMUILog 中是否使用了 F Word。
* Created by Kayo on 2017/9/19.
*/
public class QMUIFWordDetector extends Detector implements Detector.UastScanner {
public static final Issue ISSUE_F_WORD =
Issue.create("QMUIDontUseTheFWordInLog",
"Please, don't use the f word, type something more nicely.",
"Do I need to explain this? \uD83D\uDD95",
Category.CORRECTNESS, 5, Severity.WARNING,
new Implementation(QMUIFWordDetector.class, EnumSet.of(Scope.JAVA_FILE)));
@Nullable
@Override
public List<Class<? extends UElement>> getApplicableUastTypes() {
return Lists.<Class<? extends UElement>>newArrayList(
UCallExpression.class);
}
@Nullable
@Override
public UElementHandler createUastHandler(@NotNull JavaContext context) {
return new FWordHandler(context);
}
static class FWordHandler extends UElementHandler {
private static final List<String> checkMedthods = Arrays.asList("e", "w", "i", "d");
private static final List<String> fWords = Arrays.asList("fuck", "bitch", "bullshit");
private JavaContext mJavaContext;
FWordHandler(@NotNull JavaContext context) {
mJavaContext = context;
}
@Override
public void visitCallExpression(@NotNull UCallExpression node) {
JavaEvaluator evaluator = mJavaContext.getEvaluator();
PsiMethod method = node.resolve();
if (evaluator.isMemberInClass(method, "android.util.Log") ||
evaluator.isMemberInClass(method, "com.qmuiteam.qmui.QMUILog")) {
String methodName = node.getMethodName();
if (checkMedthods.contains(methodName)) {
List<UExpression> expressions = node.getValueArguments();
for (UExpression expression : expressions) {
String text = expression.asRenderString();
for(String fword: fWords){
int index = text.indexOf(fword);
if(index >= 0){
mJavaContext.report(
ISSUE_F_WORD, expression,
mJavaContext.getRangeLocation(expression, index, fword.length()), "\uD83D\uDD95");
}
}
}
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.ResourceContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
/**
* 检测图片的尺寸的正确性,例如2倍图的宽高应该为偶数,3倍图的宽高应该为3的倍数
* Created by Kayo on 2017/9/7.
*/
public class QMUIImageScaleDetector extends Detector implements Detector.BinaryResourceScanner {
public static final Issue ISSUE_IMAGE_SCALE =
Issue.create("QMUIImageSizeDisproportionate",
"The size of this image is disproportionate.",
"Please check the size of the image, for example, the height and width of the 3x plot should be 1.5 times 2x plot.",
Category.ICONS, 4, Severity.WARNING,
new Implementation(QMUIImageScaleDetector.class, Scope.BINARY_RESOURCE_FILE_SCOPE));
private static final String IGNORE_IMAGE_NIGHT_PNG = ".9.png";
private static final String CHECK_IMAGE_WEBP = ".webp";
private static final String CHECK_IMAGE_PNG = ".png";
private static final String CHECK_IMAGE_JPEG = ".jpeg";
private static final String CHECK_IMAGE_JPG = ".jpg";
@Override
public boolean appliesTo(ResourceFolderType var1) {
return var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.MIPMAP)) || var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.DRAWABLE));
}
@Override
public void checkBinaryResource(ResourceContext context) {
String filename = context.file.getName();
if (filename.contains(IGNORE_IMAGE_NIGHT_PNG)) {
return;
}
if (filename.contains(CHECK_IMAGE_WEBP) || filename.contains(CHECK_IMAGE_PNG) || filename.contains(CHECK_IMAGE_JPEG) || filename.contains(CHECK_IMAGE_JPG)) {
String filePath = context.file.getPath();
String pattern = ".*?[mipmap|drawable]\\-xhdpi.*?";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(filePath);
if (m.find()) {
String threePlotFilePath = filePath.replace("xhdpi", "xxhdpi");
File threePlotFile = new File(threePlotFilePath);
try {
BufferedImage targetImage = ImageIO.read(context.file);
int targetWidth = targetImage.getWidth();
int targetHeight = targetImage.getHeight();
BufferedImage threePlotImage = ImageIO.read(threePlotFile);
int threePlotWidth = threePlotImage.getWidth();
int threePlotHeight = threePlotImage.getHeight();
if ((double) threePlotWidth / targetWidth != 1.5 || (double) threePlotHeight / targetHeight != 1.5) {
Location fileLocation = Location.create(context.file);
context.report(ISSUE_IMAGE_SCALE, fileLocation, "2倍图 " + filePath +
" 与其3倍图宽高分别为 (" + targetWidth + ", " + targetHeight + ") 和 (" + threePlotWidth + ", " + threePlotHeight + "),不符合比例关系。");
}
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.ResourceContext;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import java.awt.image.BufferedImage;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
/**
* 检测图片的尺寸的正确性,例如2倍图的宽高应该为偶数,3倍图的宽高应该为3的倍数
* Created by Kayo on 2017/8/30.
*/
public class QMUIImageSizeDetector extends Detector implements Detector.BinaryResourceScanner {
public static final Issue ISSUE_IMAGE_SIZE =
Issue.create("QMUIImageSizeInvalid",
"The size of this image is not correct.",
"Please check the size of the image, for example, the height and width of the 2x plot should be even.",
Category.ICONS, 2, Severity.WARNING,
new Implementation(QMUIImageSizeDetector.class, Scope.BINARY_RESOURCE_FILE_SCOPE));
private static final String IGNORE_IMAGE_NIGHT_PNG = ".9.png";
private static final String CHECK_IMAGE_WEBP = ".webp";
private static final String CHECK_IMAGE_PNG = ".png";
private static final String CHECK_IMAGE_JPEG = ".jpeg";
private static final String CHECK_IMAGE_JPG = ".jpg";
/**
* 去掉数值多余的0与小数点符号
*/
public static String trimZeroAndDot(double number) {
String value = String.valueOf(number);
if (value.indexOf(".") > 0) {
value = value.replaceAll("0+?$", ""); // 去掉多余的0
value = value.replaceAll("[.]$", ""); // 若此时最后一位是小数点符号,则去掉该符号
}
return value;
}
@Override
public boolean appliesTo(ResourceFolderType var1) {
return var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.MIPMAP)) || var1.getName().equalsIgnoreCase(String.valueOf(ResourceFolderType.DRAWABLE));
}
@Override
public void checkBinaryResource(ResourceContext context) {
String filename = context.file.getName();
if (filename.contains(IGNORE_IMAGE_NIGHT_PNG)) {
return;
}
if (filename.contains(CHECK_IMAGE_WEBP) || filename.contains(CHECK_IMAGE_PNG) || filename.contains(CHECK_IMAGE_JPEG) || filename.contains(CHECK_IMAGE_JPG)) {
String filePath = context.file.getPath();
String pattern = ".*?[mipmap|drawable]\\-(x*)hdpi.*?";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(filePath);
if (m.find()) {
double multiple = 1.5;
if (m.group(1).length() > 0) {
multiple = m.group(1).length() + 1;
}
try {
BufferedImage targetImage = ImageIO.read(context.file);
int width = targetImage.getWidth();
int height = targetImage.getHeight();
if (width % multiple != 0 || height % multiple != 0) {
Location fileLocation = Location.create(context.file);
context.report(ISSUE_IMAGE_SIZE, fileLocation, filePath + " 为" + trimZeroAndDot(multiple) + "倍图,其宽高应该是" + trimZeroAndDot(multiple) + "的倍数,目前宽高为 (" + width + ", " + height + ")。");
}
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.tools.lint.client.api.IssueRegistry;
import com.android.tools.lint.detector.api.Issue;
import java.util.Arrays;
import java.util.List;
import static com.android.tools.lint.detector.api.ApiKt.CURRENT_API;
@SuppressWarnings("unused")
public final class QMUIIssueRegistry extends IssueRegistry {
@Override public List<Issue> getIssues() {
return Arrays.asList(
QMUIFWordDetector.ISSUE_F_WORD,
QMUIJavaVectorDrawableDetector.ISSUE_JAVA_VECTOR_DRAWABLE,
QMUIXmlVectorDrawableDetector.ISSUE_XML_VECTOR_DRAWABLE,
QMUIImageSizeDetector.ISSUE_IMAGE_SIZE,
QMUIImageScaleDetector.ISSUE_IMAGE_SCALE
);
}
@Override
public int getApi() {
return CURRENT_API;
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import android.icu.util.ULocale;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import javax.inject.Scope;
/**
* 检测是否在 getDrawable 方法中传入了 Vector Drawable,在 4.0 及以下版本的系统中会导致 Crash
* Created by Kayo on 2017/8/24.
*/
public class QMUIJavaVectorDrawableDetector extends Detector implements Detector.UastScanner {
public static final Issue ISSUE_JAVA_VECTOR_DRAWABLE =
Issue.create("QMUIGetVectorDrawableWithWrongFunction",
"Should use the corresponding method to get vector drawable.",
"Using the normal method to get the vector drawable will cause a crash on Android versions below 4.0",
ULocale.Category.CORRECTNESS, 8, Severity.ERROR,
new Implementation(QMUIJavaVectorDrawableDetector.class, Scope.JAVA_FILE_SCOPE));
@Override
public List<String> getApplicableMethodNames() {
return Collections.singletonList("getDrawable");
}
@Override
public void visitMethod(@NotNull JavaContext context,
@Nullable JavaElementVisitor visitor,
@NotNull PsiMethodCallExpression call,
@NotNull PsiMethod method) {
super.visitMethod(context, visitor, call, method);
PsiExpressionList args = call.getArgumentList();
if (args.getExpressions().length == 0) {
return;
}
Project project = context.getProject();
List<File> resourceFolder = project.getResourceFolders();
if (resourceFolder.isEmpty()) {
return;
}
String resourcePath = resourceFolder.get(0).getAbsolutePath();
for (PsiExpression expression : args.getExpressions()) {
String input = expression.toString();
if (input != null && input.contains("R.drawable")) {
// 找出 drawable 相关的参数
// 获取 drawable 名字
String drawableName = input.replace("R.drawable.", "");
try {
// 若 drawable 为 Vector Drawable,则文件后缀为 xml,根据 resource 路径,drawable 名字,文件后缀拼接出完整路径
FileInputStream fileInputStream = new FileInputStream(resourcePath + "/drawable/" + drawableName + ".xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
String line = reader.readLine();
if (line.contains("vector")) {
// 若文件存在,并且包含首行包含 vector,则为 Vector Drawable,抛出警告
context.report(ISSUE_JAVA_VECTOR_DRAWABLE, method, context.getLocation(method), expression.toString() + " 为 Vector Drawable,请使用 getVectorDrawable 方法获取,避免 4.0 及以下版本的系统产生 Crash");
}
reader.close();
fileInputStream.close();
} catch (Exception ignored) {
}
}
}
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qmuiteam.qmui.lint;
import com.android.annotations.NonNull;
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Project;
import com.android.tools.lint.detector.api.ResourceXmlDetector;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import com.android.tools.lint.detector.api.XmlContext;
import com.google.common.collect.Lists;
import org.w3c.dom.Attr;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.List;
import static com.android.SdkConstants.ATTR_DRAWABLE_BOTTOM;
import static com.android.SdkConstants.ATTR_DRAWABLE_LEFT;
import static com.android.SdkConstants.ATTR_DRAWABLE_RIGHT;
import static com.android.SdkConstants.ATTR_DRAWABLE_TOP;
/**
* 检测是否在 drawableLeft / drawableRight / drawableTop / drawableBottom 中传入了 Vector Drawable,在 4.0 及以下版本的系统中会导致 Crash
* Created by Kayo on 2017/8/29.
*/
public class QMUIXmlVectorDrawableDetector extends ResourceXmlDetector {
public static final Issue ISSUE_XML_VECTOR_DRAWABLE =
Issue.create("QMUIGetVectorDrawableWithWrongProperty",
"Should use the corresponding property to get vector drawable.",
"Using the normal property to get the vector drawable will cause a crash on Android versions below 4.0.",
Category.CORRECTNESS, 8, Severity.ERROR,
new Implementation(QMUIXmlVectorDrawableDetector.class, Scope.RESOURCE_FILE_SCOPE));
private static final Collection<String> mAttrList = Lists.newArrayList(ATTR_DRAWABLE_LEFT, ATTR_DRAWABLE_RIGHT, ATTR_DRAWABLE_TOP, ATTR_DRAWABLE_BOTTOM);
@Override
public boolean appliesTo(ResourceFolderType folderType) {
return ResourceFolderType.LAYOUT == folderType;
}
@Override
public Collection<String> getApplicableElements() {
return ALL;
}
@Override
public Collection<String> getApplicableAttributes() {
return mAttrList;
}
@Override
public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) {
// 判断资源文件夹是否存在
Project project = context.getProject();
List<File> resourceFolder = project.getResourceFolders();
if (resourceFolder.isEmpty()) {
return;
}
// 获取项目资源文件夹路径
String resourcePath = resourceFolder.get(0).getAbsolutePath();
// 获取 drawable 名字
String drawableName = attribute.getValue().replace("@drawable/", "");
FileInputStream fileInputStream = null;
BufferedReader reader = null;
try {
// 若 drawable 为 Vector Drawable,则文件后缀为 xml,根据 resource 路径,drawable 名字,文件后缀拼接出完整路径
fileInputStream = new FileInputStream(resourcePath + "/drawable/" + drawableName + ".xml");
reader = new BufferedReader(new InputStreamReader(fileInputStream));
String line = reader.readLine();
if (line.contains("vector")) {
// 若文件存在,并且包含首行包含 vector,则为 Vector Drawable,抛出警告
context.report(ISSUE_XML_VECTOR_DRAWABLE, attribute, context.getLocation(attribute), attribute.getValue() + " 为 Vector Drawable,请使用 Vector 属性进行设置,避免 4.0 及以下版本的系统产生 Crash");
}
} catch (Exception ignored) {
}finally {
if(fileInputStream != null){
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(reader != null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
...@@ -5,7 +5,6 @@ include 'cc-register', ...@@ -5,7 +5,6 @@ include 'cc-register',
'arms', 'arms',
'pools', 'pools',
'qm-qmui', 'qm-qmui',
// 'qm-lintrule',
'qm-arch', 'qm-arch',
'qm-arch-annotation', 'qm-arch-annotation',
'qm-skin-maker', 'qm-skin-maker',
......
...@@ -17,6 +17,7 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils; ...@@ -17,6 +17,7 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils; import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.ComboItem; import com.gingersoft.gsa.cloud.database.bean.ComboItem;
import com.gingersoft.gsa.cloud.database.bean.Discount; import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.Food; import com.gingersoft.gsa.cloud.database.bean.Food;
...@@ -700,7 +701,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -700,7 +701,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
private void printSendOrder(boolean initTable) { private void printSendOrder(boolean initTable) {
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("printActivity") .setActionName("printActivity")
.addParam("type", 3) .addParam(PrintConstans.PRINT_TYPE, 3)
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
// if (result.isSuccess()) { // if (result.isSuccess()) {
......
...@@ -20,6 +20,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage; ...@@ -20,6 +20,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.constans.GoldConstants; import com.gingersoft.gsa.cloud.constans.GoldConstants;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.Discount; import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.print.PrinterUtils; import com.gingersoft.gsa.cloud.print.PrinterUtils;
...@@ -316,7 +317,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra ...@@ -316,7 +317,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
MyOrderManage.getInstance().setNewFoodList(newFoods); MyOrderManage.getInstance().setNewFoodList(newFoods);
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("printActivity") .setActionName("printActivity")
.addParam("type", 3) .addParam(PrintConstans.PRINT_TYPE, 3)
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
Log.e("error", "是否成功打印:" + result.isSuccess()); Log.e("error", "是否成功打印:" + result.isSuccess());
...@@ -357,7 +358,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra ...@@ -357,7 +358,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
public void onNext(@NonNull BaseRespose info) { public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) { if (info != null && info.isSuccess()) {
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.addParam("type", 1)//印單 .addParam(PrintConstans.PRINT_TYPE, 1)//印單
.setActionName("printActivity") .setActionName("printActivity")
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
......
...@@ -162,33 +162,6 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -162,33 +162,6 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
mRootView.setCurrentOperatType(TableOperatTypeConstant.print_parper_2); mRootView.setCurrentOperatType(TableOperatTypeConstant.print_parper_2);
break; break;
} }
// if (mBottomFunctionList.get(position).getResUrl().equals(ComponentTable.Function.bottom[0].getKeyRes())) {
// //重置
// mRootView.setCurrentOperatType(TableOperatTypeConstant.init_table_3);
// return;
// }
// if (mBottomFunctionList.get(position).getResUrl().equals(ComponentTable.Function.bottom[1].getKeyRes())) {
// //轉檯
// mRootView.setCurrentOperatType(TableOperatTypeConstant.move_table_4);
// return;
// }
// if (mBottomFunctionList.get(position).getResUrl().equals(ComponentTable.Function.bottom[2].getKeyRes())) {
// //分檯
// return;
// }
// if (mBottomFunctionList.get(position).getResUrl().equals(ComponentTable.Function.bottom[3].getKeyRes())) {
// //上菜紙
// CC.obtainBuilder("Component.Print")
// .setActionName("printActivity")
// .addParam("type", 0)
// .build()
// .callAsync((cc, result) -> {
// if (result.isSuccess()) {
// //打印成功
// }
// });
// return;
// }
} }
}); });
} }
......
...@@ -12,6 +12,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.TableBean; ...@@ -12,6 +12,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.mvp.contract.AllOrderContract; import com.gingersoft.gsa.cloud.table.mvp.contract.AllOrderContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.OrderDetailItem; import com.gingersoft.gsa.cloud.table.mvp.model.bean.OrderDetailItem;
...@@ -162,7 +163,7 @@ public class AllOrderPresenter extends BasePresenter<AllOrderContract.Model, All ...@@ -162,7 +163,7 @@ public class AllOrderPresenter extends BasePresenter<AllOrderContract.Model, All
MyOrderManage.getInstance().setBillMoney(payMethodList); MyOrderManage.getInstance().setBillMoney(payMethodList);
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("printActivity") .setActionName("printActivity")
.addParam("type", 2) .addParam(PrintConstans.PRINT_TYPE, 2)
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
Log.e("error", "是否成功打印:" + result.isSuccess()); Log.e("error", "是否成功打印:" + result.isSuccess());
......
...@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; ...@@ -24,6 +24,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.VibratorUtils; import com.gingersoft.gsa.cloud.base.utils.VibratorUtils;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil; import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.print.PrinterUtils; import com.gingersoft.gsa.cloud.print.PrinterUtils;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2; import com.gingersoft.gsa.cloud.table.R2;
...@@ -504,7 +505,7 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements ...@@ -504,7 +505,7 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements
//打印結賬單 //打印結賬單
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("printActivity") .setActionName("printActivity")
.addParam("type", 2) .addParam(PrintConstans.PRINT_TYPE, 2)
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
Log.e("error", "是否成功打印:" + result.isSuccess()); Log.e("error", "是否成功打印:" + result.isSuccess());
......
...@@ -25,6 +25,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage; ...@@ -25,6 +25,7 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils; import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil; import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.Discount; import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2; import com.gingersoft.gsa.cloud.table.R2;
...@@ -367,7 +368,7 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl ...@@ -367,7 +368,7 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("printActivity") .setActionName("printActivity")
.addParam("type", 2) .addParam(PrintConstans.PRINT_TYPE, 2)
.build() .build()
.callAsyncCallbackOnMainThread((cc, result) -> { .callAsyncCallbackOnMainThread((cc, result) -> {
Log.e("error", "是否成功打印:" + result.isSuccess()); Log.e("error", "是否成功打印:" + result.isSuccess());
......
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