fix #30, hide the fab when keyboard is shown

This commit is contained in:
tibbi 2016-11-21 19:30:08 +01:00
parent 53be83418b
commit e50c4f600f

View File

@ -38,9 +38,16 @@ class MainActivity : SimpleActivity(), OpenNoteDialog.OpenNoteListener {
mDb = DBHelper.newInstance(applicationContext)
mNotes = mDb.getNotes()
updateSelectedNote(config.currentNoteId)
notes_fab.setOnClickListener { displayNewNoteDialog() }
notes_fab.viewTreeObserver.addOnGlobalLayoutListener {
val heightDiff = notes_coordinator.rootView.height - notes_coordinator.height
notes_fab.visibility = if (heightDiff > dpToPx(this, 200f)) View.INVISIBLE else View.VISIBLE
}
}
fun dpToPx(context: Context, valueInDp: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, valueInDp, context.resources.displayMetrics)
override fun onResume() {
super.onResume()
invalidateOptionsMenu()