Commit dfa80941 by Wyh

7.10 prj打印測試版

parent 1e5bffbd
...@@ -156,7 +156,7 @@ public class ImageUtils { ...@@ -156,7 +156,7 @@ public class ImageUtils {
Matrix matrix = new Matrix(); Matrix matrix = new Matrix();
float scaleWidth = ((float) w / width); float scaleWidth = ((float) w / width);
float scaleHeight = ((float) h / height); float scaleHeight = ((float) h / height);
matrix.postScale(scaleWidth, scaleWidth); matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(oldbmp, 0, 0, width, height, return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true); matrix, true);
} }
...@@ -171,6 +171,17 @@ public class ImageUtils { ...@@ -171,6 +171,17 @@ public class ImageUtils {
matrix, true); matrix, true);
} }
public static Bitmap zoomDrawable(Bitmap oldbmp, int w, double heightMultiple) {
int width = oldbmp.getWidth();
int height = oldbmp.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) w / width);
float scaleHeight = (float) (scaleWidth/heightMultiple);
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true);
}
/** /**
* 缩放图片 * 缩放图片
......
...@@ -66,6 +66,13 @@ public class PrinterDeviceBean implements Serializable { ...@@ -66,6 +66,13 @@ public class PrinterDeviceBean implements Serializable {
this.flyPrinterDeviceId2 = flyPrinterDeviceId2; this.flyPrinterDeviceId2 = flyPrinterDeviceId2;
} }
public PrinterDeviceBean(String ip, Integer port, String paperSpecification) {
this.ip = ip;
this.port = port;
this.paperSpecification = paperSpecification;
}
public Long getId() { public Long getId() {
return id; return id;
} }
......
...@@ -21,6 +21,7 @@ import android.content.Context; ...@@ -21,6 +21,7 @@ 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 com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
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;
...@@ -130,36 +131,8 @@ public class PrinterUtils { ...@@ -130,36 +131,8 @@ public class PrinterUtils {
* @param num 倍数 * @param num 倍数
* @return bytes for this command * @return bytes for this command
*/ */
public static byte[] fontSizeSetBig(int num) { public static byte[] fontSizeSetBig(double num) {
byte realSize = 0; return PrintCommands.selectCharacterSize((int) (17 * num));
switch (num) {
case 0:
//noinspection ConstantConditions
realSize = 0;
break;
case 1:
realSize = 17;
break;
case 2:
realSize = 34;
break;
case 3:
realSize = 51;
break;
case 4:
realSize = 68;
break;
case 5:
realSize = 85;
break;
case 6:
realSize = 102;
break;
case 7:
realSize = 119;
break;
}
return PrintCommands.selectCharacterSize(realSize);
} }
/** /**
...@@ -168,6 +141,7 @@ public class PrinterUtils { ...@@ -168,6 +141,7 @@ public class PrinterUtils {
* and executes a full cut ( cuts the paper completely ) * and executes a full cut ( cuts the paper completely )
* *
* @return bytes for this command * @return bytes for this command
* @return bytes for this command
*/ */
public static byte[] feedPaperCut() { public static byte[] feedPaperCut() {
return PrintCommands.selectCutModeAndCutPaper(1, 0); return PrintCommands.selectCutModeAndCutPaper(1, 0);
......
...@@ -192,7 +192,7 @@ public abstract class PrinterWriter { ...@@ -192,7 +192,7 @@ public abstract class PrinterWriter {
* @param size 文字大小 (0~7)(默认0) * @param size 文字大小 (0~7)(默认0)
* @throws IOException 异常 * @throws IOException 异常
*/ */
public void setFontSize(int size) throws IOException { public void setFontSize(double size) throws IOException {
write(PrinterUtils.fontSizeSetBig(size)); write(PrinterUtils.fontSizeSetBig(size));
} }
......
...@@ -49,9 +49,9 @@ public class PrinterWriter58mm extends PrinterWriter { ...@@ -49,9 +49,9 @@ public class PrinterWriter58mm extends PrinterWriter {
switch (textSize) { switch (textSize) {
default: default:
case 0: case 0:
return 31; return 32;
case 1: case 1:
return 15; return 16;
} }
} }
......
...@@ -49,9 +49,9 @@ public class PrinterWriter80mm extends PrinterWriter { ...@@ -49,9 +49,9 @@ public class PrinterWriter80mm extends PrinterWriter {
switch (textSize) { switch (textSize) {
default: default:
case 0: case 0:
return 47; return 48;
case 1: case 1:
return 23; return 24;
} }
} }
......
...@@ -13,63 +13,71 @@ ...@@ -13,63 +13,71 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="19" /> android:text="19" />
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10"> android:paddingBottom="@dimen/dp_10">
<TextView <LinearLayout
android:id="@+id/tv_order_num_text" android:layout_width="match_parent"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="訂單號:" android:orientation="horizontal">
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num_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"
app:layout_constraintLeft_toRightOf="@id/tv_order_num_text" android:text="訂單號:" />
app:layout_constraintTop_toTopOf="@id/tv_order_num_text" />
<TextView <TextView
android:id="@+id/tv_opening_time_text" 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="開檯時間:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_num_text" />
<TextView </LinearLayout>
android:id="@+id/tv_opening_time"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 18:32"
app:layout_constraintLeft_toRightOf="@id/tv_opening_time_text"
app:layout_constraintTop_toTopOf="@id/tv_opening_time_text" />
<TextView <LinearLayout
android:id="@+id/tv_order_time_text" android:layout_width="match_parent"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="落單時間:" android:orientation="horizontal">
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_opening_time_text" /> <TextView
android:id="@+id/tv_opening_time_text"
<TextView style="@style/Print_text_style"
android:id="@+id/tv_order_time" android:layout_width="wrap_content"
style="@style/Print_text_style" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="開檯時間:" />
<TextView
android:id="@+id/tv_opening_time"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 18:32" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="01-04 19:32" android:orientation="horizontal">
app:layout_constraintLeft_toRightOf="@id/tv_order_time_text"
app:layout_constraintTop_toTopOf="@id/tv_order_time_text" /> <TextView
android:id="@+id/tv_order_time_text"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="落單時間:" />
<TextView
android:id="@+id/tv_order_time"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 19:32" />
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_kitchen_location" android:id="@+id/tv_kitchen_location"
...@@ -77,39 +85,36 @@ ...@@ -77,39 +85,36 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:text="K1 廚房" android:text="K1 廚房" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_time" />
<TextView <LinearLayout
android:id="@+id/tv_people_text" android:layout_width="match_parent"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人數:"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_kitchen_location" />
<TextView
android:id="@+id/tv_people"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="10" android:orientation="horizontal">
app:layout_constraintBottom_toBottomOf="@id/tv_people_text"
app:layout_constraintLeft_toRightOf="@id/tv_people_text" <TextView
app:layout_constraintTop_toTopOf="@id/tv_people_text" /> android:id="@+id/tv_people_text"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人數:"
android:visibility="gone" />
<TextView
android:id="@+id/tv_people"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1000"
android:visibility="gone" />
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_operator" android:id="@+id/tv_operator"
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="gsadmin" android:text="gsadmin" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_people" />
<TextView <TextView
android:id="@+id/line_kitchen_info" android:id="@+id/line_kitchen_info"
...@@ -117,25 +122,22 @@ ...@@ -117,25 +122,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:text="——————————————————————————————————————————————————" android:text="——————————————————————————————————————————————————"
app:layout_constraintTop_toBottomOf="@id/tv_people_text" /> app:layout_constraintTop_toBottomOf="@id/tv_operator" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_kitchen_food" android:id="@+id/rv_kitchen_food"
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:layout_marginTop="@dimen/dp_10" />
app:layout_constraintTop_toBottomOf="@id/line_kitchen_info" />
<TextView <TextView
android:id="@+id/tv_kitchen_print_table_number2" android:id="@+id/tv_kitchen_print_table_number2"
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:layout_gravity="center_horizontal"
app:layout_constraintLeft_toLeftOf="parent" android:text="19" />
app:layout_constraintRight_toRightOf="parent" </LinearLayout>
app:layout_constraintTop_toBottomOf="@id/rv_kitchen_food" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -282,18 +282,18 @@ ...@@ -282,18 +282,18 @@
</style> </style>
<style name="Print_text_style"> <style name="Print_text_style">
<item name="android:textColor">@color/theme_333_color</item> <item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/sp_24</item> <item name="android:textSize">@dimen/sp_24</item>
</style> </style>
<!-- 廚房單菜品名字體樣式--> <!-- 廚房單菜品名字體樣式-->
<style name="Print_large_text_style"> <style name="Print_large_text_style">
<item name="android:textColor">@color/theme_333_color</item> <item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/sp_34</item> <item name="android:textSize">@dimen/sp_34</item>
</style> </style>
<!-- 廚房單台號體樣式--> <!-- 廚房單台號體樣式-->
<style name="Print_kitchen_table_number_text_style"> <style name="Print_kitchen_table_number_text_style">
<item name="android:textColor">@color/theme_333_color</item> <item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/sp_38</item> <item name="android:textSize">@dimen/sp_38</item>
</style> </style>
......
...@@ -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 : 13, versionCode : 17,
versionName : "1.1.3" versionName : "1.2.2"
] ]
version = [ version = [
......
...@@ -10,12 +10,11 @@ import com.gingersoft.gsa.cloud.base.common.bean.FoodBean; ...@@ -10,12 +10,11 @@ import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.common.bean.RestaurantExpandInfoUtils; import com.gingersoft.gsa.cloud.base.common.bean.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.CommonConfiguration; import com.gingersoft.gsa.cloud.base.utils.CommonConfiguration;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.constans.HttpsConstans; import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.Discount; import com.gingersoft.gsa.cloud.database.bean.Discount;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo; import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterListBean;
import com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils; import com.gingersoft.gsa.cloud.database.utils.ComboItemDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.DiscountDaoUtils; import com.gingersoft.gsa.cloud.database.utils.DiscountDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils; import com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils;
...@@ -25,9 +24,10 @@ import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils; ...@@ -25,9 +24,10 @@ import com.gingersoft.gsa.cloud.database.utils.FoodModifierDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils; import com.gingersoft.gsa.cloud.database.utils.ModifierDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils; import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone; import com.gingersoft.gsa.cloud.download.mvp.model.bean.ComboItemRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState; import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodComboRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodModifierRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionRespone;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone; import com.gingersoft.gsa.cloud.download.mvp.model.bean.ModifierRespone;
...@@ -35,10 +35,17 @@ import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadManager; ...@@ -35,10 +35,17 @@ import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadManager;
import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadRequest; import com.gingersoft.gsa.cloud.download.mvp.model.downmanager.DownloadRequest;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity; import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter; import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope; import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull; import io.reactivex.annotations.NonNull;
...@@ -47,15 +54,6 @@ import io.reactivex.schedulers.Schedulers; ...@@ -47,15 +54,6 @@ import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.List;
/** /**
* ================================================ * ================================================
...@@ -690,9 +688,9 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow ...@@ -690,9 +688,9 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
if (result.getData() != null) { if (result.getData() != null) {
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(IActivity); PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(IActivity);
printerDeviceDaoUtils.deleteAll(); printerDeviceDaoUtils.deleteAll();
List<PrinterDeviceBean> printerDeviceBeanList = JsonUtils.parseArray(result.getData(), PrinterDeviceBean.class); PrinterListBean printerListBean = JsonUtils.parseObject(result.getData(), PrinterListBean.class);
if (printerDeviceBeanList != null) { if (printerListBean != null && printerListBean.getList() != null) {
printerDeviceDaoUtils.insertMultPrinterDeviceBean(printerDeviceBeanList); printerDeviceDaoUtils.insertMultPrinterDeviceBean(printerListBean.getList());
} }
} }
DataDownLoadState loadState = mList.get(downTag); DataDownLoadState loadState = mList.get(downTag);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application <application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
......
...@@ -81,11 +81,6 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas ...@@ -81,11 +81,6 @@ public class BaseLoginPresenter<M extends BaseLoginContract.Model, V extends Bas
GsaCloudApplication.userName = info.getData().getUser().getUserName(); GsaCloudApplication.userName = info.getData().getUser().getUserName();
mRootView.showMessage("登陸成功"); mRootView.showMessage("登陸成功");
mRootView.loginSuccess(info); mRootView.loginSuccess(info);
//開啟Prj打印服務
CC.obtainBuilder("Component.Print")
.setActionName("openPrintService")
.build()
.call();
} else { } else {
GsaCloudApplication.isLogin = false; GsaCloudApplication.isLogin = false;
mRootView.showMessage(info.getErrMsg()); mRootView.showMessage(info.getErrMsg());
......
...@@ -101,6 +101,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -101,6 +101,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
((ImageView)findViewById(R.id.iv_top_bg)).setAdjustViewBounds(true);
// inside your activity (if you did not enable transitions in your theme) // inside your activity (if you did not enable transitions in your theme)
// getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); // getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
// set an exit transition // set an exit transition
......
...@@ -13,16 +13,19 @@ ...@@ -13,16 +13,19 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/iv_top_bg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY" android:scaleType="fitXY"
android:layout_height="wrap_content"
android:src="@drawable/img_login_top_bg" /> android:src="@drawable/img_login_top_bg" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="@dimen/dp_19" android:paddingLeft="@dimen/dp_19"
android:paddingRight="@dimen/dp_19" android:paddingRight="@dimen/dp_19"
android:layout_marginTop="@dimen/dp_20"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
...@@ -30,14 +33,10 @@ ...@@ -30,14 +33,10 @@
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:layout_marginTop="80dp"
android:text="@string/user_login_welcome_login" android:text="@string/user_login_welcome_login"
android:textColor="@color/theme_color" android:textColor="@color/theme_color"
android:textSize="@dimen/dp_20" android:textSize="@dimen/dp_20"
android:textStyle="bold" android:textStyle="bold" />
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_account_text" android:id="@+id/tv_account_text"
...@@ -206,22 +205,21 @@ ...@@ -206,22 +205,21 @@
app:layout_constraintTop_toTopOf="@id/rb_auto_login" /> app:layout_constraintTop_toTopOf="@id/rb_auto_login" />
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_gsa_user_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_50"
android:background="@drawable/selector_login_btn"
android:gravity="center"
android:text="登錄"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout> </LinearLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_gsa_user_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_login_btn"
android:gravity="center"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_60"
android:text="登錄"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
...@@ -173,6 +173,17 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -173,6 +173,17 @@ 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打印服務
CC.obtainBuilder("Component.Print")
.setActionName("openPrintService")
.build()
.call();
} }
/** /**
...@@ -184,12 +195,13 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -184,12 +195,13 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "複製Token"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌")); // mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
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, "修改密碼"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "設置"));
} }
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "查看日誌"));
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "清機")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_settlement_report, "清機"));
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境")); mainSideMenuBeans.add(new MainSideMenuBean(R.drawable.ic_setting, "切換環境"));
...@@ -376,6 +388,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -376,6 +388,12 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
//切換餐廳,發送關閉接單的廣播,並清除心跳 //切換餐廳,發送關閉接單的廣播,並清除心跳
sendBroadcast(new Intent(AppConstans.CLEAR_ORDER_RECEIVING_HEART)); sendBroadcast(new Intent(AppConstans.CLEAR_ORDER_RECEIVING_HEART));
//关闭Prj打印服務
CC.obtainBuilder("Component.Print")
.setActionName("stopPrintService")
.build()
.call();
BrandsBean.BrandsData brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brandsBeans, item.getId()); BrandsBean.BrandsData brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brandsBeans, item.getId());
if (brandsBean != null) { if (brandsBean != null) {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<activity android:name=".ui.activity.DeliverySettingActivity" /> <activity android:name=".ui.activity.DeliverySettingActivity" />
<activity android:name=".ui.activity.OrderDetailsActivity" /> <activity android:name=".ui.activity.OrderDetailsActivity" />
<activity android:name=".ui.activity.PayActivity" /> <activity android:name=".ui.activity.PayActivity" />
<activity android:name=".ui.activity.LogActivity"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +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" />
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WAKE_LOCK" />
<application <application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
android:networkSecurityConfig="@xml/network_android" android:networkSecurityConfig="@xml/network_android"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".ui.activity.LogActivity"/>
<activity android:name=".ui.activity.OrderDetailsActivity" /> <activity android:name=".ui.activity.OrderDetailsActivity" />
<activity <activity
android:name=".ui.activity.OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
......
...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.other_order_mode.model.viewModel ...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.other_order_mode.model.viewModel
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.util.Log
import android.view.Gravity import android.view.Gravity
import android.view.WindowManager import android.view.WindowManager
import android.widget.TextView import android.widget.TextView
...@@ -22,6 +23,7 @@ import com.gingersoft.gsa.cloud.print.bean.OrderDetails ...@@ -22,6 +23,7 @@ import com.gingersoft.gsa.cloud.print.bean.OrderDetails
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.WeatherRepository import com.gingersoft.gsa.other_order_mode.data.WeatherRepository
import com.gingersoft.gsa.other_order_mode.data.model.bean.* import com.gingersoft.gsa.other_order_mode.data.model.bean.*
import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.DeliveryAdapter
import com.jess.arms.utils.ArmsUtils import com.jess.arms.utils.ArmsUtils
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
...@@ -40,6 +42,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -40,6 +42,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
val CancelOrder = 1005//取消訂單 val CancelOrder = 1005//取消訂單
val CancelLogistics = 1006//取消物流 val CancelLogistics = 1006//取消物流
val ProductionComplete = 1007//製作完成 val ProductionComplete = 1007//製作完成
val DeliveryPrint = 1008//訂單確認成功,是否成功打印回調
} }
var mOrderNum = arrayListOf<MutableLiveData<Int>>() var mOrderNum = arrayListOf<MutableLiveData<Int>>()
...@@ -110,7 +114,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -110,7 +114,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
mOrderNum[0].value = num mOrderNum[0].value = num
} }
}, { }, {
it.printStackTrace()
}) })
} }
...@@ -175,7 +179,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -175,7 +179,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
}, { }, {
it.printStackTrace()
}) })
} }
...@@ -189,6 +193,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -189,6 +193,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
}, { }, {
//出錯 //出錯
it.printStackTrace()
listener.invoke(null) listener.invoke(null)
}) })
} }
...@@ -262,7 +267,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -262,7 +267,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
launch({ launch({
repository.updateIsRead(orderId) repository.updateIsRead(orderId)
}, { }, {
it.printStackTrace()
}) })
} }
...@@ -304,11 +309,15 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -304,11 +309,15 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
}, { }, {
listener.invoke(0, false) listener.invoke(0, false)
it.printStackTrace()
Log.e("eee", it.javaClass.name + "錯誤信息111:" + it.message)
GetInfoUpdateService.loginfo.append("錯誤信息111:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
GetInfoUpdateService.loginfo.append("\n")
}) })
} }
fun gsUpdateOrderStatus(orderDetails: OrderDetails.DataBean, payTypeId: Int = 0, payName:String?, listener: (Int, Boolean) -> Unit) { fun gsUpdateOrderStatus(orderDetails: OrderDetails.DataBean, payTypeId: Int = 0, payName: String?, listener: (Int, Boolean) -> Unit) {
launch({ launch({
repository.gsUpdateOrderStatus(orderDetails.ID.toString(), 4, orderDetails.order_type, 3, "", "", "", "0", "", 1, 0, payTypeId).apply { repository.gsUpdateOrderStatus(orderDetails.ID.toString(), 4, orderDetails.order_type, 3, "", "", "", "0", "", 1, 0, payTypeId).apply {
orderDetails.payType = payTypeId orderDetails.payType = payTypeId
...@@ -322,12 +331,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -322,12 +331,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
}, { }, {
listener.invoke(OrderDelivery, false) listener.invoke(OrderDelivery, false)
it.printStackTrace()
// integralBean.postValue(null) // integralBean.postValue(null)
}) })
} }
/** /**
* 待確認 --- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬 * 待確認--- 確認之後狀態變為 製作中,按鈕顯示:自取:製作完成,外賣:指派送貨----自取的狀態為待取餐,按鈕為結賬,外賣的狀態為派送中,按鈕顯示結賬
* 更新訂單信息,自取或是外賣 * 更新訂單信息,自取或是外賣
* status 0,1待確認 * status 0,1待確認
* 2 已確認,外賣是指派送單,自取是製作完成 * 2 已確認,外賣是指派送單,自取是製作完成
...@@ -459,13 +469,28 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -459,13 +469,28 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
launch({ launch({
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯 //單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString()) repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString())
}, {}) GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
GetInfoUpdateService.loginfo.append("\n")
}, {
it.printStackTrace()
Log.e("eee", "錯誤信息222:" + it.message)
GetInfoUpdateService.loginfo.append("錯誤信息222:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
GetInfoUpdateService.loginfo.append("\n")
})
if (this.code == "1") { if (this.code == "1") {
// 打印印單 // 打印印單
// 初始化用於打印的view // 初始化用於打印的view
// 送單成功後,再調用接口獲取取餐碼 // 送單成功後,再調用接口獲取取餐碼
repository.getOrderInfo(dataBean.ID.toString()).apply { repository.getOrderInfo(dataBean.ID.toString()).apply {
printOrder(OrderDelivery, data?.get(0)!!, listener) if(data != null && data!!.isNotEmpty()){
data?.get(0)?.let {
it.order_type = dataBean.order_type
it.orderPayType = dataBean.orderPayType
printOrder(DeliveryPrint, it, listener)
}
} else {
listener.invoke(OrderDelivery, false)
}
} }
} else { } else {
listener.invoke(OrderDelivery, false) listener.invoke(OrderDelivery, false)
...@@ -478,7 +503,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -478,7 +503,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
* 打印訂單 * 打印訂單
*/ */
private fun printOrder(code: Int, dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) { private fun printOrder(code: Int, dataBean: OrderDetails.DataBean, listener: (Int, Boolean) -> Unit) {
//訂單信息和廚房單 //訂單信息和廚房單,打印前需要修改dataBean的order_type和orderPayType
MyOrderManage.setDataBean(dataBean) MyOrderManage.setDataBean(dataBean)
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 5) .addParam(PrintConstans.PRINT_TYPE, 5)
...@@ -509,6 +534,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -509,6 +534,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
* 打開錢箱 * 打開錢箱
*/ */
fun openCashBox() { fun openCashBox() {
launch({
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj("11112364", "153", "48863116,48863117,48863119")
}, {
it.printStackTrace()
Log.e("eee", "錯誤信息222:" + it.message)
})
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 6) .addParam(PrintConstans.PRINT_TYPE, 6)
.addParam(PrintConstans.PRINT_LOADING, false) .addParam(PrintConstans.PRINT_LOADING, false)
...@@ -594,7 +626,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -594,7 +626,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
}, { }, {
it.printStackTrace()
}) })
} else { } else {
ToastUtils.show(context, "請至少選擇一個送貨員") ToastUtils.show(context, "請至少選擇一個送貨員")
...@@ -607,7 +639,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -607,7 +639,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
.show() .show()
} }
}, { }, {
it.printStackTrace()
}) })
} }
......
package com.gingersoft.gsa.other_order_mode.ui.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.gingersoft.gsa.other_order_mode.R;
import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService;
public class LogActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log);
loadInfo();
findViewById(R.id.btn_clear_log).setOnClickListener(v -> {
GetInfoUpdateService.loginfo.setLength(0);
loadInfo();
});
findViewById(R.id.btn_back).setOnClickListener(v ->finish());
}
private void loadInfo() {
((TextView) findViewById(R.id.tv_log)).setText(GetInfoUpdateService.loginfo.toString());
}
}
...@@ -21,6 +21,7 @@ import com.gingersoft.gsa.other_order_mode.data.model.bean.BtnBuilder ...@@ -21,6 +21,7 @@ import com.gingersoft.gsa.other_order_mode.data.model.bean.BtnBuilder
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOrderDetailsBinding import com.gingersoft.gsa.other_order_mode.databinding.ActivityOrderDetailsBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.Closing import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.Closing
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.DeliveryPrint
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.OrderDelivery import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.OrderDelivery
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.PrintCode import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.PrintCode
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.SendCode import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel.Companion.SendCode
...@@ -167,7 +168,7 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -167,7 +168,7 @@ class OrderDetailsActivity : BaseActivity() {
cancelLogistics(orderDetails) cancelLogistics(orderDetails)
BtnBuilder.assignDeliveryBtn -> BtnBuilder.assignDeliveryBtn ->
//指派送貨 //指派送貨
selectorDelivery(this@OrderDetailsActivity, orderDetails, 3) { status, isSuccess -> getOrderDetails(orderId, binding) } selectorDelivery(this@OrderDetailsActivity, orderDetails, 3) { status, isSuccess -> finish() }
BtnBuilder.cancelBtn -> BtnBuilder.cancelBtn ->
//取消訂單 //取消訂單
cancelOrder(orderDetails) cancelOrder(orderDetails)
...@@ -192,6 +193,14 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -192,6 +193,14 @@ class OrderDetailsActivity : BaseActivity() {
updateOrderStatusByBtn(btnList[position].type, orderDetails, GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString()) { status, isSuccess -> updateOrderStatusByBtn(btnList[position].type, orderDetails, GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString()) { status, isSuccess ->
cancelDialogForLoading() cancelDialogForLoading()
when (status) { when (status) {
DeliveryPrint -> {//訂單已確認,是否打印成功
finish()
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"打印成功"
} else {
"打印失敗"
})
}
PrintCode -> { PrintCode -> {
ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) { ToastUtils.show(this@OrderDetailsActivity, if (isSuccess) {
"打印成功" "打印成功"
...@@ -205,6 +214,9 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -205,6 +214,9 @@ class OrderDetailsActivity : BaseActivity() {
} else { } else {
"指派送貨失敗" "指派送貨失敗"
}) })
if(isSuccess){
finish()
}
} }
OrderDelivery -> { OrderDelivery -> {
//已確認訂單,重新刷新當前頁面 //已確認訂單,重新刷新當前頁面
...@@ -236,7 +248,7 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -236,7 +248,7 @@ class OrderDetailsActivity : BaseActivity() {
} }
else -> { else -> {
cancelDialogForLoading() cancelDialogForLoading()
ToastUtils.show(this@OrderDetailsActivity, "修改訂單狀態失敗") // ToastUtils.show(this@OrderDetailsActivity, "修改訂單狀態失敗")
} }
} }
} }
......
...@@ -446,6 +446,11 @@ class OtherOrderActivity : BaseActivity() { ...@@ -446,6 +446,11 @@ class OtherOrderActivity : BaseActivity() {
pageViewModel.openCashBox() pageViewModel.openCashBox()
pop!!.dismiss() pop!!.dismiss()
} }
view.findViewById<QMUIAlphaTextView>(R.id.tv_check_log).setOnClickListener {
//查看日誌
startActivity(Intent(this, LogActivity::class.java))
pop!!.dismiss()
}
} else { } else {
pop!!.show(it) pop!!.show(it)
} }
......
package com.gingersoft.gsa.other_order_mode.ui.activity
fun main() {
var aaa = "1234567891023456789"
var cd = aaa.length / 2
var buffer = StringBuffer()
if (cd >= 5) {
cd = aaa.length - 5
}
repeat(cd) {
buffer.append("*")
}
var bbb = aaa.substring(0, 1)
var ccc = aaa.substring(cd + 1, aaa.length)
print(bbb + buffer.toString() + ccc)
}
\ No newline at end of file
...@@ -8,14 +8,15 @@ import java.util.concurrent.TimeUnit ...@@ -8,14 +8,15 @@ import java.util.concurrent.TimeUnit
class RxTimerUtil { class RxTimerUtil {
companion object { companion object {
var mDisposable: Disposable? = null var mIntervalDisposable: Disposable? = null
var timerDisposable: Disposable? = null
/** /**
* 执行定时任务 * 执行定时任务
*/ */
fun timer(block: () -> Unit, milliseconds: Long) { fun interval(block: () -> Unit, milliseconds: Long) {
Observable.interval(0, milliseconds, TimeUnit.MILLISECONDS) Observable.interval(0, milliseconds, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<Long> { .subscribe(object : Observer<Long> {
override fun onError(e: Throwable) {} override fun onError(e: Throwable) {}
override fun onComplete() {} override fun onComplete() {}
...@@ -24,7 +25,7 @@ class RxTimerUtil { ...@@ -24,7 +25,7 @@ class RxTimerUtil {
} }
override fun onSubscribe(d: Disposable) { override fun onSubscribe(d: Disposable) {
mDisposable = d mIntervalDisposable = d
} }
}) })
} }
...@@ -32,11 +33,37 @@ class RxTimerUtil { ...@@ -32,11 +33,37 @@ class RxTimerUtil {
/** /**
* 取消定时器 * 取消定时器
*/ */
fun cancel() { fun cancelInterval() {
if (mDisposable != null && !mDisposable!!.isDisposed) { if (mIntervalDisposable != null && !mIntervalDisposable!!.isDisposed) {
mDisposable!!.dispose() mIntervalDisposable!!.dispose()
} }
} }
fun cancelTimerDisposable() {
if (timerDisposable != null && !timerDisposable!!.isDisposed) {
timerDisposable!!.dispose()
}
}
fun delayFun(block: () -> Unit, milliseconds: Long) {
Observable.timer(milliseconds, TimeUnit.SECONDS)
.subscribe(object : Observer<Long> {
override fun onSubscribe(d: Disposable) {
timerDisposable = d
}
override fun onNext(t: Long) {
block()
}
override fun onError(e: Throwable) {
}
override fun onComplete() {
}
})
}
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ui.activity.LogActivity">
<Button
android:id="@+id/btn_back"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:text="返回"
android:textSize="@dimen/dp_16" />
<Button
android:id="@+id/btn_clear_log"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:layout_above="@id/btn_back"
android:layout_margin="@dimen/dp_10"
android:text="清空日誌"
android:textSize="@dimen/dp_16" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/btn_clear_log"
android:scrollbars="vertical"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/tv_log"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16" />
</ScrollView>
</RelativeLayout>
\ No newline at end of file
...@@ -47,4 +47,19 @@ ...@@ -47,4 +47,19 @@
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_check_log"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_20"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10"
android:text="查看日誌"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</LinearLayout> </LinearLayout>
...@@ -42,6 +42,7 @@ dependencies { ...@@ -42,6 +42,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
//不要超過1.0.2,不然android5.1.1用webview會有問題 //不要超過1.0.2,不然android5.1.1用webview會有問題
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
package="com.joe.print"> package="com.joe.print">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application> <application>
<activity <activity
android:name=".mvp.ui.activity.PrintActivity" android:name=".mvp.ui.activity.PrintActivity"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.joe.print">
package="com.joe.print">
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.PrintActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<activity android:name=".mvp.ui.activity.PrinterListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" /> <application
</intent-filter> android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
</activity> android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.PrintActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<activity android:name=".mvp.ui.activity.PrintTestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<meta-data <category android:name="android.intent.category.LAUNCHER" />
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" </intent-filter>
android:value="ConfigModule" /> </activity>
</application> <activity android:name="com.joe.print.mvp.ui.activity.PrinterListActivity"/>
</manifest> <meta-data
\ No newline at end of file android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
</application>
</manifest>
<resources>
<string name="app_name">PrintModule</string>
</resources>
...@@ -55,6 +55,10 @@ public class PrintComponent implements IComponent { ...@@ -55,6 +55,10 @@ public class PrintComponent implements IComponent {
cc.getContext().startService(intent); cc.getContext().startService(intent);
CC.sendCCResult(cc.getCallId(), CCResult.success()); CC.sendCCResult(cc.getCallId(), CCResult.success());
break; break;
case "stopPrintService":
cc.getContext().stopService(new Intent(cc.getContext(), PrjService.class));
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
default: default:
// cc.callAsync(new IComponentCallback() { // cc.callAsync(new IComponentCallback() {
// @Override // @Override
......
package com.joe.print.mvp.model.bean;
public class PrintInfoBean {
//數組多長就有多少列
private String[] content;
// private int[] widght;//每列佔比權重
private Boolean[] isBold = new Boolean[]{false};
private int[] color = new int[]{0};
private double[] size = new double[]{0};
//content數量為1時才生效,默認居中
private int gravity = 1;
public PrintInfoBean(String[] content) {
this.content = content;
}
public PrintInfoBean(String[] content, double[] size) {
this.content = content;
this.size = size;
}
public PrintInfoBean(String[] content, int gravity) {
this.content = content;
this.gravity = gravity;
}
public PrintInfoBean(String[] content, Boolean[] isBold) {
this.content = content;
this.isBold = isBold;
}
public PrintInfoBean(String[] content, double[] size, int gravity) {
this.content = content;
this.size = size;
this.gravity = gravity;
}
public PrintInfoBean(String[] content, Boolean[] isBold, int gravity) {
this.content = content;
this.isBold = isBold;
this.gravity = gravity;
}
public PrintInfoBean(String[] content, Boolean[] isBold, double[] size) {
this.content = content;
this.isBold = isBold;
this.size = size;
}
public PrintInfoBean(String[] content, Boolean[] isBold, double[] size, int gravity) {
this.content = content;
this.isBold = isBold;
this.size = size;
this.gravity = gravity;
}
public String[] getContent() {
return content;
}
public void setContent(String[] content) {
this.content = content;
}
public Boolean[] getIsBold() {
return isBold;
}
public void setIsBold(Boolean[] isBold) {
this.isBold = isBold;
}
public int[] getColor() {
return color;
}
public void setColor(int[] color) {
this.color = color;
}
public double[] getSize() {
return size;
}
public void setSize(double[] size) {
this.size = size;
}
public int getGravity() {
return gravity;
}
public void setGravity(int gravity) {
this.gravity = gravity;
}
}
...@@ -5,6 +5,7 @@ import android.app.Application; ...@@ -5,6 +5,7 @@ import android.app.Application;
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;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterListBean; import com.gingersoft.gsa.cloud.database.bean.PrinterListBean;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
...@@ -13,7 +14,6 @@ import com.jess.arms.integration.AppManager; ...@@ -13,7 +14,6 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.IpPrintListActivityContract; import com.joe.print.mvp.contract.IpPrintListActivityContract;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import java.util.List; import java.util.List;
......
...@@ -2,9 +2,11 @@ package com.joe.print.mvp.print; ...@@ -2,9 +2,11 @@ package com.joe.print.mvp.print;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.util.Log;
import com.epson.epos2.Epos2Exception; 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.ReceiveListener; import com.epson.epos2.printer.ReceiveListener;
public class EpsonPrint { public class EpsonPrint {
...@@ -52,6 +54,7 @@ public class EpsonPrint { ...@@ -52,6 +54,7 @@ public class EpsonPrint {
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
} }
private int lineCount = 42;
/** /**
* 創建打印數據 * 創建打印數據
* *
...@@ -59,7 +62,7 @@ public class EpsonPrint { ...@@ -59,7 +62,7 @@ public class EpsonPrint {
*/ */
private boolean createPrintData(Bitmap bitmap) { private boolean createPrintData(Bitmap bitmap) {
// String method = ""; // String method = "";
// StringBuilder textData = new StringBuilder(); StringBuilder textData = new StringBuilder();
// final int barcodeWidth = 2; // final int barcodeWidth = 2;
// final int barcodeHeight = 100; // final int barcodeHeight = 100;
if (mPrinter == null) { if (mPrinter == null) {
...@@ -67,32 +70,61 @@ public class EpsonPrint { ...@@ -67,32 +70,61 @@ public class EpsonPrint {
} }
try { try {
// method = "addPulse"; // method = "addPulse";
// mPrinter.addPulse(Printer.PARAM_DEFAULT, // mPrinter.addPulse(Printer.PARAM_DEFAULT,
// Printer.PARAM_DEFAULT); // Printer.PARAM_DEFAULT);
// method = "addTextAlign"; // method = "addTextAlign";
// mPrinter.addTextAlign(Printer.ALIGN_CENTER); // mPrinter.addPageBegin();
// mPrinter.addTextFont(Printer.FONT_A);
// mPrinter.addTextLang(Printer.LANG_ZH_TW);
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
// method = "addImage"; // method = "addImage";
Log.e("ccc", "Epson寬度:" + bitmap.getWidth() + "高度:" + bitmap.getHeight());
mPrinter.addImage(bitmap, 0, 0, mPrinter.addImage(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getWidth(),
bitmap.getHeight(), bitmap.getHeight(),
Printer.COLOR_NONE, Printer.COLOR_1,
Printer.MODE_MONO, Printer.MODE_MONO_HIGH_DENSITY,//高密度
Printer.HALFTONE_DITHER, Printer.HALFTONE_DITHER,//半色調抖動
Printer.PARAM_DEFAULT, Printer.PARAM_DEFAULT,
Printer.COMPRESS_AUTO); Printer.COMPRESS_NONE);//壓縮
//COLOR_NONE 為普通顏色 COLOR_2為紅色 //COLOR_NONE 為普通顏色 COLOR_2為紅色
// method = "addCut"; // mPrinter.addTextSize(2, 2);
// mPrinter.addTextStyle(0,0,1, Printer.COLOR_1);
// mPrinter.addText("炒爐打印測試\n");
//
// //第一個參數不清楚作用,第二個參數ul是加下劃線,第三個參數em是加深顏色,第四個參數color修改文字顏色
// mPrinter.addTextAlign(Printer.ALIGN_LEFT);
// mPrinter.addTextStyle(0,0,0, Printer.COLOR_1);
// mPrinter.addText("時間:" + TimeUtil.getCurrentDate(TimeUtil.dateFormatYMDHMS)+"\n");
// mPrinter.addTextSize(1, 1);
// mPrinter.addText("-------項目-------\n");
// mPrinter.addText("--測試子食品 x1\n");
// mPrinter.addTextAlign(Printer.ALIGN_CENTER);
// mPrinter.addText("----Powered by Gingersoft----\n");
// mPrinter.addTextLang(Printer.LANG_ZH_TW);
// textData.append("------項目-----\n");
// textData.append("測試食品 x1\n");
// textData.append("測試子食品 x1\n");
// mPrinter.addTextSize(3, 3);
// mPrinter.addText(textData.toString());
// textData.setLength(0);
// mPrinter.addFeedLine(2);
// mPrinter.addPageEnd();
mPrinter.addCut(Printer.CUT_FEED); mPrinter.addCut(Printer.CUT_FEED);
// method = "addFeedLine";
// mPrinter.addFeedLine(1); // textData.append("\n");
// textData.append("THE STORE 123 (555) 555 – 5555\n");
// textData.append("STORE DIRECTOR – John Smith\n");
// textData.append("\n");
// textData.append("7/01/07 16:58 6153 05 0191 134\n"); // textData.append("7/01/07 16:58 6153 05 0191 134\n");
// textData.append("ST# 21 OP# 001 TE# 01 TR# 747\n"); // textData.append("ST# 21 OP# 001 TE# 01 TR# 747\n");
// textData.append("------------------------------\n"); // textData.append("------------------------------\n");
// method = "addText"; // method = "addText";
// mPrinter.addText(textData.toString()); // mPrinter.addText(textData.toString());
// mPrinter.addTextStyle(0,0,0,Printer.COLOR_2);
// mPrinter.addText(textData.toString());
// mPrinter.addCut(Printer.CUT_FEED);
// textData.delete(0, textData.length()); // textData.delete(0, textData.length());
// //
// textData.append("400 OHEIDA 3PK SPRINGF 9.99 R\n"); // textData.append("400 OHEIDA 3PK SPRINGF 9.99 R\n");
...@@ -142,15 +174,17 @@ public class EpsonPrint { ...@@ -142,15 +174,17 @@ public class EpsonPrint {
// textData.delete(0, textData.length()); // textData.delete(0, textData.length());
// method = "addFeedLine"; // method = "addFeedLine";
// mPrinter.addFeedLine(2); // mPrinter.addFeedLine(2);
// mPrinter.addPageEnd();
// mPrinter.addCut(Printer.CUT_FEED);
// //
// method = "addBarcode"; // method = "addBarcode";
// mPrinter.addBarcode("01209457", // mPrinter.addBarcode("01209457",
// Printer.BARCODE_CODE39, // Printer.BARCODE_CODE39,
// Printer.HRI_BELOW, // Printer.HRI_BELOW,
// Printer.FONT_A, // Printer.FONT_A,
// barcodeWidth, // 2, 100);
// barcodeHeight);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
return false; return false;
} }
...@@ -158,6 +192,14 @@ public class EpsonPrint { ...@@ -158,6 +192,14 @@ public class EpsonPrint {
return true; return true;
} }
// private String getDataByTextSize(int textsize){
//
//
//
//
// }
public boolean printData(String ip, Bitmap bitmap) { public boolean printData(String ip, Bitmap bitmap) {
if (!createPrintData(bitmap)) { if (!createPrintData(bitmap)) {
return false; return false;
...@@ -165,11 +207,14 @@ public class EpsonPrint { ...@@ -165,11 +207,14 @@ public class EpsonPrint {
if (mPrinter == null) { if (mPrinter == null) {
return false; return false;
} }
if (!connectPrinter(ip)) { // loginfo(mPrinter.getStatus());
mPrinter.clearCommandBuffer(); connectPrinter(ip);
return false; // if (!connectPrinter(ip)) {
} // mPrinter.clearCommandBuffer();
// return false;
// }
try { try {
loginfo(mPrinter.getStatus());
mPrinter.sendData(Printer.PARAM_DEFAULT); mPrinter.sendData(Printer.PARAM_DEFAULT);
} catch (Exception e) { } catch (Exception e) {
mPrinter.clearCommandBuffer(); mPrinter.clearCommandBuffer();
...@@ -185,6 +230,24 @@ public class EpsonPrint { ...@@ -185,6 +230,24 @@ public class EpsonPrint {
return true; return true;
} }
private void loginfo(PrinterStatusInfo statusInfo) {
int connection = statusInfo.getConnection();
int online = statusInfo.getOnline();
int coverOpen = statusInfo.getCoverOpen();
int paper = statusInfo.getPaper();
int paperFeed = statusInfo.getPaperFeed();
int panelSwitch = statusInfo.getPanelSwitch();
int waitOnline = statusInfo.getOnline();
int drawer = statusInfo.getDrawer();
int errorStatus = statusInfo.getErrorStatus();
int autoRecoverError = statusInfo.getAutoRecoverError();
int buzzer = statusInfo.getBuzzer();
int adapter = statusInfo.getAdapter();
int batteryLevel = statusInfo.getBatteryLevel();
Log.e("eee", "connection->" + connection + "online->" + online + "coverOpen->" + coverOpen + "paper->" + paper + "paperFeed->" + paperFeed + "panelSwitch->" + panelSwitch + "waitOnline->" + waitOnline + "drawer->" + drawer + "errorStatus->" + errorStatus + "autoRecoverError->" + autoRecoverError + "buzzer->" + buzzer + "adapter->" + adapter + "batteryLevel->" + batteryLevel);
}
private boolean isConnect = false; private boolean isConnect = false;
private boolean connectPrinter(String ip) { private boolean connectPrinter(String ip) {
......
...@@ -9,11 +9,7 @@ import android.widget.TextView; ...@@ -9,11 +9,7 @@ import android.widget.TextView;
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.adapter.print.KitChenPrintFoodAdapter;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; 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.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.joe.print.R; import com.joe.print.R;
...@@ -24,11 +20,6 @@ import java.util.ArrayList; ...@@ -24,11 +20,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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;
/** /**
* 廚房單打印 * 廚房單打印
...@@ -45,10 +36,22 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -45,10 +36,22 @@ public class PrintPrjKitchen extends PrinterRoot {
String key = entry.getKey(); String key = entry.getKey();
List<Bitmap> bitmaps = new ArrayList<>(); List<Bitmap> bitmaps = new ArrayList<>();
Bitmap bitmap = getKitChenPrintBitmap(mContext, key, entry.getValue()); List<PrjBean.DataBean.Bean> noCut = new ArrayList<>();
//不帶*號,所有同樣廚房位置的食品都在一張紙上 //不帶*號,所有同樣廚房位置的食品都在一張紙上
bitmaps.add(bitmap); for (PrjBean.DataBean.Bean bean : entry.getValue()) {
if (bean.getStatus() == 2) {
List<PrjBean.DataBean.Bean> beans = new ArrayList<>();
beans.add(bean);
Bitmap bitmap = getKitChenPrintBitmap(mContext, key, beans);
bitmaps.add(bitmap);
} else {
noCut.add(bean);
}
}
if(noCut.size()>0) {
Bitmap bitmap = getKitChenPrintBitmap(mContext, key, noCut);
bitmaps.add(bitmap);
}
bitmapMaps.put(key, bitmaps); bitmapMaps.put(key, bitmaps);
} }
prjMap.clear(); prjMap.clear();
...@@ -88,6 +91,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -88,6 +91,7 @@ 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 tvOrderNumber = view.findViewById(R.id.tv_order_num); TextView tvOrderNumber = view.findViewById(R.id.tv_order_num);
...@@ -113,9 +117,10 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -113,9 +117,10 @@ public class PrintPrjKitchen extends PrinterRoot {
tvTableNumber.setText(data.get(0).getTableName()); tvTableNumber.setText(data.get(0).getTableName());
tvTableNumber2.setText(data.get(0).getTableName()); tvTableNumber2.setText(data.get(0).getTableName());
//人數 //人數
if(data.get(0).getPerson() != 0) { if (data.get(0).getPerson() != 0) {
tvPeople.setText(data.get(0).getPerson() + ""); tvPeople.setText(data.get(0).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);
} }
//訂單號 //訂單號
tvOrderNumber.setText(data.get(0).getOrderNo()); tvOrderNumber.setText(data.get(0).getOrderNo());
...@@ -136,7 +141,7 @@ public class PrintPrjKitchen extends PrinterRoot { ...@@ -136,7 +141,7 @@ public class PrintPrjKitchen extends PrinterRoot {
//落單時間,為當前時間 //落單時間,為當前時間
tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)); tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT));
//操作人員 //操作人員
tvOperator.setText(""); tvOperator.setText(GsaCloudApplication.getMemberName(context));
return viewToBitmap(context, view); return viewToBitmap(context, view);
} }
......
...@@ -353,7 +353,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -353,7 +353,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) { private void defaultPrint(List<PrinterDeviceBean> printerDeviceBeans, List<Bitmap> bitmaps) {
//獲取默認打印方式,本機、IP //獲取默認打印方式,本機、IP
String deftultPrint = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_METHOD, ""); String deftultPrint = (String) SPUtils.get(mContext, PrintConstans.DEFAULT_PRINT_METHOD, "");
if (deftultPrint.equals("")) { if (deftultPrint != null && deftultPrint.equals("")) {
// 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印 // 如果沒有默認打印位置,彈出彈窗讓用戶選擇是本機打印還是ip打印
new DialogUtils(mContext, R.layout.print_dialog_select_device) { new DialogUtils(mContext, R.layout.print_dialog_select_device) {
@Override @Override
...@@ -390,7 +390,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -390,7 +390,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
}); });
} }
}.show(); }.show();
} else if (deftultPrint.equals(PrintConstans.LOCAL_PRINT)) { } else if (deftultPrint != null && deftultPrint.equals(PrintConstans.LOCAL_PRINT)) {
// 默認打印方式為本地,進行本地打印 // 默認打印方式為本地,進行本地打印
locationPrint(bitmaps, new PrintListener() { locationPrint(bitmaps, new PrintListener() {
@Override @Override
...@@ -408,7 +408,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -408,7 +408,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
setPrintState(PrintActivity.FINISH); setPrintState(PrintActivity.FINISH);
} }
}); });
} else if (deftultPrint.equals(PrintConstans.IP_PRINT)) { } else if (deftultPrint != null && deftultPrint.equals(PrintConstans.IP_PRINT)) {
// 默認打印方式為ip打印,調用ip打印方法 // 默認打印方式為ip打印,調用ip打印方法
// 獲取默認ip打印機 // 獲取默認ip打印機
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) { if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
...@@ -466,7 +466,8 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -466,7 +466,8 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} }
} }
.setHeight(ArmsUtils.getScreenHeidth(mContext) / 2) .setHeight(ArmsUtils.getScreenHeidth(mContext) / 2)
.setOnDismissListener(dialog -> setPrintState(PrintActivity.DIMISS_LOADING)) .setWidth((int) (ArmsUtils.getScreenWidth(mContext) * 0.8))
.setOnDismissListener(dialog -> setPrintState(PrintActivity.FINISH))
.show(); .show();
} }
} else { } else {
...@@ -499,21 +500,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -499,21 +500,23 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
printWidth = 480; printWidth = 480;
printerDeviceBean.setPaperSpecification(printWidth + ""); printerDeviceBean.setPaperSpecification(printWidth + "");
} }
Log.e("ccc", "紙張寬度:" + printWidth);
List<Bitmap> zoomBitmap = null;
if (bitmaps != null) {
zoomBitmap = new ArrayList<>();
for (int i = 0; i < bitmaps.size(); i++) {
zoomBitmap.add(ImageUtils.zoomDrawable(bitmaps.get(i), printWidth));
}
}
if (zoomBitmap == null) {
printListener.printFile();
return;
}
//獲取打印機機型,如果是EPSON的打印機,調用EPSON的打印方法 //獲取打印機機型,如果是EPSON的打印機,調用EPSON的打印方法
if (printerDeviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()) if ((printerDeviceBean.getPrinterName() != null && printerDeviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
|| printerDeviceBean.getModel().toLowerCase().contains("EPSON".toLowerCase())) { && (printerDeviceBean.getModel() != null && printerDeviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
List<Bitmap> zoomBitmap = null;
if (bitmaps != null) {
zoomBitmap = new ArrayList<>();
for (int i = 0; i < bitmaps.size(); i++) {
if(bitmaps.get(i) != null) {
Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth, 2d);
zoomBitmap.add(newBitmap);
}
}
}
if (zoomBitmap == null) {
printListener.printFile();
return;
}
List<Bitmap> finalZoomBitmap = zoomBitmap; List<Bitmap> finalZoomBitmap = zoomBitmap;
mPrinter = new EpsonPrint(); mPrinter = new EpsonPrint();
mPrinter.initializeObject(mContext, this); mPrinter.initializeObject(mContext, this);
...@@ -532,6 +535,19 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -532,6 +535,19 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
} }
}).start(); }).start();
} else { } else {
List<Bitmap> zoomBitmap = null;
if (bitmaps != null) {
zoomBitmap = new ArrayList<>();
for (int i = 0; i < bitmaps.size(); i++) {
Bitmap newBitmap = ImageUtils.zoomDrawable(bitmaps.get(i), printWidth);
Log.e("eee", "寬度:" + newBitmap.getWidth() + "高度:" + newBitmap.getHeight());
zoomBitmap.add(newBitmap);
}
}
if (zoomBitmap == null) {
printListener.printFile();
return;
}
PrintExecutor executor = new PrintExecutor(printerDeviceBean); PrintExecutor executor = new PrintExecutor(printerDeviceBean);
executor.setOnStateChangedListener(stateChangedListener); executor.setOnStateChangedListener(stateChangedListener);
executor.setOnPrintResultListener(resultListener); executor.setOnPrintResultListener(resultListener);
......
package com.joe.print.mvp.print;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriterExecutor;
import com.joe.print.mvp.model.bean.PrintInfoBean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Wyh on 2020/1/9.
* ip打印類
*/
public class TestPrintMaker implements PrintDataMaker {
private PrinterWriter printer;
private List<PrintInfoBean> printInfoBeans;
public TestPrintMaker(PrinterWriter printer, List<PrintInfoBean> printInfoBeans) {
this.printer = printer;
this.printInfoBeans = printInfoBeans;
}
@Override
public List<byte[]> getPrintData() {
ArrayList<byte[]> data = new ArrayList<>();
try {
for (PrintInfoBean printInfoBean : printInfoBeans) {
if (printInfoBean.getGravity() == 0) {
printer.setAlignLeft();
}
if (printInfoBean.getGravity() == 1) {
printer.setAlignCenter();
}
if (printInfoBean.getGravity() == 2) {
printer.setAlignRight();
}
if(printInfoBean.getSize().length > 1){
//如果打印多列內容,並且字體大小配置多個,則每一列取自己對應的字體大小
for (int i = 0; i < printInfoBean.getSize().length; i++) {
//打印多列
if (printInfoBean.getIsBold()[i]) {
printer.setEmphasizedOn();
} else {
printer.setEmphasizedOff();
}
printer.setFontSize(printInfoBean.getSize()[i]);
printer.print(printInfoBean.getContent()[i]);
}
} else {
if(printInfoBean.getContent().length == 1){
//如果只打印一列內容,則字體大小只取size數組的第一個
if (printInfoBean.getIsBold()[0]) {
printer.setEmphasizedOn();
} else {
printer.setEmphasizedOff();
}
printer.setFontSize(printInfoBean.getSize()[0]);
printer.print(printInfoBean.getContent()[0]);
}
}
printer.print("\n");
}
printer.printLineFeed();
printer.printLineFeed();
printer.feedPaperCutPartial();
data.add(printer.getDataAndReset());
data.add(printer.getDataAndClose());
return data;
} catch (Exception e) {
return new ArrayList<>();
}
}
}
...@@ -57,13 +57,17 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -57,13 +57,17 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
super.onCreate(); super.onCreate();
//讀取本地ip打印機 //讀取本地ip打印機
Log.e("eee", "開啟打印服務"); Log.e("eee", "開啟打印服務");
if (printerDeviceBeans == null) { getPrintList();
//開始請求
startGetPrjInfo();
}
private void getPrintList() {
if (printerDeviceBeans == null || printerDeviceBeans.size() == 0) {
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this); PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean(); printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
printerDeviceDaoUtils.closeConnection(); printerDeviceDaoUtils.closeConnection();
} }
//開始請求
startGetPrjInfo();
} }
@Nullable @Nullable
...@@ -110,7 +114,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -110,7 +114,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
private void getPrjInfo() { private void getPrjInfo() {
OkHttp3Utils.get(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + "printerRecording/get?restaurantId=" + GsaCloudApplication.getRestaurantId(this)) OkHttp3Utils.get(HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + "printerRecording/get?restaurantId=" + GsaCloudApplication.getRestaurantId(this))
.subscribeOn(Schedulers.io())//切换到io线程進行網絡請求 .subscribeOn(Schedulers.io())//切换到io线程進行網絡請求
.observeOn(AndroidSchedulers.mainThread())//切換到主線程處理請求結果 .observeOn(Schedulers.io())//切換到io线程處理請求結果
.subscribe(new Observer<String>() { .subscribe(new Observer<String>() {
@Override @Override
...@@ -124,6 +128,9 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -124,6 +128,9 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢 //請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
startPrint(s); startPrint(s);
//開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。 //開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。
if(wakeDisposable != null){
wakeDisposable.dispose();
}
Observable.timer(10, TimeUnit.SECONDS) Observable.timer(10, TimeUnit.SECONDS)
.subscribe(new Observer<Long>() { .subscribe(new Observer<Long>() {
@Override @Override
...@@ -192,7 +199,8 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -192,7 +199,8 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
// if (key.equals("-1")) { // if (key.equals("-1")) {
// PrintPrjKitchen.getPrjMap().put("", datas); // PrintPrjKitchen.getPrjMap().put("", datas);
// } else { // } else {
Log.e("eee", "打印數據條數:" + datas.size()); Log.e("eee", key + "打印數據條數:" + datas.size());
PrintPrjKitchen.getPrjMap().put(key, datas); PrintPrjKitchen.getPrjMap().put(key, datas);
// } // }
printDatas.addAll(datas); printDatas.addAll(datas);
...@@ -204,14 +212,19 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -204,14 +212,19 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
if (printerInIt == null) { if (printerInIt == null) {
printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN); printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN);
} }
// if(printerInIt != null && printerInIt.getPrintBitmap(this).size() <=0){
// return;
// }
getPrintList();
if (printerInIt != null) { if (printerInIt != null) {
Log.e("aaa", "打印機數量:" +printerDeviceBeans.size());
printerInIt.setmContext(this); printerInIt.setmContext(this);
for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this).entrySet()) { for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this).entrySet()) {
//遍歷所有的需要打印的內容 //遍歷所有的需要打印的內容
for (int i = 0; i < printerDeviceBeans.size(); i++) { for (int i = 0; i < printerDeviceBeans.size(); i++) {
//遍歷打印機列表,找到對應的打印機,沒找到的就不打印 //遍歷打印機列表,找到對應的打印機,沒找到的就不打印
if (entry.getKey().equalsIgnoreCase(printerDeviceBeans.get(i).getName())) { if (entry.getKey().equalsIgnoreCase(printerDeviceBeans.get(i).getName())) {
Log.e("eee", entry.getKey() + "開始打印IP:" + printerDeviceBeans.get(i).getIp());
printerInIt.ipDevicePrint(printerDeviceBeans.get(i), entry.getValue(), this, this); printerInIt.ipDevicePrint(printerDeviceBeans.get(i), entry.getValue(), this, this);
break; break;
} }
......
package com.joe.print.mvp.ui.activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.print.PrintHelper;
import android.os.Bundle;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.R;
import com.joe.print.mvp.model.bean.PrintInfoBean;
import com.joe.print.mvp.print.IpPrintMaker;
import com.joe.print.mvp.print.TestPrintMaker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class PrintTestActivity extends AppCompatActivity implements PrintSocketHolder.OnStateChangedListener, PrintExecutor.OnPrintResultListener {
private int lineLength = 42;//一行42個
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_print_test);
PrinterDeviceBean printerDeviceBean = new PrinterDeviceBean("192.168.1.218", 9100, "400");
List<PrintInfoBean> printInfoBeans = new ArrayList<>();
printInfoBeans.add(new PrintInfoBean(new String[]{"正式測試品牌"}, new double[]{1}));
printInfoBeans.add(new PrintInfoBean(new String[]{"純屬餐廳"}, new double[]{1}));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("自取", 1.5)}, new Boolean[]{true}, new double[]{1.5}));
printInfoBeans.add(new PrintInfoBean(new String[]{"貨到付款"}, new Boolean[]{true}, new double[]{1.5}));
printInfoBeans.add(new PrintInfoBean(new String[]{"07-08(週三)立即"}, new double[]{1.5}));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1)}));
findViewById(R.id.btn_test).setOnClickListener(view -> {
//打印測試
PrintHelper helper = new PrintHelper(this);
// helper.printBitmap("192.168.1.218", );
PrintExecutor executor = new PrintExecutor(printerDeviceBean);
executor.setOnStateChangedListener(this);
executor.setOnPrintResultListener(this);
TestPrintMaker maker = null;
try {
maker = new TestPrintMaker(new PrinterWriter80mm(255), printInfoBeans);
} catch (IOException e) {
e.printStackTrace();
}
executor.doPrinterRequestAsync(maker);
});
}
@Override
public void onResult(int errorCode, PrinterDeviceBean printerDeviceBean) {
}
@Override
public void onStateChanged(int state, PrinterDeviceBean printerDeviceBean) {
}
private String getLineBorder(String text, double fontSize) {
if(fontSize == 0){
fontSize = 1;
}
int count = (int) ((lineLength / fontSize) - text.length());
StringBuilder builder = new StringBuilder();
for (int i = 0; i < count / 2; i++) {
builder.append("-");
}
builder.append(text);
for (int i = 0; i < count / 2; i++) {
builder.append("-");
}
return builder.toString();
}
}
...@@ -116,12 +116,12 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -116,12 +116,12 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
mTvModel.setText(printerDeviceBean.getPrinterName() + "\u3000" + printerDeviceBean.getModel()); mTvModel.setText(printerDeviceBean.getPrinterName() + "\u3000" + printerDeviceBean.getModel());
} }
} }
mSwitchDefalute.setChecked(printerDeviceBean.getType() == 2); mSwitchDefalute.setChecked(printerDeviceBean.getPrinterDeviceDefaultId() != null);
if (devicess != null && devicess.size() > 0) { if (devicess != null && devicess.size() > 0) {
if (printerDeviceBean.getFlyPrinterDeviceId() != null && printerDeviceBean.getFlyPrinterDeviceId() != 0) { if (printerDeviceBean.getFlyPrinterDeviceId() != null && printerDeviceBean.getFlyPrinterDeviceId() != 0) {
//有飛單 //有飛單
for (int i = 0; i < devicess.size(); i++) { for (int i = 0; i < devicess.size(); i++) {
if (devicess.get(i).getId() == printerDeviceBean.getFlyPrinterDeviceId()) { if (devicess.get(i).getId().equals(printerDeviceBean.getFlyPrinterDeviceId())) {
mTvFailNameOne.setText(devicess.get(i).getName()); mTvFailNameOne.setText(devicess.get(i).getName());
oneFailPosition = i; oneFailPosition = i;
mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c)); mTvFailNameOne.setTextColor(getResources().getColor(R.color.color_3c));
...@@ -131,7 +131,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -131,7 +131,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
if (printerDeviceBean.getFlyPrinterDeviceId2() != null && printerDeviceBean.getFlyPrinterDeviceId2() != 0) { if (printerDeviceBean.getFlyPrinterDeviceId2() != null && printerDeviceBean.getFlyPrinterDeviceId2() != 0) {
//有飛單2222 //有飛單2222
for (int i = 0; i < devicess.size(); i++) { for (int i = 0; i < devicess.size(); i++) {
if (devicess.get(i).getId() == printerDeviceBean.getFlyPrinterDeviceId2()) { if (devicess.get(i).getId().equals(printerDeviceBean.getFlyPrinterDeviceId2())) {
mTvFailNameTwo.setText(devicess.get(i).getName()); mTvFailNameTwo.setText(devicess.get(i).getName());
twoFailPosition = i; twoFailPosition = i;
mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c)); mTvFailNameTwo.setTextColor(getResources().getColor(R.color.color_3c));
...@@ -168,7 +168,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem ...@@ -168,7 +168,7 @@ public class PrinterAddActivity extends BaseActivity<PrinterAddPresenter> implem
printModelLabels = new ArrayList<>(); printModelLabels = new ArrayList<>();
for (int i = 0; i < printModelBeans.size(); i++) { for (int i = 0; i < printModelBeans.size(); i++) {
printModelLabels.add(printModelBeans.get(i).getPrinterName() + "\u3000" + printModelBeans.get(i).getModel()); printModelLabels.add(printModelBeans.get(i).getPrinterName() + "\u3000" + printModelBeans.get(i).getModel());
if (printerDeviceBean != null && printerDeviceBean.getPrinterModelId() == printModelBeans.get(i).getId()) { if (printerDeviceBean != null && printerDeviceBean.getPrinterModelId() != null && printerDeviceBean.getPrinterModelId() == printModelBeans.get(i).getId()) {
modelPosition = i; modelPosition = i;
} }
} }
......
...@@ -3,11 +3,9 @@ package com.joe.print.mvp.ui.fragment; ...@@ -3,11 +3,9 @@ package com.joe.print.mvp.ui.fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.util.Log;
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.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -88,12 +86,6 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit ...@@ -88,12 +86,6 @@ public class IpPrintListActivityFragment extends BaseFragment<IpPrintListActivit
mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext)); mPresenter.getPrinterList(GsaCloudApplication.getRestaurantId(mContext));
} }
@Override
public void onStart() {
super.onStart();
}
/** /**
* 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法, * 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法,
* 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {#setData(Object)} * 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {#setData(Object)}
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.joe.print.mvp.ui.activity.PrintTestActivity">
<Button
android:id="@+id/btn_test"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:layout_centerInParent="true"
android:text="打印測試" />
</RelativeLayout>
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<TextView <TextView
android:id="@+id/tv_printer_port" android:id="@+id/tv_printer_port"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:singleLine="true" android:singleLine="true"
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
android:singleLine="true" android:singleLine="true"
android:text="端口號:" android:text="端口號:"
android:textColor="@color/normal_color" android:textColor="@color/normal_color"
android:visibility="gone"
android:textSize="@dimen/dp_12" android:textSize="@dimen/dp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_printer_ip" app:layout_constraintLeft_toLeftOf="@id/tv_printer_ip"
app:layout_constraintTop_toBottomOf="@id/tv_printer_ip" /> app:layout_constraintTop_toBottomOf="@id/tv_printer_ip" />
......
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