}
}
}
override fun onMyClick(position: Int, lectures: Lectures) {
if (position == 0) {
findNavController().navigate(R.id.infoFragment)
} else if (position == 1) {
findNavController().navigate(R.id.lcturesFragment)
} else if (position == 2) {
findNavController().navigate(R.id.laboratoriesFragment)
} else if (position == 3) {
findNavController().navigate(R.id.manualFragment)
} else {
findNavController().navigate(R.id.testFragment)
}
}
override fun onClick(position: Int, lectures: Lectures) {
if (position == 0) {
val info = MySharedPreferences.loadData2("ali1")
if (info.name == null) {
findNavController().navigate(R.id.infoFragment)
} else {
val bundle = bundleOf("info" to info)
findNavController().navigate(R.id.dataFragment, bundle)
}
} else if (position == 1) {
val info = MySharedPreferences.loadData2("ali2")
if (info.name == null) {
findNavController().navigate(R.id.lcturesFragment)
} else {
val bundle = bundleOf("info" to info)
findNavController().navigate(R.id.dataFragment, bundle)
}
} else if (position == 2) {
val info = MySharedPreferences.loadData2("ali")
if (info.name == null) {
findNavController().navigate(R.id.laboratoriesFragment)
} else {
val bundle = bundleOf("info" to info)
findNavController().navigate(R.id.dataFragment, bundle)
}
} else if (position == 3) {
findNavController().navigate(R.id.manualFragment)
} else {
findNavController().navigate(R.id.testFragment)
}
}
}
package com.example.computergraphics
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.computergraphics.adapters.InfoAdapter
import com.example.computergraphics.databinding.FragmentInfoBinding
import com.example.computergraphics.utils.Info
import android.widget.ImageView
import android.widget.Toast
import androidx.core.os.bundleOf
import androidx.navigation.fragment.findNavController
import com.example.computergraphics.adapters.OnMyClickListener1
import com.example.computergraphics.db.MyDbHelper
import com.example.computergraphics.utils.MySharedPreferences
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"
/**
* A simple [Fragment] subclass.
* Use the [InfoFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class InfoFragment : Fragment(), OnMyClickListener1 {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
Do'stlaringiz bilan baham: |