package com.example.computergraphics
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.navigation.NavigationView
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import androidx.drawerlayout.widget.DrawerLayout
import androidx.appcompat.app.AppCompatActivity
import com.example.computergraphics.databinding.ActivityMainBinding
import com.example.computergraphics.databinding.NavHeaderMainBinding
import com.google.android.material.internal.ContextUtils.getActivity
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.appBarMain.toolbar.title = "Computer Graphics"
setSupportActionBar(binding.appBarMain.toolbar)
val drawerLayout: DrawerLayout = binding.drawerLayout
val navView: NavigationView = binding.navView
val navController = findNavController(R.id.nav_host_fragment_content_main)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(
setOf(
R.id.nav_home, R.id.bookmarksFragment, R.id.helpCenterFragment
), drawerLayout
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
navView.setNavigationItemSelectedListener(object :
NavigationView.OnNavigationItemSelectedListener {
override fun onNavigationItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.rate -> {
Toast.makeText(
this@MainActivity,
"Mazkur funksiya tez orada qo`shiladi :)",
Toast.LENGTH_SHORT
).show()
}
R.id.more -> {
Toast.makeText(
this@MainActivity,
"Mazkur funksiya tez orada qo`shiladi :)",
Toast.LENGTH_SHORT
).show()
}
R.id.send -> {
Toast.makeText(
this@MainActivity,
"Mazkur funksiya tez orada qo`shiladi :)",
Toast.LENGTH_SHORT
).show()
}
R.id.share -> {
Toast.makeText(
this@MainActivity,
"Mazkur funksiya tez orada qo`shiladi :)",
Toast.LENGTH_SHORT
).show()
}
}
return false
}
})
}
override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.nav_host_fragment_content_main)
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
}
package com.example.computergraphics.adapters
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.example.computergraphics.R
import com.example.computergraphics.databinding.ItemInfoBinding
import com.example.computergraphics.utils.Info
class InfoAdapter(var list: ArrayList, var onMyClickListener1: OnMyClickListener1) :
RecyclerView.Adapter() {
private var listener: ((Int) -> Unit)? = null
inner class Vh(var binding: ItemInfoBinding) : RecyclerView.ViewHolder(binding.root) {
fun onBind(info: Info) {
binding.number.text = info.number.toString()
binding.reading.text = info.read
binding.text.text = info.name
binding.imageView.setImageResource(info.image!!)
binding.infoBtn.setOnClickListener {
onMyClickListener1.onMyClick(adapterPosition, info)
Do'stlaringiz bilan baham: |