mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-02-07 23:18:46 +01:00
allow changing the current note
This commit is contained in:
parent
6d7746f66c
commit
2ea85dbb4a
@ -42,10 +42,9 @@ public class MainActivity extends SimpleActivity {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
mDb = DBHelper.newInstance(getApplicationContext());
|
||||
mCurrentNote = mDb.getGeneralNote();
|
||||
mNotesView.setText(mCurrentNote.getValue());
|
||||
mCurrNoteTitle.setText(mCurrentNote.getTitle());
|
||||
}
|
||||
mNotes = mDb.getNotes();
|
||||
updateCurrentNote(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@ -53,11 +52,7 @@ public class MainActivity extends SimpleActivity {
|
||||
invalidateOptionsMenu();
|
||||
mNotesView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Utils.getTextSize(getApplicationContext()));
|
||||
|
||||
mNotes = mDb.getNotes();
|
||||
invalidateOptionsMenu();
|
||||
|
||||
mCurrNoteLabel.setVisibility(mNotes.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||
mCurrNoteTitle.setVisibility(mNotes.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +102,15 @@ public class MainActivity extends SimpleActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCurrentNote(int index) {
|
||||
mCurrentNote = mNotes.get(index);
|
||||
mNotesView.setText(mCurrentNote.getValue());
|
||||
mCurrNoteTitle.setText(mCurrentNote.getTitle());
|
||||
|
||||
mCurrNoteLabel.setVisibility(mNotes.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||
mCurrNoteTitle.setVisibility(mNotes.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@OnClick(R.id.notes_fab)
|
||||
public void fabClicked(View view) {
|
||||
final View newNoteView = getLayoutInflater().inflate(R.layout.new_note, null);
|
||||
@ -169,7 +173,7 @@ public class MainActivity extends SimpleActivity {
|
||||
builder.setItems(notes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
updateCurrentNote(which);
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
Loading…
x
Reference in New Issue
Block a user