Commit adb3da61 authored by Tristan's avatar Tristan
Browse files

V4 Tristan Insh c'est l'ultilme

parent 8a8d1683
......@@ -15,28 +15,46 @@ import com.example.wastedfood.models.IngredientItem;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
public class MonFrigo extends AppCompatActivity {
public final ServeurBDD BDD = new ServeurBDD(this);;
private Button ajouter_ingredient;
private ListView listView;
private String ingredient, date;
private HashMap<String,String> map;
private IngredientItem ingredientItem = new IngredientItem();
private static ServeurBDD serveurBDD;
private List<IngredientItem> list;
private int i=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mon_frigo);
//list ingrédient
listView = findViewById(R.id.ingredient_list_view);
BDD.open();
Bundle extras = getIntent().getExtras();
if(BDD.getServeurs() !=null){
list=BDD.getServeurs();
while(list.get(i) !=null) {
ingredientItem = list.get(i);
map = new HashMap<String,String>();
map.put("ingrédient",ingredientItem.getName());
map.put("date",ingredientItem.getDate());
ingredientItem.valeurs.add(map);
}
}
if(extras!=null)
{
ingredient = extras.getString("ingrédient");
date = extras.getString("date");
map = new HashMap<String,String>();
BDD.insererIng(ingredient,date);
map.put("ingrédient",ingredient);
map.put("date",date);
ingredientItem.valeurs.add(map);
......
......@@ -38,12 +38,12 @@ public class ServeurBDD
return bdd;
}
public long insererIng(IngredientItem serveur)
public long insererIng(String a,String b)
{
ContentValues values = new ContentValues();
values.put(ServeurSQL.COL_NOM, serveur.getName());
values.put(ServeurSQL.COL_DATE_PER, serveur.getDate());
values.put(ServeurSQL.COL_NOM, a);
values.put(ServeurSQL.COL_DATE_PER, b);
return bdd.insert(ServeurSQL.TABLE_SERVEURS, null, values);
}
......
Supports Markdown
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