Commit 217a8f2f authored by MAQUIGNON Alexis's avatar MAQUIGNON Alexis
Browse files

deuxième commit

parent 7bfcfe06
package com.example.wastedfood;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.example.wastedfood.adapters.RecetteItemAdapter;
import com.example.wastedfood.models.RecetteItem;
import java.util.ArrayList;
import java.util.List;
public class Recette_Informations extends AppCompatActivity {
TextView recetteName;
// int position;
// RecetteItem recetteItem = new RecetteItem();
private TextView recetteName;
private ImageView itemIconView;
private Context context;
private TextView recetteEtape;
private TextView recetteIngredients;
@Override
......@@ -24,11 +29,37 @@ public class Recette_Informations extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recette__informations);
recetteName = findViewById(R.id.recette_name);
recetteName = (TextView)findViewById(R.id.recette_name);
Intent intent = getIntent();
itemIconView = (ImageView)findViewById(R.id.recette_icon);
recetteEtape = (TextView)findViewById(R.id.recette_etape);
recetteIngredients = (TextView)findViewById(R.id.recette_ingredients);
SimpleAdapter adapter = new SimpleAdapter(Recette_Informations.this, RecetteItem.valeurs, R.layout.activity_recette__informations,
//Titre
String Title = intent.getExtras().getString("name");
recetteName.setText(Title);
//Photo
String tagPhoto =intent.getExtras().getString("tagPhoto");
String resourceName = "item_" + tagPhoto + "_icon";
int resId = getResources().getIdentifier(resourceName,"drawable",getPackageName());
itemIconView.setImageResource(resId);
//étape
String etape = intent.getExtras().getString("etape");
recetteEtape.setText(etape);
//Ingrédients
// ArrayList<String> Ingredients = intent.getExtras().getStringArrayList("ingredientsList");
//recetteIngredients.setText((CharSequence) Ingredients);
/* SimpleAdapter adapter = new SimpleAdapter(Recette_Informations.this, RecetteItem.valeurs, R.layout.activity_recette__informations,
new String[]{"ingrédient"}, new int[]{R.id.recette_name});
recetteName.setText((CharSequence) adapter);
recetteName.setText((CharSequence) adapter);*/
}
......
......@@ -18,9 +18,25 @@ public class Recettes extends AppCompatActivity {
setContentView(R.layout.activity_recettes);
//list recettes
/*List<String> omelette_ingredientList = new ArrayList<>();
omelette_ingredientList.add("Oeufs");
omelette_ingredientList.add("Herbes");
List<String> Cr_monsieur_ingredientList = new ArrayList<>();
omelette_ingredientList.add("Pain_de_mie");
omelette_ingredientList.add("Jambon");
omelette_ingredientList.add("Fromage");*/
List<RecetteItem> recetteItemList = new ArrayList<>();
recetteItemList.add(new RecetteItem("Croque-Monsieur","croque","Facile"));
recetteItemList.add(new RecetteItem("Omelette","omelette","Facile"));
recetteItemList.add(new RecetteItem("Croque-Monsieur","croque","Facile",
"tartiner un peu de beurre sur 2 tranches de pain de mie\n" +
"mettre une tranche de jambon\n" +
"mettre une tranche de fromage"));
recetteItemList.add(new RecetteItem("Omelette","omelette","Facile","2 cuillères à café d'huile d'olive\n" +
"50g de beurres\n" +
"3 oeufs"));
//get list view
ListView recettesListView = findViewById(R.id.recette_list_view);
......
......@@ -2,6 +2,7 @@ package com.example.wastedfood.adapters;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -14,6 +15,8 @@ import com.example.wastedfood.R;
import com.example.wastedfood.Recette_Informations;
import com.example.wastedfood.models.RecetteItem;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class RecetteItemAdapter extends BaseAdapter {
......@@ -55,6 +58,8 @@ public class RecetteItemAdapter extends BaseAdapter {
String itemName = itemCourant.getName();
String tagPhoto = itemCourant.getTagPhoto();
String itemLevel = itemCourant.getLevel();
String itemEtape = itemCourant.getEtape();
//ArrayList<String> itemIngredients = (ArrayList<String>) itemCourant.getIngredients();
//get item icon view
ImageView itemIconView = convertView.findViewById(R.id.recette_icon);
......@@ -74,8 +79,14 @@ public class RecetteItemAdapter extends BaseAdapter {
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent otherActivity = new Intent(context.getApplicationContext(), Recette_Informations.class);
context.startActivity(otherActivity);
Intent intent= new Intent(context.getApplicationContext(), Recette_Informations.class);
intent.putExtra("name",recetteItemList.get(position).getName());
intent.putExtra("tagPhoto",recetteItemList.get(position).getTagPhoto());
intent.putExtra("etape",recetteItemList.get(position).getEtape());
// intent.putExtra("ingredientsList", recetteItemList.get(position).getIngredients());
context.startActivity(intent);
}
});
......
......@@ -2,6 +2,7 @@ package com.example.wastedfood.models;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RecetteItem {
......@@ -9,12 +10,16 @@ public class RecetteItem {
private String name;
private String tagPhoto;
private String level;
private String etape;
//private List<String> ingredientsList;
// Constructeur
public RecetteItem(String name, String tagPhoto, String level){
public RecetteItem(String name, String tagPhoto, String level, String etape){
this.name = name;
this.tagPhoto = tagPhoto;
this.level = level;
this.etape = etape;
// this.ingredientsList = ingredientsList;
}
// methods
......@@ -28,5 +33,9 @@ public class RecetteItem {
return level;
}
public static ArrayList<HashMap<String,String>> valeurs = new ArrayList<HashMap<String, String>>();
public String getEtape() { return etape; }
//public List<String> getIngredients() { return ingredientsList; }
//public static ArrayList<HashMap<String,String>> valeurs = new ArrayList<HashMap<String, String>>();
}
......@@ -8,14 +8,66 @@
android:padding="20dp"
tools:context=".Recette_Informations">
<ImageView
android:id="@+id/recette_icon"
android:layout_width="match_parent"
android:layout_height="100dp"
android:src="@drawable/item_croque_icon" />
<TextView
android:id="@+id/recette_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:text="@string/recette_default_name"
android:gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:layout_marginTop="20dp"
android:textAlignment="textStart"
android:text="Ingrédients:"
android:gravity="center_horizontal"
tools:ignore="RtlCompat" />
<TextView
android:id="@+id/recette_ingredients"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13dp"
android:layout_marginTop="20dp"
android:textAlignment="textStart"
android:layout_marginLeft="20dp"
android:text="@string/recette_default_ingredients"
android:gravity="center_horizontal"
tools:ignore="RtlCompat" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:layout_marginTop="20dp"
android:textAlignment="textStart"
android:text="Etape:"
android:gravity="center_horizontal"
tools:ignore="RtlCompat" />
<TextView
android:id="@+id/recette_etape"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13dp"
android:layout_marginTop="20dp"
android:textAlignment="textStart"
android:layout_marginLeft="20dp"
android:text="@string/recette_default_etape"
android:gravity="center_horizontal"
tools:ignore="RtlCompat" />
</LinearLayout>
\ No newline at end of file
......@@ -5,8 +5,8 @@
<ImageView
android:id="@+id/recette_icon"
android:layout_width="175dp"
android:layout_height="126dp"
android:layout_width="200dp"
android:layout_height="100dp"
android:src="@drawable/item_croque_icon" />
<RelativeLayout
......@@ -18,6 +18,7 @@
android:id="@+id/recette_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:textColor="@color/black"
android:text="@string/recette_default_name"/>
......@@ -28,6 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:textColor="@color/black"
android:text="@string/recette_default_dif"
android:layout_below="@id/recette_name"/>
......
......@@ -2,4 +2,6 @@
<string name="app_name">Wasted Food</string>
<string name="recette_default_name">Nom de la recette</string>
<string name="recette_default_dif">Difficulté de la recette</string>
<string name="recette_default_etape">Etape de la recette</string>
<string name="recette_default_ingredients">Ingrédients recette</string>
</resources>
\ No newline at end of file
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