Skip to content

Commit

Permalink
Fix current category not selected for new notes
Browse files Browse the repository at this point in the history
  • Loading branch information
udenr committed Sep 4, 2024
1 parent e3c4a65 commit 69152ac
Showing 1 changed file with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
if (className == MainFABFragment::class.java.name) {
this@MainActivity.fab = MainFABFragment {
Log.d("Received", "$it")
Intent(
val i = Intent(
application, when (it) {
DbContract.NoteEntry.TYPE_TEXT -> TextNoteActivity::class.java
DbContract.NoteEntry.TYPE_CHECKLIST -> ChecklistNoteActivity::class.java
DbContract.NoteEntry.TYPE_AUDIO -> AudioNoteActivity::class.java
DbContract.NoteEntry.TYPE_SKETCH -> SketchActivity::class.java
else -> throw NotImplementedError("Note of type $it cannot be created")
}
).let { intent -> setCategoryResultAfter.launch(intent) }
)
i.putExtra(BaseNoteActivity.EXTRA_CATEGORY, mainActivityViewModel.getCategory())
setCategoryResultAfter.launch(i)
fab.close()
}
return fab
Expand Down Expand Up @@ -327,25 +329,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
return true
}

/**
* Handles when notes are added.
* @param v
*/
override fun onClick(v: View) {
val intent =
Function { activity: Class<out BaseNoteActivity?>? ->
val i = Intent(application, activity)
i.putExtra(BaseNoteActivity.EXTRA_CATEGORY, mainActivityViewModel.getCategory())
i
}
var i: Intent? = null
when (v.id) {
R.id.fab_text -> i = intent.apply(TextNoteActivity::class.java)
R.id.fab_checklist -> i = intent.apply(ChecklistNoteActivity::class.java)
R.id.fab_audio -> i = intent.apply(AudioNoteActivity::class.java)
R.id.fab_sketch -> i = intent.apply(SketchActivity::class.java)
}
setCategoryResultAfter.launch(i)
}

override fun onPause() {
Expand Down

0 comments on commit 69152ac

Please sign in to comment.