Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CMBC
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈前
CMBC
Commits
12a9706b
Commit
12a9706b
authored
Jun 21, 2019
by
陈前
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
民生
parent
b2c46c0c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
130 additions
and
46 deletions
+130
-46
app/build.gradle
app/build.gradle
+22
-7
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+10
-4
app/src/main/java/com/xingdata/cmbc/resturant/MainActivity.java
...c/main/java/com/xingdata/cmbc/resturant/MainActivity.java
+69
-13
app/src/main/java/com/xingdata/cmbc/resturant/print/PrintSetting.java
.../java/com/xingdata/cmbc/resturant/print/PrintSetting.java
+4
-9
app/src/main/java/com/xingdata/cmbc/resturant/print/ZX_Printer.java
...in/java/com/xingdata/cmbc/resturant/print/ZX_Printer.java
+3
-7
app/src/main/java/com/xingdata/cmbc/resturant/print/util/ZXingUtils.java
...va/com/xingdata/cmbc/resturant/print/util/ZXingUtils.java
+1
-1
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+18
-4
app/src/main/res/mipmap-hdpi/tushu.png
app/src/main/res/mipmap-hdpi/tushu.png
+0
-0
app/src/main/res/mipmap-hdpi/xiyifang.png
app/src/main/res/mipmap-hdpi/xiyifang.png
+0
-0
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+2
-0
build.gradle
build.gradle
+1
-1
No files found.
app/build.gradle
View file @
12a9706b
apply
plugin:
'com.android.application'
android
{
compileSdkVersion
27
productFlavors
{
xiyifang
{
manifestPlaceholders
=
[
APP_CHANNEL_VALUE:
"xiyifang"
,
app_name:
"@string/app_name_c"
,
app_icons:
"@mipmap/xiyifang"
]
}
tushuguan
{
manifestPlaceholders
=
[
APP_CHANNEL_VALUE:
"tushuguan"
,
app_name:
"@string/app_name_b"
,
app_icons:
"@mipmap/tushu"
]
}
}
compileSdkVersion
28
defaultConfig
{
applicationId
"com.xingdata.cmbc.resturant"
minSdkVersion
23
targetSdkVersion
2
7
targetSdkVersion
2
8
multiDexEnabled
false
versionCode
17
versionName
"
1.2.2
"
versionCode
20
versionName
"
2.0.0
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
flavorDimensions
"20"
//一般与versionCode相同
}
buildTypes
{
release
{
minifyEnabled
false
...
...
@@ -27,7 +43,7 @@ android {
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
}
buildToolsVersion
'2
7
.0.3'
buildToolsVersion
'2
8
.0.3'
}
dependencies
{
...
...
@@ -42,10 +58,9 @@ dependencies {
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
'com.github.ybq:Android-SpinKit:1.1.0'
implementation
files
(
'libs/PosApi_V1.09_20180129.jar'
)
implementation
files
(
'libs/RF610_Dll.jar'
)
}
app/src/main/AndroidManifest.xml
View file @
12a9706b
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.xingdata.cmbc.resturant"
>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
...
...
@@ -7,11 +8,16 @@
<application
android:allowBackup=
"true"
android:icon=
"
@mipmap/qd_logo
"
android:label=
"
@string/app_name
"
android:roundIcon=
"
@mipmap/qd_logo
"
android:icon=
"
${app_icons}
"
android:label=
"
${app_name}
"
android:roundIcon=
"
${app_icons}
"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
tools:ignore=
"GoogleAppIndexingWarning"
tools:replace=
"label,roundIcon,icon"
>
<meta-data
android:name=
"APP_CHANNEL"
android:value=
"${APP_CHANNEL_VALUE}"
/>
<activity
android:name=
".MainActivity"
android:configChanges=
"locale|mcc|mnc|keyboardHidden|orientation|screenSize|keyboard|navigation|fontScale|screenLayout|uiMode|touchscreen"
>
...
...
app/src/main/java/com/xingdata/cmbc/resturant/MainActivity.java
View file @
12a9706b
...
...
@@ -4,14 +4,19 @@ import RF610_Package.RF610_Serial;
import
android.annotation.TargetApi
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.media.AudioManager
;
import
android.media.SoundPool
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.KeyEvent
;
...
...
@@ -39,6 +44,7 @@ import com.blankj.utilcode.util.DeviceUtils;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.ToastUtils
;
import
com.github.ybq.android.spinkit.SpinKitView
;
import
com.xingdata.cmbc.resturant.print.PrinterUtil
;
import
java.io.File
;
...
...
@@ -48,7 +54,7 @@ import java.io.InputStream;
import
android_serialport_api.SerialPort
;
public
class
MainActivity
extends
A
ppCompatA
ctivity
{
public
class
MainActivity
extends
Activity
{
private
final
int
CARD
=
0
;
private
final
int
CODE
=
1
;
...
...
@@ -57,6 +63,7 @@ public class MainActivity extends AppCompatActivity {
private
Button
buttonA
;
private
Button
buttonB
;
private
Button
buttonC
;
private
SpinKitView
spinKitView
;
/**
* 当前的条码扫描器
*/
...
...
@@ -64,11 +71,11 @@ public class MainActivity extends AppCompatActivity {
private
MyHandler
mainHandler
=
new
MyHandler
();
private
InputStream
inputStream
;
private
final
String
urlA
=
"http://19
7.0.32.146
:8080/cashier/index"
;
private
final
String
urlA
=
"http://19
2.168.254.153
:8080/cashier/index"
;
private
final
String
urlB
=
"http://197.0.32.146:8080/canteen/index"
;
private
final
String
urlC
=
"http://19
7.0.32.146
:8080/book/home"
;
private
final
String
urlC
=
"http://19
2.168.254.153
:8080/book/home"
;
private
String
URL
=
urlB
;
private
String
URL
;
private
Long
time
=
0L
;
...
...
@@ -143,6 +150,23 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
try
{
switch
(
getChannel
(
MainActivity
.
this
))
{
case
"tushuguan"
:
URL
=
urlC
;
break
;
case
"xiyifang"
:
URL
=
urlA
;
break
;
default
:
URL
=
urlA
;
}
}
catch
(
Exception
e
){
URL
=
urlA
;
}
rThread
=
new
ReceiveThread
();
mSoundPool
=
new
SoundPool
(
1
,
AudioManager
.
STREAM_ALARM
,
0
);
mSoundPool
.
load
(
this
,
R
.
raw
.
bling
,
1
);
...
...
@@ -161,10 +185,14 @@ public class MainActivity extends AppCompatActivity {
return
false
;
}
});
webSettings
.
setBlockNetworkImage
(
true
);
button
=
findViewById
(
R
.
id
.
btn_reload
);
buttonA
=
findViewById
(
R
.
id
.
btn_A
);
buttonB
=
findViewById
(
R
.
id
.
btn_B
);
buttonC
=
findViewById
(
R
.
id
.
btn_C
);
spinKitView
=
findViewById
(
R
.
id
.
skView
);
button
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -205,26 +233,38 @@ public class MainActivity extends AppCompatActivity {
mWebView
.
addJavascriptInterface
(
new
JSInterface
(),
"Android"
);
buttonA
.
setOnClickListener
(
v
->
{
URL
=
urlA
;
URL
=
urlA
;
mWebView
.
loadUrl
(
URL
);
chuankouInit
();
});
buttonB
.
setOnClickListener
(
v
->
{
URL
=
urlB
;
URL
=
urlB
;
mWebView
.
loadUrl
(
URL
);
chuankouInit
();
});
buttonC
.
setOnClickListener
(
v
->
{
URL
=
urlC
;
URL
=
urlC
;
mWebView
.
loadUrl
(
URL
);
chuankouInit
();
});
mWebView
.
loadUrl
(
URL
);
chuankouInit
();
// mWebView.loadUrl("file:///android_asset/js.html");
mWebView
.
setWebChromeClient
(
new
WebChromeClient
()
{
@Override
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
if
(
newProgress
==
100
)
{
// 网页加载完成
spinKitView
.
setVisibility
(
View
.
GONE
);
webSettings
.
setBlockNetworkImage
(
false
);
}
else
{
// 网页加载中
spinKitView
.
setVisibility
(
View
.
VISIBLE
);
}
}
@Override
public
boolean
onJsAlert
(
WebView
view
,
String
url
,
String
message
,
final
JsResult
result
)
{
AlertDialog
.
Builder
b
=
new
AlertDialog
.
Builder
(
MainActivity
.
this
);
...
...
@@ -244,8 +284,6 @@ public class MainActivity extends AppCompatActivity {
});
PrinterUtil
.
getInstance
().
printInit
(
this
);
// btnUrl.setOnClickListener(new View.OnClickListener() {
...
...
@@ -268,7 +306,7 @@ public class MainActivity extends AppCompatActivity {
}
private
void
chuankouInit
(){
private
void
chuankouInit
()
{
switch
(
URL
)
{
case
urlA:
case
urlC:
...
...
@@ -309,6 +347,7 @@ public class MainActivity extends AppCompatActivity {
}
}
class
JSInterface
{
@JavascriptInterface
public
void
print
(
String
arg
)
{
...
...
@@ -514,4 +553,21 @@ public class MainActivity extends AppCompatActivity {
super
.
onDestroy
();
}
/**
* 获取项目的渠道号
*
* @return
*/
public
static
String
getChannel
(
Context
context
)
{
ApplicationInfo
ai
=
null
;
try
{
ai
=
context
.
getPackageManager
().
getApplicationInfo
(
context
.
getPackageName
(),
PackageManager
.
GET_META_DATA
);
Bundle
bundle
=
ai
.
metaData
;
return
bundle
.
getString
(
"APP_CHANNEL"
);
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
}
app/src/main/java/com/xingdata/cmbc/resturant/print/PrintSetting.java
View file @
12a9706b
package
com
.
xingdata
.
cmbc
.
resturant
.
print
;
import
android.support.annotation.IntDef
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -28,14 +28,9 @@ public class PrintSetting {
public
static
final
int
NONE
=
0
;
@IntDef
({
SINGLE
,
DUAL
,
NONE
})
@Retention
(
RetentionPolicy
.
SOURCE
)
public
@interface
SalePrintNum
{
}
private
String
QRcode
;
private
SalePrintNum
printNum
;
private
int
printNum
;
private
boolean
isPrintLogo
;
private
boolean
isPrintCode
;
private
boolean
isPrintOutFood
;
...
...
@@ -70,11 +65,11 @@ public class PrintSetting {
this
.
printSize
=
printSize
;
}
public
SalePrintNum
getPrintNum
()
{
public
int
getPrintNum
()
{
return
printNum
;
}
public
void
setPrintNum
(
SalePrintNum
printNum
)
{
public
void
setPrintNum
(
int
printNum
)
{
this
.
printNum
=
printNum
;
}
...
...
app/src/main/java/com/xingdata/cmbc/resturant/print/ZX_Printer.java
View file @
12a9706b
...
...
@@ -4,7 +4,7 @@ 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
;
...
...
@@ -55,8 +55,8 @@ public class ZX_Printer {
public
static
final
int
INITING
=
2002
;
public
static
final
int
INIT_END
=
3003
;
public
static
@InitState
int
initState
;
public
static
int
initState
;
private
String
printDetail
;
...
...
@@ -96,11 +96,7 @@ public class ZX_Printer {
}
};
@IntDef
({
INIT_SATER
,
INITING
,
INIT_END
})
@Retention
(
RetentionPolicy
.
SOURCE
)
public
@interface
InitState
{
}
/**
...
...
app/src/main/java/com/xingdata/cmbc/resturant/print/util/ZXingUtils.java
View file @
12a9706b
...
...
@@ -193,7 +193,7 @@ public class ZXingUtils {
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
.
save
();
cv
.
restore
();
return
newBitmap
;
...
...
app/src/main/res/layout/activity_main.xml
View file @
12a9706b
...
...
@@ -9,24 +9,38 @@
<WebView
android:id=
"@+id/view_web"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
></WebView>
android:layout_height=
"match_parent"
/>
<com.github.ybq.android.spinkit.SpinKitView
android:id=
"@+id/skView"
style=
"@style/SpinKitView.ChasingDots"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:padding=
"30dp"
android:visibility=
"gone"
app:SpinKit_Color=
"#14233142"
/>
<LinearLayout
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<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"
...
...
app/src/main/res/mipmap-hdpi/tushu.png
0 → 100644
View file @
12a9706b
16.8 KB
app/src/main/res/mipmap-hdpi/xiyifang.png
0 → 100644
View file @
12a9706b
16.8 KB
app/src/main/res/values/strings.xml
View file @
12a9706b
<resources>
<string
name=
"app_name"
>
民生银行自助收银机
</string>
<string
name=
"app_name_c"
>
民生洗衣
</string>
<string
name=
"app_name_b"
>
民生图书
</string>
</resources>
build.gradle
View file @
12a9706b
...
...
@@ -8,7 +8,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.
3.2
'
classpath
'com.android.tools.build:gradle:3.
4.1
'
// NOTE: Do not place your application dependencies here; they belong
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment