Commit 1305e525 by 宁斌

送單食品單價傳總價問題

parent e880993e
......@@ -266,10 +266,10 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
.build()
.call();
}else if (name.equals("餐牌管理")) {
// CC.obtainBuilder("Component.Table")
// .setActionName("showOrderCenterActivity")
// .build()
// .call();
CC.obtainBuilder("Component.Table")
.setActionName("showOrderCenterActivity")
.build()
.call();
}
}
......
......@@ -60,6 +60,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/javabase64-1.2.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar')
api files('libs/nexgon5lib.jar')
// test
testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
......@@ -70,20 +71,22 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:design:28.0.0'
implementation rootProject.ext.dependencies["fastjson"]
implementation rootProject.ext.dependencies["zxing"]
implementation rootProject.ext.dependencies["progressmanager"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
// 數據庫
implementation 'org.greenrobot:greendao:3.2.2'
implementation 'org.greenrobot:greendao-generator:3.2.2'
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
implementation 'com.android.support:design:28.0.0'
implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景
api 'com.github.lihangleo2:ShadowLayout:2.1.6'
api 'com.contrarywind:Android-PickerView:3.2.4'
//時間選擇控件
implementation 'org.aspectj:aspectjrt:1.8.9'
api files('libs/nexgon5lib.jar')
//商米打印庫
api 'com.sunmi:printerlibrary:1.0.7'
//上下拉刷新
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
}
......@@ -24,4 +24,6 @@ public interface Api {
String food_comboItem = "food/comboItem";
//食品細項關係
String food_modifiere_relation = "food/modifierDetail";
//日誌上傳
String upload_app_log = "public/cloud/gsa/upload";
}
package com.gingersoft.gsa.cloud.base.application;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.RemoteException;
......@@ -18,6 +19,7 @@ import com.elvishew.xlog.printer.file.FilePrinter;
import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.common.bean.CurrentAndroidSetting;
import com.gingersoft.gsa.cloud.base.utils.AidlUtil;
import com.gingersoft.gsa.cloud.base.utils.constans.UserConstans;
......@@ -29,6 +31,14 @@ import com.gingersoft.gsa.cloud.database.DaoManager;
import com.hyweb.n5.lib.exception.NoInitPrinterException;
import com.hyweb.n5.lib.util.PrinterUtil;
import com.jess.arms.base.BaseApplication;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
/**
* Created by Wyh on 2019/12/21.
......@@ -54,20 +64,78 @@ public class GsaCloudApplication extends BaseApplication {
public static String mV2 = "V2,V2_PRO";
public static String mN5 = "N5";
/**
* 全局設置上下拉刷新框架Header 和 Footer
*/
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.theme_color, android.R.color.white);//全局设置主题颜色
return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header,默认是 贝塞尔雷达Header
}
});
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
}
});
}
@Override
public void onCreate() {
super.onCreate();
this.mAppContext = this;
CC.enableVerboseLog(true);
CC.enableDebug(true);
// CC.enableRemoteCC(true);
CC.enableRemoteCC(true);
//初始化上下拉刷新
initRefresh();
//初始化日誌管理庫
initXLog();
//初始化數據庫框架
initGreenDao();
//初始化打印相關
initPrint();
//初始化crash記錄
AppCrashHandler.getInstance().init(this);
androidSetting = new CurrentAndroidSetting();
}
public Activity getCurrentActivity() {
return mCurrentActivity;
}
public void setCurrentActivity(Activity mCurrentActivity) {
this.mCurrentActivity = mCurrentActivity;
}
private void initRefresh() {
ClassicsHeader.REFRESH_HEADER_PULLING = getString(R.string.srl_header_pulling);//"下拉可以刷新";
ClassicsHeader.REFRESH_HEADER_REFRESHING = getString(R.string.srl_header_refreshing);//"正在刷新...";
ClassicsHeader.REFRESH_HEADER_LOADING = getString(R.string.srl_header_loading);//"正在加载...";
ClassicsHeader.REFRESH_HEADER_RELEASE = getString(R.string.srl_header_release);//"释放立即刷新";
ClassicsHeader.REFRESH_HEADER_FINISH = getString(R.string.srl_header_finish);//"刷新完成";
ClassicsHeader.REFRESH_HEADER_FAILED = getString(R.string.srl_header_failed);//"刷新失败";
ClassicsHeader.REFRESH_HEADER_UPDATE = getString(R.string.srl_header_update);//"上次更新 M-d HH:mm";
ClassicsHeader.REFRESH_HEADER_UPDATE = getString(R.string.srl_header_update);//"'Last update' M-d HH:mm";
ClassicsHeader.REFRESH_HEADER_SECONDARY = getString(R.string.srl_header_secondary);//"释放进入二楼"
ClassicsFooter.REFRESH_FOOTER_PULLING = getString(R.string.srl_footer_pulling);//"上拉加载更多";
ClassicsFooter.REFRESH_FOOTER_RELEASE = getString(R.string.srl_footer_release);//"释放立即加载";
ClassicsFooter.REFRESH_FOOTER_LOADING = getString(R.string.srl_footer_loading);//"正在刷新...";
ClassicsFooter.REFRESH_FOOTER_REFRESHING = getString(R.string.srl_footer_refreshing);//"正在加载...";
ClassicsFooter.REFRESH_FOOTER_FINISH = getString(R.string.srl_footer_finish);//"加载完成";
ClassicsFooter.REFRESH_FOOTER_FAILED = getString(R.string.srl_footer_failed);//"加载失败";
ClassicsFooter.REFRESH_FOOTER_NOTHING = getString(R.string.srl_footer_nothing);//"全部加载完成";
}
private void initPrint() {
if (GsaCloudApplication.mV2.contains(Build.MODEL)) {
//商米打印
AidlUtil.getInstance().connectPrinterService(this);
......@@ -82,14 +150,6 @@ public class GsaCloudApplication extends BaseApplication {
}
}
public Activity getCurrentActivity() {
return mCurrentActivity;
}
public void setCurrentActivity(Activity mCurrentActivity) {
this.mCurrentActivity = mCurrentActivity;
}
private void initXLog() {
LogConfiguration config = new LogConfiguration.Builder()
.logLevel(BuildConfig.DEBUG ? LogLevel.ALL // 指定日志级别,低于该级别的日志将不会被打印,默认为 LogLevel.ALL
......
......@@ -120,6 +120,7 @@ public class OrderBean {
private int id;
private String productName;
private long productId;
//單價
private double price;
private double lunchboxPrice;
private int number;
......@@ -275,7 +276,7 @@ public class OrderBean {
public static List<OrderDetailsBean> transOrderDetails(List<OrderDetail> foods) {
List<OrderDetailsBean> orderDetailsBeans = new ArrayList<>();
for (OrderDetail food : foods) {
OrderDetailsBean orderDetailsBean = new OrderDetailsBean(food.getProductName(), food.getProductId(), food.getParentId(),food.getPrice(), food.getLunchboxPrice(), food.getNumber(), food.getType(),food.getOrderId());
OrderDetailsBean orderDetailsBean = new OrderDetailsBean(food.getProductName(), food.getProductId(), food.getParentId(),food.getUnit_price(), food.getLunchboxPrice(), food.getNumber(), food.getType(),food.getOrderId());
orderDetailsBeans.add(orderDetailsBean);
}
return orderDetailsBeans;
......
......@@ -12,10 +12,15 @@ import android.telecom.Call;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.elvishew.xlog.XLog;
import com.gingersoft.gsa.cloud.base.Api;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.base.utils.file.FileUtils;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils;
......@@ -46,6 +51,10 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.FormBody;
import okhttp3.RequestBody;
......@@ -119,8 +128,7 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
File file = new File(FileUtils.ERRORLOG_PATH);
if (file.exists()) {
sendPreviousReportsToServer();
file.delete();
sendCrashReportsToServer();
}
}
......@@ -144,30 +152,6 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
}
/**
* 退出应用程序
*/
public static void appExit(Context context) {
AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context);
List<Activity> activityList = appComponent.appManager().getActivityList();
try {
for (int i = 0; i < activityList.size(); i++) {
activityList.get(i).finish();
activityList.remove(i);
}
// 退出程序
android.os.Process.killProcess(android.os.Process.myPid());
/**
* finish()是Activity的类方法,仅仅针对Activity,当调用finish()时,只是将活动推向后台,并没有立即释放内存,
* 活动的资源并没有被清理;当调用System.exit(0)时,退出当前Activity并释放资源(内存),
* 但是该方法不可以结束整个App如有多个Activty或者有其他组件service等不会结束。
* 0表示正常退出,1表示非正常 。
*/
System.exit(1);
} catch (Exception e) {
}
}
/**
* 自定义错误处理,收集错误信息
* 发送错误报告等操作均在此完成.
* 开发者可以根据自己的情况来自定义异常处理逻辑
......@@ -179,7 +163,6 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
if (ex == null) {
return false;
}
//使用Toast来显示异常信息
new Thread() {
@Override
......@@ -208,12 +191,7 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
String stacktrace = result.toString();
printWriter.close();
LogUtil.d(TAG, stacktrace);
// XLog.tag(TAG).d(stacktrace);
//收集设备信息
collectCrashDeviceInfo(mContext);
//保存错误报告到SP
saveCrashInfoToSP(ex);
//保存错误报告到文件
saveCrashInfo2File(ex);
//发送错误报告到服务器
......@@ -222,82 +200,54 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
}
/**
* 在程序启动时候, 可以调用该函数来发送以前没有发送的报告
*/
public void sendPreviousReportsToServer() {
sendCrashReportsToServer();
}
/**
* 把错误报告发送给服务器,包含新产生的和以前没发送的.
*/
private void sendCrashReportsToServer() {
File file = new File(FileUtils.ERRORLOG_PATH);
File[] files = file.listFiles();
if (files != null && files.length > 0) {
List<File> fileList = Arrays.asList(files);
int memberId = GsaCloudApplication.getMemberId(mContext);
RequestBody requestBody = new FormBody.Builder()
.add("type", "1")
.add("uuid", String.valueOf(memberId))
.build();
OkHttp3Utils.sendFileMultipart("", file.getName(), fileList, requestBody);
}
}
// List<File> fileList = Arrays.asList(files);
List<File> fileList = new ArrayList<>();
fileList.add(files[0]);
/**
* 收集程序崩溃的设备信息
*
* @param ctx
*/
public void collectCrashDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "no set" : pi.versionName;
String versionCode = pi.versionCode + "";
info.put("versionName", versionName);
info.put("versionCode", versionCode);
// mSetup.setSaveValue_Crash(VERSION_NAME, versionName, mContext);
// mSetup.setSaveValue_Crash(VERSION_CODE, versionCode, mContext);
}
} catch (NameNotFoundException e) {
Log.e(TAG, "Error while collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
info.put(field.getName(), field.get("").toString());
// mSetup.setSaveValue_Crash(field.getName(), String.valueOf(field.get(null)), mContext);
if (DEBUG) {
Log.d(TAG, field.getName() + " : " + field.get(null));
}
} catch (Exception e) {
Log.e(TAG, "Error while collect crash info", e);
}
}
}
HashMap<String, String> params = new HashMap<>();
params.put("type", "1");
params.put("uid", String.valueOf(GsaCloudApplication.getMemberId(mContext)));
/**
* 保存错误信息到SP
*
* @param ex
* @return
*/
private String saveCrashInfoToSP(Throwable ex) {
Writer info = new StringWriter();
PrintWriter printWriter = new PrintWriter(info);
ex.printStackTrace(printWriter);
String url = HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL + Api.upload_app_log;
OkHttp3Utils.sendFileMultipart(url, "files", fileList, params)
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(String data) {
BaseResult result = JsonUtils.parseObject(data, BaseResult.class);
if (result.isSuccess()) {
//上傳成功后刪除對應文件
// for (File dfile : file.listFiles()) {
// boolean result = dfile.delete();
// LogUtil.d(TAG, "delete result : " + result);
// }
}
XLog.d(TAG, "sendFileMultipart onNext: " + data);
}
@Override
public void onError(Throwable t) {
XLog.d(TAG, "sendFileMultipart onError: " + t.getMessage());
}
@Override
public void onComplete() {
}
});
}
printWriter.close();
return null;
}
private String saveCrashInfo2File(Throwable ex) {
......@@ -343,6 +293,30 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
return null;
}
/**
* 退出应用程序
*/
public static void appExit(Context context) {
AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context);
List<Activity> activityList = appComponent.appManager().getActivityList();
try {
for (int i = 0; i < activityList.size(); i++) {
activityList.get(i).finish();
activityList.remove(i);
}
// 退出程序
android.os.Process.killProcess(android.os.Process.myPid());
/**
* finish()是Activity的类方法,仅仅针对Activity,当调用finish()时,只是将活动推向后台,并没有立即释放内存,
* 活动的资源并没有被清理;当调用System.exit(0)时,退出当前Activity并释放资源(内存),
* 但是该方法不可以结束整个App如有多个Activty或者有其他组件service等不会结束。
* 0表示正常退出,1表示非正常 。
*/
System.exit(1);
} catch (Exception e) {
}
}
public void setErrorStr(String ErrorStr) {
this.ErrorStr = ErrorStr;
}
......
......@@ -121,8 +121,9 @@ public class OkHttp3Utils {
* @param reqUrl URL地址
* @param file_key 上传文件的关键字
* @param files 文件
* @param params 用戶ID,日誌類型
*/
public static Observable<String> sendFileMultipart(String reqUrl, String file_key, List<File> files, RequestBody body) {
public static Observable<String> sendFileMultipart(String reqUrl, String file_key, List<File> files, HashMap<String, String> params) {
getOkHttpClient();
return Observable.create(new ObservableOnSubscribe<String>() {
......@@ -130,15 +131,18 @@ public class OkHttp3Utils {
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder();
multipartBodyBuilder.setType(MultipartBody.FORM);
//遍历map中所有参数到builder
if (params != null) {
for (String key : params.keySet()) {
multipartBodyBuilder.addFormDataPart(key, params.get(key));
}
}
//遍历paths中所有图片绝对路径到builder,并约定key如“upload”作为后台接受多张图片的key
if (files != null) {
for (int i = 0; i < files.size(); i++) {
multipartBodyBuilder.addFormDataPart(file_key + i, files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i)));
multipartBodyBuilder.addFormDataPart(file_key , files.get(i).getName(), RequestBody.create(MEDIA_TYPE_PNG, files.get(i)));
}
}
if (body != null) {
multipartBodyBuilder.addPart(body);
}
//构建请求体
RequestBody requestBody = multipartBodyBuilder.build();
......
<?xml version="1.0" encoding="utf-8"?>
<!--
Tencent is pleased to support the open source community by making QMUI_Android available.
Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- 在Topbar下方的Tab面板的背景,带底部分割线 -->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/list_divider_height_negative"
android:insetTop="@dimen/list_divider_height_negative"
android:insetRight="@dimen/list_divider_height_negative">
<shape>
<solid android:color="@color/tab_panel_bg" />
<stroke
android:width="@dimen/list_divider_height"
android:color="@color/tab_panel_divider" />
</shape>
</inset>
\ No newline at end of file
......@@ -50,6 +50,10 @@
<dimen name="main_shadow_dy">@dimen/dp_1</dimen>
<dimen name="main_shadow_limit">@dimen/dp_3</dimen>
<!-- ListView -->
<dimen name="list_divider_height">1px</dimen>
<dimen name="list_divider_height_negative">-1px</dimen>
<dimen name="report_ranking_item_height">@dimen/dp_47</dimen>
<!-- dp and sp values, must be defind in this file! -->
<!-- view size,you can add if there is no one -->
......
......@@ -99,6 +99,24 @@
<string name="mealheight">菜單高度</string>
<string name="datadown">數據下載</string>
<!-- 上下拉刷新 -->
<string name="srl_header_pulling">下拉可以刷新</string>
<string name="srl_header_refreshing">正在刷新…</string>
<string name="srl_header_loading">正在加載…</string>
<string name="srl_header_release">釋放立即刷新</string>
<string name="srl_header_finish">刷新完成</string>
<string name="srl_header_failed">刷新失敗</string>
<string name="srl_header_update">上次更新 M-d HH:mm</string>
<string name="srl_header_secondary">釋放進入二層</string>
<string name="srl_footer_pulling">上拉加載更多</string>
<string name="srl_footer_release">釋放立即加載</string>
<string name="srl_footer_loading">正在加載…</string>
<string name="srl_footer_refreshing">正在刷新…</string>
<string name="srl_footer_finish">加載完成</string>
<string name="srl_footer_failed">加載失敗</string>
<string name="srl_footer_nothing">沒有更多數據了</string>
<!-- HttpError -->
<string name="response_error_unknown_error">未知錯誤</string>
<string name="response_error_network_unavailable">網絡不可用</string>
......
package com.gingersoft.gsa.cloud.table.mvp.contract;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
......@@ -20,6 +21,8 @@ public interface AllOrderContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void setAllOrderAdapter(DefaultAdapter adapter);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
package com.gingersoft.gsa.cloud.table.mvp.presenter;
import android.app.Application;
import android.content.Context;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderCenterAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.TableAdapter;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
......@@ -12,6 +17,10 @@ import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.table.mvp.contract.AllOrderContract;
import com.jess.arms.utils.DeviceUtils;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -37,6 +46,9 @@ public class AllOrderPresenter extends BasePresenter<AllOrderContract.Model, All
@Inject
AppManager mAppManager;
private OrderCenterAdapter mOrderCenterAdapter;
private List<Object> mTableList = new ArrayList<>();
@Inject
public AllOrderPresenter(AllOrderContract.Model model, AllOrderContract.View rootView) {
super(model, rootView);
......@@ -50,4 +62,12 @@ public class AllOrderPresenter extends BasePresenter<AllOrderContract.Model, All
this.mImageLoader = null;
this.mApplication = null;
}
public void initOrderAdapter(Context context) {
if (mOrderCenterAdapter == null) {
mOrderCenterAdapter = new OrderCenterAdapter(context, mTableList);
mRootView.setAllOrderAdapter(mOrderCenterAdapter);
}
}
}
......@@ -366,7 +366,7 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
request.setProductId(food.getProductId());
request.setParentId(food.getParentId());
request.setNumber(food.getNumber());
request.setPrice(food.getPrice());
request.setPrice(food.getUnit_price());
request.setType(food.getType());
request.setLunchboxPrice(0);
if (food.isNew()) {
......@@ -426,7 +426,7 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
request.setProductId(food.getProductId());
request.setParentId(food.getParentId());
request.setNumber(food.getNumber());
request.setPrice(food.getPrice());
request.setPrice(food.getUnit_price());
request.setType(food.getType());
request.setLunchboxPrice(0);
if (food.isNew()) {
......
......@@ -12,18 +12,19 @@ import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.qmui.arch.QMUIFragment;
import com.gingersoft.gsa.cloud.base.qmui.arch.QMUIFragmentPagerAdapter;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.BaseFragmentAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.AllOrderFragment;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.AllTableFragment;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.InputTableFragment;
import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.StateTableFragment;
import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.di.component.DaggerOrderCenterComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.OrderCenterContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.OrderCenterPresenter;
import com.gingersoft.gsa.cloud.table.R;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
......@@ -31,15 +32,19 @@ import com.qmuiteam.qmui.widget.QMUIViewPager;
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -64,37 +69,9 @@ public class OrderCenterActivity extends BaseActivity<OrderCenterPresenter> impl
@BindView(R2.id.tabSegment)
QMUITabSegment mTabSegment;
@BindView(R2.id.contentViewPager)
QMUIViewPager mContentViewPager;
private Map<ContentPage, View> mPageMap = new HashMap<>();
private ContentPage mDestPage = ContentPage.Item1;
private PagerAdapter mPagerAdapter = new PagerAdapter() {
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public int getCount() {
return ContentPage.SIZE;
}
@Override
public Object instantiateItem(final ViewGroup container, int position) {
ContentPage page = ContentPage.getPage(position);
View view = getPageView(page);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
container.addView(view, params);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
};
ViewPager mContentViewPager;
private String[] tabTitles = {"全部", "已取消"};
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -118,33 +95,36 @@ public class OrderCenterActivity extends BaseActivity<OrderCenterPresenter> impl
}
private void initTabAndPager() {
mContentViewPager.setAdapter(mPagerAdapter);
mContentViewPager.setCurrentItem(mDestPage.getPosition(), false);
QMUITabBuilder builder = mTabSegment.tabBuilder();
mTabSegment.addTab(builder.setText(getString(R.string.tabSegment_order_all_title)).build(this));
mTabSegment.addTab(builder.setText(getString(R.string.tabSegment_order_cancel_title)).build(this));
mTabSegment.setupWithViewPager(mContentViewPager, false);
mTabSegment.setMode(QMUITabSegment.MODE_FIXED);
mTabSegment.addOnTabSelectedListener(new QMUITabSegment.OnTabSelectedListener() {
QMUIFragmentPagerAdapter pagerAdapter = new QMUIFragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public void onTabSelected(int index) {
public Fragment createFragment(int position) {
AllOrderFragment fragment = new AllOrderFragment();
Bundle bundle = new Bundle();
bundle.putInt("currentPageIndex", position);
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onTabUnselected(int index) {
public int getCount() {
return 2;
}
@Override
public void onTabReselected(int index) {
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "全部";
case 1:
return "已取消";
case 3:
default:
return "全部";
}
}
@Override
public void onDoubleTap(int index) {
mTabSegment.clearSignCountView(index);
}
});
};
mContentViewPager.setAdapter(pagerAdapter);
mTabSegment.setupWithViewPager(mContentViewPager);
}
@Override
......@@ -182,18 +162,21 @@ public class OrderCenterActivity extends BaseActivity<OrderCenterPresenter> impl
@Override
public void showLoading(String message) {
if (message != null)
LoadingDialog.showDialogForLoading(this, message, true);
else
LoadingDialog.showDialogForLoading(this);
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
ArmsUtils.makeText(this, message);
}
@Override
......@@ -208,47 +191,4 @@ public class OrderCenterActivity extends BaseActivity<OrderCenterPresenter> impl
}
private View getPageView(ContentPage page) {
View view = mPageMap.get(page);
if (view == null) {
TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
textView.setTextColor(ContextCompat.getColor(this, R.color.app_color_description));
if (page == ContentPage.Item1) {
textView.setText(R.string.tabSegment_order_all_title);
} else if (page == ContentPage.Item2) {
textView.setText(R.string.tabSegment_order_cancel_title);
}
view = textView;
mPageMap.put(page, view);
}
return view;
}
public enum ContentPage {
Item1(0),
Item2(1);
public static final int SIZE = 2;
private final int position;
ContentPage(int pos) {
position = pos;
}
public static ContentPage getPage(int position) {
switch (position) {
case 0:
return Item1;
case 1:
return Item2;
default:
return Item1;
}
}
public int getPosition() {
return position;
}
}
}
package com.gingersoft.gsa.cloud.table.mvp.ui.adapter;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.BillOrderMoney;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import java.util.List;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/6/27
* 修订历史:2018/6/27
* 描述:
*/
public class OrderCenterAdapter extends DefaultAdapter<Object> {
private Context mContext;
public OrderCenterAdapter(Context context, List<Object> infos) {
super(infos);
this.mContext = context;
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public BaseHolder<Object> getHolder(View v, int viewType) {
return new OrderCenterItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.item_order_center;
}
class OrderCenterItemHolder extends BaseHolder<Object> {
@BindView(R2.id.ll_root_container)
LinearLayout ll_root_container;
@BindView(R2.id.tv_table_name)
TextView tv_table_name;
@BindView(R2.id.tv_order_num)
TextView tv_order_num;
@BindView(R2.id.tv_people_num)
TextView tv_people_num;
@BindView(R2.id.tv_open_time)
TextView tv_open_time;
@BindView(R2.id.tv_pay_time)
TextView tv_pay_time;
@BindView(R2.id.tv_pay_money)
TextView tv_pay_money;
@BindView(R2.id.btn_print_order)
QMUIAlphaButton btn_print_order;
@BindView(R2.id.btn_tips)
QMUIAlphaButton btn_tips;
@BindView(R2.id.btn_refund)
QMUIAlphaButton btn_refund;
@BindView(R2.id.btn_modify_order)
QMUIAlphaButton btn_modify_order;
@BindView(R2.id.btn_cancel_order)
QMUIAlphaButton btn_cancel_order;
@BindView(R2.id.btn_order_status)
QMUIAlphaButton btn_order_status;
@BindView(R2.id.ll_bottom)
QMUIAlphaButton ll_bottom;
public OrderCenterItemHolder(View itemView) {
super(itemView);
}
@Override
public void setData(Object datasBean, int position) {
}
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(BillOrderMoney datasBean, int position);
}
}
......@@ -6,16 +6,25 @@ import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.GridDividerItemDecoration;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.di.component.DaggerAllOrderComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.AllOrderContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.AllOrderPresenter;
import com.gingersoft.gsa.cloud.table.R;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -34,6 +43,13 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/
public class AllOrderFragment extends BaseFragment<AllOrderPresenter> implements AllOrderContract.View {
@BindView(R2.id.refreshLayout)
SmartRefreshLayout refreshLayout;
@BindView(R2.id.recycle_order)
RecyclerView recycle_order;
private int currentPageInde;
public static AllOrderFragment newInstance() {
AllOrderFragment fragment = new AllOrderFragment();
return fragment;
......@@ -56,12 +72,31 @@ public class AllOrderFragment extends BaseFragment<AllOrderPresenter> implements
@Override
public void initData(@Nullable Bundle savedInstanceState) {
currentPageInde = (int) getArguments().getInt("currentPageIndex",0);
mPresenter.initOrderAdapter(getActivity());
}
@Override
public void setData(@Nullable Object data) {
if (data != null && data instanceof Message) {
switch (((Message) data).what) {
case 0:
break;
case 1://刷新全部数据
// datasBeans = (List<TableBean.DataBean>) ((Message) data).obj;
// if (mPresenter != null) {
// //recycleView正在滑动
// if (recycle_all_table.getScrollState() != 0) {
// } else {
// mPresenter.updateAllTableData(getActivity(), datasBeans);
// }
// }
default:
//do something
break;
}
}
}
@Override
......@@ -88,6 +123,19 @@ public class AllOrderFragment extends BaseFragment<AllOrderPresenter> implements
@Override
public void killMyself() {
}
@Override
public void setAllOrderAdapter(DefaultAdapter adapter) {
recycle_order.setAdapter(adapter);
initAllOrderRecycleViewLayout();
}
private void initAllOrderRecycleViewLayout() {
LinearLayoutManager mAllOrderRecycleLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recycle_order.setLayoutManager(mAllOrderRecycleLayoutManager);
recycle_order.addItemDecoration(new GridDividerItemDecoration(QMUIDisplayHelper.dpToPx(1), ArmsUtils.getColor(getActivity(), R.color.theme_grey_color)));
}
}
......@@ -22,7 +22,8 @@
<com.qmuiteam.qmui.widget.tab.QMUITabSegment
android:id="@+id/tabSegment"
android:layout_width="match_parent"
android:layout_height="40dp" />
android:layout_height="@dimen/dp_45"
android:background="@drawable/shape_tab_panel_bg"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/contentViewPager"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_order"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ 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"
android:id="@+id/ll_root_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_item_background"
android:orientation="vertical"
android:padding="@dimen/dp_8">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_table_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="檯號:501"
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/dp_20"
android:text="訂單:123456"
android:textColor="@color/black"
android:textSize="@dimen/sp_14" />
<TextView
android:id="@+id/tv_people_num"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_weight="1"
android:gravity="right"
android:text="人數:2"
android:textColor="@color/black"
android:textSize="@dimen/sp_14" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_3"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_open_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="開檯:2019-7-2"
android:textColor="@color/black"
android:textSize="@dimen/sp_14" />
<TextView
android:id="@+id/tv_pay_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:text="金額:$230"
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/tv_pay_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/dp_3"
android:text="結賬:2019-7-2"
android:textColor="@color/black"
android:textSize="@dimen/sp_14" />
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:gravity="right|center_vertical"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_print_order"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/orange_400"
android:text="打印訂單"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_tips"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/green_400"
android:text="貼士"
android:visibility="gone"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_cancel_order"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:background="@color/red_400"
android:layout_marginRight="@dimen/dp_10"
android:text="取消訂單"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_refund"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/red_500"
android:text="退款"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="visible" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_modify_order"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:background="@color/blue_300"
android:text="修改訂單"
android:visibility="gone"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_order_status"
android:layout_width="@dimen/dp_65"
android:layout_height="@dimen/dp_35"
android:background="@color/gray"
android:text="已取消"
android:textColor="@color/theme_white_color"
android:clickable="false"
android:textSize="@dimen/sp_13"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.gingersoft.gsa.cloud.base.utils.constans.UserConstans;
import com.gingersoft.gsa.cloud.base.utils.crash.AppCrashHandler;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
......
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