mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 23:12:02 +02:00
fix #120, make sure the proper note is shown at clicking a widget
This commit is contained in:
parent
67a3a5e811
commit
f52aa7f245
@ -21,10 +21,12 @@
|
||||
|
||||
<activity
|
||||
android:name=".activities.SplashActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/SplashTheme"/>
|
||||
|
||||
<activity
|
||||
android:name=".activities.MainActivity">
|
||||
android:name=".activities.MainActivity"
|
||||
android:launchMode="singleTask">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
|
@ -193,6 +193,11 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
view_pager.currentItem = getWantedNoteIndex()
|
||||
}
|
||||
|
||||
private fun storeStateVariables() {
|
||||
config.apply {
|
||||
storedEnableLineWrap = enableLineWrap
|
||||
@ -236,17 +241,10 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
private fun initViewPager() {
|
||||
mNotes = dbHelper.getNotes()
|
||||
mCurrentNote = mNotes[0]
|
||||
var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1)
|
||||
if (wantedNoteId == -1) {
|
||||
wantedNoteId = config.currentNoteId
|
||||
}
|
||||
|
||||
val itemIndex = getNoteIndexWithId(wantedNoteId)
|
||||
|
||||
mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this)
|
||||
view_pager.apply {
|
||||
adapter = mAdapter
|
||||
currentItem = itemIndex
|
||||
currentItem = getWantedNoteIndex()
|
||||
addOnPageChangeListener(this@MainActivity)
|
||||
}
|
||||
|
||||
@ -255,6 +253,14 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWantedNoteIndex(): Int {
|
||||
var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1)
|
||||
if (wantedNoteId == -1) {
|
||||
wantedNoteId = config.currentNoteId
|
||||
}
|
||||
return getNoteIndexWithId(wantedNoteId)
|
||||
}
|
||||
|
||||
private fun currentNotesView() = if (view_pager == null) {
|
||||
null
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user