diff --git a/app/src/main/java/com/edricchan/studybuddy/ui/modules/tips/fragment/TipsFragment.kt b/app/src/main/java/com/edricchan/studybuddy/ui/modules/tips/fragment/TipsFragment.kt index 45a4b61f..4c3adf8d 100644 --- a/app/src/main/java/com/edricchan/studybuddy/ui/modules/tips/fragment/TipsFragment.kt +++ b/app/src/main/java/com/edricchan/studybuddy/ui/modules/tips/fragment/TipsFragment.kt @@ -10,20 +10,23 @@ import android.view.View import android.view.ViewGroup import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment +import androidx.navigation.NavController +import androidx.navigation.fragment.findNavController import com.edricchan.studybuddy.BuildConfig import com.edricchan.studybuddy.R import com.edricchan.studybuddy.constants.Constants import com.edricchan.studybuddy.databinding.FragTipsBinding -import com.edricchan.studybuddy.exts.androidx.fragment.startActivity import com.edricchan.studybuddy.exts.androidx.preference.defaultSharedPreferences import com.edricchan.studybuddy.exts.androidx.viewbinding.viewInflateBinding -import com.edricchan.studybuddy.ui.modules.debug.DebugActivity -import com.edricchan.studybuddy.ui.modules.settings.SettingsActivity +import com.edricchan.studybuddy.navigation.compat.navigateToDebug +import com.edricchan.studybuddy.navigation.compat.navigateToSettings import com.edricchan.studybuddy.utils.web.launchUri class TipsFragment : Fragment() { private var preferences: SharedPreferences? = null + private lateinit var navController: NavController + private val binding by viewInflateBinding(FragTipsBinding::inflate) private val menuProvider = object : MenuProvider { @@ -41,12 +44,12 @@ class TipsFragment : Fragment() { override fun onMenuItemSelected(item: MenuItem) = when (item.itemId) { R.id.action_debug -> { - startActivity() + navController.navigateToDebug() true } R.id.action_settings -> { - startActivity() + navController.navigateToSettings() true } @@ -58,6 +61,8 @@ class TipsFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) preferences = requireContext().defaultSharedPreferences + + navController = findNavController() activity?.addMenuProvider(menuProvider) }