Commit 03737d19 by 宁斌

使用会员调整

parent ea7060d3
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.jess.arms.base; package com.jess.arms.base;
import android.app.Application;
import android.content.Context; import android.content.Context;
import com.jess.arms.base.delegate.AppDelegate; import com.jess.arms.base.delegate.AppDelegate;
...@@ -37,7 +38,7 @@ import androidx.multidex.MultiDexApplication; ...@@ -37,7 +38,7 @@ import androidx.multidex.MultiDexApplication;
* <a href="https://github.com/JessYanCoding">Follow me</a> * <a href="https://github.com/JessYanCoding">Follow me</a>
* ================================================ * ================================================
*/ */
public class BaseApplication extends MultiDexApplication implements App { public class BaseApplication extends Application implements App {
private AppLifecycles mAppDelegate; private AppLifecycles mAppDelegate;
/** /**
......
...@@ -62,8 +62,19 @@ dependencies { ...@@ -62,8 +62,19 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/javabase64-1.2.jar') implementation files('libs/javabase64-1.2.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar') implementation files('libs/sun.misc.BASE64Decoder.jar')
// implementation files('libs/ZXing-core-3.2.1.jar')
api files('libs/nexgon5lib.jar') api files('libs/nexgon5lib.jar')
if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
} else {
compileOnly rootProject.ext.dependencies["dagger2-compiler"]
compileOnly rootProject.ext.dependencies["canary-debug"]
compileOnly rootProject.ext.dependencies["canary-release"]
compileOnly rootProject.ext.dependencies["canary-release"]
}
api 'androidx.viewpager2:viewpager2:1.0.0-alpha03' api 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] debugImplementation rootProject.ext.dependencies["canary-debug"]
...@@ -88,7 +99,6 @@ dependencies { ...@@ -88,7 +99,6 @@ dependencies {
api 'com.github.lihangleo2:ShadowLayout:2.1.6' api 'com.github.lihangleo2:ShadowLayout:2.1.6'
//時間選擇控件 //時間選擇控件
api 'com.contrarywind:Android-PickerView:3.2.4' api 'com.contrarywind:Android-PickerView:3.2.4'
implementation 'org.aspectj:aspectjrt:1.8.9' implementation 'org.aspectj:aspectjrt:1.8.9'
//商米打印庫 //商米打印庫
api 'com.sunmi:printerlibrary:1.0.7' api 'com.sunmi:printerlibrary:1.0.7'
...@@ -96,17 +106,13 @@ dependencies { ...@@ -96,17 +106,13 @@ dependencies {
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
//多功能輸入框 //多功能輸入框
api 'com.rengwuxian.materialedittext:library:2.1.4' api 'com.rengwuxian.materialedittext:library:2.1.4'
//二维码扫描 // // 斜角标签
api 'cn.yipianfengye.android:zxing-library:2.2' // api 'com.github.poqiao:BeveLabelView:1.0.3'
// // 斜角标签 api 'androidx.core:core-ktx:+'
// api 'com.github.poqiao:BeveLabelView:1.0.3'
api "androidx.core:core-ktx:+"
implementation 'org.projectlombok:lombok:1.18.8' implementation 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8' annotationProcessor 'org.projectlombok:lombok:1.18.8'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "com.github.huangyanbin:SmartTable:2.2.0" api 'com.github.huangyanbin:SmartTable:2.2.0'
} }
repositories { repositories {
mavenCentral() mavenCentral()
......
...@@ -2,5 +2,32 @@ ...@@ -2,5 +2,32 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
<activity android:name="com.gingersoft.gsa.cloud.ui.activity.WebActivity"/>
<activity android:name="com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360"/>
<meta-data
android:name="design_height_in_dp"
android:value="640"/>
</application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest> </manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.table">
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
<activity android:name="com.gingersoft.gsa.cloud.ui.activity.WebActivity"/>
<activity android:name="com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
android:value="360"/>
<meta-data
android:name="design_height_in_dp"
android:value="640"/>
</application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
\ No newline at end of file
package debug;
import com.billy.cc.core.component.CC;
import com.jess.arms.base.BaseApplication;
/**
* @author billy.qi
* @since 17/11/20 20:02
*/
public class MyApp extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
}
}
<resources>
<!-- &lt;!&ndash; Base application theme. &ndash;&gt;-->
<!-- <style name="table_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!-- <item name="colorPrimary">@color/table_colorPrimary</item>-->
<!-- <item name="colorPrimaryDark">@color/table_colorPrimaryDark</item>-->
<!-- <item name="colorAccent">@color/table_colorAccent</item>-->
<!-- </style>-->
</resources>
...@@ -126,7 +126,7 @@ public class MemberInfo { ...@@ -126,7 +126,7 @@ public class MemberInfo {
private String memberNo; private String memberNo;
private int MemberPoint; private int MemberPoint;
private String memberName; private String memberName;
private int phone; private String phone;
private int birthdaybonusratio; private int birthdaybonusratio;
private int creditPoints; private int creditPoints;
private int birthdayperiod; private int birthdayperiod;
......
...@@ -10,6 +10,7 @@ import lombok.Data; ...@@ -10,6 +10,7 @@ import lombok.Data;
* 创建日期:2019-12-28 * 创建日期:2019-12-28
* 修订历史:2019-12-28 * 修订历史:2019-12-28
* 描述: * 描述:
*
*/ */
public class TableBean { public class TableBean {
...@@ -90,11 +91,11 @@ public class TableBean { ...@@ -90,11 +91,11 @@ public class TableBean {
/** /**
* 最大就餐人數 * 最大就餐人數
*/ */
private Integer maxSeatCount; private int maxSeatCount;
/** /**
* 最小就餐人數 * 最小就餐人數
*/ */
private Integer minSeatCount; private int minSeatCount;
private String createTime; private String createTime;
private String createBy; private String createBy;
private String qrCodeImg; private String qrCodeImg;
......
...@@ -5,6 +5,7 @@ import android.text.TextUtils; ...@@ -5,6 +5,7 @@ import android.text.TextUtils;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BillOrderMoney; import com.gingersoft.gsa.cloud.base.common.bean.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.common.bean.MemberInfo;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean; import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail; import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.PayMethod; import com.gingersoft.gsa.cloud.base.common.bean.PayMethod;
...@@ -56,6 +57,11 @@ public class MyOrderManage { ...@@ -56,6 +57,11 @@ public class MyOrderManage {
private int mseq = 0;//三级序 private int mseq = 0;//三级序
private OrderBean orderBean; private OrderBean orderBean;
/**
* 會員信息
*/
private MemberInfo memberInfo;
/** /**
* 食品列表 * 食品列表
*/ */
...@@ -131,6 +137,14 @@ public class MyOrderManage { ...@@ -131,6 +137,14 @@ public class MyOrderManage {
return orderBean; return orderBean;
} }
public MemberInfo getMemberInfo() {
return memberInfo;
}
public void setMemberInfo(MemberInfo memberInfo) {
this.memberInfo = memberInfo;
}
public void changeNumber(int number) { public void changeNumber(int number) {
if (orderFoodList.size() <= 0) { if (orderFoodList.size() <= 0) {
...@@ -1055,6 +1069,9 @@ public class MyOrderManage { ...@@ -1055,6 +1069,9 @@ public class MyOrderManage {
} }
public void clear() { public void clear() {
if (memberInfo != null) {
memberInfo = null;
}
if (orderFoodList != null) { if (orderFoodList != null) {
orderFoodList.clear(); orderFoodList.clear();
} }
......
package com.gingersoft.gsa.cloud.base.utils.view; package com.gingersoft.gsa.cloud.base.utils.view;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Log;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
...@@ -9,6 +14,8 @@ import com.google.zxing.WriterException; ...@@ -9,6 +14,8 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -88,4 +95,103 @@ public class BitmapUtil { ...@@ -88,4 +95,103 @@ public class BitmapUtil {
} }
return null; return null;
} }
/**
* 读取一个缩放后的图片,限定图片大小,避免OOM
*
* @param uri 图片uri,支持“file://”、“content://”
* @param maxWidth 最大允许宽度
* @param maxHeight 最大允许高度
* @return 返回一个缩放后的Bitmap,失败则返回null
*/
public static Bitmap decodeUri(Context context, Uri uri, int maxWidth, int maxHeight) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; //只读取图片尺寸
readBitmapScale(context, uri, options);
//计算实际缩放比例
int scale = 1;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
if ((options.outWidth / scale > maxWidth &&
options.outWidth / scale > maxWidth * 1.4) ||
(options.outHeight / scale > maxHeight &&
options.outHeight / scale > maxHeight * 1.4)) {
scale++;
} else {
break;
}
}
options.inSampleSize = scale;
options.inJustDecodeBounds = false;//读取图片内容
options.inPreferredConfig = Bitmap.Config.RGB_565; //根据情况进行修改
Bitmap bitmap = null;
try {
bitmap = readBitmapData(context, uri, options);
} catch (Throwable e) {
e.printStackTrace();
}
return bitmap;
}
private static void readBitmapScale(Context context, Uri uri, BitmapFactory.Options options) {
if (uri == null) {
return;
}
String scheme = uri.getScheme();
if (ContentResolver.SCHEME_CONTENT.equals(scheme) ||
ContentResolver.SCHEME_FILE.equals(scheme)) {
InputStream stream = null;
try {
stream = context.getContentResolver().openInputStream(uri);
BitmapFactory.decodeStream(stream, null, options);
} catch (Exception e) {
Log.w("readBitmapScale", "Unable to open content: " + uri, e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
Log.e("readBitmapScale", "Unable to close content: " + uri, e);
}
}
}
} else if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(scheme)) {
Log.e("readBitmapScale", "Unable to close content: " + uri);
} else {
Log.e("readBitmapScale", "Unable to close content: " + uri);
}
}
private static Bitmap readBitmapData(Context context, Uri uri, BitmapFactory.Options options) {
if (uri == null) {
return null;
}
Bitmap bitmap = null;
String scheme = uri.getScheme();
if (ContentResolver.SCHEME_CONTENT.equals(scheme) ||
ContentResolver.SCHEME_FILE.equals(scheme)) {
InputStream stream = null;
try {
stream = context.getContentResolver().openInputStream(uri);
bitmap = BitmapFactory.decodeStream(stream, null, options);
} catch (Exception e) {
Log.e("readBitmapData", "Unable to open content: " + uri, e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
Log.e("readBitmapData", "Unable to close content: " + uri, e);
}
}
}
} else if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(scheme)) {
Log.e("readBitmapData", "Unable to close content: " + uri);
} else {
Log.e("readBitmapData", "Unable to close content: " + uri);
}
return bitmap;
}
} }
...@@ -8,6 +8,9 @@ import org.greenrobot.greendao.annotation.NotNull; ...@@ -8,6 +8,9 @@ import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Property; import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Transient; import org.greenrobot.greendao.annotation.Transient;
import lombok.Data;
import lombok.extern.java.Log;
/** /**
* 作者:ELEGANT_BIN * 作者:ELEGANT_BIN
* 版本:1.6.0 * 版本:1.6.0
......
...@@ -54,8 +54,8 @@ public class MyResponseErrorListener implements ResponseErrorListener { ...@@ -54,8 +54,8 @@ public class MyResponseErrorListener implements ResponseErrorListener {
} }
// ArmsUtils.snackbarText(msg); // ArmsUtils.snackbarText(msg);
// LogUtil.d("handleResponseError: " + t.getMessage()); // LogUtil.d("handleResponseError: " + t.getMessage());
LogUtil.d(TAG, t.getMessage()); LogUtil.d(TAG, t.getMessage());
if(!TextUtils.isEmpty(msg)){ if (!TextUtils.isEmpty(msg)) {
ToastUtils.show(context, msg); ToastUtils.show(context, msg);
} }
} }
...@@ -74,33 +74,25 @@ public class MyResponseErrorListener implements ResponseErrorListener { ...@@ -74,33 +74,25 @@ public class MyResponseErrorListener implements ResponseErrorListener {
Activity activity = GsaCloudApplication.getAppContext().getCurrentActivity(); Activity activity = GsaCloudApplication.getAppContext().getCurrentActivity();
if (!showloggedDialog && activity != null) { if (!showloggedDialog && activity != null) {
showloggedDialog = true; showloggedDialog = true;
showloggedDialog(activity,ArmsUtils.getString(context, R.string.response_error_request_logged)); showloggedDialog(activity, ArmsUtils.getString(context, R.string.response_error_request_logged));
} }
} else { } else {
if (httpException.code() == 400) {
//Bad Request
Activity activity = GsaCloudApplication.getAppContext().getCurrentActivity();
toLoginActivity(activity);
}
msg = httpException.message(); msg = httpException.message();
} }
return msg; return msg;
} }
private void showloggedDialog(Activity context,String msg) { private void showloggedDialog(Activity context, String msg) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context); QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(context);
dialogBuilder.setMessage(msg); dialogBuilder.setMessage(msg);
dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_warn); dialogBuilder.setTitleIcon(R.drawable.qmui_icon_dialog_warn);
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> { dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, (dialog, index) -> {
//清空用戶信息 toLoginActivity(context);
GsaCloudApplication.clearMemberInfo();
//清空賬單數據
MyOrderManage.getInstance().clear();
//清空開檯數據
OpenTableManage.getDefault().clear();
//修改登錄狀態
GsaCloudApplication.isLogin = false;
CC.obtainBuilder("User.Component.Login")
.setActionName("showActivityA")
.build()
.call();
showloggedDialog = false;
context.finish();
dialog.dismiss(); dialog.dismiss();
}); });
dialogBuilder.setCancelable(false); dialogBuilder.setCancelable(false);
...@@ -109,4 +101,21 @@ public class MyResponseErrorListener implements ResponseErrorListener { ...@@ -109,4 +101,21 @@ public class MyResponseErrorListener implements ResponseErrorListener {
} }
private void toLoginActivity(Activity context) {
//清空用戶信息
GsaCloudApplication.clearMemberInfo();
//清空賬單數據
MyOrderManage.getInstance().clear();
//清空開檯數據
OpenTableManage.getDefault().clear();
//修改登錄狀態
GsaCloudApplication.isLogin = false;
CC.obtainBuilder("User.Component.Login")
.setActionName("showActivityA")
.build()
.call();
showloggedDialog = false;
context.finish();
}
} }
...@@ -9,11 +9,9 @@ import android.graphics.Paint; ...@@ -9,11 +9,9 @@ import android.graphics.Paint;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
import com.hyweb.n5.lib.util.DeviceUtil; import com.hyweb.n5.lib.util.DeviceUtil;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.uuzuche.lib_zxing.DisplayUtil;
public class WebViewProgressBar extends View { public class WebViewProgressBar extends View {
......
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class AutoFocusCallback implements Camera.AutoFocusCallback {
private static final String TAG = AutoFocusCallback.class.getSimpleName();
private static final long AUTOFOCUS_INTERVAL_MS = 2000L;
private Handler autoFocusHandler;
private int autoFocusMessage;
void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
this.autoFocusHandler = autoFocusHandler;
this.autoFocusMessage = autoFocusMessage;
}
public void onAutoFocus(boolean success, Camera camera) {
if (autoFocusHandler != null) {
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
autoFocusHandler = null;
} else {
Log.d(TAG, "Got auto-focus callback, but no handler for it");
}
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.os.IBinder;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* This class is used to activate the weak light on some camera phones (not flash)
* in order to illuminate surfaces for scanning. There is no official way to do this,
* but, classes which allow access to this function still exist on some devices.
* This therefore proceeds through a great deal of reflection.
*
* See <a href="http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/">
* http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/</a> and
* <a href="http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java">
* http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java</a>.
* Thanks to Ryan Alford for pointing out the availability of this class.
*/
final class FlashlightManager {
private static final String TAG = FlashlightManager.class.getSimpleName();
private static final Object iHardwareService;
private static final Method setFlashEnabledMethod;
static {
iHardwareService = getHardwareService();
setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
if (iHardwareService == null) {
Log.v(TAG, "This device does supports control of a flashlight");
} else {
Log.v(TAG, "This device does not support control of a flashlight");
}
}
private FlashlightManager() {
}
/**
* �����������ƿ���
*/
//FIXME
static void enableFlashlight() {
setFlashlight(false);
}
static void disableFlashlight() {
setFlashlight(false);
}
private static Object getHardwareService() {
Class<?> serviceManagerClass = maybeForName("android.os.ServiceManager");
if (serviceManagerClass == null) {
return null;
}
Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class);
if (getServiceMethod == null) {
return null;
}
Object hardwareService = invoke(getServiceMethod, null, "hardware");
if (hardwareService == null) {
return null;
}
Class<?> iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub");
if (iHardwareServiceStubClass == null) {
return null;
}
Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class);
if (asInterfaceMethod == null) {
return null;
}
return invoke(asInterfaceMethod, null, hardwareService);
}
private static Method getSetFlashEnabledMethod(Object iHardwareService) {
if (iHardwareService == null) {
return null;
}
Class<?> proxyClass = iHardwareService.getClass();
return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class);
}
private static Class<?> maybeForName(String name) {
try {
return Class.forName(name);
} catch (ClassNotFoundException cnfe) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding class " + name, re);
return null;
}
}
private static Method maybeGetMethod(Class<?> clazz, String name, Class<?>... argClasses) {
try {
return clazz.getMethod(name, argClasses);
} catch (NoSuchMethodException nsme) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding method " + name, re);
return null;
}
}
private static Object invoke(Method method, Object instance, Object... args) {
try {
return method.invoke(instance, args);
} catch (IllegalAccessException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e);
return null;
} catch (InvocationTargetException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e.getCause());
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while invoking " + method, re);
return null;
}
}
private static void setFlashlight(boolean active) {
if (iHardwareService != null) {
invoke(setFlashEnabledMethod, iHardwareService, active);
}
}
}
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.graphics.Bitmap;
import com.google.zxing.LuminanceSource;
/**
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
* with the option to crop to a rectangle within the full data. This can be used to exclude
* superfluous pixels around the perimeter and speed up decoding.
*
* It works for any pixel format where the Y channel is planar and appears first, including
* YCbCr_420_SP and YCbCr_422_SP.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class PlanarYUVLuminanceSource extends LuminanceSource {
private final byte[] yuvData;
private final int dataWidth;
private final int dataHeight;
private final int left;
private final int top;
public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
int width, int height) {
super(width, height);
if (left + width > dataWidth || top + height > dataHeight) {
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
}
this.yuvData = yuvData;
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
}
@Override
public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == null || row.length < width) {
row = new byte[width];
}
int offset = (y + top) * dataWidth + left;
System.arraycopy(yuvData, offset, row, 0, width);
return row;
}
@Override
public byte[] getMatrix() {
int width = getWidth();
int height = getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the
// original data. The docs specifically warn that result.length must be ignored.
if (width == dataWidth && height == dataHeight) {
return yuvData;
}
int area = width * height;
byte[] matrix = new byte[area];
int inputOffset = top * dataWidth + left;
// If the width matches the full width of the underlying data, perform a single copy.
if (width == dataWidth) {
System.arraycopy(yuvData, inputOffset, matrix, 0, area);
return matrix;
}
// Otherwise copy one cropped row at a time.
byte[] yuv = yuvData;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
inputOffset += dataWidth;
}
return matrix;
}
@Override
public boolean isCropSupported() {
return true;
}
public int getDataWidth() {
return dataWidth;
}
public int getDataHeight() {
return dataHeight;
}
public Bitmap renderCroppedGreyscaleBitmap() {
int width = getWidth();
int height = getHeight();
int[] pixels = new int[width * height];
byte[] yuv = yuvData;
int inputOffset = top * dataWidth + left;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
for (int x = 0; x < width; x++) {
int grey = yuv[inputOffset + x] & 0xff;
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
}
inputOffset += dataWidth;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.camera;
import android.graphics.Point;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private final boolean useOneShotPreviewCallback;
private Handler previewHandler;
private int previewMessage;
PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) {
this.configManager = configManager;
this.useOneShotPreviewCallback = useOneShotPreviewCallback;
}
void setHandler(Handler previewHandler, int previewMessage) {
this.previewHandler = previewHandler;
this.previewMessage = previewMessage;
}
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.gingersoft.gsa.cloud.zxing.view.ViewfinderResultPointCallback;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import java.util.Vector;
/**
* This class handles all the messaging which comprises the state machine for capture.
*/
public final class CaptureActivityHandler extends Handler {
private static final String TAG = CaptureActivityHandler.class.getSimpleName();
private final MipcaCaptureActivity activity;
private final DecodeThread decodeThread;
private State state;
private enum State {
PREVIEW,
SUCCESS,
DONE
}
public CaptureActivityHandler(MipcaCaptureActivity activity, Vector<BarcodeFormat> decodeFormats,
String characterSet) {
this.activity = activity;
decodeThread = new DecodeThread(activity, decodeFormats, characterSet, new ViewfinderResultPointCallback(activity.getViewfinderView()));
decodeThread.start();
state = State.SUCCESS;
// Start ourselves capturing previews and decoding.
CameraManager.get().startPreview();
restartPreviewAndDecode();
}
@Override
public void handleMessage(Message message) {
if (message.what == R.id.auto_focus) {//Log.d(TAG, "Got auto-focus message");
// When one auto focus pass finishes, start another. This is the closest thing to
// continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
if (state == State.PREVIEW) {
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
}
} else if (message.what == R.id.restart_preview) {
Log.d(TAG, "Got restart preview message");
restartPreviewAndDecode();
} else if (message.what == R.id.decode_succeeded) {
Log.d(TAG, "Got decode succeeded message");
state = State.SUCCESS;
Bundle bundle = message.getData();
/***********************************************************************/
Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳�
activity.handleDecode((Result) message.obj, barcode);//���ؽ��? /***********************************************************************/
} else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails, start another.
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
} else if (message.what == R.id.return_scan_result) {
Log.d(TAG, "Got return scan result message");
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
} else if (message.what == R.id.launch_product_query) {
Log.d(TAG, "Got product query message");
String url = (String) message.obj;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
}
}
public void quitSynchronously() {
state = State.DONE;
CameraManager.get().stopPreview();
Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
quit.sendToTarget();
try {
decodeThread.join();
} catch (InterruptedException e) {
// continue
}
// Be absolutely sure we don't send any queued up messages
removeMessages(R.id.decode_succeeded);
removeMessages(R.id.decode_failed);
}
private void restartPreviewAndDecode() {
if (state == State.SUCCESS) {
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
activity.drawViewfinder();
}
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.content.Intent;
import android.net.Uri;
import com.google.zxing.BarcodeFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.regex.Pattern;
final class DecodeFormatManager {
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
static final Vector<BarcodeFormat> PRODUCT_FORMATS;
static final Vector<BarcodeFormat> ONE_D_FORMATS;
static final Vector<BarcodeFormat> QR_CODE_FORMATS;
static final Vector<BarcodeFormat> DATA_MATRIX_FORMATS;
static {
PRODUCT_FORMATS = new Vector<BarcodeFormat>(5);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_A);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
PRODUCT_FORMATS.add(BarcodeFormat.RSS_14);
ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 4);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
ONE_D_FORMATS.add(BarcodeFormat.CODE_93);
ONE_D_FORMATS.add(BarcodeFormat.CODE_128);
ONE_D_FORMATS.add(BarcodeFormat.ITF);
QR_CODE_FORMATS = new Vector<BarcodeFormat>(1);
QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE);
DATA_MATRIX_FORMATS = new Vector<BarcodeFormat>(1);
DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX);
}
private DecodeFormatManager() {}
static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
List<String> scanFormats = null;
String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
if (scanFormatsString != null) {
scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
}
return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
}
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
if (formats != null && formats.size() == 1 && formats.get(0) != null){
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
}
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
}
private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
String decodeMode) {
if (scanFormats != null) {
Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
try {
for (String format : scanFormats) {
formats.add(BarcodeFormat.valueOf(format));
}
return formats;
} catch (IllegalArgumentException iae) {
// ignore it then
}
}
if (decodeMode != null) {
if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
return PRODUCT_FORMATS;
}
if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
return QR_CODE_FORMATS;
}
if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
return DATA_MATRIX_FORMATS;
}
if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
return ONE_D_FORMATS;
}
}
return null;
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.gingersoft.gsa.cloud.zxing.camera.PlanarYUVLuminanceSource;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;
import java.util.Hashtable;
final class DecodeHandler extends Handler {
private static final String TAG = DecodeHandler.class.getSimpleName();
private final MipcaCaptureActivity activity;
private final MultiFormatReader multiFormatReader;
DecodeHandler(MipcaCaptureActivity activity, Hashtable<DecodeHintType, Object> hints) {
multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(hints);
this.activity = activity;
}
@Override
public void handleMessage(Message message) {
if (message.what == R.id.decode) {//Log.d(TAG, "Got decode message");
decode((byte[]) message.obj, message.arg1, message.arg2);
} else if (message.what == R.id.quit) {
Looper.myLooper().quit();
}
}
/**
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
* reuse the same reader objects from one decode to the next.
*
* @param data The YUV preview frame.
* @param width The width of the preview frame.
* @param height The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
long start = System.currentTimeMillis();
Result rawResult = null;
//modify here
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width; // Here we are swapping, that's the difference to #11
width = height;
height = tmp;
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
if (rawResult != null) {
long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle);
//Log.d(TAG, "Sending decode succeeded message...");
message.sendToTarget();
} else {
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed);
message.sendToTarget();
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.os.Handler;
import android.os.Looper;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
import com.google.zxing.ResultPointCallback;
import java.util.Hashtable;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
/**
* This thread does all the heavy lifting of decoding the images.
* 解码线程
*/
final class DecodeThread extends Thread {
public static final String BARCODE_BITMAP = "barcode_bitmap";
private final MipcaCaptureActivity activity;
private final Hashtable<DecodeHintType, Object> hints;
private Handler handler;
private final CountDownLatch handlerInitLatch;
DecodeThread(MipcaCaptureActivity activity,
Vector<BarcodeFormat> decodeFormats,
String characterSet,
ResultPointCallback resultPointCallback) {
this.activity = activity;
handlerInitLatch = new CountDownLatch(1);
hints = new Hashtable<DecodeHintType, Object>(3);
if (decodeFormats == null || decodeFormats.isEmpty()) {
decodeFormats = new Vector<BarcodeFormat>();
decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
}
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
if (characterSet != null) {
hints.put(DecodeHintType.CHARACTER_SET, characterSet);
}
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
Handler getHandler() {
try {
handlerInitLatch.await();
} catch (InterruptedException ie) {
// continue?
}
return handler;
}
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(activity, hints);
handlerInitLatch.countDown();
Looper.loop();
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import android.content.DialogInterface;
/**
* Simple listener used to exit the app in a few cases.
*
*/
public final class FinishListener
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable {
private final Activity activityToFinish;
public FinishListener(Activity activityToFinish) {
this.activityToFinish = activityToFinish;
}
public void onCancel(DialogInterface dialogInterface) {
run();
}
public void onClick(DialogInterface dialogInterface, int i) {
run();
}
public void run() {
activityToFinish.finish();
}
}
/*
* Copyright (C) 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.app.Activity;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
/**
* Finishes an activity after a period of inactivity.
*/
public final class InactivityTimer {
private static final int INACTIVITY_DELAY_SECONDS = 5 * 60;
private final ScheduledExecutorService inactivityTimer =
Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory());
private final Activity activity;
private ScheduledFuture<?> inactivityFuture = null;
public InactivityTimer(Activity activity) {
this.activity = activity;
onActivity();
}
public void onActivity() {
cancel();
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
INACTIVITY_DELAY_SECONDS,
TimeUnit.SECONDS);
}
private void cancel() {
if (inactivityFuture != null) {
inactivityFuture.cancel(true);
inactivityFuture = null;
}
}
public void shutdown() {
cancel();
inactivityTimer.shutdown();
}
private static final class DaemonThreadFactory implements ThreadFactory {
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
}
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.decoding;
/**
* This class provides the constants to use when sending an Intent to Barcode Scanner.
* These strings are effectively API and cannot be changed.
*/
public final class Intents {
private Intents() {
}
public static final class Scan {
/**
* Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
* the results.
*/
public static final String ACTION = "com.google.zxing.client.android.SCAN";
/**
* By default, sending Scan.ACTION will decode all barcodes that we understand. However it
* may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
* one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
* Optional.
*
* Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
* It is overridden by that setting.
*/
public static final String MODE = "SCAN_MODE";
/**
* Comma-separated list of formats to scan for. The values must match the names of
* {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
* Example: "EAN_13,EAN_8,QR_CODE"
*
* This overrides {@link #MODE}.
*/
public static final String SCAN_FORMATS = "SCAN_FORMATS";
/**
* @see com.google.zxing.DecodeHintType#CHARACTER_SET
*/
public static final String CHARACTER_SET = "CHARACTER_SET";
/**
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
* prices, reviews, etc. for products.
*/
public static final String PRODUCT_MODE = "PRODUCT_MODE";
/**
* Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
*/
public static final String ONE_D_MODE = "ONE_D_MODE";
/**
* Decode only QR codes.
*/
public static final String QR_CODE_MODE = "QR_CODE_MODE";
/**
* Decode only Data Matrix codes.
*/
public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
/**
* If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
* requested the scan via startSubActivity(). The barcodes contents can be retrieved with
* intent.getStringExtra(RESULT). If the user presses Back, the result code will be
* RESULT_CANCELED.
*/
public static final String RESULT = "SCAN_RESULT";
/**
* Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
* See Contents.Format for possible values.
*/
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
/**
* Setting this to false will not save scanned codes in the history.
*/
public static final String SAVE_HISTORY = "SAVE_HISTORY";
private Scan() {
}
}
public static final class Encode {
/**
* Send this intent to encode a piece of data as a QR code and display it full screen, so
* that another person can scan the barcode from your screen.
*/
public static final String ACTION = "com.google.zxing.client.android.ENCODE";
/**
* The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
* Bundle, depending on the type and format specified. Non-QR Code formats should
* just use a String here. For QR Code, see Contents for details.
*/
public static final String DATA = "ENCODE_DATA";
/**
* The type of data being supplied if the format is QR Code. Use
* Intent.putExtra(TYPE, type) with one of Contents.Type.
*/
public static final String TYPE = "ENCODE_TYPE";
/**
* The barcode format to be displayed. If this isn't specified or is blank,
* it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
* format is one of Contents.Format.
*/
public static final String FORMAT = "ENCODE_FORMAT";
private Encode() {
}
}
public static final class SearchBookContents {
/**
* Use Google Book Search to search the contents of the book provided.
*/
public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
/**
* The book to search, identified by ISBN number.
*/
public static final String ISBN = "ISBN";
/**
* An optional field which is the text to search for.
*/
public static final String QUERY = "QUERY";
private SearchBookContents() {
}
}
public static final class WifiConnect {
/**
* Internal intent used to trigger connection to a wi-fi network.
*/
public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String SSID = "SSID";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String TYPE = "TYPE";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String PASSWORD = "PASSWORD";
private WifiConnect() {
}
}
public static final class Share {
/**
* Give the user a choice of items to encode as a barcode, then render it as a QR Code and
* display onscreen for a friend to scan with their phone.
*/
public static final String ACTION = "com.google.zxing.client.android.SHARE";
private Share() {
}
}
}
package com.gingersoft.gsa.cloud.zxing.decoding;
import android.graphics.Bitmap;
import com.google.zxing.LuminanceSource;
/**
* Created by Administrator on 2017/5/5 0005.
*/
public class RGBLuminanceSource extends LuminanceSource {
private byte bitmapPixels[];
public RGBLuminanceSource(Bitmap bitmap) {
super(bitmap.getWidth(), bitmap.getHeight());
// 首先,要取得该图片的像素数组内容
int[] data = new int[bitmap.getWidth() * bitmap.getHeight()];
this.bitmapPixels = new byte[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(data, 0, getWidth(), 0, 0, getWidth(), getHeight());
// 将int数组转换为byte数组
for (int i = 0; i < data.length; i++) {
this.bitmapPixels[i] = (byte) data[i];
}
}
@Override
public byte[] getMatrix() {
// 返回我们生成好的像素数据
return bitmapPixels;
}
@Override
public byte[] getRow(int y, byte[] row) {
// 这里要得到指定行的像素数据
System.arraycopy(bitmapPixels, y * getWidth(), row, 0, getWidth());
return row;
}
}
/*
* Copyright (C) 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.view;
import com.google.zxing.ResultPoint;
import com.google.zxing.ResultPointCallback;
public final class ViewfinderResultPointCallback implements ResultPointCallback {
private final ViewfinderView viewfinderView;
public ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
this.viewfinderView = viewfinderView;
}
public void foundPossibleResultPoint(ResultPoint point) {
viewfinderView.addPossibleResultPoint(point);
}
}
/*
* Copyright (C) 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.zxing.view;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.zxing.camera.CameraManager;
import com.google.zxing.ResultPoint;
import com.jess.arms.utils.ArmsUtils;
import java.util.Collection;
import java.util.HashSet;
/**
* This view is overlaid on top of the camera preview. It adds the viewfinder
* rectangle and partial transparency outside it, as well as the laser scanner
* animation and result points.
*/
public final class ViewfinderView extends View {
private static final String TAG = "log";
/**
* 刷新界面的时间
*/
private static final long ANIMATION_DELAY = 10L;
private static final int OPAQUE = 0xFF;
/**
* 四个绿色边角对应的长度
*/
private int ScreenRate;
/**
* 四个绿色边角对应的宽度
*/
private static final int CORNER_WIDTH = 10;
/**
* 扫描框中的中间线的宽度
*/
private static final int MIDDLE_LINE_WIDTH = 6;
/**
* 扫描框中的中间线的与扫描框左右的间隙
*/
private static final int MIDDLE_LINE_PADDING = 5;
/**
* 中间那条线每次刷新移动的距离
*/
private static final int SPEEN_DISTANCE = 5;
/**
* 手机的屏幕密度
*/
private static float density;
/**
* 字体大小
*/
private final int TEXT_SIZE = (int) getResources().getDimension(R.dimen.sp_14);
/**
* 字体距离扫描框下面的距离
*/
private static final int TEXT_PADDING_TOP = 50;
/**
* 画笔对象的引用
*/
private Paint paint;
/**
* 中间滑动线的最顶端位置
*/
private int slideTop;
/**
* 中间滑动线的最底端位置
*/
private int slideBottom;
private StaticLayout layoutBottom;//绘制扫描框下字体
private TextPaint textPaint;
/**
* 将扫描的二维码拍下来,这里没有这个功能,暂时不考虑
*/
private Bitmap resultBitmap;
private final int maskColor;
private final int resultColor;
private final int resultPointColor;
private Collection<ResultPoint> possibleResultPoints;
private Collection<ResultPoint> lastPossibleResultPoints;
boolean isFirst;
public ViewfinderView(Context context, AttributeSet attrs) {
super(context, attrs);
density = context.getResources().getDisplayMetrics().density;
//将像素转换成dp
ScreenRate = (int) (20 * density);
paint = new Paint();
Resources resources = getResources();
maskColor = resources.getColor(R.color.viewfinder_mask);
resultColor = resources.getColor(R.color.result_view);
resultPointColor = resources.getColor(R.color.possible_result_points);
possibleResultPoints = new HashSet<ResultPoint>(5);
}
@Override
public void onDraw(Canvas canvas) {
//中间的扫描框,你要修改扫描框的大小,去CameraManager里面修改
CameraManager.init(this.getContext());
Rect frame = CameraManager.get().getFramingRect();
if (frame == null) {
return;
}
//初始化中间线滑动的最上边和最下边
if (!isFirst) {
isFirst = true;
slideTop = frame.top;
slideBottom = frame.bottom;
}
//获取屏幕的宽和高
int width = canvas.getWidth();
int height = canvas.getHeight();
paint.setColor(resultBitmap != null ? resultColor : maskColor);
//画出扫描框外面的阴影部分,共四个部分,扫描框的上面到屏幕上面,扫描框的下面到屏幕下面
//扫描框的左边面到屏幕左边,扫描框的右边到屏幕右边
canvas.drawRect(0, 0, width, frame.top, paint);
canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1,
paint);
canvas.drawRect(0, frame.bottom + 1, width, height, paint);
if (resultBitmap != null) {
// Draw the opaque result bitmap over the scanning rectangle
paint.setAlpha(OPAQUE);
canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
} else {
//画扫描框边上的角,总共8个部分
// int themeColor = (Integer) SPUtils.get(SApplication.getInstance(), DefaultConfig.THEME_COLOR, getResources().getColor(R.color.theme_color));
int themeColor = getResources().getColor(R.color.theme_color);
// paint.setColor(Color.GREEN);
paint.setColor(themeColor);
canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left
+ ScreenRate, frame.bottom, paint);
canvas.drawRect(frame.left, frame.bottom - ScreenRate,
frame.left + CORNER_WIDTH, frame.bottom, paint);
canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH,
frame.right, frame.bottom, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate,
frame.right, frame.bottom, paint);
//绘制中间的线,每次刷新界面,中间的线往下移动SPEEN_DISTANCE
slideTop += SPEEN_DISTANCE;
if (slideTop >= frame.bottom) {
slideTop = frame.top;
}
canvas.drawRect(frame.left + MIDDLE_LINE_PADDING, slideTop - MIDDLE_LINE_WIDTH / 2, frame.right - MIDDLE_LINE_PADDING, slideTop + MIDDLE_LINE_WIDTH / 2, paint);
if (textPaint == null) {
textPaint = new TextPaint();
}
//画扫描框下面的字
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(TEXT_SIZE);
// textPaint.setAlpha(0x40);
textPaint.setTypeface(Typeface.create("System", Typeface.BOLD));
if (layoutBottom == null) {
layoutBottom = new StaticLayout("請掃描二維碼", textPaint, (frame.right - frame.left), Layout.Alignment.ALIGN_CENTER, 1.4F, 0.0F, true);
}
canvas.save();//锁画布(为了保存之前的画布状态)
//开始绘制的位置,相对偏移
canvas.translate(frame.left, (float) (frame.bottom) + ArmsUtils.dip2px(getContext(), 50));
layoutBottom.draw(canvas);
canvas.restore();
//识别闪烁点
// Collection<ResultPoint> currentPossible = possibleResultPoints;
// Collection<ResultPoint> currentLast = lastPossibleResultPoints;
// if (currentPossible.isEmpty()) {
// lastPossibleResultPoints = null;
// } else {
// possibleResultPoints = new HashSet<ResultPoint>(5);
// lastPossibleResultPoints = currentPossible;
// paint.setAlpha(OPAQUE);
// paint.setColor(resultPointColor);
// for (ResultPoint point : currentPossible) {
// canvas.drawCircle(frame.left + point.getX(), frame.top
// + point.getY(), 6.0f, paint);
// }
// }
// if (currentLast != null) {
// paint.setAlpha(OPAQUE / 2);
// paint.setColor(resultPointColor);
// for (ResultPoint point : currentLast) {
// canvas.drawCircle(frame.left + point.getX(), frame.top
// + point.getY(), 3.0f, paint);
// }
// }
//只刷新扫描框的内容,其他地方不刷新
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top,
frame.right, frame.bottom);
}
}
public void drawViewfinder() {
resultBitmap = null;
invalidate();
}
/**
* Draw a bitmap with the result points highlighted instead of the live
* scanning display.
*
* @param barcode An image of the decoded barcode.
*/
public void drawResultBitmap(Bitmap barcode) {
resultBitmap = barcode;
invalidate();
}
public void addPossibleResultPoint(ResultPoint point) {
possibleResultPoints.add(point);
}
}
<?xml version="1.0" encoding="utf-8"?>
<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" >
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
app:qmui_topbar_title_color="@color/theme_white_color" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/head_height">
<SurfaceView
android:id="@+id/preview_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
<com.gingersoft.gsa.cloud.zxing.view.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<TextView
android:id="@+id/btn_album"
android:layout_margin="@dimen/dp_10"
android:text="相冊"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/normal_space12"
android:paddingRight="@dimen/normal_space12"
android:paddingTop="@dimen/normal_space5"
android:paddingBottom="@dimen/normal_space5"
android:textColor="@color/white"
android:background="@drawable/shape_delivery_item_btn_normal"
android:textSize="@dimen/font_normal2"
android:layout_gravity="right"/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
...@@ -25,4 +25,21 @@ ...@@ -25,4 +25,21 @@
<item name="layout_for_test" type="id"/> <item name="layout_for_test" type="id"/>
<item name="topbar_heart_disconnect" type="id"/> <item name="topbar_heart_disconnect" type="id"/>
<!-- Messages IDs -->
<item name="auto_focus" type="id" />
<item name="decode" type="id" />
<item name="decode_failed" type="id" />
<item name="decode_succeeded" type="id" />
<item name="encode_failed" type="id" />
<item name="encode_succeeded" type="id" />
<item name="launch_product_query" type="id" />
<item name="quit" type="id" />
<item name="restart_preview" type="id" />
<item name="return_scan_result" type="id" />
<item name="search_book_contents_failed" type="id" />
<item name="search_book_contents_succeeded" type="id" />
<item name="gridview" type="id" />
<item name="webview" type="id" />
<item name="about_version_code" type="id"/>
<item name="split" type="id"/>
</resources> </resources>
\ No newline at end of file
...@@ -56,8 +56,8 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B ...@@ -56,8 +56,8 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B
int restaurantId = GsaCloudApplication.getRestaurantId(this); int restaurantId = GsaCloudApplication.getRestaurantId(this);
if (restaurantId != 0) { if (restaurantId != 0) {
//上一次進入app有選擇餐廳,通過餐廳ID獲取允許的最大登陸數 //上一次進入app有選擇餐廳,通過餐廳ID獲取允許的最大登陸數
// mPresenter.getLoginLimit(restaurantId, false); mPresenter.getLoginLimit(restaurantId, false);
jumpMainActivity(); // jumpMainActivity();
return; return;
} }
} }
...@@ -69,9 +69,9 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B ...@@ -69,9 +69,9 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B
if (brandsBean != null) { if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), restaurantsBean); saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), restaurantsBean);
//通過餐廳ID獲取允許的最大登陸數 //通過餐廳ID獲取允許的最大登陸數
// mPresenter.getLoginLimit(restaurantsBean.getRestaurantId(), true); mPresenter.getLoginLimit(restaurantsBean.getRestaurantId(), true);
} }
jumpDownloadActivity(); // jumpDownloadActivity();
} else { } else {
showChooseRestaurantDialog(brandsBeans, brands); showChooseRestaurantDialog(brandsBeans, brands);
} }
...@@ -99,10 +99,10 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B ...@@ -99,10 +99,10 @@ public abstract class LoginInterfaceImpl<P extends BaseLoginPresenter> extends B
BrandsBean.BrandsData brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brands, item.getRestaurantId()); BrandsBean.BrandsData brandsBean = RestaurantInfoUtils.getBrandByRestaurantId(brands, item.getRestaurantId());
if (brandsBean != null) { if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item); saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item);
// mPresenter.getLoginLimit(item.getRestaurantId(), true); mPresenter.getLoginLimit(item.getRestaurantId(), true);
} }
dialog.dismiss(); dialog.dismiss();
jumpDownloadActivity(); // jumpDownloadActivity();
} }
protected void saveBrandAndRestaurantInfo(int brandId, String brandName, BrandsBean.BrandsData.RestaurantsBean restaurantsBean) { protected void saveBrandAndRestaurantInfo(int brandId, String brandName, BrandsBean.BrandsData.RestaurantsBean restaurantsBean) {
......
...@@ -84,6 +84,27 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -84,6 +84,27 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
private boolean passwrodVisibility = false; private boolean passwrodVisibility = false;
/**
* 轉台操作后需要重算的點:
* 合計(食品總金額)
* 服務費
* 折扣
* 賬單小數
*/
/**
* 服務費:
* 1、A 轉 B,服務費不用轉過去 用目標檯的即可
*/
/**
* 折扣:
* A 轉 B
* 1、A B都有折扣不用轉過去
* 2、A有折扣B沒有 需要轉過去
* 3、B有折扣A沒有 不用管
*/
@Override @Override
public void setupActivityComponent(@NonNull AppComponent appComponent) { public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerLoginComponent //如找不到该类,请编译一下项目 DaggerLoginComponent //如找不到该类,请编译一下项目
......
...@@ -202,7 +202,6 @@ public class SettlementReportPresenter extends BasePresenter<SettlementReportCon ...@@ -202,7 +202,6 @@ public class SettlementReportPresenter extends BasePresenter<SettlementReportCon
showMergeSettlementDialog(IActivity,"今天已清機過,是否合併清機"); showMergeSettlementDialog(IActivity,"今天已清機過,是否合併清機");
} else { } else {
if (!TextUtils.isEmpty(info.getErrMsg())) { if (!TextUtils.isEmpty(info.getErrMsg())) {
// mRootView.showMessage(info.getErrMsg() + ",清機失敗");
showSettlementErrorDialog(info.getErrMsg() + ",清機失敗"); showSettlementErrorDialog(info.getErrMsg() + ",清機失敗");
} else { } else {
mRootView.showMessage("清機失敗"); mRootView.showMessage("清機失敗");
......
...@@ -127,12 +127,12 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter< ...@@ -127,12 +127,12 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
viewHolder.ll_container.setBackgroundColor(Color.parseColor("#FFFFFFFF")); viewHolder.ll_container.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
setBackGroundWork(viewHolder, Color.parseColor("#FFFFFFFF"), R.color.black, R.color.theme_black); setBackGroundWork(viewHolder, Color.parseColor("#FFFFFFFF"), R.color.black, R.color.theme_black);
viewHolder.cb_checked.setChecked(false); // viewHolder.cb_checked.setChecked(false);
viewHolder.cb_checked.setOnCheckedChangeListener(null); viewHolder.cb_checked.setOnCheckedChangeListener(null);
viewHolder.cb_checked.setVisibility(View.GONE); viewHolder.cb_checked.setVisibility(View.GONE);
} else { } else {
viewHolder.cb_checked.setChecked(false); // viewHolder.cb_checked.setChecked(false);
viewHolder.rl_table.setVisibility(View.VISIBLE); viewHolder.rl_table.setVisibility(View.VISIBLE);
viewHolder.fl_add_table.setVisibility(View.GONE); viewHolder.fl_add_table.setVisibility(View.GONE);
...@@ -147,7 +147,6 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter< ...@@ -147,7 +147,6 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
viewHolder.tv_service_fee.setVisibility(View.GONE); viewHolder.tv_service_fee.setVisibility(View.GONE);
} }
if (isRadioEdit && tableItem.getUseStatus() == 0 && tableItem.getStatus() == 0) { if (isRadioEdit && tableItem.getUseStatus() == 0 && tableItem.getStatus() == 0) {
viewHolder.cb_checked.setChecked(tableItem.isChecked());
viewHolder.cb_checked.setVisibility(View.VISIBLE); viewHolder.cb_checked.setVisibility(View.VISIBLE);
viewHolder.cb_checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { viewHolder.cb_checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
...@@ -161,6 +160,7 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter< ...@@ -161,6 +160,7 @@ public class TableManageSectiontAdapter extends QMUIDefaultStickySectionAdapter<
viewHolder.cb_checked.setVisibility(View.GONE); viewHolder.cb_checked.setVisibility(View.GONE);
} }
} }
viewHolder.cb_checked.setChecked(tableItem.isChecked());
viewHolder.ll_container.setRadiusAndShadow(mRadius, QMUIDisplayHelper.dp2px(context, mShadowElevationDp), mShadowAlpha); viewHolder.ll_container.setRadiusAndShadow(mRadius, QMUIDisplayHelper.dp2px(context, mShadowElevationDp), mShadowAlpha);
} }
......
...@@ -58,7 +58,11 @@ import org.json.JSONException; ...@@ -58,7 +58,11 @@ import org.json.JSONException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -168,7 +172,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -168,7 +172,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
initRecycleScrollListener(); initRecycleScrollListener();
mActivity.queryAreas(null); mActivity.queryAreas(null);
mActivity.queryTables(null); mActivity.queryTables(null);
// mActivity.initGetTableTimer(); mActivity.initGetTableTimer();
cb_all_select.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cb_all_select.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
...@@ -188,14 +192,14 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -188,14 +192,14 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
super.onResume(); super.onResume();
hideSoftInput(); hideSoftInput();
//開始刷新餐檯數據 //開始刷新餐檯數據
// mActivity.onStartRefreshTableData(); mActivity.onStartRefreshTableData();
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
//停止刷新餐檯數據 //停止刷新餐檯數據
// mActivity.onPauseRefreshTableData(); mActivity.onPauseRefreshTableData();
} }
@Override @Override
...@@ -271,7 +275,6 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -271,7 +275,6 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
if (isRadioEdit) { if (isRadioEdit) {
item.setChecked(!item.isChecked()); item.setChecked(!item.isChecked());
mAdapter.notifyItemChanged(position); mAdapter.notifyItemChanged(position);
// mAdapter.notifyDataSetChanged();
} else { } else {
if (item.getStatus() == 0) { if (item.getStatus() == 0) {
start(AddTableFragment.newInstance(item)); start(AddTableFragment.newInstance(item));
...@@ -344,7 +347,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -344,7 +347,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
return layoutManager; return layoutManager;
} }
public void setAreaData(List<TableArea> tableAreaList){ public void setAreaData(List<TableArea> tableAreaList) {
initParms(); initParms();
...@@ -437,7 +440,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -437,7 +440,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
showMessage("請選擇餐檯"); showMessage("請選擇餐檯");
return; return;
} }
showEditTextDialog(mActivity, "批量修改服務費", "請輸入服務費",InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); showEditTextDialog(mActivity, "批量修改服務費", "請輸入服務費", InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
} }
@OnClick(R2.id.btn_delete) @OnClick(R2.id.btn_delete)
...@@ -484,7 +487,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -484,7 +487,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
return updateServiceCharges; return updateServiceCharges;
} }
public void showEditTextDialog(Activity context, String title, String placeholder,int inputType) { public void showEditTextDialog(Activity context, String title, String placeholder, int inputType) {
final QMUIDialog.EditTextDialogBuilder dialogBuilder = new QMUIDialog.EditTextDialogBuilder(context); final QMUIDialog.EditTextDialogBuilder dialogBuilder = new QMUIDialog.EditTextDialogBuilder(context);
dialogBuilder.setTitle(title); dialogBuilder.setTitle(title);
dialogBuilder.setPlaceholder(placeholder); dialogBuilder.setPlaceholder(placeholder);
...@@ -634,7 +637,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen ...@@ -634,7 +637,7 @@ public class TableListFragment extends BaseFragment<TableListPresenter> implemen
ll_bottom_operat.setVisibility(View.VISIBLE); ll_bottom_operat.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams layoutParam = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams layoutParam = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParam.setMargins(0, 0, 0, ArmsUtils.getDimens(mActivity,R.dimen.dp_48)); layoutParam.setMargins(0, 0, 0, ArmsUtils.getDimens(mActivity, R.dimen.dp_48));
fl_section_layout.setLayoutParams(layoutParam); fl_section_layout.setLayoutParams(layoutParam);
} else { } else {
......
...@@ -92,11 +92,11 @@ public class PrintBill extends PrinterRoot { ...@@ -92,11 +92,11 @@ public class PrintBill extends PrinterRoot {
layout.addView(getHalfLine(mContext)); layout.addView(getHalfLine(mContext));
BigDecimal totalAmount = new BigDecimal(0); // BigDecimal totalAmount = new BigDecimal(0);
for (OrderDetail OrderDetail : MyOrderManage.getInstance().getOrderFoodList()) { // for (OrderDetail OrderDetail : MyOrderManage.getInstance().getOrderFoodList()) {
totalAmount = MoneyUtil.sum(totalAmount, OrderDetail.getPrice()); // totalAmount = MoneyUtil.sum(totalAmount, OrderDetail.getPrice());
} // }
layout.addView(getAmountText(mContext, "總金額:" + totalAmount)); layout.addView(getAmountText(mContext, "總金額:" + MyOrderManage.getInstance().getTotalAmount()));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
layout.addView(getDiningBillPayMethod(mContext, MyOrderManage.getInstance().getBillMoney())); layout.addView(getDiningBillPayMethod(mContext, MyOrderManage.getInstance().getBillMoney()));
layout.addView(getLine(mContext)); layout.addView(getLine(mContext));
......
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.table"> package="com.gingersoft.gsa.cloud.table">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:networkSecurityConfig="@xml/network_android"> android:networkSecurityConfig="@xml/network_android">
<activity android:name=".mvp.ui.activity.TableActivity"/> <activity android:name=".mvp.ui.activity.TableActivity"/>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
android:name="design_height_in_dp" android:name="design_height_in_dp"
android:value="640"/> android:value="640"/>
</application> </application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<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" />
......
...@@ -50,6 +50,13 @@ public class OrderDetailItem implements Serializable { ...@@ -50,6 +50,13 @@ public class OrderDetailItem implements Serializable {
private String tableName; private String tableName;
private int tableId; private int tableId;
private int person; private int person;
/**
* 订单类型
* 0#堂食
* 1#外賣
* 2#自取
*/
private int orderType;
/**總金額*/ /**總金額*/
private double totalAmount; private double totalAmount;
private int totalPoints; private int totalPoints;
......
...@@ -20,6 +20,7 @@ public class AddOrderRequest { ...@@ -20,6 +20,7 @@ public class AddOrderRequest {
private long orderId; private long orderId;
private long tableId; private long tableId;
private String tableNumber; private String tableNumber;
private Integer memberId;
/**賬單小數*/ /**賬單小數*/
private Double rounding; private Double rounding;
/**整單折扣ID*/ /**整單折扣ID*/
......
...@@ -22,6 +22,7 @@ public class CreateOrderRequest { ...@@ -22,6 +22,7 @@ public class CreateOrderRequest {
private String tableNumber; private String tableNumber;
private String tableName; private String tableName;
private int restaurantId; private int restaurantId;
private Integer memberId;
/**賬單小數*/ /**賬單小數*/
private Double rounding; private Double rounding;
/**整單折扣ID*/ /**整單折扣ID*/
......
...@@ -119,7 +119,6 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas ...@@ -119,7 +119,6 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
this.mOrderFoodList = myOrderManage.getOrderFoodList(); this.mOrderFoodList = myOrderManage.getOrderFoodList();
this.mOrderMoneyList = myOrderManage.getOrderMoneyList(); this.mOrderMoneyList = myOrderManage.getOrderMoneyList();
if (IActivity instanceof OrderContentActivity) { if (IActivity instanceof OrderContentActivity) {
mOrderContentActivity = (OrderContentActivity) IActivity; mOrderContentActivity = (OrderContentActivity) IActivity;
} }
...@@ -300,6 +299,7 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas ...@@ -300,6 +299,7 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
updateTableServiceAmount(); updateTableServiceAmount();
updateOrderDiscount(); updateOrderDiscount();
updateOrderRounding(); updateOrderRounding();
myOrderManage.setTotalAmount(getTotalAmount());
} }
/** /**
...@@ -758,6 +758,9 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas ...@@ -758,6 +758,9 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
request.setTableName(OpenTableManage.getDefault().getTableBean().getTableName()); request.setTableName(OpenTableManage.getDefault().getTableBean().getTableName());
request.setRounding(getRounding()); request.setRounding(getRounding());
request.setRestaurantId(restaurantId); request.setRestaurantId(restaurantId);
if (MyOrderManage.getInstance().getMemberInfo() != null) {
request.setMemberId(MyOrderManage.getInstance().getMemberInfo().getId());
}
Discount orderDiscount = getNesOrderDiscount(); Discount orderDiscount = getNesOrderDiscount();
if (orderDiscount != null) { if (orderDiscount != null) {
request.setDiscountId(orderDiscount.getId()); request.setDiscountId(orderDiscount.getId());
...@@ -784,6 +787,9 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas ...@@ -784,6 +787,9 @@ public class BaseOrderPresenter<M extends BaseOrderContract.Model, V extends Bas
if (orderDiscount != null) { if (orderDiscount != null) {
request.setDiscountId(orderDiscount.getId()); request.setDiscountId(orderDiscount.getId());
} }
if (MyOrderManage.getInstance().getMemberInfo() != null) {
request.setMemberId(MyOrderManage.getInstance().getMemberInfo().getId());
}
return request; return request;
} }
......
...@@ -47,6 +47,7 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.ModifierAdapter; ...@@ -47,6 +47,7 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.ModifierAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.SelectMealAdapter; import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.meal.SelectMealAdapter;
import com.gingersoft.gsa.cloud.table.mvp.ui.widget.CancelFoodDialog; import com.gingersoft.gsa.cloud.table.mvp.ui.widget.CancelFoodDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.CommonTipDialog;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope; import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
...@@ -164,7 +165,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -164,7 +165,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
@Override @Override
public void onRequestPermissionSuccess() { public void onRequestPermissionSuccess() {
Intent intent = new Intent(IActivity, CaptureActivity.class); Intent intent = new Intent(IActivity, MipcaCaptureActivity.class);
IActivity.startActivityForResult(intent, MealStandActivity.SCAN_REQUEST_CODE); IActivity.startActivityForResult(intent, MealStandActivity.SCAN_REQUEST_CODE);
} }
...@@ -374,7 +375,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -374,7 +375,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
// if (!discountConditionFilter(datasBean)) { // if (!discountConditionFilter(datasBean)) {
// return; // return;
// } // }
cutOutDiscount();
addDiscountItem(datasBean); addDiscountItem(datasBean);
} }
}); });
...@@ -500,6 +501,23 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -500,6 +501,23 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
} }
/** /**
* 暂时食品折扣只能有一个
*
* @return
*/
private void cutOutDiscount() {
OrderDetail mainOrderDetail = mSelectMealAdapter.getCurrentMainOrderDetail();
if (mainOrderDetail.getItemType() == 1) {
for (OrderDetail orderDetail : mOrderFoodList) {
if (orderDetail.getParentIndex() == mainOrderDetail.getMyIndex() && orderDetail.getType() == OrderDetail.DISCOUNT_TYPE) {
mOrderFoodList.remove(orderDetail);
break;
}
}
}
}
/**
* 裁減掉已超出的細項 * 裁減掉已超出的細項
* *
* @param datasBean * @param datasBean
...@@ -866,8 +884,10 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -866,8 +884,10 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
public void queryMember(int type, String parm, String shopName) { public void queryMember(int type, String parm, String shopName) {
mModel.queryMember(type, parm, shopName) mModel.queryMember(type, parm, shopName)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread()) .subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult2>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<BaseResult2>(mErrorHandler) {
...@@ -1615,7 +1635,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -1615,7 +1635,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
if (def == mid) { if (def == mid) {
modifier.setDefmodifier("1"); modifier.setDefmodifier("1");
} else { } else {
if(TextUtils.isEmpty(modifier.getDefmodifier()) || "0".equals(modifier.getDefmodifier())){ if (!modifier.getDefmodifier().equals("1")) {
modifier.setDefmodifier("0"); modifier.setDefmodifier("0");
} }
} }
...@@ -1657,7 +1677,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod ...@@ -1657,7 +1677,7 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
if (def == fid) { if (def == fid) {
comboItem.setDefmodifier("1"); comboItem.setDefmodifier("1");
} else { } else {
if(TextUtils.isEmpty(comboItem.getDefmodifier()) || "0".equals(comboItem.getDefmodifier())){ if (!comboItem.getDefmodifier().equals("1")) {
comboItem.setDefmodifier("0"); comboItem.setDefmodifier("0");
} }
} }
......
...@@ -365,7 +365,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra ...@@ -365,7 +365,7 @@ public class OrderContentPresenter extends BaseOrderPresenter<OrderContentContra
//// //打印成功 //// //打印成功
//// ////
//// } //// }
// mRootView.sendSuccess(); mRootView.sendSuccess();
// }); // });
} }
......
package com.gingersoft.gsa.cloud.table.mvp.ui.activity; package com.gingersoft.gsa.cloud.table.mvp.ui.activity;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
...@@ -75,6 +76,7 @@ import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip; ...@@ -75,6 +76,7 @@ import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.gingersoft.gsa.cloud.ui.view.RecyclerViewNoBugLinearLayoutManager; import com.gingersoft.gsa.cloud.ui.view.RecyclerViewNoBugLinearLayoutManager;
import com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView; import com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog; import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.gsa.cloud.zxing.MipcaCaptureActivity;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.BaseFragmentActivity; import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
...@@ -246,10 +248,12 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -246,10 +248,12 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
private ChooseNumberDialog mChooseNumberDialog; private ChooseNumberDialog mChooseNumberDialog;
private UseMemberDialog mUseMemberDialog; private UseMemberDialog mUseMemberDialog;
private UseMemberDialog.BottomLayoutBuilder mUseMemberLayoutBuilder;
private MemberInfoAdapter mMemberInfoAdapter; private MemberInfoAdapter mMemberInfoAdapter;
private List<SectionTextItem> mMemberInfoList; private List<SectionTextItem> mMemberInfoList;
private RecyclerView recycler_member_info;
private MemberInfo mMemberInfo;
/** /**
* 是否初始化细项布局 * 是否初始化细项布局
*/ */
...@@ -289,10 +293,6 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -289,10 +293,6 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
EventBus.getDefault().registerSticky(this); EventBus.getDefault().registerSticky(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
OrderBean order = MyOrderManage.getInstance().getOrderBean();
if (order != null) {
// ArmsUtils.snackbarText("訂單ID:" + order.getId());
}
} }
@Override @Override
...@@ -586,7 +586,8 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -586,7 +586,8 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
} }
@Override @Override
public void setAdapter(RecyclerView recycler_member_info) { public void setAdapter(RecyclerView recycler_member_info, UseMemberDialog.BottomLayoutBuilder layoutBuilder) {
mUseMemberLayoutBuilder = layoutBuilder;
if (mMemberInfoList == null) { if (mMemberInfoList == null) {
mMemberInfoList = new ArrayList<>(); mMemberInfoList = new ArrayList<>();
} }
...@@ -597,11 +598,26 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -597,11 +598,26 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
} }
@Override @Override
public void onUseMember(UseMemberDialog dialog) {
MyOrderManage.getInstance().setMemberInfo(mMemberInfo);
btn_table.setBackgroundResource(R.color.pink_300);
}
@Override
public void clearMemberInfo() { public void clearMemberInfo() {
btn_table.setBackgroundColor(Color.parseColor("#336699"));
MyOrderManage.getInstance().setMemberInfo(null);
if (mMemberInfoList.size() > 0) { if (mMemberInfoList.size() > 0) {
mMemberInfoList.clear(); mMemberInfoList.clear();
} }
mMemberInfoAdapter.notifyDataSetChanged(); mMemberInfoAdapter.notifyDataSetChanged();
if (mUseMemberLayoutBuilder != null) {
mUseMemberLayoutBuilder.showBottomLayoutVisibility(false);
}
}
}).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
} }
}) })
.build(); .build();
...@@ -610,6 +626,7 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -610,6 +626,7 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
@Override @Override
public void updateMemberInfo(MemberInfo memberInfo) { public void updateMemberInfo(MemberInfo memberInfo) {
this.mMemberInfo = memberInfo;
if (mUseMemberDialog != null) { if (mUseMemberDialog != null) {
List<SectionTextItem> data = getMemberInfoItem(memberInfo); List<SectionTextItem> data = getMemberInfoItem(memberInfo);
if (mMemberInfoList.size() > 0) { if (mMemberInfoList.size() > 0) {
...@@ -618,15 +635,24 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -618,15 +635,24 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
mMemberInfoList.addAll(data); mMemberInfoList.addAll(data);
mMemberInfoAdapter.notifyDataSetChanged(); mMemberInfoAdapter.notifyDataSetChanged();
if (mUseMemberLayoutBuilder != null) {
mUseMemberLayoutBuilder.showBottomLayoutVisibility(true);
}
} }
} }
private List<SectionTextItem> getMemberInfoItem(MemberInfo memberInfo) { private List<SectionTextItem> getMemberInfoItem(MemberInfo memberInfo) {
List<SectionTextItem> textItems = new ArrayList<>(); List<SectionTextItem> textItems = new ArrayList<>();
// textItems.add(new SectionTextItem("會員號碼: " + memberInfo.getMemberNo())); String memberName;
// textItems.add(new SectionTextItem("會員電話: " + memberInfo.getPhone())); if (TextUtils.isEmpty(memberInfo.getMemberName())) {
// textItems.add(new SectionTextItem("會員名稱: " + memberInfo.getMemberName())); memberName = memberInfo.getLevelName1();
// textItems.add(new SectionTextItem("積分: " + memberInfo.getMemberPoint())); } else {
memberName = memberInfo.getMemberName();
}
textItems.add(new SectionTextItem("會員號碼: " + memberInfo.getMemberNo()));
textItems.add(new SectionTextItem("會員電話: " + memberInfo.getPhone()));
textItems.add(new SectionTextItem("會員名稱: " + memberName));
textItems.add(new SectionTextItem("積分: " + memberInfo.getMemberPoint()));
return textItems; return textItems;
} }
...@@ -846,9 +872,12 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -846,9 +872,12 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
@Override @Override
public void onComfirmClick(String number) { public void onComfirmClick(String number) {
recordOperat(true); recordOperat(true);
Integer maxSeatCount = OpenTableManage.getDefault().getTableBean().getMaxSeatCount(); int maxSeatCount = 0;
if (maxSeatCount != null && maxSeatCount.intValue() < Integer.parseInt(number)) { if (OpenTableManage.getDefault().getTableBean() != null) {
showMessage("最大就餐人數不能超過" + maxSeatCount.intValue() + "人!"); maxSeatCount = OpenTableManage.getDefault().getTableBean().getMaxSeatCount();
}
if (maxSeatCount != 0 && maxSeatCount < Integer.parseInt(number)) {
showMessage("最大就餐人數不能超過" + maxSeatCount + "人!");
return; return;
} }
mPresenter.updateOrderPerson(number, btn_numberman); mPresenter.updateOrderPerson(number, btn_numberman);
...@@ -1212,6 +1241,10 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -1212,6 +1241,10 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
return mFoodGroupAdapter; return mFoodGroupAdapter;
} }
public MemberInfo getMemberInfo() {
return mMemberInfo;
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
...@@ -1223,6 +1256,8 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter> ...@@ -1223,6 +1256,8 @@ public class MealStandActivity extends BaseFragmentActivity<MealStandPresenter>
//,關閉當前頁面 //,關閉當前頁面
killMyself(); killMyself();
} }
} else if (requestCode == MipcaCaptureActivity.CALL_BACK_QR_RESULT) {
String qrCodeResult = data.getStringExtra("qrCodeResult");
} }
} }
......
...@@ -177,7 +177,9 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl ...@@ -177,7 +177,9 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
} }
tv_total_money.setText("$" + orderDetailItem.getTotalAmount()); tv_total_money.setText("$" + orderDetailItem.getTotalAmount());
setTitleByOrderType(orderDetailItem);
setOrderStatus(orderDetailItem); setOrderStatus(orderDetailItem);
setBtnVisibilityByOrderType(orderDetailItem);
mOrderDetailList = OrderAssemblyUtil.assemblyOrder(OrderDetail.orderTransOrderDetails(orderDetailItem.getOrderDetails())); mOrderDetailList = OrderAssemblyUtil.assemblyOrder(OrderDetail.orderTransOrderDetails(orderDetailItem.getOrderDetails()));
setOrderDetailAdapter(mOrderDetailList); setOrderDetailAdapter(mOrderDetailList);
...@@ -336,6 +338,14 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl ...@@ -336,6 +338,14 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
return otherMoney; return otherMoney;
} }
private void setTitleByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1) {
tv_table_name.setText("外賣");
} else if (item.getOrderType() == 2) {
tv_table_name.setText("自取");
}
}
/** /**
* 設置訂單狀態 * 設置訂單狀態
* *
...@@ -355,6 +365,14 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl ...@@ -355,6 +365,14 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
} }
} }
private void setBtnVisibilityByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1 || item.getOrderType() == 2) {
//外賣自取 不可以修改訂單 取消訂單
btn_modify_order.setVisibility(View.GONE);
btn_cancel_order.setVisibility(View.GONE);
}
}
@OnClick({R2.id.btn_print_order, R2.id.btn_cancel_order, R2.id.btn_modify_order}) @OnClick({R2.id.btn_print_order, R2.id.btn_cancel_order, R2.id.btn_modify_order})
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
...@@ -435,8 +453,8 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl ...@@ -435,8 +453,8 @@ public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> impl
private List<BillOrderMoney> getOrderMoneyList() { private List<BillOrderMoney> getOrderMoneyList() {
List<BillOrderMoney> billOrderMoneyList = new ArrayList<>(); List<BillOrderMoney> billOrderMoneyList = new ArrayList<>();
if(mOrderCenterMoneyList != null){ if (mOrderCenterMoneyList != null) {
for (SectionTextItem3 item: mOrderCenterMoneyList) { for (SectionTextItem3 item : mOrderCenterMoneyList) {
BillOrderMoney billOrderMoney = new BillOrderMoney(); BillOrderMoney billOrderMoney = new BillOrderMoney();
billOrderMoney.setTitle(item.getLeftText()); billOrderMoney.setTitle(item.getLeftText());
billOrderMoney.setMoney(Double.parseDouble(item.getRightText())); billOrderMoney.setMoney(Double.parseDouble(item.getRightText()));
......
...@@ -106,7 +106,9 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> { ...@@ -106,7 +106,9 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
} }
tv_pay_money.setText(amount + item.getTotalAmount()); tv_pay_money.setText(amount + item.getTotalAmount());
setOrderStatus(item,position); setTitleByOrderType(item);
setOrderStatus(item, position);
setBtnVisibilityByOrderType(item);
ll_root_container.setOnClickListener(new View.OnClickListener() { ll_root_container.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -118,13 +120,21 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> { ...@@ -118,13 +120,21 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
}); });
} }
private void setOrderStatus(OrderDetailItem item,int position) { private void setTitleByOrderType(OrderDetailItem item) {
if(item.getStatus() == 6){ if (item.getOrderType() == 1) {
tv_table_name.setText("外賣");
} else if (item.getOrderType() == 2) {
tv_table_name.setText("自取");
}
}
private void setOrderStatus(OrderDetailItem item, int position) {
if (item.getStatus() == 6) {
btn_print_order.setVisibility(View.GONE); btn_print_order.setVisibility(View.GONE);
btn_modify_order.setVisibility(View.GONE); btn_modify_order.setVisibility(View.GONE);
btn_cancel_order.setVisibility(View.GONE); btn_cancel_order.setVisibility(View.GONE);
btn_order_status.setVisibility(View.VISIBLE); btn_order_status.setVisibility(View.VISIBLE);
}else { } else {
btn_print_order.setText(LanguageUtils.get_language_system(mContext, "print.order", "打印賬單")); btn_print_order.setText(LanguageUtils.get_language_system(mContext, "print.order", "打印賬單"));
btn_tips.setText(LanguageUtils.get_language_system(mContext, "public.tips", "貼士")); btn_tips.setText(LanguageUtils.get_language_system(mContext, "public.tips", "貼士"));
btn_modify_order.setText(LanguageUtils.get_language_system(mContext, "modify.order", "修改訂單")); btn_modify_order.setText(LanguageUtils.get_language_system(mContext, "modify.order", "修改訂單"));
...@@ -159,6 +169,14 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> { ...@@ -159,6 +169,14 @@ public class OrderCenterAdapter extends DefaultAdapter<OrderDetailItem> {
}); });
} }
} }
private void setBtnVisibilityByOrderType(OrderDetailItem item) {
if (item.getOrderType() == 1 || item.getOrderType() == 2) {
//外賣自取 不可以修改訂單 取消訂單
btn_modify_order.setVisibility(View.GONE);
btn_cancel_order.setVisibility(View.GONE);
}
}
} }
private OnItemClickListener mOnItemClickListener; private OnItemClickListener mOnItemClickListener;
......
...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.cloud.table.mvp.ui.widget; ...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.cloud.table.mvp.ui.widget;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
...@@ -15,6 +16,7 @@ import android.view.animation.Animation; ...@@ -15,6 +16,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationSet; import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.view.animation.TranslateAnimation; import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
...@@ -63,7 +65,6 @@ public class UseMemberDialog extends Dialog { ...@@ -63,7 +65,6 @@ public class UseMemberDialog extends Dialog {
private View mContentView; private View mContentView;
private boolean mIsAnimating = false; private boolean mIsAnimating = false;
private OnBottomSheetShowListener mOnBottomSheetShowListener; private OnBottomSheetShowListener mOnBottomSheetShowListener;
public UseMemberDialog(Context context) { public UseMemberDialog(Context context) {
...@@ -115,6 +116,7 @@ public class UseMemberDialog extends Dialog { ...@@ -115,6 +116,7 @@ public class UseMemberDialog extends Dialog {
super.setContentView(view); super.setContentView(view);
} }
/** /**
* BottomSheet升起动画 * BottomSheet升起动画
*/ */
...@@ -267,6 +269,7 @@ public class UseMemberDialog extends Dialog { ...@@ -267,6 +269,7 @@ public class UseMemberDialog extends Dialog {
iv_no_data = view.findViewById(R.id.iv_no_data); iv_no_data = view.findViewById(R.id.iv_no_data);
btn_query_memeber = view.findViewById(R.id.btn_query_memeber); btn_query_memeber = view.findViewById(R.id.btn_query_memeber);
btn_scan = view.findViewById(R.id.btn_scan); btn_scan = view.findViewById(R.id.btn_scan);
ll_bottom = view.findViewById(R.id.ll_bottom);
btn_use_member = view.findViewById(R.id.btn_use_member); btn_use_member = view.findViewById(R.id.btn_use_member);
btn_clear_member = view.findViewById(R.id.btn_use_member); btn_clear_member = view.findViewById(R.id.btn_use_member);
...@@ -295,7 +298,9 @@ public class UseMemberDialog extends Dialog { ...@@ -295,7 +298,9 @@ public class UseMemberDialog extends Dialog {
btn_use_member.setOnClickListener(new View.OnClickListener() { btn_use_member.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (onLayoutClickListener != null) {
onLayoutClickListener.onUseMember(mDialog);
}
} }
}); });
btn_clear_member.setOnClickListener(new View.OnClickListener() { btn_clear_member.setOnClickListener(new View.OnClickListener() {
...@@ -307,20 +312,22 @@ public class UseMemberDialog extends Dialog { ...@@ -307,20 +312,22 @@ public class UseMemberDialog extends Dialog {
} }
}); });
if (onLayoutClickListener != null) { if (onLayoutClickListener != null) {
onLayoutClickListener.setAdapter(recycler_member_info); onLayoutClickListener.setAdapter(recycler_member_info,this);
} }
return view; return view;
} }
private void initTopbar() { private void initTopbar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.theme_color)); mTopBar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.theme_color));
mTopBar.addRightTextButton("清除",R.id.btn_right) // Button rightBtn = mTopBar.addRightTextButton("清除", R.id.btn_right);
.setOnClickListener(new View.OnClickListener() { // rightBtn.setTextColor(ContextCompat.getColor(mContext, R.color.theme_white_color));
@Override // rightBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { // @Override
// public void onClick(View v) {
} //
}); //
// }
// });
mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() { mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -351,6 +358,10 @@ public class UseMemberDialog extends Dialog { ...@@ -351,6 +358,10 @@ public class UseMemberDialog extends Dialog {
}; };
} }
public void showBottomLayoutVisibility(boolean show){
ll_bottom.setVisibility(show?View.VISIBLE:View.GONE);
}
private String getTvPhone() { private String getTvPhone() {
return ed_phone.getText().toString(); return ed_phone.getText().toString();
} }
...@@ -378,7 +389,9 @@ public class UseMemberDialog extends Dialog { ...@@ -378,7 +389,9 @@ public class UseMemberDialog extends Dialog {
void onScanAction(UseMemberDialog dialog); void onScanAction(UseMemberDialog dialog);
void setAdapter(RecyclerView recycler_member_info); void setAdapter(RecyclerView recycler_member_info,BottomLayoutBuilder layoutBuilder);
void onUseMember(UseMemberDialog dialog);
void clearMemberInfo(); void clearMemberInfo();
} }
......
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