Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
2020-04-28 Version 4.1.1: Fixed navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
fartem committed Apr 28, 2020
1 parent a50b598 commit 24bdf98
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class MainActivity : AppCompatActivity() {
supportFragmentManager.addOnBackStackChangedListener(
fragmentsStack
)
showNotesListFragment()
}

fun showNotesListFragment() {
showBaseFragment(
NotesListFragment()
)
}

fun authComplete() {
onBackPressed()
}

fun showAuthFragment() {
showBaseFragment(
CloudAuthFragment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class BaseFragment : Fragment() {
setHasOptionsMenu(true)
}

fun resume() {
open fun resume() {
(activity as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(
showHomeAsUpEnabled()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface NotesListPresenter {
success: Boolean
)

fun authChanged()
fun handleAuthRequest()

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class NotesListPresenterImpl : NotesListPresenter {

notes.addAll(dataRepository.allNotes())
this.notesListView.refreshNotesList(notes)
if (this.cloudAuth.isAuthorized()) {
this.notesListView.setAuthenticated()
} else {
this.notesListView.setUnauthenticated()
}
}

override fun shareNotes() {
Expand Down Expand Up @@ -92,6 +87,14 @@ class NotesListPresenterImpl : NotesListPresenter {
}
}

override fun authChanged() {
if (cloudAuth.isAuthorized()) {
notesListView.setAuthenticated()
} else {
notesListView.setUnauthenticated()
}
}

override fun handleAuthRequest() {
if (cloudAuth.isAuthorized()) {
cloudAuth.logOut {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CloudAuthFragment : BaseFragment(), CloudAuthView {
}

override fun authSuccess() {
(activity as MainActivity).showNotesListFragment()
(activity as MainActivity).authComplete()
}

override fun authError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class NotesListFragment : BaseFragment(), NotesListView,
}
}

override fun resume() {
super.resume()
notesListPresenter.authChanged()
}

override fun showHomeAsUpEnabled(): Boolean {
return false
}
Expand Down Expand Up @@ -142,7 +147,7 @@ class NotesListFragment : BaseFragment(), NotesListView,
}

override fun setAuthenticated() {
if (getMenu() == null) {
if (getMenu()?.findItem(R.id.menu_auth_action) == null) {
menuInitTasks.add(object : MenuTask {
override fun execute() {
validateAuthMenuIcon(true)
Expand All @@ -154,7 +159,7 @@ class NotesListFragment : BaseFragment(), NotesListView,
}

override fun setUnauthenticated() {
if (getMenu() == null) {
if (getMenu()?.findItem(R.id.menu_auth_action) == null) {
menuInitTasks.add(object : MenuTask {
override fun execute() {
validateAuthMenuIcon(false)
Expand Down

0 comments on commit 24bdf98

Please sign in to comment.