Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @AndroidEntryPoint
- class ProfileFragment : Fragment() {
- @Inject
- lateinit var repository: GirlsRepositoryImpl
- private var _binding: FragmentProfileBinding? = null
- private val binding get() = _binding!!
- private val viewModel by viewModels<ProfileViewModel>()
- private lateinit var name: String
- private lateinit var birthday: String
- private lateinit var info: String
- private lateinit var busyness: String
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- _binding = FragmentProfileBinding.inflate(inflater, container, false)
- return binding.root
- }
- @SuppressLint("TimberArgCount")
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- initView()
- subscribeToObservables()
- /* var user: UserEntity = repository.getUserFromDb()
- binding.apply {
- currentNameUser.setText(user?.name)
- currentBirthdayDate.text = user?.birthdayDate
- currentUserInfo.setText(user?.info)
- currentUserBusyness.setText(user?.busyness)
- }*/
- }
- private fun subscribeToObservables() {
- viewModel.user2.observe(viewLifecycleOwner, {
- Timber.e("subscribeToObservables name = ${it?.name} info = ${it?.info} img = ${it.imageUrl}")
- binding.apply {
- name = checkNotNull(it.name)
- info = it.info
- birthday = it.birthdayDate
- busyness = it.busyness
- currentNameUser.setText(it?.name)
- currentBirthdayDate.text = it?.birthdayDate
- currentUserInfo.setText(it?.info)
- currentUserBusyness.setText(it?.busyness)
- }
- })
- }
- private fun initView() {
- binding.pickImage.setOnClickListener {
- pickImage.launch(MIMETYPE_IMAGES)
- }
- binding.apply {
- currentNameUser.afterTextChanged { name ->
- Timber.e("currentNameUser.afterTextChanged ")
- viewModel.updateUser2(
- UserEntity(
- name = name,
- info = info,
- birthdayDate = birthday,
- busyness = busyness,
- imageUrl = imageUri
- )
- )
- }
- currentUserBusyness.afterTextChanged { busyness ->
- Timber.e("currentUserBusyness.afterTextChanged ")
- viewModel.updateUser2(
- UserEntity(
- name = name,
- info = info,
- birthdayDate = birthday,
- busyness = busyness,
- imageUrl = imageUri
- )
- )
- }
- currentUserInfo.afterTextChanged { info ->
- Timber.e("currentUserInfo.afterTextChanged ")
- viewModel.updateUser2(
- UserEntity(
- name = name,
- info = info,
- birthdayDate = birthday,
- busyness = busyness,
- imageUrl = imageUri
- )
- )
- }
- }
- }
- override fun onDestroy() {
- super.onDestroy()
- _binding = null
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement