Skip to content

Commit

Permalink
implementation changed as per new modification of connectionLD
Browse files Browse the repository at this point in the history
  • Loading branch information
pravinyo committed Apr 25, 2020
1 parent 3ddd4c6 commit e3f083b
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class MainActivity : BaseActivity() {
"bookName" to lastPlayedTrack.bookName,
"trackNumber" to lastPlayedTrack.position)

connectionListener.value?.let { connected->
if(connected){
connectionListener.value?.let { connectedEvent->
if(connectedEvent.peekContent()){
Navigation.findNavController(this,R.id.navHostFragment)
.navigate(com.allsoftdroid.feature_book.R.id.action_AudioBookListFragment_to_AudioBookDetailsFragment,bundle)
mainActivityViewModel.clearSharedPref()
Expand All @@ -121,7 +121,7 @@ class MainActivity : BaseActivity() {
mainActivityViewModel.bindAudioService()

connectionListener.observe(this, Observer {isConnected ->
showNetworkMessage(isConnected)
showNetworkMessage(isConnected.peekContent())
})

Timber.d("Main Activity start")
Expand All @@ -134,11 +134,15 @@ class MainActivity : BaseActivity() {

mainActivityViewModel.playerEvent.observeForever {
it.getContentIfNotHandled()?.let {audioPlayerEvent ->
connectionListener.value?.let { isConnected ->
Timber.d("Event is new and is being handled")
if(!isConnected) Toast.makeText(this,"Please Connect to Internet",Toast.LENGTH_SHORT).show()
performAction(audioPlayerEvent)
}

// connectionListener.value?.let { isConnectedEvent ->
// isConnectedEvent.getContentIfNotHandled()?.let {isConnected ->
// if(!isConnected) Toast.makeText(this,"Please Connect to Internet",Toast.LENGTH_SHORT).show()
// }
// }

Timber.d("Event is new and is being handled")
performAction(audioPlayerEvent)
}
}

Expand Down

0 comments on commit e3f083b

Please sign in to comment.