Dodaj szkielet kafelku identyfikującego zeskanowany produkt; dodaj przejście pomiędzy activity dekodowania a activity wyników; dodaj odrzucaniekodów nie znajdujących się w bazie danych w activity wyników
This commit is contained in:
parent
049f2dcdb4
commit
7514f6bf10
@ -15,7 +15,8 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".Popup"></activity>
|
||||
<activity android:name=".Results" />
|
||||
<activity android:name=".Results"
|
||||
android:theme="@style/NoBar"/>
|
||||
<activity android:name=".ProductsAdapter" />
|
||||
<activity android:name=".Product" />
|
||||
<activity android:name=".DecodeFail" />
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productnamedet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
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"
|
||||
tools:layout_editor_absoluteY="312dp" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/productimagedet" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productpricedet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.681"
|
||||
tools:layout_editor_absoluteX="74dp" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productretailerdet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
tools:layout_editor_absoluteX="56dp"
|
||||
tools:layout_editor_absoluteY="398dp" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcolourdet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
tools:layout_editor_absoluteX="84dp"
|
||||
tools:layout_editor_absoluteY="435dp" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productstyledet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.596"
|
||||
tools:layout_editor_absoluteX="118dp" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcollectiondet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
tools:layout_editor_absoluteX="128dp"
|
||||
tools:layout_editor_absoluteY="530dp" />
|
||||
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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcodedet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
tools:layout_editor_absoluteX="128dp"
|
||||
tools:layout_editor_absoluteY="611dp" />
|
||||
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" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/back_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Zamknij"
|
||||
tools:layout_editor_absoluteX="203dp"
|
||||
tools:layout_editor_absoluteY="506dp" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!--
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,22 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
<RelativeLayout
|
||||
android:background="#EC2929"
|
||||
android:layout_weight="0.9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
card_view:cardUseCompatPadding="true"
|
||||
card_view:cardElevation="4dp"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_weight="0.1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
card_view:cardUseCompatPadding="true"
|
||||
card_view:cardElevation="4dp"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="475dp"
|
||||
android:padding="5dp"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/productimagedet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcodedet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productnamedet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productpricedet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productretailerdet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcolourdet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productstyledet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productcollectiondet"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/favourite_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Dodaj do "
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/back_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Powrót"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!--
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
-->
|
@ -8,4 +8,11 @@
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="NoBar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user