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
4881eaf6
authored
Jan 22, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Empty categories bug fixed.
parent
e707b27c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
android/Pictogrammar/app/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogrammar/app/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
4881eaf6
...
...
@@ -124,12 +124,9 @@ public class Vocabulary implements Iterable<Picto>, iRestapiListener, iVocabular
private
int
find_picto_index
(
int
pic_cat
,
int
pic_id
)
{
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
int
index
=-
1
;
Log
.
d
(
"Vocabulary BORRA 2.1"
,
pic_cat
+
" "
+
pic_id
);
for
(
int
i
=
0
;
i
<
pictos_cat
.
size
()
&&
index
==-
1
;
i
++)
{
Log
.
d
(
"Vocabulary BORRA 2.15"
,
i
+
":"
+
pictos_cat
.
get
(
i
).
get_id
());
if
(
pictos_cat
.
get
(
i
).
get_id
()==
pic_id
)
index
=
i
;
if
(
pictos_cat
.
get
(
i
).
get_id
()==
pic_id
)
index
=
i
;
}
Log
.
d
(
"Vocabulary BORRA 2.2"
,
pic_cat
+
" "
+
pic_id
+
" "
+
index
);
return
index
;
}
/**
...
...
@@ -138,8 +135,11 @@ public class Vocabulary implements Iterable<Picto>, iRestapiListener, iVocabular
*/
public
void
removePicto
(
int
pic_cat
,
int
pic_id
){
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
pictos_cat
.
remove
(
find_picto_index
(
pic_cat
,
pic_id
));
PCBcontext
.
getPcbdb
().
deletePicto
(
pic_id
);
int
index
=
find_picto_index
(
pic_cat
,
pic_id
);
if
(
index
>
0
)
{
//puede ocurrir que se intente borrar un pictograma dos veces
pictos_cat
.
remove
();
PCBcontext
.
getPcbdb
().
deletePicto
(
pic_id
);
}
}
/**
...
...
@@ -150,10 +150,12 @@ public class Vocabulary implements Iterable<Picto>, iRestapiListener, iVocabular
*/
public
void
modifyAttsPicto
(
int
pic_cat
,
int
pic_id
,
JSONObject
attrs
)
{
Log
.
d
(
"Vocabulary MOD BORRA 2"
,
pic_cat
+
"---"
+
pic_id
);
Picto
picto
=
this
.
pictos
.
get
(
pic_cat
).
get
(
find_picto_index
(
pic_cat
,
pic_id
));
picto
.
set_json_attr
(
attrs
);
PCBcontext
.
getPcbdb
().
modifyPicto
(
pic_id
,
attrs
.
toString
());
int
index
=
find_picto_index
(
pic_cat
,
pic_id
);
if
(
index
>
0
)
{
//puede ocurrir que se intente modificar un pictograma que fue borrado
Picto
picto
=
this
.
pictos
.
get
(
pic_cat
).
get
(
index
);
picto
.
set_json_attr
(
attrs
);
PCBcontext
.
getPcbdb
().
modifyPicto
(
pic_id
,
attrs
.
toString
());
}
}
/**
...
...
@@ -292,20 +294,15 @@ public class Vocabulary implements Iterable<Picto>, iRestapiListener, iVocabular
public
void
change
(
action
action
,
int
picto_cat
,
int
picto_id
,
JSONObject
args
)
{
switch
(
action
)
{
case
delete:
{
Log
.
d
(
"Vocabulary.java"
,
"Entra en el case delete. Picto cat: "
+
picto_cat
+
" y picto_id: "
+
picto_id
);
removePicto
(
picto_cat
,
picto_id
);
break
;
}
case
update:
{
Log
.
d
(
"Vocabulary.java"
,
"Update cat"
+
picto_cat
+
". icto_id: "
+
picto_id
);
modifyAttsPicto
(
picto_cat
,
picto_id
,
args
);
break
;
}
case
add:
{
Log
.
d
(
"Vocabulary.java"
,
"Entra en el case add. Picto_id: "
+
picto_id
);
try
{
String
text
=
args
.
getJSONObject
(
"expression"
).
getString
(
"text"
);
String
uri
=
args
.
getJSONObject
(
"picto"
).
getString
(
"uri"
);
...
...
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