From 7514f6bf1055f2adf8ebfd38b95a14e26e44faab Mon Sep 17 00:00:00 2001 From: Kacper Dudzic Date: Mon, 17 Feb 2020 23:58:13 +0100 Subject: [PATCH] =?UTF-8?q?Dodaj=20szkielet=20kafelku=20identyfikuj=C4=85c?= =?UTF-8?q?ego=20zeskanowany=20produkt;=20dodaj=20przej=C5=9Bcie=20pomi?= =?UTF-8?q?=C4=99dzy=20activity=20dekodowania=20a=20activity=20wynik=C3=B3?= =?UTF-8?q?w;=20dodaj=20odrzucaniekod=C3=B3w=20nie=20znajduj=C4=85cych=20s?= =?UTF-8?q?i=C4=99=20w=20bazie=20danych=20w=20activity=20wynik=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lookify/app/src/main/AndroidManifest.xml | 3 +- .../java/com/example/lookifyv2/Decode.java | 12 +- .../java/com/example/lookifyv2/Results.java | 20 ++++ .../src/main/res/layout/activity_popup.xml | 113 ++++++++++-------- .../src/main/res/layout/activity_results.xml | 53 +++++--- Lookify/app/src/main/res/layout/popup.xml | 92 -------------- Lookify/app/src/main/res/values/styles.xml | 7 ++ 7 files changed, 142 insertions(+), 158 deletions(-) delete mode 100644 Lookify/app/src/main/res/layout/popup.xml diff --git a/Lookify/app/src/main/AndroidManifest.xml b/Lookify/app/src/main/AndroidManifest.xml index 66b9a31..8638220 100644 --- a/Lookify/app/src/main/AndroidManifest.xml +++ b/Lookify/app/src/main/AndroidManifest.xml @@ -15,7 +15,8 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/Lookify/app/src/main/java/com/example/lookifyv2/Decode.java b/Lookify/app/src/main/java/com/example/lookifyv2/Decode.java index c476da1..9a92403 100644 --- a/Lookify/app/src/main/java/com/example/lookifyv2/Decode.java +++ b/Lookify/app/src/main/java/com/example/lookifyv2/Decode.java @@ -118,6 +118,7 @@ public class Decode extends AppCompatActivity { hints.put(DecodeHintType.POSSIBLE_FORMATS, formats); hints.put(DecodeHintType.TRY_HARDER, true); + int reminder = 0; //Szukanie kodu na wczytanym zdjęciu MultiFormatReader reader = new MultiFormatReader(); String contents = null; @@ -125,13 +126,18 @@ public class Decode extends AppCompatActivity { Result result = reader.decode(bitmap, hints); contents = result.getText(); } catch (NotFoundException e) { + reminder = -1; e.printStackTrace(); Intent intent_DecodeFail = new Intent(this, DecodeFail.class); startActivity(intent_DecodeFail); - Decode.this.finish(); + finish(); + } + if(reminder == 0) { + Intent intent_Results = new Intent(this, Results.class); + intent_Results.putExtra("decodedcode", contents); + startActivity(intent_Results); + finish(); } - Toast toast = Toast.makeText(this, contents, Toast.LENGTH_LONG); - toast.show(); } //Druga część potrzebna do ładowania OpenCV w odpowiednim momencie 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 9bd2867..debf901 100644 --- a/Lookify/app/src/main/java/com/example/lookifyv2/Results.java +++ b/Lookify/app/src/main/java/com/example/lookifyv2/Results.java @@ -3,6 +3,7 @@ package com.example.lookifyv2; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; +import android.content.Intent; import android.os.Bundle; import android.os.AsyncTask; @@ -31,6 +32,7 @@ public class Results extends AppCompatActivity { private RecyclerView recyclerView; private GridLayoutManager gridLayout; private ProductsAdapter adapter; + String decodedCode; @Override protected void onCreate(Bundle savedInstanceState) { @@ -41,6 +43,24 @@ 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); diff --git a/Lookify/app/src/main/res/layout/activity_popup.xml b/Lookify/app/src/main/res/layout/activity_popup.xml index 218bc9f..bf75c5a 100644 --- a/Lookify/app/src/main/res/layout/activity_popup.xml +++ b/Lookify/app/src/main/res/layout/activity_popup.xml @@ -10,97 +10,114 @@ android:id="@+id/productimagedet" android:layout_width="match_parent" android:layout_height="300dp" - android:scaleType="fitCenter" /> + android:scaleType="fitCenter" + app:layout_constraintBottom_toTopOf="@+id/productnamedet" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/productimagedet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productnamedet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productpricedet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productretailerdet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productcolourdet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productstyledet" /> + android:layout_marginStart="8dp" + android:layout_marginLeft="8dp" + android:layout_marginTop="8dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/productcollectiondet" + app:layout_constraintVertical_bias="0.0" />