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
f386fccf
authored
Mar 08, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working on alter status from pcb when offline
parent
3b732ed6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
13 deletions
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/dao/PCBDBHelper.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/PictoUploader.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/Action.java
View file @
f386fccf
...
...
@@ -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
,
"-1"
);
//jsonObject.put(param_id_dev, PCBcontext.getDevice().getDeviceID()
);
return
jsonObject
;
}
catch
(
JSONException
e
)
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/action/ActionLog.java
View file @
f386fccf
...
...
@@ -50,11 +50,17 @@ public class ActionLog implements iRestapiListener {
if
(!
actions_buffer
.
isEmpty
())
{
Hashtable
<
String
,
String
>
params
=
new
Hashtable
<>(
1
);
String
url
=
"stu/actions_batch"
;
String
actions
=
""
;
JSONArray
actions
=
new
JSONArray
();
for
(
JSONObject
action:
actions_buffer
)
actions
+=
","
+
action
.
toString
();
actions
=
"{actions: ["
+
actions
.
substring
(
1
)
+
"]}"
;
params
.
put
(
"json"
,
actions
);
actions
.
put
(
action
);
//actions= "{actions: [" + actions.substring(1) + "]}";
try
{
params
.
put
(
"json"
,
new
JSONObject
().
put
(
"actions"
,
actions
).
toString
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
" Batch action error: "
+
e
.
getMessage
());
}
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
" Sending batch actions: "
+
url
+
": "
+
actions
);
PCBcontext
.
getRestapiWrapper
().
ask
(
url
,
params
,
"post"
,
true
,
this
);
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
f386fccf
...
...
@@ -266,7 +266,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
ContentValues
values
=
new
ContentValues
(
1
);
values
.
put
(
"attributes"
,
attrs
);
int
updates
=
db
.
update
(
"collection"
,
values
,
"id_stu=? AND id_picto=?"
,
new
String
[]
{
Integer
.
toString
(
id_stu
),
Integer
.
toString
(
picto_id
)});
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Modify "
+
updates
+
"
Picto attributes:
"
+
picto_id
+
" attributes="
+
attrs
);
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Modify "
+
updates
+
"
picto, id.
"
+
picto_id
+
" attributes="
+
attrs
);
db
.
close
();
}
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
f386fccf
...
...
@@ -102,15 +102,19 @@ public class Picto extends Img {
}
/**
* JSON attribute of the picto
* JSON attrs of the picto except the param regarding is locally modified since this is not saved into the server
*
*
*/
public
String
get_json_attr
(
String
attr
)
{
public
String
get_json_server_attrs
()
{
JSONObject
json
=
null
;
try
{
return
this
.
attributes
.
getString
(
attr
);
json
=
new
JSONObject
(
this
.
attributes
.
toString
()
);
}
catch
(
JSONException
e
)
{
return
null
;
e
.
printStackTrace
()
;
}
json
.
remove
(
JSON_ATTTRS
.
PCB_STATUS_MODIFICATION
);
return
json
.
toString
();
}
/**
* Set JSON attribute of the picto
...
...
@@ -318,6 +322,7 @@ public class Picto extends Img {
*/
public
boolean
alter_status
()
{
String
status
=
is_enabled
()
?
JSON_ATTTR_STATUS_VALUES
.
DISABLED
:
JSON_ATTTR_STATUS_VALUES
.
ENABLED
;
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
STATUS
,
status
);
status_modified
(
true
);
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
f386fccf
...
...
@@ -106,8 +106,8 @@ public class Vocabulary implements Iterable<Picto> {
for
(
Picto
picto:
this
)
{
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
());
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto status modified while offline. Picto label
: "
+
picto
.
get_translation
()
+
"
, id
:"
+
picto
.
get_id
()
+
" Current status:"
+
picto
.
status_modified
());
}
if
(
picto
.
get_id
()
<
0
)
try
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
f386fccf
...
...
@@ -180,7 +180,7 @@ public class PictoUploader {
public
void
uploadState
(
){
Hashtable
<
String
,
String
>
params
=
new
Hashtable
<
String
,
String
>(
1
);
params
.
put
(
"attributes"
,
picto
.
get_json_attrs
());
params
.
put
(
"attributes"
,
picto
.
get_json_
server_
attrs
());
params
.
put
(
"id_stu"
,
Integer
.
toString
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_id_stu
()));
params
.
put
(
"id_pic"
,
Integer
.
toString
(
this
.
picto
.
get_id
()));
...
...
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