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
2f0c9f00
authored
May 08, 2017
by
Germán Callejas Alcántara
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
pcbddbhelper changed
parent
ab222a4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
2f0c9f00
...
...
@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao;
import
android.content.ContentValues
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase.CursorFactory
;
...
...
@@ -170,9 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
Log
.
e
(
LOG_TAG
,
"Error setting active scene:"
+
e
.
getMessage
());
}
Cursor
cursor
=
getReadableDatabase
().
rawQuery
(
"SELECT * FROM scene"
,
null
);
/*
Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM scene",null);
Log.i(LOG_TAG,"tam scen: "+cursor.getCount());
cursor
.
close
();
cursor.close();
*/
}
/**
...
...
@@ -221,14 +222,24 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public
void
setStudentVocabulary
(
Vocabulary
vocabulary
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
<<<<<<<
4748
b817cf03a1d7c60a8b8cde67f05075afe99f
=======
int
seconds1
=
Calendar
.
getInstance
().
get
(
Calendar
.
SECOND
);
Log
.
i
(
LOG_TAG
,
"tamVoc to insert: "
+
vocabulary
.
size
());
>>>>>>>
dbcde972e39f99c8d77c15874db2f92ed0515887
db
.
delete
(
"collection"
,
"id_stu="
+
id_stu
,
null
);
ContentValues
values
=
new
ContentValues
(
6
);
values
.
put
(
"id_stu"
,
id_stu
);
db
.
beginTransaction
();
for
(
Picto
picto
:
vocabulary
)
{
<<<<<<<
4748
b817cf03a1d7c60a8b8cde67f05075afe99f
=======
Log
.
i
(
LOG_TAG
,
"inserting "
+
picto
.
get_id
()+
":"
+
picto
.
get_translation
()+
":"
+
picto
.
get_json_attrs
()+
"-id_sce: "
+
getActiveSceneForStudent
(
id_stu
));
newsize
++;
>>>>>>>
dbcde972e39f99c8d77c15874db2f92ed0515887
values
.
put
(
"id_picto"
,
picto
.
get_id
());
values
.
put
(
"id_scene"
,
135
/*getActiveSceneForStudent(id_stu)*/
);
values
.
put
(
"id_scene"
,
vocabulary
.
getId_scene
()
);
values
.
put
(
"url"
,
picto
.
get_url
());
values
.
put
(
"translation"
,
picto
.
get_translation
());
values
.
put
(
"attributes"
,
picto
.
get_json_attrs
());
...
...
@@ -249,10 +260,11 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public
void
savePicto
(
Picto
picto
)
{
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
(
6
);
ContentValues
values
=
new
ContentValues
(
7
);
values
.
put
(
"id_stu"
,
id_stu
);
values
.
put
(
"id_picto"
,
picto
.
get_id
());
//values.put("id_scene",picto.get_scene());
//TODO: Añadir aqui el id de escena activa para el estudiante
values
.
put
(
"id_scene"
,
getActiveSceneForStudent
(
id_stu
));
values
.
put
(
"url"
,
picto
.
get_url
());
values
.
put
(
"translation"
,
picto
.
get_translation
());
values
.
put
(
"attributes"
,
picto
.
get_json_attrs
());
...
...
@@ -269,10 +281,11 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*/
public
void
deletePicto
(
int
picto_id
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
delete
(
"collection"
,
"id_stu=? AND id_picto=?"
,
//TODO: Añadir aqui el id de escena activa para el estudiante
db
.
delete
(
"collection"
,
"id_stu=? AND id_picto=?
AND id_scene=?
"
,
new
String
[]{
Integer
.
toString
(
this
.
currentUser
.
get_id_stu
()),
Integer
.
toString
(
picto_id
)});
Integer
.
toString
(
picto_id
),
Integer
.
toString
(
getActiveSceneForStudent
(
this
.
currentUser
.
get_id_stu
()))});
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
}
...
...
@@ -288,7 +301,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
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
)});
//TODO: Añadir aqui el id de escena activa para el estudiante
int
updates
=
db
.
update
(
"collection"
,
values
,
"id_stu=? AND id_picto=? AND id_scene=?"
,
new
String
[]
{
Integer
.
toString
(
id_stu
),
Integer
.
toString
(
picto_id
),
Integer
.
toString
(
getActiveSceneForStudent
(
this
.
currentUser
.
get_id_stu
()))});
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Modify "
+
updates
+
" Picto, id. "
+
picto_id
+
" attributes="
+
attrs
);
//+ "::"+ Arrays.toString(Thread.currentThread().getStackTrace()));
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
}
...
...
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