}//itemdagi bosilishni eshtib oldik va viewmodelga berib yubordik
adapter.setRootListener {//adapterdagi item bosilishini sezuvchi metod
val bundle = Bundle()//bundle obektini ozgaruvchiga saqladik
bundle.putSerializable("word", it)//malumotni it korinishida berdik
preventTwoClick(requireView())//malumotni keyingi oynaga bundle qilib berib yubordik , va ikki marta bosilishni oldini oldik
findNavController().navigate(R.id.action_homeFragment_to_wordMeaningFragment, bundle)//jeetpack navigation orqali bir oynadan boshqa oynaga o`tdik
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {//ko`rinishni obektini yaratdik ya`ni viewni yaratdik , bu onViewCreated metodini qayta yosish orqali amalga oshiriladi , endi bu iynada barcha kodlarimizni yozishda davom ettira olamiz.
binding.imgMenu.setOnClickListener {//xml dagi knopkani bosilishini eshtish
binding.drawerLayout.openDrawer(GravityCompat.START)//drawerlayoutni start qildik
}
binding.navigationView.setNavigationItemSelectedListener {//drawerni ishga tushurish jarayoni
when (it.itemId) {//Bu kotlinda when javada switch case vazifasini bajaradi
R.id.about ->//about knopkasini bosilishi
{ findNavController().navigate(HomeScreenDirections.actionHomeFragmentToAboutScreen())
//about oynasiga o`tish
binding.drawerLayout.closeDrawer(GravityCompat.START)
} binding.drawerLayout.closeDrawer(GravityCompat.START){//drawerni ishga tushurish jarayoni
findNavController().navigate(HomeScreenDirections.actionHomeFragmentToSavedWordFragment())//qidiruv oynasiga o`tish
}
R.id.exit_app -> {//chiqish knopkasini bosilishini sezish
requireActivity().finish()//activitiyni finish qildik
}//ilovadan chiqib ketish
}
return@setNavigationItemSelectedListener true//operatsiya bajarilishi haqidagi elon
Do'stlaringiz bilan baham: |