mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-02-04 08:07:32 +01:00
store the selected notes index
This commit is contained in:
parent
a1ad71adcc
commit
ee8e8dd17c
@ -37,4 +37,12 @@ public class Config {
|
||||
public void setFontSize(int size) {
|
||||
mPrefs.edit().putInt(Constants.FONT_SIZE, size).apply();
|
||||
}
|
||||
|
||||
public int getCurrentNoteIndex() {
|
||||
return mPrefs.getInt(Constants.CURRENT_NOTE_INDEX, 0);
|
||||
}
|
||||
|
||||
public void setCurrentNoteIndex(int index) {
|
||||
mPrefs.edit().putInt(Constants.CURRENT_NOTE_INDEX, index).apply();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ public class Constants {
|
||||
public static final String PREFS_KEY = "Notes";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String IS_DARK_THEME = "is_dark_theme";
|
||||
public static final String CURRENT_NOTE_INDEX = "current_note_index";
|
||||
public static final String FONT_SIZE = "font_size";
|
||||
public static final String WIDGET_BG_COLOR = "widget_bg_color";
|
||||
public static final String WIDGET_TEXT_COLOR = "widget_text_color";
|
||||
|
@ -43,7 +43,7 @@ public class MainActivity extends SimpleActivity {
|
||||
|
||||
mDb = DBHelper.newInstance(getApplicationContext());
|
||||
mNotes = mDb.getNotes();
|
||||
updateCurrentNote(0);
|
||||
updateCurrentNote(mConfig.getCurrentNoteIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,6 +103,7 @@ public class MainActivity extends SimpleActivity {
|
||||
}
|
||||
|
||||
private void updateCurrentNote(int index) {
|
||||
mConfig.setCurrentNoteIndex(index);
|
||||
mCurrentNote = mNotes.get(index);
|
||||
mNotesView.setText(mCurrentNote.getValue());
|
||||
mCurrNoteTitle.setText(mCurrentNote.getTitle());
|
||||
|
Loading…
x
Reference in New Issue
Block a user