use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class PhotoNoteDB method findByPhotoNoteId.
public synchronized PhotoNote findByPhotoNoteId(long photoNoteId) {
SQLiteDatabase db = mNotesSQLite.getReadableDatabase();
Cursor cursor = db.query(NotesSQLite.TABLE_PHOTONOTE, null, "_id = ?", new String[] { photoNoteId + "" }, null, null, null);
PhotoNote photoNote = null;
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("_id"));
String photoName = cursor.getString(cursor.getColumnIndex("photoName"));
long createdPhotoTime = cursor.getLong(cursor.getColumnIndex("createdPhotoTime"));
long editedPhotoTime = cursor.getLong(cursor.getColumnIndex("editedPhotoTime"));
String title = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
long createdNoteTime = cursor.getLong(cursor.getColumnIndex("createdNoteTime"));
long editedNoteTime = cursor.getLong(cursor.getColumnIndex("editedNoteTime"));
int color = cursor.getInt(cursor.getColumnIndex("palette"));
int tag = cursor.getInt(cursor.getColumnIndex("tag"));
int categoryId_ = cursor.getInt(cursor.getColumnIndex("categoryId"));
photoNote = new PhotoNote(id, photoName, createdPhotoTime, editedPhotoTime, title, content, createdNoteTime, editedNoteTime, categoryId_);
photoNote.setPaletteColor(color);
}
cursor.close();
db.close();
return photoNote;
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class PhotoNoteDB method isExistInDB.
public synchronized boolean isExistInDB(PhotoNote photoNote) {
int categoryId = photoNote.getCategoryId();
List<PhotoNote> photoNoteList = findByCategoryId(categoryId);
for (PhotoNote item : photoNoteList) {
if (item.getId() == photoNote.getId()) {
return true;
}
}
return false;
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class PhotoNoteDB method save.
public synchronized long save(PhotoNote... photoNotes) {
SQLiteDatabase db = mNotesSQLite.getWritableDatabase();
db.beginTransaction();
long id = -1;
try {
for (PhotoNote photoNote : photoNotes) {
ContentValues contentValues = new ContentValues();
contentValues.put("photoName", photoNote.getPhotoName());
contentValues.put("createdPhotoTime", photoNote.getCreatedPhotoTime());
contentValues.put("editedPhotoTime", photoNote.getEditedPhotoTime());
contentValues.put("title", photoNote.getTitle());
contentValues.put("content", photoNote.getContent());
contentValues.put("createdNoteTime", photoNote.getCreatedNoteTime());
contentValues.put("editedNoteTime", photoNote.getEditedNoteTime());
contentValues.put("palette", photoNote.getPaletteColor());
// contentValues.put("tag", );
contentValues.put("categoryId", photoNote.getCategoryId());
contentValues.put("categoryLabel", "");
id = db.insert(NotesSQLite.TABLE_PHOTONOTE, null, contentValues);
db.setTransactionSuccessful();
}
} catch (Exception e) {
YLog.e(e);
return -1;
} finally {
db.endTransaction();
db.close();
}
return id;
}
Aggregations