use of com.kiminonawa.mydiary.db.DBManager 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();
}
use of com.kiminonawa.mydiary.db.DBManager in project MyDiary by erttyy8821.
the class EditMemoDialogFragment method updateMemo.
private void updateMemo() {
if (memoId != -1) {
DBManager dbManager = new DBManager(getActivity());
dbManager.opeDB();
dbManager.updateMemoContent(memoId, EDT_edit_memo_content.getText().toString());
dbManager.closeDB();
}
}
use of com.kiminonawa.mydiary.db.DBManager in project MyDiary by erttyy8821.
the class MemoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_memo);
//For set status bar
ChinaPhoneHelper.setStatusBar(this, true);
topicId = getIntent().getLongExtra("topicId", -1);
if (topicId == -1) {
finish();
}
/**
* init UI
*/
RL_memo_topbar_content = (RelativeLayout) findViewById(R.id.RL_memo_topbar_content);
RL_memo_topbar_content.setBackgroundColor(ThemeManager.getInstance().getThemeMainColor(this));
RL_memo_content_bg = (RelativeLayout) findViewById(R.id.RL_memo_content_bg);
RL_memo_content_bg.setBackground(ThemeManager.getInstance().getMemoBgDrawable(this, topicId));
TV_memo_topbar_title = (TextView) findViewById(R.id.TV_memo_topbar_title);
IV_memo_edit = (ImageView) findViewById(R.id.IV_memo_edit);
IV_memo_edit.setOnClickListener(this);
String diaryTitle = getIntent().getStringExtra("diaryTitle");
if (diaryTitle == null) {
diaryTitle = "Memo";
}
TV_memo_topbar_title.setText(diaryTitle);
RecyclerView_memo = (RecyclerView) findViewById(R.id.RecyclerView_memo);
rootView = findViewById(R.id.Layout_memo_item_add);
TV_memo_item_add = (TextView) rootView.findViewById(R.id.TV_memo_item_add);
TV_memo_item_add.setTextColor(ThemeManager.getInstance().getThemeDarkColor(this));
TV_memo_item_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditMemoDialogFragment editMemoDialogFragment = EditMemoDialogFragment.newInstance(topicId, -1, true, "");
editMemoDialogFragment.show(getSupportFragmentManager(), "editMemoDialogFragment");
}
});
memoList = new ArrayList<>();
dbManager = new DBManager(MemoActivity.this);
loadMemo(true);
initTopicAdapter();
}
use of com.kiminonawa.mydiary.db.DBManager in project MyDiary by erttyy8821.
the class InitTask method doInBackground.
@Override
protected Boolean doInBackground(Long... params) {
try {
DBManager dbManager = new DBManager(mContext);
dbManager.opeDB();
loadSampleData(dbManager);
updateData(dbManager);
dbManager.closeDB();
saveCurrentVersionCode();
} catch (Exception e) {
e.printStackTrace();
}
return showReleaseNote;
}
use of com.kiminonawa.mydiary.db.DBManager in project MyDiary by erttyy8821.
the class ContactsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contacts);
//For set status bar
ChinaPhoneHelper.setStatusBar(this, true);
themeManager = ThemeManager.getInstance();
initLanguageStr();
topicId = getIntent().getLongExtra("topicId", -1);
if (topicId == -1) {
finish();
}
/**
* init UI
*/
RL_contacts_content = (RelativeLayout) findViewById(R.id.RL_contacts_content);
RL_contacts_content.setBackground(themeManager.getContactsBgDrawable(this, topicId));
TV_contact_short_sort = (TextView) findViewById(R.id.TV_contact_short_sort);
TV_contact_short_sort.setBackgroundColor(themeManager.getThemeDarkColor(ContactsActivity.this));
STL_contacts = (LatterSortLayout) findViewById(R.id.STL_contacts);
STL_contacts.setSortTextView(TV_contact_short_sort);
STL_contacts.setOnTouchingLetterChangedListener(this);
EDT_main_contacts_search = (EditText) findViewById(R.id.EDT_main_contacts_search);
IV_contacts_add = (ImageView) findViewById(R.id.IV_contacts_add);
IV_contacts_add.setOnClickListener(this);
IV_contacts_title = (TextView) findViewById(R.id.IV_contacts_title);
String diaryTitle = getIntent().getStringExtra("diaryTitle");
if (diaryTitle == null) {
diaryTitle = "Contacts";
}
IV_contacts_title.setText(diaryTitle);
/**
* init RecyclerVie
*/
STL_contacts = (LatterSortLayout) findViewById(R.id.STL_contacts);
RecyclerView_contacts = (RecyclerView) findViewById(R.id.RecyclerView_contacts);
contactsNamesList = new ArrayList<>();
dbManager = new DBManager(ContactsActivity.this);
initTopbar();
loadContacts();
initTopicAdapter();
}
Aggregations