Fixed long standing options menu issue
*/
package com.github.pockethub.android.ui.comment
-import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.Menu
@@ -35,8 +34,6 @@ import javax.inject.Inject
*/
abstract class CreateCommentActivity : BaseActivity() {
- private var applyItem: MenuItem? = null
-
/**
* Avatar loader
*/
@@ -69,12 +66,6 @@ abstract class CreateCommentActivity : BaseActivity() {
lifecycle.removeObserver(pagerHandler!!)
}
- override fun invalidateOptionsMenu() {
- super.invalidateOptionsMenu()
- applyItem?.isEnabled =
- pagerHandler?.adapter != null && pagerHandler?.adapter!!.commentText.isNotEmpty()
- }
-
/**
* Create comment
*
@@ -119,11 +110,15 @@ abstract class CreateCommentActivity : BaseActivity() {
return CommentPreviewPagerAdapter(this, null)
}
- // For some reason we can't call the super method since that makes invalidateOptionsMenu weird
- @SuppressLint("MissingSuperCall")
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.activity_comment, menu)
- applyItem = menu.findItem(R.id.m_apply)
+ return true
+ }
+
+ override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
+ val applyItem = menu?.findItem(R.id.m_apply)
+ applyItem?.isEnabled =
+ pagerHandler?.adapter != null && pagerHandler?.adapter!!.commentText.isNotEmpty()
return true
}
}
