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