use of com.kiminonawa.mydiary.entries.entries.EntriesEntity in project MyDiary by erttyy8821.
the class DiaryActivity method loadEntries.
/**
*
*/
public void loadEntries() {
entriesList.clear();
DBManager dbManager = new DBManager(this);
dbManager.opeDB();
//Select diary info
Cursor diaryCursor = dbManager.selectDiaryList(getTopicId());
for (int i = 0; i < diaryCursor.getCount(); i++) {
//get diary info
String title = diaryCursor.getString(2);
if ("".equals(title)) {
title = getString(R.string.diary_no_title);
}
EntriesEntity entity = new EntriesEntity(diaryCursor.getLong(0), new Date(diaryCursor.getLong(1)), title.substring(0, Math.min(MAX_TEXT_LENGTH, title.length())), diaryCursor.getInt(4), diaryCursor.getInt(3), diaryCursor.getInt(5) > 0 ? true : false);
//select first diary content
Cursor diaryContentCursor = dbManager.selectDiaryContentByDiaryId(entity.getId());
if (diaryContentCursor != null && diaryContentCursor.getCount() > 0) {
String summary = "";
//Check content Type
if (diaryContentCursor.getInt(1) == IDairyRow.TYPE_PHOTO) {
summary = getString(R.string.entries_summary_photo);
} else if (diaryContentCursor.getInt(1) == IDairyRow.TYPE_TEXT) {
summary = diaryContentCursor.getString(3).substring(0, Math.min(MAX_TEXT_LENGTH, diaryContentCursor.getString(3).length()));
}
entity.setSummary(summary);
diaryContentCursor.close();
}
//Add entity
entriesList.add(entity);
diaryCursor.moveToNext();
}
diaryCursor.close();
dbManager.closeDB();
}
Aggregations