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)
......
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;
}
}
...@@ -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();
} }
......
...@@ -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" />
......
...@@ -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) {
}
}
}
}
}
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