Códico aparentemente igual ao da aula
package br.com.alura.orgs.ui.activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import br.com.alura.orgs.R
import br.com.alura.orgs.model.Product
import br.com.alura.orgs.ui.listadeprodutos.adapter.ListaProdutosAdapter
import com.google.android.material.floatingactionbutton.FloatingActionButton
import java.math.BigDecimal
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val recyclerView = findViewById<RecyclerView>(R.id.recyclerview)
recyclerView.adapter = ListaProdutosAdapter(
context = this, listOf(
Product(
nome = "Teste",
descricao = "Teste desc",
valor = BigDecimal("19.9")
),
Product(
nome = "Teste 1",
descricao = "Teste desc 1",
valor = BigDecimal("29.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
Product(
nome = "Teste 2",
descricao = "Teste desc 2",
valor = BigDecimal("39.9")
),
)
)
val fab = findViewById<FloatingActionButton>(R.id.floatingActionButton)
fab.setOnClickListener {
val intent = Intent(this, ProductFormActivity::class.java)
startActivity(intent)
}
}
}