Skip to content

Instantly share code, notes, and snippets.

@kaszabimre
Created July 17, 2020 10:35
Show Gist options
  • Save kaszabimre/db3015c1367110d80976f36304da641d to your computer and use it in GitHub Desktop.
Save kaszabimre/db3015c1367110d80976f36304da641d to your computer and use it in GitHub Desktop.
Update MainMenuFragment again
@AndroidEntryPoint
class MainMenuFragment : Fragment() {
// @Inject
// lateinit var viewModelFactory: ViewModelProvider.Factory
@Inject
lateinit var notificationManager: NotificationManager
// private val viewModel = viewModels<MainMenuViewModel>(factoryProducer = { viewModelFactory })
private val viewModel: MainMenuViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_main, container, false)
val textView = view.findViewById<TextView>(R.id.text)
// viewModel.value.textValue.asFlow()
viewModel.textValue.asFlow()
.onEach { text ->
textView.text = text
createNotification(text)
}
.launchIn(viewLifecycleOwner.lifecycleScope)
return view
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment