diff --git a/Lookify/app/src/main/java/com/example/lookifyv2/Results.java b/Lookify/app/src/main/java/com/example/lookifyv2/Results.java
index debf901..6997ed0 100644
--- a/Lookify/app/src/main/java/com/example/lookifyv2/Results.java
+++ b/Lookify/app/src/main/java/com/example/lookifyv2/Results.java
@@ -3,16 +3,24 @@ package com.example.lookifyv2;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import com.bumptech.glide.Glide;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -33,6 +41,8 @@ public class Results extends AppCompatActivity {
private GridLayoutManager gridLayout;
private ProductsAdapter adapter;
String decodedCode;
+ Button button_favourite;
+ Button button_details;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -43,24 +53,6 @@ public class Results extends AppCompatActivity {
products = new ArrayList<>();
getProductsFromDB(0);
- Bundle extras = getIntent().getExtras();
- decodedCode = extras.getString("decodedcode");
-
- int foundPosition = -1;
- for(int i = 0; i < products.size(); i++){
- if(decodedCode.equals(products.get(i).getproductCode())){
- foundPosition = i;
- break;
- }
- }
- if(foundPosition == -1){
- Intent intent_DecodeFail = new Intent(this, DecodeFail.class);
- startActivity(intent_DecodeFail);
- finish();
- }
-
-
-
gridLayout = new GridLayoutManager(this, 2);
recyclerView.setLayoutManager(gridLayout);
@@ -117,10 +109,81 @@ public class Results extends AppCompatActivity {
@Override
protected void onPostExecute(Void aVoid) {
adapter.notifyDataSetChanged();
+
+ /*
+ Bundle extras = getIntent().getExtras();
+ decodedCode = extras.getString("decodedcode");
+
+ int foundPosition = -1;
+ for(int i = 0; i < products.size(); i++){
+ if(decodedCode.equals(products.get(i).getproductCode())){
+ foundPosition = i;
+ break;
+ }
+ }
+ if(foundPosition == -1){
+ Intent intent_DecodeFail = new Intent(this, DecodeFail.class);
+ startActivity(intent_DecodeFail);
+ finish();
+ }
+ */
+
+ int foundPosition = 1; //TESTESTSRETSTETSTETT
+
+ ImageView imageView = findViewById(R.id.foundproductimage);
+ TextView foundProductPrice = findViewById(R.id.foundproductprice);
+ TextView foundProductName = findViewById(R.id.foundproductname);
+ TextView getFoundProductRetailer = findViewById(R.id.foundproductretailer);
+
+ Glide.with(Results.this).load(products.get(foundPosition).getImageLink()).into(imageView);
+ foundProductPrice.setText(products.get(foundPosition).getproductPrice());
+ foundProductName.setText(products.get(foundPosition).getproductName());
+ getFoundProductRetailer.setText(products.get(foundPosition).getproductRetailer());
+
+ button_favourite = findViewById(R.id.favourite_button);
+ button_details = findViewById(R.id.details_button);
+
+ final int finalFoundPosition = foundPosition;
+ button_favourite.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ addFavourite(Results.this, finalFoundPosition);
+ }
+ });
+ button_details.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ openDetails(finalFoundPosition);
+ }
+ });
}
};
asyncTask.execute(id);
}
+ public void openDetails(int position){
+ Intent intent_Details = new Intent(this, Popup.class);
+
+ Bundle bundle = new Bundle();
+
+ bundle.putSerializable("productimage", products.get(position).getImageLink());
+ bundle.putSerializable("productcode", products.get(position).getproductCode());
+ bundle.putSerializable("productname", products.get(position).getproductName());
+ bundle.putSerializable("productprice", products.get(position).getproductPrice());
+ bundle.putSerializable("productretailer", products.get(position).getproductRetailer());
+ bundle.putSerializable("productcolour", products.get(position).getproductColour());
+ bundle.putSerializable("productstyle", products.get(position).getproductStyle());
+ bundle.putSerializable("productcollection", products.get(position).getproductCollection());
+
+ intent_Details.putExtras(bundle);
+
+ startActivity(intent_Details);
+ }
+
+ public void addFavourite(Context context, int position){
+ Toast.makeText(context, "Produkt \"" + products.get(position).getproductName() + "\" został dodany do obserwowanych",
+ Toast.LENGTH_SHORT).show();
+ }
+
}
diff --git a/Lookify/app/src/main/res/layout/activity_results.xml b/Lookify/app/src/main/res/layout/activity_results.xml
index d77326d..7506ef6 100644
--- a/Lookify/app/src/main/res/layout/activity_results.xml
+++ b/Lookify/app/src/main/res/layout/activity_results.xml
@@ -8,40 +8,110 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools">
-
+ android:layout_height="match_parent"
+ android:layout_weight="0.8">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_height="match_parent"
+ android:layout_weight="0.2"
+ android:background="#2196F3">
+ android:layout_marginTop="6dp"
+ android:layout_marginRight="5dp"
+ android:scrollbars="vertical"
+ card_view:cardCornerRadius="4dp"
+ card_view:cardElevation="4dp"
+ card_view:cardUseCompatPadding="true" />
\ No newline at end of file
diff --git a/Lookify/app/src/main/res/layout/card.xml b/Lookify/app/src/main/res/layout/card.xml
index b151ee7..aa66a6e 100644
--- a/Lookify/app/src/main/res/layout/card.xml
+++ b/Lookify/app/src/main/res/layout/card.xml
@@ -29,7 +29,7 @@
android:background="?attr/selectableItemBackgroundBorderless"/>
-
-
+ />
+
+
diff --git a/Lookify/app/src/main/res/menu/menu_context.xml b/Lookify/app/src/main/res/menu/menu_context.xml
index dc083ee..8770631 100644
--- a/Lookify/app/src/main/res/menu/menu_context.xml
+++ b/Lookify/app/src/main/res/menu/menu_context.xml
@@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
+ android:title="Obserwuj" />