Commit 2d98e570 authored by m-spi's avatar m-spi

corec2

parent fa1d8dd1
......@@ -30,7 +30,7 @@ class MarketFragment : Fragment() {
private lateinit var listView: ListView
private lateinit var gridView: GridView
private lateinit var toggleButton: ToggleButton
private lateinit var adAdapter: AdAdapter
private lateinit var adapter: DbAdapter
private var isGridViewEnabled = false
......@@ -51,15 +51,15 @@ class MarketFragment : Fragment() {
val listView: ListView = binding.listView
// seed market items
var annonces: List<AdModel> = listOf<AdModel>(
AdModel("Poutre", "1 rue Jean-Pierre", R.drawable.pichu, 25.0),
AdModel("Briques", "2 rue Jean-Michel", R.drawable.pichu, 16.0),
AdModel("Mur en bois", "4 rue Alain-Juju", R.drawable.pichu, 7.2),
AdModel("Maison de pierre", "7 rue Joris Belhomme", R.drawable.pichu, 3.99),
AdModel("Téléphone de Timothé", "8 rue de Timothé", R.drawable.pichu, 0.85),
AdModel("Oridnateur", "10 rue Jean-Charles", R.drawable.pichu, 104.98),
AdModel("Charnières", "22 rue Jeanne-Marie", R.drawable.pichu, 2648.97),
AdModel("Porte en marbre", "1 rue Jean-Pierre", R.drawable.pichu, 480.0),
AdModel("Cheminée", "33 rue du Gouvernement", R.drawable.pichu, 800.0),
AdModel("Poutre", "1 rue Jean-Pierre", R.drawable.pichu.toString(), 25.0),
AdModel("Briques", "2 rue Jean-Michel", R.drawable.pichu.toString(), 16.0),
AdModel("Mur en bois", "4 rue Alain-Juju", R.drawable.pichu.toString(), 7.2),
AdModel("Maison de pierre", "7 rue Joris Belhomme", R.drawable.pichu.toString(), 3.99),
AdModel("Téléphone de Timothé", "8 rue de Timothé", R.drawable.pichu.toString(), 0.85),
AdModel("Oridnateur", "10 rue Jean-Charles", R.drawable.pichu.toString(), 104.98),
AdModel("Charnières", "22 rue Jeanne-Marie", R.drawable.pichu.toString(), 2648.97),
AdModel("Porte en marbre", "1 rue Jean-Pierre", R.drawable.pichu.toString(), 480.0),
AdModel("Cheminée", "33 rue du Gouvernement", R.drawable.pichu.toString(), 800.0),
)
toggleButton.setOnCheckedChangeListener { _, isChecked ->
......@@ -70,8 +70,7 @@ class MarketFragment : Fragment() {
val dbManager: DBManager? = DBManager.getDBManager(requireContext())
dbManager!!.init()
val cursor = dbManager.fetch()
Log.i(null, cursor?.getColumnName(0).toString())
val adapter = DbAdapter(requireContext(), cursor!!, R.layout.item_listview_ad)
adapter = DbAdapter(requireContext(), cursor!!, R.layout.item_listview_ad)
adapter.notifyDataSetChanged()
listView.adapter = adapter
return root
......@@ -81,11 +80,11 @@ class MarketFragment : Fragment() {
if (isGridViewEnabled) {
listView.visibility = View.GONE
gridView.visibility = View.VISIBLE
gridView.adapter = adAdapter
gridView.adapter = adapter
} else {
gridView.visibility = View.GONE
listView.visibility = View.VISIBLE
listView.adapter = adAdapter
listView.adapter = adapter
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment