Commit 44cc7624 authored by m-spi's avatar m-spi

On fait quelque progrès...

parent 16ad45d7
......@@ -77,6 +77,7 @@ private constructor(private val context: Context) {
contentValue.put(DBHelper.TITLE, ad.title)
contentValue.put(DBHelper.ADDRESS, ad.address)
contentValue.put(DBHelper.IMAGE, ad.image)
contentValue.put(DBHelper.PRIX, ad.prix)
this.database!!.insert(DBHelper.TABLE_NAME, null, contentValue)
}
......
......@@ -3,6 +3,7 @@ package com.example.elbuenopeso.ui.market
import AdAdapter
import android.database.Cursor
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -38,30 +39,29 @@ class MarketFragment : Fragment() {
val listView: ListView = binding.listView
// seed market items
// var annonces: List<AdModel> = listOf<AdModel>(
// AdModel("Poutre", "1 rue Jean-Pierre", "drawable/pichu.png", 25.0),
// AdModel("Briques", "2 rue Jean-Michel", "drawable/pichu.png", 16.0),
// AdModel("Mur en bois", "4 rue Alain-Juju", "drawable/pichu.png", 7.2),
// AdModel("Maison de pierre", "7 rue Joris Belhomme", "drawable/pichu.png", 3.99),
// AdModel("Téléphone de Timothé", "8 rue de Timothé", "drawable/pichu.png", 0.85),
// AdModel("Oridnateur", "10 rue Jean-Charles", "drawable/pichu.png", 104.98),
// AdModel("Charnières", "22 rue Jeanne-Marie", "drawable/pichu.png", 2648.97),
// AdModel("Porte en marbre", "1 rue Jean-Pierre", "drawable/pichu.png", 480.0),
// AdModel("Cheminée", "33 rue du Gouvernement", "drawable/pichu.png", 800.0),
// )
//
// val adAdapter: AdAdapter = AdAdapter(requireContext(), annonces)
// listView.adapter = adAdapter
var annonces: List<AdModel> = listOf<AdModel>(
AdModel("Poutre", "1 rue Jean-Pierre", "drawable/pichu.png", 25.0),
AdModel("Briques", "2 rue Jean-Michel", "drawable/pichu.png", 16.0),
AdModel("Mur en bois", "4 rue Alain-Juju", "drawable/pichu.png", 7.2),
AdModel("Maison de pierre", "7 rue Joris Belhomme", "drawable/pichu.png", 3.99),
AdModel("Téléphone de Timothé", "8 rue de Timothé", "drawable/pichu.png", 0.85),
AdModel("Oridnateur", "10 rue Jean-Charles", "drawable/pichu.png", 104.98),
AdModel("Charnières", "22 rue Jeanne-Marie", "drawable/pichu.png", 2648.97),
AdModel("Porte en marbre", "1 rue Jean-Pierre", "drawable/pichu.png", 480.0),
AdModel("Cheminée", "33 rue du Gouvernement", "drawable/pichu.png", 800.0),
)
/*marketViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}*/
var dbManager: DBManager? = DBManager.getDBManager(requireContext());
dbManager = dbManager!!.open();
val cursor = dbManager.fetch();
val adapter = DbAdapter(requireContext(), cursor!!, R.layout.fragment_market);
adapter.notifyDataSetChanged();
listView.adapter = adapter;
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.fragment_market)
adapter.notifyDataSetChanged()
listView.adapter = adapter
return root
}
......
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