Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
barcode-scan
Overview
Overview
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
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Andrés Branas
barcode-scan
Commits
e2e97195
Commit
e2e97195
authored
Sep 26, 2017
by
Oscar Fuentes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change plugin initialize
parent
8ca4fb80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
17 deletions
+14
-17
src/android/com/cocodin/barcodescan/plugin/BarcodeScanChainway.java
+1
-2
src/android/com/cocodin/barcodescan/plugin/PluginHelper.java
+13
-15
No files found.
src/android/com/cocodin/barcodescan/plugin/BarcodeScanChainway.java
View file @
e2e97195
...
...
@@ -20,11 +20,10 @@ public class BarcodeScanChainway extends CordovaPlugin {
}
public
boolean
execute
(
String
action
,
JSONArray
args
,
final
CallbackContext
callbackContext
)
{
PluginHelper
.
init
(
cordova
);
Log
.
d
(
TAG
,
"execute: "
+
action
);
if
(
action
.
equalsIgnoreCase
(
"scan"
))
{
PluginHelper
.
scan
(
cordova
,
webView
,
args
,
callbackContext
);
}
else
if
(
action
.
equalsIgnoreCase
(
"getDevices"
))
{
}
else
if
(
action
.
equalsIgnoreCase
(
"getDevices"
))
{
PluginHelper
.
getDevices
(
cordova
,
webView
,
args
,
callbackContext
);
}
return
true
;
...
...
src/android/com/cocodin/barcodescan/plugin/PluginHelper.java
View file @
e2e97195
...
...
@@ -27,24 +27,22 @@ public class PluginHelper {
private
static
Barcode2DWithSoft
mInstance
;
private
static
JSONArray
Devices
=
new
JSONArray
().
put
(
"camera"
).
put
(
"c4050"
);
public
static
void
init
(
CordovaInterface
cordova
)
{
Context
context
=
cordova
.
getActivity
();
try
{
mInstance
=
Barcode2DWithSoft
.
getInstance
();
if
(
mInstance
!=
null
)
{
mInstance
.
open
(
context
);
}
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
e
.
getMessage
());
}
}
public
static
void
scan
(
CordovaInterface
cordova
,
CordovaWebView
webView
,
JSONArray
args
,
final
CallbackContext
callbackContext
)
{
String
device
=
""
;
try
{
device
=
args
.
get
(
0
).
toString
();
if
(
device
.
equalsIgnoreCase
(
Devices
.
getString
(
1
)))
{
Context
context
=
cordova
.
getActivity
();
try
{
mInstance
=
Barcode2DWithSoft
.
getInstance
();
if
(
mInstance
!=
null
)
{
mInstance
.
open
(
context
);
}
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
e
.
getMessage
());
callbackContext
.
sendPluginResult
(
new
PluginResult
(
Status
.
ERROR
,
e
.
getMessage
()));
}
mInstance
.
setScanCallback
(
new
Barcode2DWithSoft
.
ScanCallback
()
{
@Override
public
void
onScanComplete
(
int
i
,
int
length
,
byte
[]
data
)
{
...
...
@@ -62,8 +60,7 @@ public class PluginHelper {
JSONObject
result
=
new
JSONObject
().
put
(
"text"
,
barCode
);
callbackContext
.
sendPluginResult
(
new
PluginResult
(
Status
.
OK
,
result
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
callbackContext
.
sendPluginResult
(
new
PluginResult
(
Status
.
ERROR
,
""
));
callbackContext
.
sendPluginResult
(
new
PluginResult
(
Status
.
ERROR
,
e
.
getMessage
()));
}
}
});
...
...
@@ -81,7 +78,8 @@ public class PluginHelper {
}
}
public
static
void
getDevices
(
CordovaInterface
cordova
,
CordovaWebView
webView
,
JSONArray
args
,
final
CallbackContext
callbackContext
){
public
static
void
getDevices
(
CordovaInterface
cordova
,
CordovaWebView
webView
,
JSONArray
args
,
final
CallbackContext
callbackContext
)
{
callbackContext
.
sendPluginResult
(
new
PluginResult
(
Status
.
OK
,
Devices
));
}
}
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