Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
miya-hardware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
miya-hardware
Commits
340eef2d
Commit
340eef2d
authored
Feb 25, 2019
by
pengguangpu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改英泰机器是否在线状态检测方法;
英泰机器添加beginPrint方法内触发式检测是否已连接
parent
71a7607d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
4 deletions
+61
-4
misc.xml
.idea/misc.xml
+36
-1
activity_print.xml
app/src/main/res/layout/activity_print.xml
+1
-1
AndroidManifest.xml
print/src/main/AndroidManifest.xml
+5
-1
YingtaiPrinter.java
print/src/main/java/com/miya/print/YingtaiPrinter.java
+19
-1
No files found.
.idea/misc.xml
View file @
340eef2d
...
...
@@ -5,7 +5,42 @@
<configuration
PROFILE_NAME=
"Debug"
CONFIG_NAME=
"Debug"
/>
</configurations>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<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=
"10"
>
<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"
/>
<item
index=
"7"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.qual.Nullable"
/>
<item
index=
"8"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.compatqual.NullableDecl"
/>
<item
index=
"9"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.compatqual.NullableType"
/>
</list>
</value>
</option>
<option
name=
"myNotNulls"
>
<value>
<list
size=
"9"
>
<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"
/>
<item
index=
"6"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.qual.NonNull"
/>
<item
index=
"7"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.compatqual.NonNullDecl"
/>
<item
index=
"8"
class=
"java.lang.String"
itemvalue=
"org.checkerframework.checker.nullness.compatqual.NonNullType"
/>
</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"
>
...
...
app/src/main/res/layout/activity_print.xml
View file @
340eef2d
...
...
@@ -79,7 +79,7 @@
android:id=
"@+id/btnPrintText"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"打印
默认
字符"
/>
android:text=
"打印
输入
字符"
/>
</TableRow>
<TableRow
android:visibility=
"gone"
>
...
...
print/src/main/AndroidManifest.xml
View file @
340eef2d
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.miya.print"
/>
package=
"com.miya.print"
>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
</manifest>
print/src/main/java/com/miya/print/YingtaiPrinter.java
View file @
340eef2d
...
...
@@ -30,7 +30,7 @@ public class YingtaiPrinter extends BasePrinter {
this
.
context
=
context
;
mPrinter
=
PrinterAPI
.
getInstance
();
io
=
new
USBAPI
(
context
);
if
(!
io
.
isOpen
().
booleanValue
())
{
if
(!
mPrinter
.
isConnect
())
{
if
(
PrinterAPI
.
SUCCESS
==
mPrinter
.
connect
(
io
))
{
PrintLogger
.
i
(
TAG
,
"英泰打印机连接成功"
);
return
true
;
...
...
@@ -54,11 +54,29 @@ public class YingtaiPrinter extends BasePrinter {
return
true
;
}
@Override
public
int
beginPrint
()
{
if
(
mPrinter
!=
null
&&
!
mPrinter
.
isConnect
())
{
if
(
PrinterAPI
.
SUCCESS
==
mPrinter
.
connect
(
io
))
{
PrintLogger
.
i
(
TAG
,
"之前的连接断掉了,重新连接后,英泰打印机连接成功"
);
return
PrinterStatusEnum
.
CODE_SUCCESS
.
status
;
}
else
{
PrintLogger
.
e
(
TAG
,
"之前的连接断掉了,重新连接后,英泰打印机连接失败"
);
throw
new
PrinterException
(
PrinterStatusEnum
.
CODE_FAILED
.
status
,
"重连尝试,英泰打印机连接失败,请重试"
);
}
}
return
PrinterStatusEnum
.
CODE_SUCCESS
.
status
;
}
@Override
public
int
printText
(
int
align
,
int
size
,
String
content
,
boolean
isFeed
)
{
if
(
mPrinter
!=
null
)
{
int
ret
=
setAlign
(
align
);
try
{
//设置字体大小,可传0~7
if
(
size
>=
0
&&
size
<=
7
)
{
ret
=
mPrinter
.
setCharSize
(
size
,
size
);
}
ret
=
mPrinter
.
printString
(
content
,
"GBK"
,
isFeed
);
return
ret
;
}
catch
(
UnsupportedEncodingException
e
)
{
...
...
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