Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchtabian committed Mar 24, 2020
1 parent 94172fe commit 483ad95
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.codingwithmitch.openapi.ui.auth

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
Expand All @@ -27,11 +29,15 @@ constructor(

lateinit var uiCommunicationListener: UICommunicationListener

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupChannel()
}

private fun setupChannel() = viewModel.setupChannel()

override fun onAttach(context: Context) {
super.onAttach(context)
setupChannel()
try{
uiCommunicationListener = context as UICommunicationListener
}catch(e: ClassCastException){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ constructor(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupActionBarWithNavController(R.id.accountFragment, activity as AppCompatActivity)
setupChannel()
}

private fun setupChannel() = viewModel.setupChannel()
Expand All @@ -51,7 +52,6 @@ constructor(

override fun onAttach(context: Context) {
super.onAttach(context)
setupChannel()
try{
uiCommunicationListener = context as UICommunicationListener
}catch(e: ClassCastException){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package com.codingwithmitch.openapi.ui.main.account
import android.os.Bundle
import android.util.Log
import android.view.*
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.codingwithmitch.openapi.R
import com.codingwithmitch.openapi.models.AccountProperties
import com.codingwithmitch.openapi.ui.main.account.state.ACCOUNT_VIEW_STATE_BUNDLE_KEY
Expand Down Expand Up @@ -59,6 +57,7 @@ constructor(
viewModel.stateMessage.observe(viewLifecycleOwner, Observer { stateMessage ->

stateMessage?.let {

uiCommunicationListener.onResponseReceived(
response = it.response,
stateMessageCallback = object: StateMessageCallback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ constructor(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupActionBarWithNavController(R.id.blogFragment, activity as AppCompatActivity)

setupChannel()
}


Expand All @@ -56,7 +56,6 @@ constructor(

override fun onAttach(context: Context) {
super.onAttach(context)
setupChannel()
try{
uiCommunicationListener = context as UICommunicationListener
}catch(e: ClassCastException){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ constructor(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupActionBarWithNavController(R.id.createBlogFragment, activity as AppCompatActivity)
setupChannel()
}

private fun setupChannel() = viewModel.setupChannel()
Expand All @@ -51,7 +52,6 @@ constructor(

override fun onAttach(context: Context) {
super.onAttach(context)
setupChannel()
try{
uiCommunicationListener = context as UICommunicationListener
}catch(e: ClassCastException){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ class SuccessHandling {
const val SUCCESS_BLOG_DELETED = "deleted"
const val SUCCESS_BLOG_UPDATED = "updated"



}
}

0 comments on commit 483ad95

Please sign in to comment.