Commit 34895cf0 authored by Inès EL HADRI's avatar Inès EL HADRI 💤

fix click detail screen

parent fab70a91
......@@ -20,15 +20,11 @@ public class DetailScreen extends AppCompatActivity {
Intent intent = this.getIntent();
if (intent != null){
Annonce annonce = intent.getParcelableExtra("annonce");
String titre = intent.getStringExtra("titre");
String adresse = intent.getStringExtra("adresse");
String description = intent.getStringExtra("description");
Double prix = intent.getDoubleExtra("prix",999);
binding.adresseTextView.setText(adresse);
binding.prixTextView.setText(prix.toString()+" €");
binding.adresseTextView.setText(annonce.getAdresse());
binding.prixTextView.setText( Double.toString(annonce.getPrix()) + " €");
binding.imageView.setImageResource(R.drawable.ic_account_circle_black_24dp);
binding.descriptionTextView4.setText(description);
binding.descriptionTextView4.setText(annonce.);
binding.titreTextView.setText(titre);
}
}
......
......@@ -23,9 +23,8 @@ import java.util.ArrayList;
public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
private static final String TAG = "CustomAdapter";
private ArrayList<Annonce> mDataSet;
private static ArrayList<Annonce> mDataSet;
private boolean mIsGrid;
private static Context mContext;
/**
* Provide a reference to the type of views that you are using (custom ViewHolder)
......@@ -33,6 +32,7 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
public static class ViewHolder extends RecyclerView.ViewHolder {
private final TextView titreTextView;
private final TextView adresseTextView;
private final TextView prixTextView;
public ViewHolder(View v) {
super(v);
......@@ -41,9 +41,8 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
@Override
public void onClick(View v) {
// TODO : mettre la page de Donia
Intent detailIntent = new Intent(mContext, DetailScreen.class);
detailIntent.putExtra("titre", titreTextView.getText());
detailIntent.putExtra("adresse", adresseTextView.getText());
Intent detailIntent = new Intent(v.getContext(), DetailScreen.class);
detailIntent.putExtra("annonce", mDataSet.get(getAdapterPosition()));
v.getContext().startActivity(detailIntent);
//detailIntent.putExtra("prix", prix);
Log.d(TAG, "Element " + getAdapterPosition() + " clicked.");
......@@ -51,6 +50,7 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
});
titreTextView = (TextView) v.findViewById(R.id.titre_annonce);
adresseTextView = (TextView) v.findViewById(R.id.adresse_annonce);
prixTextView = (TextView) v.findViewById(R.id.prix_annonce);
}
public TextView getTitreTextView() {
......@@ -59,6 +59,9 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
public TextView getAdresseTextView() {
return adresseTextView;
}
public TextView getPrixTextView() {
return prixTextView;
}
}
/**
......@@ -70,7 +73,6 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder> {
public HomeAdapter(ArrayList<Annonce> dataSet, boolean isGrid, Context context) {
mDataSet = dataSet;
mIsGrid = isGrid;
mContext = context;
}
// Create new views (invoked by the layout manager)
......
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