Commit deabfead by Wyh

7.11 上線Google Play前提交

parent dfa80941
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
style="@style/Print_kitchen_table_number_text_style" style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="19" /> android:text="19"
android:textSize="@dimen/dp_48"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -35,28 +37,35 @@ ...@@ -35,28 +37,35 @@
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num"
style="@style/Print_text_style" style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:text="AE86"
android:textSize="@dimen/dp_40" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_take_code"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/tv_opening_time_text" android:id="@+id/tv_take_code_text"
style="@style/Print_text_style" style="@style/Print_text_style"
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_20"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/tv_opening_time" android:id="@+id/tv_take_code"
style="@style/Print_text_style" style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="01-04 18:32" /> android:textSize="@dimen/dp_20"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -69,23 +78,61 @@ ...@@ -69,23 +78,61 @@
style="@style/Print_text_style" style="@style/Print_text_style"
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_28" />
<TextView <TextView
android:id="@+id/tv_order_time" android:id="@+id/tv_order_time"
style="@style/Print_text_style" style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="01-04 19:32" /> android:text="01-04 19:32"
android:textSize="@dimen/dp_28" />
</LinearLayout> </LinearLayout>
<TextView <LinearLayout
android:id="@+id/tv_kitchen_location" android:id="@+id/layout_opening_table_time"
style="@style/Print_text_style" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:orientation="horizontal">
android:text="K1 廚房" />
<TextView
android:id="@+id/tv_opening_time_text"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="開檯時間:"
android:textSize="@dimen/dp_20" />
<TextView
android:id="@+id/tv_opening_time"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_20" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_kitchen_location"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_20"
android:text="K1 廚房" />
<TextView
android:id="@+id/tv_operator"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gsadmin" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -109,12 +156,6 @@ ...@@ -109,12 +156,6 @@
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/tv_operator"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gsadmin" />
<TextView <TextView
android:id="@+id/line_kitchen_info" android:id="@+id/line_kitchen_info"
...@@ -136,7 +177,9 @@ ...@@ -136,7 +177,9 @@
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="19" /> android:text="19"
android:textSize="@dimen/dp_48"
android:textStyle="bold" />
</LinearLayout> </LinearLayout>
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:textStyle="bold"
android:gravity="center" android:gravity="center"
android:text="1" /> android:text="1" />
<TextView <TextView
android:id="@+id/tv_food_name" android:id="@+id/tv_food_name"
style="@style/Print_large_text_style" style="@style/Print_large_text_style"
android:textStyle="bold"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
......
...@@ -7,8 +7,8 @@ ext { ...@@ -7,8 +7,8 @@ ext {
targetSdkVersion : 28, targetSdkVersion : 28,
//正式版: 1.0.1 1 //正式版: 1.0.1 1
//內部測試版:1.1.1 11 //內部測試版:1.1.1 11
versionCode : 17, versionCode : 18,
versionName : "1.2.2" versionName : "1.2.3"
] ]
version = [ version = [
......
...@@ -124,7 +124,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -124,7 +124,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// mPresenter.checkAppVersion(); mPresenter.checkAppVersion();
} }
@Override @Override
...@@ -173,12 +173,6 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -173,12 +173,6 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
} else { } else {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this)); tv_version_name.setText("v_" + DeviceUtils.getVersionName(this));
} }
}
@Override
protected void onStart() {
super.onStart();
//開啟Prj打印服務 //開啟Prj打印服務
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.setActionName("openPrintService") .setActionName("openPrintService")
......
...@@ -5,7 +5,7 @@ public class PrintInfoBean { ...@@ -5,7 +5,7 @@ public class PrintInfoBean {
//數組多長就有多少列 //數組多長就有多少列
private String[] content; private String[] content;
// private int[] widght;//每列佔比權重 //private int[] widght;//每列佔比權重
private Boolean[] isBold = new Boolean[]{false}; private Boolean[] isBold = new Boolean[]{false};
...@@ -13,6 +13,8 @@ public class PrintInfoBean { ...@@ -13,6 +13,8 @@ public class PrintInfoBean {
private double[] size = new double[]{0}; private double[] size = new double[]{0};
//語言,每列是什麼語言
private String[] Language = new String[]{"tw"};
//content數量為1時才生效,默認居中 //content數量為1時才生效,默認居中
private int gravity = 1; private int gravity = 1;
...@@ -20,11 +22,22 @@ public class PrintInfoBean { ...@@ -20,11 +22,22 @@ public class PrintInfoBean {
this.content = content; this.content = content;
} }
public PrintInfoBean(String[] content, String[] language) {
this.content = content;
Language = language;
}
public PrintInfoBean(String[] content, double[] size) { public PrintInfoBean(String[] content, double[] size) {
this.content = content; this.content = content;
this.size = size; this.size = size;
} }
public PrintInfoBean(String[] content, double[] size, String[] language) {
this.content = content;
this.size = size;
Language = language;
}
public PrintInfoBean(String[] content, int gravity) { public PrintInfoBean(String[] content, int gravity) {
this.content = content; this.content = content;
this.gravity = gravity; this.gravity = gravity;
...@@ -53,6 +66,13 @@ public class PrintInfoBean { ...@@ -53,6 +66,13 @@ public class PrintInfoBean {
this.size = size; this.size = size;
} }
public PrintInfoBean(String[] content, Boolean[] isBold, double[] size, String[] language) {
this.content = content;
this.isBold = isBold;
this.size = size;
Language = language;
}
public PrintInfoBean(String[] content, Boolean[] isBold, double[] size, int gravity) { public PrintInfoBean(String[] content, Boolean[] isBold, double[] size, int gravity) {
this.content = content; this.content = content;
this.isBold = isBold; this.isBold = isBold;
...@@ -99,4 +119,12 @@ public class PrintInfoBean { ...@@ -99,4 +119,12 @@ public class PrintInfoBean {
public void setGravity(int gravity) { public void setGravity(int gravity) {
this.gravity = gravity; this.gravity = gravity;
} }
public String[] getLanguage() {
return Language;
}
public void setLanguage(String[] language) {
Language = language;
}
} }
...@@ -73,6 +73,12 @@ public class PrjBean { ...@@ -73,6 +73,12 @@ public class PrjBean {
private String number; private String number;
private String productId; private String productId;
private Long createTime; private Long createTime;
private int requests;
private int actualPrinterDeviceId;
private String takeFoodCode;
private String billNo;
private int orderType;
/*** /***
* 層級 * 層級
* 1:主食品 * 1:主食品
...@@ -80,6 +86,10 @@ public class PrjBean { ...@@ -80,6 +86,10 @@ public class PrjBean {
* 3:細項 * 3:細項
*/ */
private int itemType; private int itemType;
private String sender;
public int getId() { public int getId() {
return id; return id;
...@@ -224,6 +234,54 @@ public class PrjBean { ...@@ -224,6 +234,54 @@ public class PrjBean {
public void setCreateTime(Long createTime) { public void setCreateTime(Long createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public int getRequests() {
return requests;
}
public void setRequests(int requests) {
this.requests = requests;
}
public int getActualPrinterDeviceId() {
return actualPrinterDeviceId;
}
public void setActualPrinterDeviceId(int actualPrinterDeviceId) {
this.actualPrinterDeviceId = actualPrinterDeviceId;
}
public String getTakeFoodCode() {
return takeFoodCode;
}
public void setTakeFoodCode(String takeFoodCode) {
this.takeFoodCode = takeFoodCode;
}
public String getBillNo() {
return billNo;
}
public void setBillNo(String billNo) {
this.billNo = billNo;
}
public int getOrderType() {
return orderType;
}
public void setOrderType(int orderType) {
this.orderType = orderType;
}
public String getSender() {
return sender;
}
public void setSender(String sender) {
this.sender = sender;
}
} }
public Map<String, List<Bean>> getPrjMap() { public Map<String, List<Bean>> getPrjMap() {
......
...@@ -48,7 +48,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -48,7 +48,7 @@ public class PrintPrjKitchen extends PrinterRoot {
noCut.add(bean); noCut.add(bean);
} }
} }
if(noCut.size()>0) { if (noCut.size() > 0) {
Bitmap bitmap = getKitChenPrintBitmap(mContext, key, noCut); Bitmap bitmap = getKitChenPrintBitmap(mContext, key, noCut);
bitmaps.add(bitmap); bitmaps.add(bitmap);
} }
...@@ -73,6 +73,10 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -73,6 +73,10 @@ public class PrintPrjKitchen extends PrinterRoot {
if (data == null || data.size() <= 0) { if (data == null || data.size() <= 0) {
return null; return null;
} }
PrjBean.DataBean.Bean prjBean = data.get(0);
if (prjBean == null) {
return null;
}
for (PrjBean.DataBean.Bean bean : data) { for (PrjBean.DataBean.Bean bean : data) {
if (bean.getParentId() == 0) { if (bean.getParentId() == 0) {
//沒有父級id,則是第一級食品 //沒有父級id,則是第一級食品
...@@ -91,10 +95,12 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -91,10 +95,12 @@ public class PrintPrjKitchen extends PrinterRoot {
} }
} }
} }
// PrintHelper
View view = LinearLayout.inflate(context, R.layout.print_kitchen, null); View view = LinearLayout.inflate(context, R.layout.print_kitchen, null);
TextView tvTableNumber = view.findViewById(R.id.tv_kitchen_print_table_number); TextView tvTableNumber = view.findViewById(R.id.tv_kitchen_print_table_number);
TextView tvOrderNumberText = view.findViewById(R.id.tv_order_num_text);
TextView tvOrderNumber = view.findViewById(R.id.tv_order_num); TextView tvOrderNumber = view.findViewById(R.id.tv_order_num);
TextView tvTakeCodeText = view.findViewById(R.id.tv_take_code_text);
TextView tvTakeCode = view.findViewById(R.id.tv_take_code);
TextView tvOpeningTime = view.findViewById(R.id.tv_opening_time); TextView tvOpeningTime = view.findViewById(R.id.tv_opening_time);
TextView tvOrderTime = view.findViewById(R.id.tv_order_time); TextView tvOrderTime = view.findViewById(R.id.tv_order_time);
TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location); TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location);
...@@ -102,44 +108,69 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -102,44 +108,69 @@ public class PrintPrjKitchen extends PrinterRoot {
TextView tvOperator = view.findViewById(R.id.tv_operator); TextView tvOperator = view.findViewById(R.id.tv_operator);
RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food); RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food);
TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number2); TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number2);
if (data.size() > 0 && data.get(0) != null) { LinearLayout layoutOpenTableTime = view.findViewById(R.id.layout_opening_table_time);
KitChenPrjPrintFoodAdapter foodAdapter = new KitChenPrjPrintFoodAdapter(data);
rvFood.setLayoutManager(new LinearLayoutManager(context)); KitChenPrjPrintFoodAdapter foodAdapter = new KitChenPrjPrintFoodAdapter(data);
rvFood.setAdapter(foodAdapter); rvFood.setLayoutManager(new LinearLayoutManager(context));
//廚房位置 rvFood.setAdapter(foodAdapter);
if (!TextUtil.isEmptyOrNullOrUndefined(key) && !key.equals("-1")) { //廚房位置
tvKitChenLocation.setText(key);//.replace("*", "") if (!TextUtil.isEmptyOrNullOrUndefined(key) && !key.equals("-1")) {
tvKitChenLocation.setVisibility(View.VISIBLE); tvKitChenLocation.setText(key + "廚房");//.replace("*", "")
tvKitChenLocation.setVisibility(View.VISIBLE);
} else {
tvKitChenLocation.setVisibility(View.GONE);
}
if (!TextUtil.isEmptyOrNullOrUndefined(prjBean.getBillNo())) {
//訂單碼不為空
tvOrderNumberText.setText("訂單碼:");
tvOrderNumber.setText(prjBean.getBillNo());
} else {
//訂單號
tvOrderNumber.setText(prjBean.getOrderNo());
}
if (TextUtil.isEmptyOrNullOrUndefined(prjBean.getTableName())) {
layoutOpenTableTime.setVisibility(View.GONE);
if (prjBean.getOrderType() == 7) {
tvTableNumber.setText("自取");
tvTableNumber2.setText("自取");
if(!TextUtil.isEmptyOrNullOrUndefined(prjBean.getTakeFoodCode())){
tvTakeCodeText.setVisibility(View.VISIBLE);
tvTakeCode.setVisibility(View.VISIBLE);
tvTakeCode.setText(prjBean.getTakeFoodCode());
}
} else { } else {
tvKitChenLocation.setVisibility(View.GONE); tvTableNumber.setText("外賣");
tvTableNumber2.setText("外賣");
tvOrderNumberText.setText("訂單碼:");
tvOrderNumber.setText(prjBean.getTakeFoodCode());
} }
} else {
tvTableNumber.setText(prjBean.getTableName());
tvTableNumber2.setText(prjBean.getTableName());
} }
tvTableNumber.setText(data.get(0).getTableName());
tvTableNumber2.setText(data.get(0).getTableName());
//人數 //人數
if (data.get(0).getPerson() != 0) { if (prjBean.getPerson() != 0) {
tvPeople.setText(data.get(0).getPerson() + ""); tvPeople.setText(prjBean.getPerson() + "");
view.findViewById(R.id.tv_people_text).setVisibility(View.VISIBLE); view.findViewById(R.id.tv_people_text).setVisibility(View.VISIBLE);
view.findViewById(R.id.tv_people).setVisibility(View.VISIBLE); view.findViewById(R.id.tv_people).setVisibility(View.VISIBLE);
} }
//訂單號
tvOrderNumber.setText(data.get(0).getOrderNo());
//開台時間 //開台時間
tvOpeningTime.setText(TimeUtils.parseTimeRepeat(data.get(0).getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_FORMAT)); tvOpeningTime.setText(TimeUtils.parseTimeRepeat(prjBean.getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_MDHM));
// if (OpenTableManage.getDefault().getTableBean() != null) { // if (OpenTableManage.getDefault().getTableBean() != null) {
// //台號 // //台號
// tvTableNumber.setText(data.get(0).getTableName()); // tvTableNumber.setText(prjBean.getTableName());
// tvTableNumber2.setText(data.get(0).getTableName()); // tvTableNumber2.setText(prjBean.getTableName());
// //人數 // //人數
// tvPeople.setText(data.get(0).getPerson() + ""); // tvPeople.setText(prjBean.getPerson() + "");
// //訂單號 // //訂單號
// tvOrderNumber.setText(data.get(0).getOrderNo()); // tvOrderNumber.setText(prjBean.getOrderNo());
// //開台時間 // //開台時間
// tvOpeningTime.setText(TimeUtils.parseTimeRepeat(data.get(0).getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_FORMAT)); // tvOpeningTime.setText(TimeUtils.parseTimeRepeat(prjBean.getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_FORMAT));
// } // }
//落單時間,為當前時間 //落單時間,為當前時間
tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)); tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_MDHM));
//操作人員 //操作人員
tvOperator.setText(GsaCloudApplication.getMemberName(context)); tvOperator.setText(GsaCloudApplication.getMemberName(context));
return viewToBitmap(context, view); return viewToBitmap(context, view);
......
...@@ -14,7 +14,6 @@ import androidx.core.content.ContextCompat; ...@@ -14,7 +14,6 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.epson.epos2.Epos2Exception;
import com.epson.epos2.printer.Printer; import com.epson.epos2.printer.Printer;
import com.epson.epos2.printer.PrinterStatusInfo; import com.epson.epos2.printer.PrinterStatusInfo;
import com.epson.epos2.printer.ReceiveListener; import com.epson.epos2.printer.ReceiveListener;
...@@ -507,7 +506,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -507,7 +506,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
if (bitmaps != null) { if (bitmaps != null) {
zoomBitmap = new ArrayList<>(); zoomBitmap = new ArrayList<>();
for (int i = 0; i < bitmaps.size(); i++) { for (int i = 0; i < bitmaps.size(); i++) {
if(bitmaps.get(i) != null) { if (bitmaps.get(i) != null) {
Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth, 2d); Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth, 2d);
zoomBitmap.add(newBitmap); zoomBitmap.add(newBitmap);
} }
...@@ -518,19 +517,18 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -518,19 +517,18 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return; return;
} }
List<Bitmap> finalZoomBitmap = zoomBitmap; List<Bitmap> finalZoomBitmap = zoomBitmap;
mPrinter = new EpsonPrint(); mPrinter = EpsonPrint.getInstance();
mPrinter.initializeObject(mContext, this); mPrinter.initializeObject(GsaCloudApplication.getAppContext(), this);
new Thread(() -> { new Thread(() -> {
boolean isSuccess = true; int state = 0;//0打印失敗,1打印成功,2沒紙
for (int j = 0; j < finalZoomBitmap.size(); j++) { for (int j = 0; j < finalZoomBitmap.size(); j++) {
isSuccess = mPrinter.printData(printerDeviceBean.getIp(), finalZoomBitmap.get(j)); state = mPrinter.putPrintData(printerDeviceBean.getIp(), finalZoomBitmap.get(j));
} }
disconnectPrinter();
if (printListener != null) { if (printListener != null) {
if (isSuccess) { if (state == 2) {
printListener.printSuccess(); printListener.printStateChanged(PrintActivity.LACK_OF_PAPER);
} else { } else {
printListener.printFile(); printListener.printStateChanged(PrintActivity.FINISH);
} }
} }
}).start(); }).start();
...@@ -709,34 +707,16 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -709,34 +707,16 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} }
} }
private void disconnectPrinter() {
if (mPrinter == null) {
return;
}
while (true) {
try {
mPrinter.disconnect();
break;
} catch (final Exception e) {
if (e instanceof Epos2Exception) {
//Note: If printer is processing such as printing and so on, the disconnect API returns ERR_PROCESSING.
if (((Epos2Exception) e).getErrorStatus() == Epos2Exception.ERR_PROCESSING) {
} else {
break;
}
} else {
break;
}
}
}
mPrinter.clearCommandBuffer();
}
@Override @Override
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) { public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) {
Log.e("eee", "EPSON打印結果:" + i); Log.e("eee", "EPSON打印結果:" + i);
disconnectPrinter(); if (i == 0) {
printListener.printSuccess();
} else {
printListener.printFile();
}
// EpsonPrint.getInstance().disconnectPrinter();
// EpsonPrint.getInstance().finalizeObject();
} }
} }
...@@ -51,15 +51,24 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -51,15 +51,24 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
private Disposable wakeDisposable; private Disposable wakeDisposable;
private List<PrinterDeviceBean> printerDeviceBeans; private List<PrinterDeviceBean> printerDeviceBeans;
private List<PrjBean.DataBean.Bean> printDatas = new ArrayList<>(); private List<PrjBean.DataBean.Bean> printDatas = new ArrayList<>();
//
// @Override
// public void onCreate() {
// super.onCreate();
// //讀取本地ip打印機
// Log.e("eee", "開啟打印服務");
// getPrintList();
// //開始請求
// startGetPrjInfo();
// }
@Override @Override
public void onCreate() { public int onStartCommand(Intent intent, int flags, int startId) {
super.onCreate();
//讀取本地ip打印機
Log.e("eee", "開啟打印服務"); Log.e("eee", "開啟打印服務");
getPrintList(); getPrintList();
//開始請求 //開始請求
startGetPrjInfo(); startGetPrjInfo();
return super.onStartCommand(intent, flags, startId);
} }
private void getPrintList() { private void getPrintList() {
......
...@@ -69,6 +69,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -69,6 +69,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
public final static int DIMISS_LOADING = 1002;//關閉加載窗 public final static int DIMISS_LOADING = 1002;//關閉加載窗
public final static int FINISH = 1003;//關閉頁面 public final static int FINISH = 1003;//關閉頁面
public final static int ADD_PRINT_DEVICE = 1004;//添加打印機 public final static int ADD_PRINT_DEVICE = 1004;//添加打印機
public final static int LACK_OF_PAPER = 1005;//缺紙
public static List<PrinterDeviceBean> printerDeviceBeans; public static List<PrinterDeviceBean> printerDeviceBeans;
private String callId; private String callId;
...@@ -162,9 +164,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -162,9 +164,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
} }
private void setLoadingText(String tip) { private void setLoadingText(String tip) {
if (mLoadingDialog != null && mLoadingDialog.isShowing()) { runOnUiThread(() -> {
mTvLoadingTip.setText(tip); if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
} mTvLoadingTip.setText(tip);
}
});
} }
@Override @Override
...@@ -237,6 +241,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -237,6 +241,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
case ADD_PRINT_DEVICE: case ADD_PRINT_DEVICE:
addPrintDevice(); addPrintDevice();
break; break;
case LACK_OF_PAPER:
//缺紙
ToastUtils.show(mContext, "打印機缺紙");
printFile();
break;
} }
setLoadingText(tip); setLoadingText(tip);
} }
...@@ -346,8 +355,10 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print ...@@ -346,8 +355,10 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
} }
private void disLoadingDialog() { private void disLoadingDialog() {
if (mLoadingDialog != null) { runOnUiThread(() -> {
mLoadingDialog.dismiss(); if (mLoadingDialog != null) {
} mLoadingDialog.dismiss();
}
});
} }
} }
package com.joe.print.mvp.ui.activity; package com.joe.print.mvp.ui.activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.print.PrintHelper;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
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;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.R; import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrintInfoBean; import com.joe.print.mvp.model.bean.PrintInfoBean;
import com.joe.print.mvp.print.IpPrintMaker; import com.joe.print.mvp.print.EpsonPrint;
import com.joe.print.mvp.print.TestPrintMaker;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PrintTestActivity extends AppCompatActivity implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener { public class PrintTestActivity extends AppCompatActivity implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener {
private int lineLength = 42;//一行42個 private int lineLength = 24;//一行42個
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -29,31 +26,38 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH ...@@ -29,31 +26,38 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean("192.168.1.218", 9100, "400"); PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean("192.168.1.218", 9100, "400");
List<PrintInfoBean> printInfoBeans = new ArrayList<>(); List<PrintInfoBean> printInfoBeans = new ArrayList<>();
printInfoBeans.add(new PrintInfoBean(new String[]{"正式測試品牌"}, new double[]{1})); printInfoBeans.add(new PrintInfoBean(new String[]{"正式測試品牌"}, new double[]{1}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"純屬餐廳"}, new double[]{1})); printInfoBeans.add(new PrintInfoBean(new String[]{"純屬餐廳"}, new double[]{1}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("自取", 1.5)}, new Boolean[]{true}, new double[]{1.5})); printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("自取", 2)}, new Boolean[]{true}, new double[]{2}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"貨到付款"}, new Boolean[]{true}, new double[]{1.5})); printInfoBeans.add(new PrintInfoBean(new String[]{"貨到付款"}, new Boolean[]{true}, new double[]{2}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{"07-08(週三)立即"}, new double[]{1.5})); printInfoBeans.add(new PrintInfoBean(new String[]{"07-08(週三)立即"}, new double[]{2}, new String[]{"tw"}));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1)})); printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1)}, new String[]{"tw"}));
findViewById(R.id.btn_test).setOnClickListener(view -> { findViewById(R.id.btn_test).setOnClickListener(view -> {
//打印測試 //打印測試
PrintHelper helper = new PrintHelper(this); // PrintExecutor executor = new PrintExecutor(printerDeviceBean);
// executor.setOnStateChangedListener(this);
// helper.printBitmap("192.168.1.218", ); // executor.setOnPrintResultListener(this);
PrintExecutor executor = new PrintExecutor(printerDeviceBean); //
executor.setOnStateChangedListener(this); // TestPrintMaker maker = null;
executor.setOnPrintResultListener(this); // try {
// maker = new TestPrintMaker(new PrinterWriter80mm(255), printInfoBeans);
TestPrintMaker maker = null; // } catch (IOException e) {
try { // e.printStackTrace();
maker = new TestPrintMaker(new PrinterWriter80mm(255), printInfoBeans); // }
} catch (IOException e) { // executor.doPrinterRequestAsync(maker);
e.printStackTrace();
} EpsonPrint mPrinter = EpsonPrint.getInstance();
executor.doPrinterRequestAsync(maker); mPrinter.initializeObject(GsaCloudApplication.getAppContext(), null);
mPrinter.putPrintString("192.168.1.203", printInfoBeans);
// new Thread(() -> {
// for (int j = 0; j < finalZoomBitmap.size(); j++) {
// mPrinter.putPrintData(printerDeviceBean.getIp(), finalZoomBitmap.get(j));
// }
// }).start();
}); });
} }
...@@ -68,9 +72,10 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH ...@@ -68,9 +72,10 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
} }
private String getLineBorder(String text, double fontSize) { private String getLineBorder(String text, double fontSize) {
if(fontSize == 0){ if (fontSize == 0) {
fontSize = 1; fontSize = 1;
} }
int count = (int) ((lineLength / fontSize) - text.length()); int count = (int) ((lineLength / fontSize) - text.length());
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = 0; i < count / 2; i++) { for (int i = 0; i < count / 2; i++) {
......
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