mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-18 01:07:23 +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
|
<activity
|
||||||
android:name=".activities.SplashActivity"
|
android:name=".activities.SplashActivity"
|
||||||
|
android:launchMode="singleTask"
|
||||||
android:theme="@style/SplashTheme"/>
|
android:theme="@style/SplashTheme"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.MainActivity">
|
android:name=".activities.MainActivity"
|
||||||
|
android:launchMode="singleTask">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<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() {
|
private fun storeStateVariables() {
|
||||||
config.apply {
|
config.apply {
|
||||||
storedEnableLineWrap = enableLineWrap
|
storedEnableLineWrap = enableLineWrap
|
||||||
@ -236,17 +241,10 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
|||||||
private fun initViewPager() {
|
private fun initViewPager() {
|
||||||
mNotes = dbHelper.getNotes()
|
mNotes = dbHelper.getNotes()
|
||||||
mCurrentNote = mNotes[0]
|
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)
|
mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this)
|
||||||
view_pager.apply {
|
view_pager.apply {
|
||||||
adapter = mAdapter
|
adapter = mAdapter
|
||||||
currentItem = itemIndex
|
currentItem = getWantedNoteIndex()
|
||||||
addOnPageChangeListener(this@MainActivity)
|
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) {
|
private fun currentNotesView() = if (view_pager == null) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user