Commit b2c46c0c authored by 陈前's avatar 陈前

“”Initial

git push -u origin master

git commit -m “”Initial
parents
Pipeline #1377 failed with stages
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState />
</value>
</entry>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/navigation/ic_arrow_forward_black_24dp.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputName" value="ic_arrow_forward_black_24dp" />
<entry key="sourceFile" value="C:\Users\moli7" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xingdata.cmbc.resturant"
minSdkVersion 23
targetSdkVersion 27
multiDexEnabled false
versionCode 17
versionName "1.2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.alibaba:fastjson:1.1.68.android'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'com.blankj:utilcode:1.20.4'
implementation 'com.sunmi:printerlibrary:1.0.0'
runtimeOnly 'com.landicorp.eptapilibrary:ept-and-sdk:2.1.9'
implementation 'com.landicorp.devicekit:printer:2.1.5'
implementation 'com.google.zxing:core:3.3.2'
implementation files('libs/PosApi_V1.09_20180129.jar')
implementation files('libs/RF610_Dll.jar')
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.xingdata.cmbc.resturant;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.xingdata.cmbc.resturant", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xingdata.cmbc.resturant">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/qd_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/qd_logo"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".MainActivity"
android:configChanges="locale|mcc|mnc|keyboardHidden|orientation|screenSize|keyboard|navigation|fontScale|screenLayout|uiMode|touchscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".print.ui.RePrintDialog" />
</application>
</manifest>
\ No newline at end of file
/*
* Copyright 2009 Cedric Priscal
*
* 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 android_serialport_api;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.util.Log;
public class SerialPort11111 {
private static final String TAG = "SerialPort";
/*
* Do not remove or rename the field mFd: it is used by native method close();
*/
private FileDescriptor mFd;
private FileInputStream mFileInputStream;
private FileOutputStream mFileOutputStream;
public SerialPort11111(File device, int baudrate, int flags) throws SecurityException, IOException {
/* Check access permission */
if (!device.canRead() || !device.canWrite()) {
try {
/* Missing read/write permission, trying to chmod the file */
Process su;
su = Runtime.getRuntime().exec("/system/bin/su");
String cmd = "chmod 666 " + device.getAbsolutePath() + "\n"
+ "exit\n";
su.getOutputStream().write(cmd.getBytes());
if ((su.waitFor() != 0) || !device.canRead()
|| !device.canWrite()) {
throw new SecurityException();
}
} catch (Exception e) {
e.printStackTrace();
throw new SecurityException();
}
}
mFd = open(device.getAbsolutePath(), baudrate, flags);
if (mFd == null) {
Log.e(TAG, "native open returns null");
throw new IOException();
}
mFileInputStream = new FileInputStream(mFd);
mFileOutputStream = new FileOutputStream(mFd);
}
// Getters and setters
public InputStream getInputStream() {
return mFileInputStream;
}
public OutputStream getOutputStream() {
return mFileOutputStream;
}
// JNI
private native static FileDescriptor open(String path, int baudrate, int flags);
public native void close();
static {
System.loadLibrary("serial_port");
}
}
package com.xingdata.cmbc.resturant;
import android.os.Handler;
import android.view.KeyEvent;
public class ScannerUtil {
// 延迟500ms,判断扫码是否完成。
private final static long MESSAGE_DELAY = 500;
// 扫码内容
private StringBuffer mStringBufferResult = new StringBuffer();
// 大小写区分
private boolean mCaps;
//是否启动
private boolean isOpen = false;
private OnBarcodeCatchListener mOnBarcodeCatchListener;
private Handler mHandler = new Handler();
private final Runnable mScanningFishedRunnable = this::performScanSuccess;
/**
* 带参数的构造方法
*
* @param onBarcodeCatchListener 扫描完成监听
*/
public ScannerUtil(OnBarcodeCatchListener onBarcodeCatchListener) {
this.mOnBarcodeCatchListener = onBarcodeCatchListener;
this.isOpen = true;
}
/**
* 启动
*/
public void open() {
isOpen = true;
}
/**
* 关闭
*/
public void close() {
isOpen = false;
}
/**
* 返回扫描结果
*/
private void performScanSuccess() {
String barcode = mStringBufferResult.toString();
if (mOnBarcodeCatchListener != null) mOnBarcodeCatchListener.onBarcodeCatch(barcode);
mStringBufferResult.setLength(0);
}
/**
* key事件处理
*
* @param event KeyEvent
*/
public void analysisKeyEvent(KeyEvent event) {
//如果已经关闭,则清空mStringBufferResult
if (!isOpen) {
mStringBufferResult.setLength(0);
return;
}
int keyCode = event.getKeyCode();
// 字母大小写判断
checkLetterStatus(event);
if (event.getAction() == KeyEvent.ACTION_DOWN) {
char aChar = getInputCode(event);
if (aChar != 0) {
mStringBufferResult.append(aChar);
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
// 若为回车键,直接返回
mHandler.removeCallbacks(mScanningFishedRunnable);
mHandler.post(mScanningFishedRunnable);
} else {
// 延迟post,若500ms内,有其他事件
mHandler.removeCallbacks(mScanningFishedRunnable);
// mHandler.postDelayed(mScanningFishedRunnable, MESSAGE_DELAY);
}
}
}
/**
* 检查shift键
*
* @param event KeyEvent
*/
private void checkLetterStatus(KeyEvent event) {
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT || keyCode == KeyEvent.KEYCODE_SHIFT_LEFT) {
// 按着shift键,表示大写 , 松开shift键,表示小写
mCaps = event.getAction() == KeyEvent.ACTION_DOWN;
}
}
/**
* 获取扫描内容
*
* @param event KeyEvent
* @return 扫描内容
*/
private char getInputCode(KeyEvent event) {
int keyCode = event.getKeyCode();
char aChar;
if (keyCode >= KeyEvent.KEYCODE_A && keyCode <= KeyEvent.KEYCODE_Z) {
// 字母
aChar = (char) ((mCaps ? 'A' : 'a') + keyCode - KeyEvent.KEYCODE_A);
} else if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
// 数字
aChar = (char) ('0' + keyCode - KeyEvent.KEYCODE_0);
} else {
// 其他符号
switch (keyCode) {
case KeyEvent.KEYCODE_PERIOD:
aChar = '.';
break;
case KeyEvent.KEYCODE_MINUS:
aChar = mCaps ? '_' : '-';
break;
case KeyEvent.KEYCODE_SLASH:
aChar = '/';
break;
case KeyEvent.KEYCODE_BACKSLASH:
aChar = mCaps ? '|' : '\\';
break;
default:
aChar = 0;
break;
}
}
return aChar;
}
/**
* 扫描成功接口
*/
public interface OnBarcodeCatchListener {
void onBarcodeCatch(String code);
}
}
package com.xingdata.cmbc.resturant.bean;
/**
* @author ZhangZhen
* @version V1.0
* @Title: DeviceEntity.java
* @Package com.xingdata.api.printConsumption.entity;
* @Description: 设备信息的实体类
* @date 2017年2月28日17:32:20
* @update 2017年3月14日 添加新的设备型号
*/
public class DeviceEntity {
private String brand, model;
/**
* 设备品牌 - 拉卡拉
*
*/
public static final String BRAND_LKL = "LKL";
/**
* 设备品牌 - 联迪
*/
public static final String BRAND_LANDI = "LANDI";
/**
* 设备品牌 - 商米
*/
public static final String BRAND_SUNMI = "SUNMI";
/**
* 设备品牌 - 百富
*/
public static final String BRAND_PAX = "PAX";
// /**
// * 设备品牌 - 联迪C10
// */
// public static final String MODEL_LANDI_C10 = "LANDI_AECR C10";
//
// /**
// * 设备品牌 - 联迪A8
// */
// public static final String MODEL_LANDI_A8 = "LANDI_APOS A8";
// /**
// * 设备品牌 - 商米
// */
//// public static final String BRAND_SUNMI = "SUNMI";
//
// /**
// * 设备品牌型号 - 商米 P1
// */
// public static final String MODEL_SUNMI_P1 = "SUNMI_P1";
//
// /**
// * 设备品牌型号 - 商米 V1
// */
// public static final String MODEL_SUNMI_V1 = "SUNMI_V1";
//
//
// /**
// * 设备品牌型号 - 商米 V2
// */
// public static final String MODEL_SUNMI_V2 = "SUNMI_V2";
//
// /**
// * 设备型号 - 商米 T1
// */
// public static final String MODEL_SUNMI_T1 = "SUNMI_t1host";
//
// /**
// * 设备型号 - 新大陆
// */
// public static final String MODEL_NDL_N910 = "qcom_N910";
//
// /**
// * 设备品牌 - 百富 A920
// */
// public static final String MODEL_PAX_A920 = "PAX_A920";
//
// /**
// * 设备品牌 - 百富 A930
// */
// public static final String MODEL_PAX_A930 = "PAX_A930";
//
// /**
// * 设备品牌 - 百富 E500
// */
// public static final String MODEL_PAX_E500 = "PAX_E500";
//
// /**
// * 设备品牌 - 百富 E800
// */
// public static final String MODEL_PAX_E800 = "PAX_E800";
// /**
// * 设备品牌 - 杰博实K9
// */
// public static final String MODEL_JPAY_K9 = "K9_V2.1.5_K9";
// /**
// * 惠尔丰
// */
// public static final String MODEL_VERIFORIE_X990 = "Verifone_X990";
}
package com.xingdata.cmbc.resturant.print;
public class C {
public static String KEY_STRING="String";
}
package com.xingdata.cmbc.resturant.print;
import android.support.annotation.IntDef;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.cmbc.resturant.bean.DeviceEntity;
import com.xingdata.cmbc.resturant.print.bean.PrintBean;
import com.xingdata.cmbc.resturant.print.bean.PrintItem;
import com.xingdata.cmbc.resturant.print.landi.PrinterLandiService;
import com.xingdata.cmbc.resturant.print.pax.PrinterPax;
import com.xingdata.cmbc.resturant.print.sunmi.SunmiPrinter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PrintSetting {
public static final int SINGLE = 1;
public static final int DUAL = 2;
public static final int NONE = 0;
@IntDef({SINGLE, DUAL, NONE})
@Retention(RetentionPolicy.SOURCE)
public @interface SalePrintNum {
}
private String QRcode;
private SalePrintNum printNum;
private boolean isPrintLogo;
private boolean isPrintCode;
private boolean isPrintOutFood;
private boolean isPrintRefund;
private boolean isPrintRecharge;
private boolean isPrintPurchase;
private List<PrintItem> printItems = new ArrayList<>();
private String printBrand;
private Integer printSize;
public String getQRcode() {
return QRcode;
}
public void setQRcode(String QRcode) {
this.QRcode = QRcode;
}
public String getPrintBrand() {
return printBrand;
}
public void setPrintBrand(String printBrand) {
this.printBrand = printBrand;
}
public void setPrintSize(Integer printSize) {
this.printSize = printSize;
}
public SalePrintNum getPrintNum() {
return printNum;
}
public void setPrintNum(SalePrintNum printNum) {
this.printNum = printNum;
}
public boolean isPrintLogo() {
return isPrintLogo;
}
public void setPrintLogo(boolean printLogo) {
isPrintLogo = printLogo;
}
public boolean isPrintCode() {
return isPrintCode;
}
public void setPrintCode(boolean printCode) {
isPrintCode = printCode;
}
public boolean isPrintOutFood() {
return isPrintOutFood;
}
public void setPrintOutFood(boolean printOutFood) {
isPrintOutFood = printOutFood;
}
public boolean isPrintRefund() {
return isPrintRefund;
}
public void setPrintRefund(boolean printRefund) {
isPrintRefund = printRefund;
}
public boolean isPrintRecharge() {
return isPrintRecharge;
}
public void setPrintRecharge(boolean printRecharge) {
isPrintRecharge = printRecharge;
}
public boolean isPrintPurchase() {
return isPrintPurchase;
}
public void setPrintPurchase(boolean printPurchase) {
isPrintPurchase = printPurchase;
}
private void initPrintString(List<PrintBean> list) {
printItems.clear();
getPrintItem(printItems, list);
}
private void getPrintItem(List<PrintItem> items, List<PrintBean> list) {
for (PrintBean printBean : list) {
if (printBean.getQrcode() != null && !printBean.getQrcode().isEmpty()) {
setQRcode(printBean.getQrcode());
items.add(new PrintItem(printBean.getStr()
, printBean.getSize(), 0, 2, ""));
} else {
items.add(new PrintItem(printBean.getStr()
, printBean.getSize(), 0, 0, ""));
}
}
}
public synchronized void startPrinr(String json) {
if (ZX_Printer.initState == ZX_Printer.INIT_END) {
initPrintString(JSON.parseArray(json, PrintBean.class));
try {
switch (printBrand) {
case DeviceEntity.BRAND_LANDI:
PrinterLandiService.print(printItems, getQRcode());
break;
case DeviceEntity.BRAND_SUNMI:
SunmiPrinter.print(printItems, getQRcode());
break;
case DeviceEntity.BRAND_PAX:
PrinterPax.print(printItems, getQRcode());
break;
}
} catch (Exception e) {
ToastUtils.showLong(e.toString());
}
} else {
ToastUtils.showShort("打印未初始化或正在初始化中");
}
}
}
package com.xingdata.cmbc.resturant.print;
import android.content.Context;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.ToastUtils;
public class PrinterUtil {
private static long mExitTime = 0;
private static final int time = 1500;
private static PrinterUtil printerUtil;
public static PrinterUtil getInstance() {
if (printerUtil == null) {
printerUtil = new PrinterUtil();
}
return printerUtil;
}
private static class PrinterUtilHolder {
private static ZX_Printer zx_printer = new ZX_Printer();
}
private static ZX_Printer getPrinterInstance() {
return PrinterUtilHolder.zx_printer;
}
public void printInit(Context context) {
printerUtil = new PrinterUtil();
try {
PrinterUtil.getPrinterInstance().init(context, DeviceUtils.getManufacturer());
} catch (Exception e) {
ToastUtils.showShort(e.getLocalizedMessage());
PrinterUtil.getPrinterInstance().init(context, DeviceUtils.getManufacturer());
}
}
public void printSale(String json) {
if ((System.currentTimeMillis() - mExitTime) > time) {
mExitTime = System.currentTimeMillis();
}
PrinterUtil.getPrinterInstance().toPrint(json);
}
public static void detory() {
if (PrinterUtil.getPrinterInstance() != null) {
PrinterUtil.getPrinterInstance().destroy();
}
}
}
package com.xingdata.cmbc.resturant.print;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.IntDef;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.cmbc.resturant.bean.DeviceEntity;
import com.xingdata.cmbc.resturant.print.bean.PrintCallback;
import com.xingdata.cmbc.resturant.print.landi.PrinterLandiService;
import com.xingdata.cmbc.resturant.print.pax.PrinterPax;
import com.xingdata.cmbc.resturant.print.sunmi.SunmiPrinter;
import com.xingdata.cmbc.resturant.print.ui.RePrintDialog;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
/**
* @author ZhangZhen
* @version V1.0
* @title: ZX_Print_POS.java
* @package com.xingdata.api.printConsumption;
* @description: POS机打印的主体类
* @date 2017年3月9日15:42:45
* @update 2017年3月13日 修改了打印的业务流程 @
* @update 2018年5月16日 修改了打印的业务流程 @
*/
public class ZX_Printer {
private static ZX_Printer printer;
//当前的设备型号
private String nowBrand;
private Context mContext;
private PrintSetting mSetting = new PrintSetting();
private CompositeDisposable mCompositeDisposable = new CompositeDisposable();
public static final int INIT_SATER = 1001;
public static final int INITING = 2002;
public static final int INIT_END = 3003;
public static @InitState
int initState;
private String printDetail;
private PrintCallback mPrintCallback = new PrintCallback() {
@Override
public void onPrintSuccess() {
}
@Override
public void onPrintFail(String s) {
Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
emitter.onComplete();
}
}).subscribeOn(AndroidSchedulers.mainThread()).observeOn(AndroidSchedulers.mainThread()).doOnComplete(new Action() {
@Override
public void run() throws Exception {
if (!s.isEmpty()) {
Intent intent = new Intent(mContext, RePrintDialog.class);
intent.putExtra(C.KEY_STRING, s);
mContext.startActivity(intent);
}
}
}).subscribe();
}
@Override
public void onPrintException(String s) {
if (s == null) {
ToastUtils.showShort("打印发生了异常情况");
} else {
ToastUtils.showShort(s);
}
}
};
@IntDef({INIT_SATER, INITING, INIT_END})
@Retention(RetentionPolicy.SOURCE)
public @interface InitState {
}
/**
* 获取实例
**/
public static ZX_Printer getDangerInstance() {
return printer;
}
/**
* POS级打印前的组件初始化准备
*
* @return
*/
public void init(Context context, String brand) {
nowBrand = brand;
mContext = context;
printer = this;
initState = ZX_Printer.INITING;
mSetting.setPrintBrand(nowBrand);
switch (nowBrand) {
case DeviceEntity.BRAND_LANDI: {
PrinterLandiService.getInstance(mContext.getApplicationContext(), mPrintCallback);
initState = ZX_Printer.INIT_END;
}
break;
case DeviceEntity.BRAND_SUNMI:
SunmiPrinter.getInstance(mContext.getApplicationContext(), mPrintCallback);
initState = ZX_Printer.INIT_END;
break;
case DeviceEntity.BRAND_PAX: {
PrinterPax.getInstance(mPrintCallback);
initState = ZX_Printer.INIT_END;
}
break;
}
}
public void destroy() {
switch (nowBrand) {
case DeviceEntity.BRAND_LANDI:
PrinterLandiService.destory();
break;
case DeviceEntity.BRAND_SUNMI:
SunmiPrinter.destory();
break;
case DeviceEntity.BRAND_PAX:
break;
}
}
/**
* 打印入口
*
* @param entity 打印对象(根据不同的打印类型传入不同的打印对象)
*/
public void toPrint(String entity) {
printDetail = entity;
mCompositeDisposable.add(
Observable.just("").
subscribeOn(Schedulers.computation())
.subscribe(
s -> {
mSetting.startPrinr(entity);
}, throwable -> {
ToastUtils.showShort(throwable.getLocalizedMessage());
}
)
);
}
public void rePrint() {
if (printDetail!=null&&!printDetail.isEmpty()){
mSetting.startPrinr(printDetail);
}else {
ToastUtils.showShort("检查打印机");
}
}
public void setQRcode(String QRcode) {
this.mSetting.setQRcode(QRcode);
}
}
\ No newline at end of file
package com.xingdata.cmbc.resturant.print.bean;
public class PrintBean {
private String str;
private int size;
private String qrcode;
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public String getQrcode() {
return qrcode;
}
public void setQrcode(String qrcode) {
this.qrcode = qrcode;
}
}
package com.xingdata.cmbc.resturant.print.bean;
/**
*
* @Title: PrintCallback.java
* @Package com.xingdata.tangku7.zxprint
* @Description: TODO(打印成功回调)
* @author Chen Qian
* @date 2018-8-28
* @version V1.0
*/
public interface PrintCallback {
void onPrintSuccess();
void onPrintFail(String s);
void onPrintException(String s);
}
package com.xingdata.cmbc.resturant.print.bean;
public class PrintItem {
public static final int FONTSIZE_SMALL = 0;
public static final int FONTSIZE_MEDIUM = 1;
public static final int FONTSIZE_BIG = 2;
public static final int LEFT = 0;
public static final int CENTER = 1;
public static final int RIGHT = 2;
/**
* 需要打印的字符串类型
*/
private String content;
/**
* 字体大小。0:小,1:中,2:大
*/
private int fontSize;
/**
* 0:左,1:中,2:右
*/
private int gravity;
private String QRCodeInfo;
private int isPrintBarCode;
public PrintItem(String content, int fontSize, int gravity, int isPrintBarCode, String QRCodeInfo) {
this.content = content;
this.fontSize = fontSize;
this.gravity = gravity;
this.isPrintBarCode = isPrintBarCode;
this.QRCodeInfo = QRCodeInfo;
}
/**
* PrintItem 对象
*
* @param content 打印内容
* @param fontSize 字体大小
* @param gravity 居中情况
* @return
*/
public PrintItem(String content, int fontSize, int gravity) {
this.content = content;
this.fontSize = fontSize;
this.gravity = gravity;
}
public PrintItem(String QRCodeInfo, int gravity) {
this.QRCodeInfo = QRCodeInfo;
this.gravity = gravity;
}
public String getQRCodeInfo() {
return QRCodeInfo;
}
public void setQRCodeInfo(String QRCodeInfo) {
this.QRCodeInfo = QRCodeInfo;
}
public int getIsPrintBarCode() {
return isPrintBarCode;
}
public void setIsPrintBarCode(int isPrintBarCode) {
this.isPrintBarCode = isPrintBarCode;
}
public int getGravity() {
return gravity;
}
public void setGravity(int gravity) {
this.gravity = gravity;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getFontSize() {
return fontSize;
}
public void setFontSize(int fontSize) {
this.fontSize = fontSize;
}
}
package com.xingdata.cmbc.resturant.print.landi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.landi.print.service.ICallback;
import com.landi.print.service.IPrintService;
import com.landi.print.service.PrintBinder;
import com.xingdata.cmbc.resturant.print.bean.PrintCallback;
import com.xingdata.cmbc.resturant.print.bean.PrintItem;
import java.util.List;
public class PrinterLandiService {
private static PrinterLandiService mPrinterLandiService;
private com.landi.print.service.IPrintService printService;
private Context mContext;
private PrintCallback mPrintCallback;
private String stateInfo;
private ICallback iCallback = new ICallback.Stub() {
@Override
public void onPrintResult(boolean isSuccess, int code, final String msg) throws RemoteException {
if (!isSuccess || code != 0) {
mPrintCallback.onPrintFail(msg);
}
}
};
private ServiceConnection connService = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
printService = null;
mPrintCallback.onPrintException("打印机服务连接失败");
ToastUtils.showLong("打印机服务连接失败");
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
printService = IPrintService.Stub.asInterface(service);
try {
printService.lineWrap(1, null);
} catch (RemoteException e) {
e.printStackTrace();
}
}
};
PrinterLandiService(Context context, PrintCallback printCallback) {
this.mPrintCallback = printCallback;
bind(context);
}
public static PrinterLandiService getInstance(Context mContext, PrintCallback printCallback) {
if (mPrinterLandiService == null) {
mPrinterLandiService = new PrinterLandiService(mContext, printCallback);
}
return mPrinterLandiService;
}
public static void destory() {
if (mPrinterLandiService != null) {
mPrinterLandiService.unbind();
}
}
public void bind(Context context) {
mContext = context;
Intent intent = new Intent();
PrintBinder.bindPrintService(context.getApplicationContext(), intent, connService, Context.BIND_AUTO_CREATE);
// Intent intent = new Intent();
// intent.setPackage("com.landi.print.service");
// intent.setAction("com.landi.print.service.Printer");
// mContext.startService(intent);
// mContext.bindService(intent, connService, Context.BIND_AUTO_CREATE);
}
public static void print(List<PrintItem> printItemsA, String QRcode) throws RemoteException {
if (mPrinterLandiService != null) {
mPrinterLandiService.printItemAndQRcode(printItemsA, QRcode);
}
}
private void printerBuffering(List<PrintItem> printItems, String QRcode) throws RemoteException {
try {
for (PrintItem printItem : printItems) {
switch (printItem.getIsPrintBarCode()) {
case 0:
switch (printItem.getFontSize()) {
case PrintItem.FONTSIZE_SMALL:
printService.setFontSize(24, null);
break;
case PrintItem.FONTSIZE_MEDIUM:
printService.setFontSize(32, null);
break;
case PrintItem.FONTSIZE_BIG:
printService.setFontSize(40, null);
break;
}
switch (printItem.getGravity()) {
case PrintItem.LEFT:
printService.setAlignment(0, null);
break;
case PrintItem.CENTER:
printService.setAlignment(1, null);
break;
case PrintItem.RIGHT:
printService.setAlignment(2, null);
break;
}
printService.printText(printItem.getContent() + "\n", null);
break;
case 1:
printService.setAlignment(0, null);
printService.printBarCode(printItem.getContent(), 8, 80, 2, 0, null);
break;
case 2:
if (QRcode != null) {
printService.setAlignment(1, null);
printService.printQRCode(QRcode, 6, 3,
null);
if (printItem.getQRCodeInfo() != null) {
printService.setFontSize(24, null);
printService.setAlignment(printItem.getGravity(), null);
printService.printText(printItem.getQRCodeInfo() + "\n", null);
}
}
break;
}
}
} catch (Exception e) {
LogUtils.e(e);
}
}
public void printItemAndQRcode(List<PrintItem> printItemsA, String QRcode) throws RemoteException {
printService.printerInit();
printService.enterPrinterBuffer(true);
printerBuffering(printItemsA, QRcode);
printService.lineWrap(4, null);
printService.cutPaper(null);
printService.exitPrinterBufferWithCallback(true, iCallback);
}
public void unbind() {
try {
mContext.unbindService(connService);
} catch (Exception e) {
e.printStackTrace();
}
}
private String getStatus(int printStatus) {
switch (printStatus) {
case 1:
stateInfo = "打印机正常";
break;
case 2:
stateInfo = "打印机更新状态中";
break;
case 3:
stateInfo = "打印机异常";
break;
case 4:
stateInfo = "打印机缺纸";
break;
case 5:
stateInfo = "打印机过热";
break;
case 6:
stateInfo = "打印机开盖";
break;
case 7:
stateInfo = "切刀异常";
break;
case 8:
stateInfo = "切刀恢复";
break;
case 9:
stateInfo = "未检测到黑标";
break;
default:
stateInfo = "未知错误";
break;
}
return stateInfo;
}
}
package com.xingdata.cmbc.resturant.print.pax;
import android.graphics.Bitmap;
import android.os.SystemClock;
import android.util.Log;
import com.pax.api.PrintException;
import com.pax.api.PrintManager;
import com.xingdata.cmbc.resturant.print.bean.PrintCallback;
import com.xingdata.cmbc.resturant.print.bean.PrintItem;
import com.xingdata.cmbc.resturant.print.util.PrintBitmapCode;
import java.util.List;
public class PrinterPax {
private static PrinterPax printerPax;
private PrintManager printManager;
private List<String> stringList;
private static final int SUCCESS = 0;
private static final int FAIL = 1;
private String state;
private PrintCallback mPrintCallback;
public PrinterPax(PrintCallback printCallback) {
this.mPrintCallback = printCallback;
}
/**
* 获取实例
**/
public synchronized static PrinterPax getInstance(PrintCallback printCallback) {
if (printerPax == null) {
printerPax = new PrinterPax(printCallback);// 单例模式
}
return printerPax;
}
public static void print(List<PrintItem> printItemsA, String QRcode) {
if (printerPax != null) {
printerPax.printItemAndQRcode(printItemsA, QRcode);
}
}
private void printerBuffering(com.pax.api.PrintManager pm, List<PrintItem> printItems, String QRcode) throws PrintException {
for (PrintItem printItem : printItems) {
switch (printItem.getIsPrintBarCode()) {
case 0:
int l = 0;
switch (printItem.getFontSize()) {
case PrintItem.FONTSIZE_SMALL:
pm.prnFontSet((byte) 1, (byte) 1);
pm.prnSpaceSet((byte) 0, (byte) 8);
l = 36;
break;
case PrintItem.FONTSIZE_MEDIUM:
pm.prnFontSet((byte) 6, (byte) 6);
pm.prnSpaceSet((byte) 0, (byte) 8);
l = 30;
break;
case PrintItem.FONTSIZE_BIG:
pm.prnFontSet((byte) 7, (byte) 7);
pm.prnSpaceSet((byte) 0, (byte) 8);
l = 18;
break;
}
switch (printItem.getGravity()) {
case PrintItem.LEFT:
pm.prnStr(printItem.getContent() + "\n", "GBK");
break;
}
break;
case 1:
pm.prnLeftIndent(new Short("0"));
Bitmap bitmap = PrintBitmapCode.getBarCode(printItem.getContent());
pm.prnBitmap(bitmap);
break;
case 2:
if (QRcode != null) {
pm.prnLeftIndent(new Short("130"));
pm.prnBitmap(PrintBitmapCode.getQRcode(QRcode));
pm.prnLeftIndent(new Short("0"));
if (printItem.getQRCodeInfo() != null) {
pm.prnFontSet((byte) 1, (byte) 1);
pm.prnSpaceSet((byte) 0, (byte) 8);
l = 36;
switch (printItem.getGravity()) {
case PrintItem.LEFT:
pm.prnStr(printItem.getQRCodeInfo() + "\n", "GBK");
break;
}
}
}
break;
}
}
}
public void printItemAndQRcode(List<PrintItem> printItemsA, String QRcode) {
try {
PrintManager pm = PrintManager.getInstance();
byte status = pm.prnStatus();
if (status != 0) {
mPrintCallback.onPrintFail(getStatus(status));
return;
}
pm.prnInit();
printerBuffering(pm, printItemsA, QRcode);
pm.prnStart();
while (true)
{
byte ret = PrintManager.getInstance().prnStatus();
Log.i("TAG", "PRINT START:" + ret);
if (ret == 0x01) {
SystemClock.sleep(10);
continue;
}
if (ret != 0) {
mPrintCallback.onPrintFail(getStatus(ret));
} else {
pm.prnCutPaper(0);
mPrintCallback.onPrintSuccess();
}
return;
}
} catch (PrintException e) {
// TODO: handle exception
mPrintCallback.onPrintException(null);
}
}
private PrintManager getPrintManager() throws PrintException {
if (printManager == null) {
printManager = PrintManager.getInstance();
}
return printManager;
}
/**
* 释放打印机
**/
public void printerPaxRelease() {
try {
printManager.finalize();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private String getStatus(byte printStatus) throws PrintException {
switch (printStatus) {
case 0x01:
state = "打印机忙碌";
break;
case 0x02:
state = "打印机缺纸";
break;
case 0x03:
state = "打印机包不对";
break;
case 0x04:
state = "打印机故障";
break;
case 0x08:
state = "打印机过热";
break;
case (byte) 0x09:
state = "打印机低电压";
break;
case (byte) 0xfe:
state = "内存不足";
break;
default:
state = "未知错误";
break;
}
return state;
}
}
package com.xingdata.cmbc.resturant.print.sunmi;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
import com.blankj.utilcode.util.LogUtils;
import com.sunmi.peripheral.printer.ICallback;
import com.sunmi.peripheral.printer.InnerPrinterCallback;
import com.sunmi.peripheral.printer.InnerPrinterException;
import com.sunmi.peripheral.printer.InnerPrinterManager;
import com.sunmi.peripheral.printer.SunmiPrinterService;
import com.xingdata.cmbc.resturant.print.bean.PrintCallback;
import com.xingdata.cmbc.resturant.print.bean.PrintItem;
import java.util.List;
public class SunmiPrinter {
private static SunmiPrinter printerSunmi;
private SunmiPrinterService printer;
private Context mContext;
private PrintCallback mPrintCallback;
private String stateInfo;
private ICallback.Stub iCallback = new ICallback.Stub() {
@Override
public void onRunResult(boolean isSuccess) throws RemoteException {
}
@Override
public void onReturnString(String result) throws RemoteException {
Log.d("onPrintString", result);
}
@Override
public void onRaiseException(int code, String msg) throws RemoteException {
mPrintCallback.onPrintException(null);
}
@Override
public void onPrintResult(int code, String msg) throws RemoteException {
if (code != 0) {
mPrintCallback.onPrintFail(getStatus(printer.updatePrinterState()));
}
}
};
private InnerPrinterCallback innerPrinterCallback = new InnerPrinterCallback() {
@Override
protected void onConnected(SunmiPrinterService service) {
printer = service;
}
@Override
protected void onDisconnected() {
printer = null;
mPrintCallback.onPrintException("打印机服务连接失败");
}
};
public SunmiPrinter(Context context, PrintCallback printCallback) {
this.mPrintCallback = printCallback;
bind(context);
}
/**
* 获取实例
**/
public synchronized static SunmiPrinter getInstance(Context context, PrintCallback printCallback) {
if (printerSunmi == null) {
printerSunmi = new SunmiPrinter(context, printCallback);// 单例模式
}
return printerSunmi;
}
public static void destory() {
if (printerSunmi != null) {
printerSunmi.unbind();
}
}
public static void print(List<PrintItem> printItemsA, String QRcode) throws RemoteException {
if (printerSunmi != null) {
printerSunmi.printItemAndQRcode(printItemsA, QRcode);
}
}
private void printerBuffering(List<PrintItem> printItems, String QRcode) throws RemoteException {
try {
for (PrintItem printItem : printItems) {
switch (printItem.getIsPrintBarCode()) {
case 0:
switch (printItem.getFontSize()) {
case PrintItem.FONTSIZE_SMALL:
printer.setFontSize(24, null);
break;
case PrintItem.FONTSIZE_MEDIUM:
printer.setFontSize(32, null);
break;
case PrintItem.FONTSIZE_BIG:
printer.setFontSize(40, null);
break;
}
switch (printItem.getGravity()) {
case PrintItem.LEFT:
printer.setAlignment(0, null);
break;
case PrintItem.CENTER:
printer.setAlignment(1, null);
break;
case PrintItem.RIGHT:
printer.setAlignment(2, null);
break;
}
printer.printText(printItem.getContent() + "\n", null);
break;
case 1:
printer.setAlignment(0, null);
printer.printBarCode(printItem.getContent(), 8, 90, 2, 0, null);
printer.printText("\n", null);
break;
case 2:
if (QRcode != null) {
printer.setAlignment(1, null);
printer.printQRCode(QRcode, 8, 3,
null);
if (printItem.getQRCodeInfo() != null) {
printer.setFontSize(24, null);
printer.setAlignment(printItem.getGravity(), null);
printer.printText(printItem.getQRCodeInfo() + "\n", null);
}
}
break;
}
}
} catch (Exception e) {
LogUtils.e(e);
}
}
public void printItemAndQRcode(List<PrintItem> printItemsA, String QRcode) throws RemoteException {
printer.printerInit(iCallback);
printer.enterPrinterBuffer(true);
printerBuffering(printItemsA, QRcode);
printer.cutPaper(null);
printer.exitPrinterBufferWithCallback(true, iCallback);
}
private void bind(Context context) {
try {
mContext = context;
InnerPrinterManager.getInstance().bindService(context,
innerPrinterCallback);
} catch (InnerPrinterException e) {
e.printStackTrace();
}
}
public void unbind() {
try {
if (mContext != null) {
InnerPrinterManager.getInstance().unBindService(mContext, innerPrinterCallback);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void openCashBox() {
try {
printer.openDrawer(null);
} catch (RemoteException e) {
e.printStackTrace();
}
}
private String getStatus(int printStatus) {
switch (printStatus) {
case 1:
stateInfo = "打印机正常";
break;
case 2:
stateInfo = "打印机更新状态中";
break;
case 3:
stateInfo = "打印机异常";
break;
case 4:
stateInfo = "打印机缺纸";
break;
case 5:
stateInfo = "打印机过热";
break;
case 6:
stateInfo = "打印机开盖";
break;
case 7:
stateInfo = "切刀异常";
break;
case 8:
stateInfo = "切刀恢复";
break;
case 9:
stateInfo = "未检测到黑标";
break;
default:
stateInfo = "未知错误";
break;
}
return stateInfo;
}
}
package com.xingdata.cmbc.resturant.print.ui;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;
import com.xingdata.cmbc.resturant.R;
import com.xingdata.cmbc.resturant.print.C;
import com.xingdata.cmbc.resturant.print.ZX_Printer;
public class RePrintDialog extends Activity {
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
textView = findViewById(R.id.tv_context);
String s = getIntent().getStringExtra(C.KEY_STRING);
new Handler(getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (s != null) {
textView.setText(s + " 请重新打印?");
}
}
});
}
public void onClick(View v) {
if (v.getId() == R.id.btn_ok) {
if (null != ZX_Printer.getDangerInstance()) {
ZX_Printer.getDangerInstance().rePrint();
}
finish();
}
}
}
package com.xingdata.cmbc.resturant.print.util;
import android.graphics.Bitmap;
import com.blankj.utilcode.util.ActivityUtils;
public class PrintBitmapCode {
public static Bitmap getQRcode(String string) {
return ZXingUtils.createQRImage(string, 300, 300);
}
public static Bitmap getBarCode(String string) {
return ZXingUtils.creatBarcode(ActivityUtils.getTopActivity(), string, 800, 80, false);
}
}
package com.xingdata.cmbc.resturant.print.util;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PointF;
import android.view.Gravity;
import android.view.View.MeasureSpec;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.util.Hashtable;
public class ZXingUtils {
/**
* 生成二维码 要转换的地址或字符串,可以是中文
*
* @param url
* @param width
* @param height
* @return
*/
public static Bitmap createQRImage(String url, final int width, final int height) {
try {
// 判断URL合法性
if (url == null || "".equals(url) || url.length() < 1) {
return null;
}
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
// 图像数据转换,使用了矩阵转换
BitMatrix bitMatrix = new QRCodeWriter().encode(url,
BarcodeFormat.QR_CODE, width, height, hints);
int[] pixels = new int[width * height];
// 下面这里按照二维码的算法,逐个生成二维码的图片,
// 两个for循环是图片横列扫描的结果
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (bitMatrix.get(x, y)) {
pixels[y * width + x] = 0xff000000;
} else {
pixels[y * width + x] = 0xffffffff;
}
}
}
// 生成二维码图片的格式,使用ARGB_8888
Bitmap bitmap = Bitmap.createBitmap(width, height,
Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
} catch (WriterException e) {
e.printStackTrace();
}
return null;
}
/**
* 生成条形码
*
* @param context
* @param contents 需要生成的内容
* @param desiredWidth 生成条形码的宽带
* @param desiredHeight 生成条形码的高度
* @param displayCode 是否在条形码下方显示内容
* @return
*/
public static Bitmap creatBarcode(Context context, String contents,
int desiredWidth, int desiredHeight, boolean displayCode) {
Bitmap ruseltBitmap = null;
/**
* 图片两端所保留的空白的宽度
*/
int marginW = 20;
/**
* 条形码的编码类型
*/
BarcodeFormat barcodeFormat = BarcodeFormat.CODE_128;
if (displayCode) {
Bitmap barcodeBitmap = encodeAsBitmap(contents, barcodeFormat,
desiredWidth, desiredHeight);
Bitmap codeBitmap = creatCodeBitmap(contents, desiredWidth + 2
* marginW, desiredHeight, context);
ruseltBitmap = mixtureBitmap(barcodeBitmap, codeBitmap, new PointF(
0, desiredHeight));
} else {
ruseltBitmap = encodeAsBitmap(contents, barcodeFormat,
desiredWidth, desiredHeight);
}
return ruseltBitmap;
}
/**
* 生成条形码的Bitmap
*
* @param contents 需要生成的内容
* @param format 编码格式
* @param desiredWidth
* @param desiredHeight
* @return
* @throws WriterException
*/
protected static Bitmap encodeAsBitmap(String contents,
BarcodeFormat format, int desiredWidth, int desiredHeight) {
final int WHITE = 0xFFFFFFFF;
final int BLACK = 0xFF000000;
MultiFormatWriter writer = new MultiFormatWriter();
BitMatrix result = null;
try {
result = writer.encode(contents, format, desiredWidth,
desiredHeight, null);
} catch (WriterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int width = result.getWidth();
int height = result.getHeight();
int[] pixels = new int[width * height];
// All are 0, or black, by default
for (int y = 0; y < height; y++) {
int offset = y * width;
for (int x = 0; x < width; x++) {
pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height,
Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
/**
* 生成显示编码的Bitmap
*
* @param contents
* @param width
* @param height
* @param context
* @return
*/
protected static Bitmap creatCodeBitmap(String contents, int width,
int height, Context context) {
TextView tv = new TextView(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(layoutParams);
tv.setText(contents);
tv.setHeight(height);
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setWidth(width);
tv.setDrawingCacheEnabled(true);
tv.setTextColor(Color.BLACK);
tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());
tv.buildDrawingCache();
Bitmap bitmapCode = tv.getDrawingCache();
return bitmapCode;
}
/**
* 将两个Bitmap合并成一个
*
* @param first
* @param second
* @param fromPoint 第二个Bitmap开始绘制的起始位置(相对于第一个Bitmap)
* @return
*/
protected static Bitmap mixtureBitmap(Bitmap first, Bitmap second,
PointF fromPoint) {
if (first == null || second == null || fromPoint == null) {
return null;
}
int marginW = 20;
Bitmap newBitmap = Bitmap.createBitmap(
first.getWidth() + second.getWidth() + marginW,
first.getHeight() + second.getHeight(), Config.ARGB_4444);
Canvas cv = new Canvas(newBitmap);
cv.drawBitmap(first, marginW, 0, null);
cv.drawBitmap(second, fromPoint.x, fromPoint.y, null);
cv.save(Canvas.ALL_SAVE_FLAG);
cv.restore();
return newBitmap;
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/view_web"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
<LinearLayout
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/btn_A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="洗衣房" />
<Button
android:id="@+id/btn_B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="餐厅" />
<Button
android:id="@+id/btn_C"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图书馆" />
<Button
android:id="@+id/btn_reload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="刷新" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center">
<RelativeLayout
android:layout_width="400dp"
android:layout_height="250dp"
android:background="@android:color/white"
android:gravity="center">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:text="系统提示"
android:textColor="#000000"
android:textSize="18sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/tv_title"
android:background="#000000" />
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:gravity="center"
android:onClick="onClick"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
<Button
android:id="@+id/btn_ok"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:onClick="onClick"
android:text="确定" />
</LinearLayout>
<TextView
android:id="@+id/tv_context"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ll_bottom"
android:layout_below="@+id/tv_title"
android:gravity="center"
android:text="请重新打印"
android:textColor="#000000"
android:textSize="17sp" />
</RelativeLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
<resources>
<string name="app_name">民生银行自助收银机</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
package com.xingdata.cmbc.resturant;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "http://maven.landicorp.com/repository/releases/" }
maven { url "http://maven.landicorp.com/repository/ept-and-sdk/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Mar 25 09:20:04 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
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