Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/src/main/java/io/plaidapp/ui/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class HomeActivity : AppCompatActivity() {
private lateinit var loading: ProgressBar
private lateinit var feedAdapter: FeedAdapter
private lateinit var filtersList: RecyclerView
private lateinit var mDesignerNewsLogin: MenuItem

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use m prefix.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I recommend not to hold on to the item in the activity scope.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your suggestion


// data
@Inject
Expand Down Expand Up @@ -439,8 +440,7 @@ class HomeActivity : AppCompatActivity() {
}

override fun onPrepareOptionsMenu(menu: Menu): Boolean {
menu.findItem(R.id.menu_designer_news_login)
.setTitle(
mDesignerNewsLogin.setTitle(
if (viewModel.isDesignerNewsUserLoggedIn()) {
R.string.designer_news_log_out
} else {
Expand All @@ -450,6 +450,12 @@ class HomeActivity : AppCompatActivity() {
return true
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.main,menu)
mDesignerNewsLogin = menu!!.findItem(R.id.menu_designer_news_login)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use !! where it can be avoided.
In this case, checking whether menu is not null is valid.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your suggestion

return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.menu_filter -> {
Expand Down