Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3b732ed6
authored
Mar 08, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on batch bug
parent
70aee8d2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
18 additions
and
16 deletions
android/Pictogram/app/src/main/java/com/yottacode/net/RestapiWrapper.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Action.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/ActionLog.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/PictosAction.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Room.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/app/src/main/java/com/yottacode/net/RestapiWrapper.java
View file @
3b732ed6
...
...
@@ -179,6 +179,7 @@ public class RestapiWrapper {
sparams
=
""
;
for
(
String
param
:
params
.
keySet
())
{
String
value
=
params
.
get
(
param
);
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
param
+
"="
+
value
+
" total:"
+
sparams
+
" json?"
+
json_params
);
if
(
param
.
equals
(
"token"
))
urlConnection
.
setRequestProperty
(
"Authorization"
,
"Bearer "
+
value
);
else
{
...
...
@@ -249,7 +250,6 @@ public class RestapiWrapper {
// onPostExecute displays the results of the AsyncTask.
@Override
protected
void
onPostExecute
(
HttpAsyncTaskParams
params
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"PICTO END RESTAPI POSTEXE "
+
params
.
url
+
":"
+
params
.
url_params
.
toString
());
try
{
//if (params.e)
if
(
params
.
result
!=
null
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Action.java
View file @
3b732ed6
...
...
@@ -52,7 +52,7 @@ public abstract class Action {
jsonObject
.
put
(
param_id_sup
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_id_sup
());
//TODO Decidir qué almacenar con DEVICE
//if (PCBcontext.getDevice().getDeviceID()!=null)
// jsonObject.put(param_id_dev, PCBcontext.getDevice().getDeviceID()
);
jsonObject
.
put
(
param_id_dev
,
"-1"
);
return
jsonObject
;
}
catch
(
JSONException
e
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/ActionLog.java
View file @
3b732ed6
...
...
@@ -53,10 +53,10 @@ public class ActionLog implements iRestapiListener {
String
actions
=
""
;
for
(
JSONObject
action:
actions_buffer
)
actions
+=
","
+
action
.
toString
();
actions
=
"
["
+
actions
.
substring
(
1
)
+
"]
"
;
params
.
put
(
"
actions
"
,
actions
);
actions
=
"
{actions: ["
+
actions
.
substring
(
1
)
+
"]}
"
;
params
.
put
(
"
json
"
,
actions
);
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
" Sending batch actions: "
+
url
+
": "
+
actions
);
PCBcontext
.
getRestapiWrapper
().
ask
(
url
,
params
,
"post"
,
this
);
PCBcontext
.
getRestapiWrapper
().
ask
(
url
,
params
,
"post"
,
t
rue
,
t
his
);
}
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/PictosAction.java
View file @
3b732ed6
...
...
@@ -59,7 +59,7 @@ public class PictosAction extends Action {
return
null
;
}
}
p
ublic
JSONObject
get_json_picto
(
Picto
picto
)
throws
JSONException
{
p
rivate
JSONObject
get_json_picto
(
Picto
picto
)
throws
JSONException
{
final
String
param_id_json
=
"id"
;
final
String
param_picto
=
"picto"
;
final
String
param_attrs
=
"attributes"
;
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Room.java
View file @
3b732ed6
...
...
@@ -50,14 +50,14 @@ public class Room {
return
new
JSONObject
().
put
(
action_param
,
action
).
put
(
attributes_param
,
attributes
);
}
public
void
emit
(
String
url
,
final
Action
action
)
{
Log
.
d
(
this
.
getClass
().
getName
(),
"Action: "
+
action
.
get_type
()
+
" / Attributes emitted: "
+
action
.
get_json
().
toString
());
Log
.
i
(
this
.
getClass
().
getName
(),
"Action: "
+
action
.
get_type
()
+
" / Attributes emitted: "
+
action
.
get_json
().
toString
());
try
{
this
.
socket
.
emit
(
url
,
this
.
common_data
(
action
.
get_type
(),
action
.
get_json
()),
new
Ack
()
{
@Override
public
void
call
(
Object
...
args
)
{
Log
.
i
(
this
.
getClass
().
getName
(),
"Ack"
);
for
(
Object
arg
:
args
)
Log
.
d
(
this
.
getClass
().
getName
(),
"Ack messsage:"
+
arg
);
Log
.
i
(
this
.
getClass
().
getName
(),
"Ack messsage:"
+
arg
);
}
});
}
catch
(
JSONException
e
)
{
...
...
@@ -85,6 +85,7 @@ public class Room {
*/
public
void
reconnect
()
{
final
String
transport
=
"polling"
;
if
(
this
.
socket
!=
null
)
this
.
socket
.
destroy
();
this
.
socket
=
new
SailsSocketsIO
(
PCBcontext
.
getRestapiWrapper
().
getServer
(),
transport
,
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
Object
...
args
)
{
...
...
@@ -96,10 +97,8 @@ public class Room {
},
new
Emitter
.
Listener
()
{
@Override
public
void
call
(
Object
...
args
)
{
Log
.
i
(
this
.
getClass
().
getName
(),
"Room exit: "
+
args
[
0
]);
if
(
args
.
length
>
0
&&
args
[
0
].
toString
().
equals
(
"transport error"
)
)
{
inRoom
=
false
;
}
Log
.
i
(
this
.
getClass
().
getName
(),
"Reconnect unsuccesful: "
+
args
[
0
]);
inRoom
=
false
;
}
});
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
3b732ed6
...
...
@@ -346,7 +346,6 @@ public class Picto extends Img {
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
PCB_STATUS_MODIFICATION
,
true
);
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
PCBcontext
.
getActionLog
().
log
(
new
VocabularyAction
(
VocabularyAction
.
ALTERATTRS
,
this
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
e
.
getMessage
());
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
3b732ed6
...
...
@@ -104,7 +104,11 @@ public class Vocabulary implements Iterable<Picto> {
Log
.
e
(
this
.
getClass
().
getName
(),
" Picto json error from local storage: "
+
e
.
getMessage
());
}
for
(
Picto
picto:
this
)
{
if
(
picto
.
status_modified
())
new
PictoUploader
(
picto
).
uploadState
();
if
(
picto
.
status_modified
())
{
new
PictoUploader
(
picto
).
uploadState
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Picto status modified while offline. Picto: "
+
picto
.
get_translation
()
+
":"
+
picto
.
get_id
()
+
" Current status:"
+
picto
.
status_modified
());
}
if
(
picto
.
get_id
()
<
0
)
try
{
new
PictoUploader
(
picto
).
upload
();
//id<0 iif it is a local id
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
3b732ed6
...
...
@@ -93,7 +93,7 @@ public class NetService implements Runnable {
PCBcontext
.
getActionLog
().
batch
();
updated
=
true
;
}
Log
.
i
(
this
.
getClass
().
getName
(),
"PCB status checked. Updated? "
+
updated
+
" in
room?
"
+
PCBcontext
.
getRoom
().
inRoom
());
Log
.
i
(
this
.
getClass
().
getName
(),
"PCB status checked. Updated? "
+
updated
+
" in
Room?
"
+
PCBcontext
.
getRoom
().
inRoom
());
}
@Override
...
...
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