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