Commit cca5a5c7 by Wyh

8.13 1、PRJ打印新增外賣和自取時間 2、修復USB打印bug 3、添加immersionbar狀態欄工具依賴,修改首頁狀態欄顯示

Signed-off-by: Wyh <1239658231>
parent d48dff72
......@@ -150,6 +150,8 @@ dependencies {
//解决Glide找不到Android声明库问题
annotationProcessor 'androidx.annotation:annotation:1.1.0'
// testApi rootProject.ext.dependencies["junit"]
api rootProject.ext.dependencies["immersionbar-components"]
api rootProject.ext.dependencies["immersionbar"]
}
......
......@@ -22,23 +22,20 @@ import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import com.jess.arms.base.delegate.IActivity;
import com.jess.arms.integration.cache.Cache;
import com.jess.arms.integration.cache.CacheType;
import com.jess.arms.integration.lifecycle.ActivityLifecycleable;
import com.jess.arms.mvp.IPresenter;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.arch.QMUIFragmentActivity;
import com.qmuiteam.qmui.skin.QMUISkinManager;
import com.trello.rxlifecycle2.android.ActivityEvent;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.subjects.BehaviorSubject;
......@@ -98,6 +95,10 @@ public abstract class BaseFragmentActivity<P extends IPresenter> extends Fragmen
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ImmersionBar.with(this)
// .statusBarDarkFont(true)
// .navigationBarDarkIcon(true)
// .init();
mDelegate.onCreate(savedInstanceState);
mContext = this;
//DecorView的背景对我来说无用,但是会产生一次Overdraw,这里去掉(过度绘制优化)
......
......@@ -46,7 +46,6 @@ public class FoodAdapter extends BaseQuickAdapter<OrderDetail, BaseViewHolder> {
}
/**
*
* @param data
* @param deviceBean 打印機信息
*/
......@@ -75,7 +74,7 @@ public class FoodAdapter extends BaseQuickAdapter<OrderDetail, BaseViewHolder> {
TextView tvFoodName = helper.getView(R.id.tv_food_name);
TextView tvNum = helper.getView(R.id.tv_food_quantity);
TextView tvPrice = helper.getView(R.id.tv_food_price);
if(showPrice){
if (showPrice) {
tvPrice.setVisibility(View.VISIBLE);
} else {
tvPrice.setVisibility(View.GONE);
......@@ -128,7 +127,7 @@ public class FoodAdapter extends BaseQuickAdapter<OrderDetail, BaseViewHolder> {
// tvFoodName.setTypeface(null, Typeface.BOLD);
// tvFoodName.setTypeface(null, Typeface.ITALIC);
// tvFoodName.setTypeface(null, Typeface.NORMAL);
helper.setText(R.id.tv_food_quantity, String.valueOf(item.getNumber()));
helper.setText(R.id.tv_food_price, "$" + item.getPrice());
tvNum.setText("X" + item.getNumber());
tvPrice.setText("$" + item.getPrice());
}
}
......@@ -20,6 +20,7 @@ import android.widget.TextView;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
......@@ -45,7 +46,6 @@ public abstract class DialogUtils implements LifecycleObserver {
}
private void init(Context context) {
// dismiss();
dialog = new Dialog(context);
viewHepler = getViewHepler(context);
initLayout(viewHepler, dialog);
......@@ -261,6 +261,13 @@ public abstract class DialogUtils implements LifecycleObserver {
return (T) view;
}
public ViewHepler setAdapter(int viewId, RecyclerView.LayoutManager layoutManager, RecyclerView.Adapter adapter){
RecyclerView rv = getView(viewId);
rv.setLayoutManager(layoutManager);
rv.setAdapter(adapter);
return this;
}
public ViewHepler setOnClickListenter(int viewId, View.OnClickListener onClickListener) {
getView(viewId).setOnClickListener(onClickListener);
return this;
......
......@@ -106,6 +106,7 @@ class OrderDetails {
// * * Order Cancelled After Collection - 訂單已取消 - 取餐后 9
// * * Order Assigned To Another Delivery Man - 已指派另一位配送員 10
var payMultiple: List<PayMultiple>? = null
var companyType:Int = -1 //物流公司類型 0 本店配送 1:zeek;2:lalamove
class PRODUCTNAMEBean : Serializable {
/**
......
......@@ -2,10 +2,16 @@ package com.gingersoft.gsa.cloud.ui.utils;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.jess.arms.utils.ArmsUtils;
public class AppDialog {
......@@ -13,12 +19,7 @@ public class AppDialog {
showWaringDialog(context, title, null, null, sureOnclickListenter, null);
}
// public static void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
// showWaringDialog(context, title, null, null, sureOnclickListenter, null);
// }
private void showWaringDialog(Context context, String title, String confimText, String cancelText, DialogOnClickListenter sureOnclickListenter, DialogOnClickListenter cancelOnclickListenter) {
//暫停接單,彈窗向用戶確認是否關閉
new DialogUtils(context, R.layout.other_order_pause_orders) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
......@@ -39,6 +40,21 @@ public class AppDialog {
}.show();
}
public void showSelectDialog(Context context, String title, RecyclerView.Adapter adapter, DialogOnClickListenter sureOnclickListenter) {
new DialogUtils(context, R.layout.dialog_select_layout) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
hepler.setText(R.id.tv_title, title);
hepler.setAdapter(R.id.rv_delivery, new GridLayoutManager(context, 4), adapter);
hepler.setOnClickListenter(R.id.tv_delivery_confirm, v -> sureOnclickListenter.onclick(v, dialog));
hepler.setOnClickListenter(R.id.tv_delivery_cancel, v -> sureOnclickListenter.onclick(v, dialog));
}
}
.setWidth(WindowManager.LayoutParams.MATCH_PARENT)
.setHeight((int) (ArmsUtils.getScreenHeidth(context) * 0.5))
.setGravity(Gravity.BOTTOM)
.show();
}
public interface DialogOnClickListenter {
void onclick(View view, Dialog dialog);
......
......@@ -10,6 +10,7 @@
style="@style/Print_text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_5"
tools:text="食品名食品名食品名食品名食品名食品名"
android:layout_weight="0.6" />
......@@ -20,7 +21,7 @@
android:layout_height="wrap_content"
android:layout_weight="0.15"
android:layout_gravity="bottom"
tools:text="X1100024242211222220"
tools:text="x111111"
android:gravity="right|center_vertical" />
<TextView
......@@ -29,7 +30,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
tools:text="價格:$100000"
android:layout_marginLeft="@dimen/dp_5"
tools:text="100000000"
android:layout_weight="0.25"
android:gravity="right|center_vertical" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
......@@ -90,6 +91,14 @@
android:textSize="@dimen/dp_28" />
</LinearLayout>
<TextView
android:id="@+id/tv_food_time"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_28"
tools:text="盡快送達" />
<LinearLayout
android:id="@+id/layout_opening_table_time"
android:layout_width="match_parent"
......
......@@ -7,8 +7,8 @@ ext {
targetSdkVersion : 28,
//正式版: 1.0.3 3
//內部測試版:1.2.0 20
versionCode : 4,
versionName : "1.0.4"
versionCode : 5,
versionName : "1.0.5"
]
version = [
......@@ -118,7 +118,12 @@ ext {
"fastjson" : "com.alibaba:fastjson:1.2.46",
"zxing" : "cn.yipianfengye.android:zxing-library:2.2",
"BaseRecyclerViewAdapter" : "com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4",
"yzjRecyclerView" : "com.yanzhenjie.recyclerview:x:1.3.2"
"yzjRecyclerView" : "com.yanzhenjie.recyclerview:x:1.3.2",
// 狀態欄基础依赖包,必须要依赖
"immersionbar" : "com.gyf.immersionbar:immersionbar:3.0.0",
// fragment快速实现(可选)
"immersionbar-components" : "com.gyf.immersionbar:immersionbar-components:3.0.0"
]
}
......@@ -86,5 +86,4 @@ dependencies {
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
implementation rootProject.ext.dependencies["autosize"]
}
......@@ -20,6 +20,8 @@
android:label="@string/user_login_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher"
android:resizeableActivity="true"
android:maxAspectRatio="2.4"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:label">
......@@ -50,6 +52,19 @@
<meta-data
android:name="design_height_in_dp"
android:value="640"/>
<meta-data
android:name="android.max_aspect"
android:value="2.4" />
<!--适配华为(huawei)刘海屏-->
<meta-data
android:name="android.notch_support"
android:value="true"/>
<!--适配小米(xiaomi)刘海屏-->
<meta-data
android:name="notch.config"
android:value="portrait|landscape" />
</application>
</manifest>
......@@ -96,8 +96,6 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override
public int initView(@Nullable Bundle savedInstanceState) {
// StatusBarUtil.setTransparent(this);
// StatusBarUtil.setDarkMode(this);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//SOFT_INPUT_ADJUST_NOTHING
return R.layout.user_login_activity_login; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
......
......@@ -63,7 +63,6 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@BindView(R2.id.tv_experience)
TextView mTvExperience;
List<GuideBean> guideBeanList = new ArrayList<>();
private final long ANIMATION_TIME = 1300;
@Override
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -8,8 +8,7 @@
<RelativeLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent">
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_welcome_title"
......@@ -140,4 +139,4 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</FrameLayout>
\ No newline at end of file
......@@ -203,7 +203,7 @@ public class SettlementReportPresenter extends BasePresenter<SettlementReportCon
} else {
if (!TextUtils.isEmpty(info.getErrMsg())) {
// mRootView.showMessage(info.getErrMsg() + ",清機失敗");
showMergeSettlementDialog(IActivity,info.getErrMsg() + ",清機失敗");
showSettlementErrorDialog(info.getErrMsg() + ",清機失敗");
} else {
mRootView.showMessage("清機失敗");
}
......
......@@ -44,6 +44,7 @@ import com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu;
import com.gingersoft.gsa.cloud.ui.bean.mode.BrandsBean;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.gyf.immersionbar.ImmersionBar;
import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
......@@ -103,7 +104,6 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@BindView(R2.id.qm_refresh)
SmartRefreshLayout refresh;
private MainTopFragment mainTopFragment;
@BindViews({R2.id.tv_function_name1, R2.id.tv_function_name2, R2.id.tv_function_name3})
TextView[] mTvFunctionNames;
......@@ -135,6 +135,8 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
@Override
public void initData(@Nullable Bundle savedInstanceState) {
// mPresenter.requestExternalStoragePermission();
ImmersionBar.with(this).titleBar(R.id.cl_title_layout).init();
ImmersionBar.with(this).titleBar(R.id.side_layout).navigationBarAlpha(1).init();
//初始化側邊欄菜單項
initSideMenu();
......
......@@ -13,6 +13,7 @@
android:orientation="horizontal">
<!-- 側邊欄內容-->
<LinearLayout
android:id="@+id/side_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
......
......@@ -30,4 +30,6 @@
<color name="payment_method_color19">#e4c6d0</color>
<color name="payment_method_color20">#103371</color>
<color name="main_top_color">#00C0FA</color>
</resources>
......@@ -24,6 +24,7 @@ class CoolWeatherNetwork {
private val orderPayService = ServiceCreator.create5(WeatherService::class.java)
private val systemService= ServiceCreator.createSystem(WeatherService::class.java)
//獲取訂單列表
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
......@@ -81,6 +82,8 @@ class CoolWeatherNetwork {
suspend fun noticePersonnel(requestBody: RequestBody) = appService.noticePersonnel(requestBody).await()
suspend fun getTransportationConfig(restaurantId: String) = systemService.getTransportationConfig(restaurantId).await()
private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation ->
enqueue(object : Callback<T> {
......
......@@ -27,7 +27,6 @@ object ServiceCreator {
.addInterceptor(LoggingInterceptor())
.addInterceptor(UserAgentIntercepter())
var ROOT_URL: String = HttpsConstans.ROOT_URL
var CLOUD_BASE_URL: String = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL
......@@ -35,6 +34,7 @@ object ServiceCreator {
private var BASE_URL2 = "$ROOT_URL/member-web/api/"
private var BASE_URL3 = "$ROOT_URL/member-web/ricepon-gsa/api/"
private var BASE_URL4 = "$ROOT_URL/ricepon-order/api/"
private var BASE_SYSTEM = "$ROOT_URL/ricepon-system/api/"
private val builder = Retrofit.Builder()
.baseUrl(BASE_URL)
......@@ -66,6 +66,12 @@ object ServiceCreator {
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
private val builderSystem = Retrofit.Builder()
.baseUrl(BASE_SYSTEM)
.client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
fun <T> create(serviceClass: Class<T>): T = builder.build().create(serviceClass)
fun <T> create2(serviceClass: Class<T>): T = builder2.build().create(serviceClass)
......@@ -76,6 +82,7 @@ object ServiceCreator {
fun <T> create5(serviceClass: Class<T>): T = builder5.build().create(serviceClass)
fun <T> createSystem(serviceClass: Class<T>): T = builderSystem.build().create(serviceClass)
/**
* 添加请求头
*/
......
......@@ -40,7 +40,7 @@ interface WeatherService {
fun thirdDelivery(@Body requestBody: RequestBody): Call<ThirdSend>
@POST("order/updateOrderInfoIsRead")
fun updateIsRead(@Body requestBody: RequestBody):Call<String>
fun updateIsRead(@Body requestBody: RequestBody): Call<String>
@POST("wechat/updateSelfOrderStatus")
fun updateSelfOrderStatus(@Body requestBody: RequestBody): Call<UpdateOrderBean>
......@@ -61,7 +61,7 @@ interface WeatherService {
fun cancelOrder(@Body requestBody: RequestBody): Call<CancelLogisticsBean>
@GET("restaurantFoodReason/config/list")
fun getCancelReason(@Query("brandId") brandId:Int, @Query("restaurantId") restaurantId:Int, @Query("type") type:Int): Call<CancelReason>
fun getCancelReason(@Query("brandId") brandId: Int, @Query("restaurantId") restaurantId: Int, @Query("type") type: Int): Call<CancelReason>
@POST("order/confirmPay")
fun getPayMethod(@Body requestBody: RequestBody): Call<PayTypeInfo>
......@@ -69,5 +69,6 @@ interface WeatherService {
@POST("printerRecording/add")
fun addPrj(@Body requestBody: RequestBody): Call<String>
@GET("restaurantTransportationConfig/list")
fun getTransportationConfig(@Query("restaurantId") restaurantId: String):Call<TransportationBean>
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding
import com.gingersoft.gsa.other_order_mode.databinding.LayoutDeliveryOrderItemBinding
import com.scwang.smartrefresh.layout.util.SmartUtil.dp2px
class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.ViewHolder>() {
......
......@@ -121,10 +121,9 @@ object OtherOrderUtils {
if (orderData.DELIVERY_CHARGE != 0.0) {
billBeans.add(BillBean("送貨費:", orderData.DELIVERY_CHARGE, 0))
}
if (orderData.discount_amount != 0.0) {
billBeans.add(BillBean("折扣:", orderData.discount_amount, 0))
}
billBeans.add(BillBean("總金額:", MoneyUtil.sub(totalAmount, orderData.discount_amount), 0))
// if (orderData.discount_amount != 0.0) {
// billBeans.add(BillBean("折扣:", orderData.discount_amount, 0))
// }
// billBeans.add(BillBean("支付金額:", MoneyUtil.sub(totalAmount, orderData.discount_amount), 1))
orderData.couponList?.let {
for (coupon in it) {
......@@ -133,6 +132,7 @@ object OtherOrderUtils {
}
}
}
billBeans.add(BillBean("支付金額:", MoneyUtil.sub(totalAmount, orderData.discount_amount), 1))
orderData.payMultiple?.let {
for (payMultiple in it) {
......
......@@ -3,6 +3,7 @@ package com.gingersoft.gsa.other_order_mode.util
import android.app.Activity
import android.app.Dialog
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
import com.gingersoft.gsa.other_order_mode.R
......@@ -28,3 +29,16 @@ fun Activity.showWaringDialog(title: String, confirm: (Dialog) -> Unit, cancel:
}
}
fun Activity.showSelectDialog(title: String, adapter: RecyclerView.Adapter<RecyclerView.ViewHolder>, confirm: (Dialog) -> Unit, cancel: (Dialog) -> Unit){
AppDialog().showSelectDialog(this, title, adapter){view, dialog->
when (view.id) {
R.id.tv_delivery_confirm -> {
confirm.invoke(dialog)
}
R.id.tv_delivery_cancel -> {
cancel.invoke(dialog)
}
}
}
}
......@@ -14,6 +14,7 @@
android:paddingRight="@dimen/dp_20"
android:paddingBottom="@dimen/dp_10"
android:text="配送設置"
android:visibility="gone"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
......
......@@ -23,7 +23,7 @@
<string name="self_taking_time">自取時間:</string>
<string name="receiving_address">收貨地址:</string>
<string name="meal_code">取餐碼:</string>
<string name="address">地址:</string>
<string name="address">\u3000址:</string>
<string name="table_number">檯號:</string>
<string name="self">自取</string>
......
......@@ -89,6 +89,9 @@ public class PrjBean {
private int itemType;
private String sender;
private String takeTime;
private String sendTime;
public int getId() {
return id;
}
......@@ -288,6 +291,22 @@ public class PrjBean {
public void setUserName(String userName) {
this.userName = userName;
}
public String getTakeTime() {
return takeTime;
}
public void setTakeTime(String takeTime) {
this.takeTime = takeTime;
}
public String getSendTime() {
return sendTime;
}
public void setSendTime(String sendTime) {
this.sendTime = sendTime;
}
}
public Map<String, List<Bean>> getPrjMap() {
......
......@@ -9,7 +9,6 @@ import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
......@@ -108,6 +107,7 @@ public class PrintPrjKitchen extends PrinterRoot {
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 tvTakeTime = view.findViewById(R.id.tv_food_time);
TextView tvOpeningTime = view.findViewById(R.id.tv_opening_time);
TextView tvOrderTime = view.findViewById(R.id.tv_order_time);
TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location);
......@@ -161,7 +161,13 @@ public class PrintPrjKitchen extends PrinterRoot {
view.findViewById(R.id.tv_people_text).setVisibility(View.VISIBLE);
view.findViewById(R.id.tv_people).setVisibility(View.VISIBLE);
}
if(TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getTakeTime())){
tvTakeTime.setText("取餐時間:" + prjBean.getTakeTime());
} else if(TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getSendTime())){
tvTakeTime.setText("送達時間:" + prjBean.getSendTime());
} else {
tvTakeTime.setVisibility(View.GONE);
}
//開台時間
tvOpeningTime.setText(TimeUtils.parseTimeRepeat(prjBean.getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_MDHM));
......
......@@ -3,14 +3,11 @@ package com.joe.print.mvp.print.usb;
import android.content.Context;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.joe.print.mvp.print.common.SendCallback;
import com.joe.print.mvp.print.common.SendResultCode;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -20,13 +17,11 @@ public class UsbPrint {
private final UsbManager usbManager;
private SendCallback sendCallback;
private final ExecutorService threadPool;
private MyHandler myHandler;
public UsbPrint(Context context, SendCallback sendCallback) {
this.usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
this.sendCallback = sendCallback;
this.threadPool = Executors.newFixedThreadPool(3);
this.myHandler = new MyHandler(this);
}
// public static UsbPrint getInstance(Context context, SendCallback sendCallback) {
......@@ -73,34 +68,13 @@ public class UsbPrint {
int sendResultCode = result > 0 ? SendResultCode.SEND_SUCCESS : SendResultCode.SEND_FAILED;
Log.e("ddd", "發送結果" + sendResultCode);
sendMessage(sendResultCode, usbPrinter.getPrinterName());
if (usbPrinter != null && sendCallback != null) {
sendCallback.onCallback(sendResultCode, usbPrinter.getPrinterName());
}
} else {
Log.e("ddd", "連接失敗");
}
}
}
private void sendMessage(int resultCode, String printerId) {
Message msg = new Message();
msg.obj = printerId;
msg.what = resultCode;
myHandler.sendMessage(msg);
}
private static class MyHandler extends Handler {
private WeakReference<UsbPrint> weakReference;
public MyHandler(UsbPrint usbPrint) {
this.weakReference = new WeakReference<>(usbPrint);
}
@Override
public void handleMessage(Message msg) {
UsbPrint usbPrint = weakReference.get();
if (usbPrint != null && usbPrint.sendCallback != null) {
usbPrint.sendCallback.onCallback(msg.what, (String) msg.obj);
}
}
}
}
......@@ -47,9 +47,9 @@ import com.joe.print.mvp.print.PrintListener;
import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.print.utils.MyPrintUtils;
import com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter;
import com.joe.print.mvp.ui.adapter.PrintProgressAdapter;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -132,7 +132,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
}
initPrintConfig();
}
private int selectPrint = -1;
private void initPrintConfig() {
PrintCurrencyBean printCurrencyBean = null;
PrinterDeviceBean defaultPrint;
......@@ -172,6 +172,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//用戶選擇的ip打印機打印
PrinterDeviceBean defaultPrint = MyPrintUtils.configPrinterProperties(finalPrintCurrencyBean, printerDeviceBeans.get(position));
printByDevice(defaultPrint);
selectPrint = position;
SPUtils.put(mContext, "defaultPrint", printerDeviceBeans.get(position).getName());
dialog.dismiss();
});
......@@ -179,6 +180,11 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
}
.setHeight(ArmsUtils.getScreenHeidth(mContext) / 2)
.setWidth((int) (ArmsUtils.getScreenWidth(mContext) * 0.8))
.setOnDismissListener(dialog -> {
if(selectPrint == -1){
printFile("未選擇打印機");
}
})
.show();
} else {
//沒有打印機
......@@ -230,9 +236,24 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
}
}
}
private PrintProgressAdapter adapter;
private void setPrintProgress(int state){
if(adapter != null){
adapter.setProgress(state);
}
}
private void initDialog() {
try {
// new DialogUtils(this, R.layout.print_layout_print_progress) {
// @Override
// public void initLayout(ViewHepler hepler, Dialog dialog) {
// List<String> stauts = Arrays.asList("生成數據中", "連接打印機", "開始寫入數據", "打印成功");
// adapter = new PrintProgressAdapter(stauts);
// hepler.setAdapter(R.id.rv_print_progress, new LinearLayoutManager(mContext), adapter);
// }
// }.setWidth((int) (DeviceUtils.getScreenWidth(mContext) * 0.8))
// .show();
View view = LayoutInflater.from(mContext).inflate(R.layout.ui_dialog_loading, null);
mTvLoadingTip = view.findViewById(R.id.tv_loading_dialog_text);
mLoadingDialog = new Dialog(mContext, R.style.ui_loading_dialog);
......@@ -240,7 +261,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
mLoadingDialog.setCanceledOnTouchOutside(false);
Window window = mLoadingDialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// window.getDecorView().setBackgroundResource(android.R.color.transparent);
mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
if (!this.isFinishing()) {
mLoadingDialog.show();
......@@ -289,6 +309,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
case PrintSocketHolder.ERROR_0:
Log.e("eee", "打印成功");
tip = "打印成功";
setPrintProgress(3);
break;
case PrintSocketHolder.ERROR_1:
Log.e("eee", "生成測試頁面數據失敗");
......@@ -310,17 +331,21 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
break;
case PrintSocketHolder.STATE_0:
Log.e("eee", "生成測試頁數據");
setPrintProgress(0);
break;
case PrintSocketHolder.STATE_1:
// Log.e("eee", "開始創建連接");
Log.e("eee", "開始創建連接");
tip = "開始創建連接";
break;
case PrintSocketHolder.STATE_2:
Log.e("eee", "創建連接成功,開始發送數據");
tip = "創建連接成功,開始發送數據";
setPrintProgress(1);
break;
case PrintSocketHolder.STATE_3:
Log.e("eee", "開始寫入數據");
tip = "開始寫入數據";
setPrintProgress(2);
break;
case PrintSocketHolder.STATE_4:
Log.e("eee", "關閉中");
......@@ -332,7 +357,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
break;
case FINISH:
finish();
printSuccess();
break;
case ADD_PRINT_DEVICE:
addPrintDevice();
......@@ -354,6 +378,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
CC.sendCCResult(callId, CCResult.success());
disLoadingDialog();
finish();
// finish();
// } else {
// printCount--;
// }
......
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