Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
Your Cashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ahmad Abi Mulya
Your Cashier
Commits
77bd59af
Commit
77bd59af
authored
Aug 24, 2020
by
Wahyu Wibowo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crud product
parent
8e558b90
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
44 deletions
+158
-44
ProductDao.java
...ain/java/com/example/yourcashiertest/daos/ProductDao.java
+26
-0
btn_shape.xml
app/src/main/res/drawable/btn_shape.xml
+14
-0
activity_product.xml
app/src/main/res/layout/activity_product.xml
+4
-0
cart_item.xml
app/src/main/res/layout/cart_item.xml
+9
-9
item_list.xml
app/src/main/res/layout/item_list.xml
+102
-35
strings.xml
app/src/main/res/values/strings.xml
+3
-0
No files found.
app/src/main/java/com/example/yourcashiertest/daos/ProductDao.java
View file @
77bd59af
package
com
.
example
.
yourcashiertest
.
daos
;
package
com
.
example
.
yourcashiertest
.
daos
;
import
androidx.lifecycle.LiveData
;
import
androidx.room.Dao
;
import
androidx.room.Delete
;
import
androidx.room.Insert
;
import
androidx.room.OnConflictStrategy
;
import
androidx.room.Query
;
import
androidx.room.Update
;
import
com.example.yourcashiertest.entities.Product
;
import
java.util.List
;
@Dao
public
interface
ProductDao
{
public
interface
ProductDao
{
@Query
(
"SELECT * FROM products ORDER BY id DESC"
)
public
LiveData
<
List
<
Product
>>
getProducts
();
@Query
(
"SELECT * FROM products WHERE name LIKE :query ORDER BY id DESC"
)
public
LiveData
<
List
<
Product
>>
getFilteredProducts
(
String
query
);
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
public
void
insertProduct
(
Product
product
);
@Update
public
void
updateProduct
(
Product
product
);
@Delete
public
void
deleteProduct
(
Product
product
);
}
}
app/src/main/res/drawable/btn_shape.xml
0 → 100644
View file @
77bd59af
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<corners
android:radius=
"50dp"
/>
<stroke
android:width=
"0.5dp"
android:color=
"#45E1D1"
/>
<solid
android:color=
"#45E1D1"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_product.xml
View file @
77bd59af
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
<variable
<variable
name=
"photo"
name=
"photo"
type=
"String"
/>
type=
"String"
/>
<variable
name=
"viewModel"
type=
"com.example.yourcashiertest.viewmodels.ProductViewModel"
/>
</data>
</data>
<LinearLayout
<LinearLayout
...
...
app/src/main/res/layout/cart_item.xml
View file @
77bd59af
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
app:layout_constraintVertical_bias=
"1.0"
/>
app:layout_constraintVertical_bias=
"1.0"
/>
<View
<View
android:id=
"@+id/
rectangle_1
"
android:id=
"@+id/
v_add
"
android:layout_width=
"78dp"
android:layout_width=
"78dp"
android:layout_height=
"40dp"
android:layout_height=
"40dp"
android:layout_alignParentLeft=
"true"
android:layout_alignParentLeft=
"true"
...
@@ -77,9 +77,9 @@
...
@@ -77,9 +77,9 @@
android:layout_height=
"10dp"
android:layout_height=
"10dp"
android:layout_marginStart=
"8dp"
android:layout_marginStart=
"8dp"
android:background=
"@drawable/minus"
android:background=
"@drawable/minus"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintStart_toStartOf=
"@+id/
rectangle_1
"
app:layout_constraintStart_toStartOf=
"@+id/
v_add
"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
app:layout_constraintVertical_bias=
"0.566"
/>
app:layout_constraintVertical_bias=
"0.566"
/>
<Button
<Button
...
@@ -88,9 +88,9 @@
...
@@ -88,9 +88,9 @@
android:layout_height=
"10dp"
android:layout_height=
"10dp"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
android:background=
"@drawable/plus"
android:background=
"@drawable/plus"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintEnd_toEndOf=
"@+id/
rectangle_1
"
app:layout_constraintEnd_toEndOf=
"@+id/
v_add
"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
app:layout_constraintVertical_bias=
"0.533"
/>
app:layout_constraintVertical_bias=
"0.533"
/>
<TextView
<TextView
...
@@ -98,10 +98,10 @@
...
@@ -98,10 +98,10 @@
android:layout_width=
"10dp"
android:layout_width=
"10dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"2"
android:text=
"2"
app:layout_constraintBottom_toBottomOf=
"@+id/
rectangle_1
"
app:layout_constraintBottom_toBottomOf=
"@+id/
v_add
"
app:layout_constraintEnd_toStartOf=
"@+id/btn_add"
app:layout_constraintEnd_toStartOf=
"@+id/btn_add"
app:layout_constraintStart_toEndOf=
"@+id/btn_min"
app:layout_constraintStart_toEndOf=
"@+id/btn_min"
app:layout_constraintTop_toTopOf=
"@+id/
rectangle_1
"
/>
app:layout_constraintTop_toTopOf=
"@+id/
v_add
"
/>
<View
<View
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/item_list.xml
View file @
77bd59af
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
>
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
<data>
<variable
name=
"product"
type=
"com.example.yourcashiertest.entities.Product"
/>
<variable
name=
"price"
type=
"String"
/>
</data>
<com.google.android.material.card.MaterialCardView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"wrap_content"
>
<ImageView
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/imageView5"
android:layout_width=
"match_parent"
android:layout_width=
"wrap_content"
android:padding=
"10dp"
android:layout_height=
"wrap_content"
android:layout_height=
"match_parent"
>
android:background=
"@drawable/elips"
app:layout_constraintBottom_toBottomOf=
"parent"
<ImageView
app:layout_constraintEnd_toEndOf=
"parent"
android:id=
"@+id/iv_product"
app:layout_constraintHorizontal_bias=
"0.452"
android:layout_width=
"wrap_content"
app:layout_constraintStart_toStartOf=
"parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toTopOf=
"parent"
android:background=
"@drawable/elips"
app:layout_constraintVertical_bias=
"0.026"
app:layout_constraintBottom_toBottomOf=
"parent"
tools:srcCompat=
"@tools:sample/avatars"
/>
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.452"
<TextView
app:layout_constraintStart_toStartOf=
"parent"
android:id=
"@+id/tv_name"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_width=
"wrap_content"
app:layout_constraintVertical_bias=
"0.026"
android:layout_height=
"wrap_content"
tools:srcCompat=
"@tools:sample/avatars"
/>
android:text=
"Burger Medium"
app:layout_constraintBottom_toBottomOf=
"parent"
<TextView
app:layout_constraintEnd_toEndOf=
"parent"
android:id=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"0.45"
android:layout_width=
"match_parent"
app:layout_constraintStart_toStartOf=
"parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@+id/imageView5"
android:text=
"@string/name"
app:layout_constraintVertical_bias=
"0.089"
/>
android:layout_margin=
"20dp"
</androidx.constraintlayout.widget.ConstraintLayout>
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
</com.google.android.material.card.MaterialCardView>
app:layout_constraintEnd_toEndOf=
"parent"
\ No newline at end of file
app:layout_constraintHorizontal_bias=
"0.45"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/iv_product"
app:layout_constraintVertical_bias=
"0.089"
/>
<TextView
android:id=
"@+id/tv_desc"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:text=
"@string/deskripsi"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"@+id/tv_name"
app:layout_constraintTop_toBottomOf=
"@+id/tv_name"
app:layout_constraintVertical_bias=
"0.045"
/>
<TextView
android:id=
"@+id/tv_price"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/price"
android:layout_marginTop=
"3dp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.055"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tv_desc"
app:layout_constraintVertical_bias=
"0.038"
/>
<View
android:id=
"@+id/v_add"
android:layout_width=
"70dp"
android:layout_height=
"30dp"
android:background=
"@drawable/btn_shape"
app:layout_constraintBottom_toBottomOf=
"@+id/tv_price"
app:layout_constraintEnd_toEndOf=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"1.0"
app:layout_constraintStart_toEndOf=
"@+id/tv_price"
app:layout_constraintTop_toTopOf=
"@+id/tv_price"
app:layout_constraintVertical_bias=
"0.0"
/>
<ImageView
android:id=
"@+id/iv_add"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"@+id/v_add"
app:layout_constraintEnd_toEndOf=
"@+id/v_add"
app:layout_constraintStart_toStartOf=
"@+id/v_add"
app:layout_constraintTop_toTopOf=
"@+id/v_add"
app:srcCompat=
"@drawable/ic_baseline_add_24"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</layout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
77bd59af
...
@@ -17,4 +17,7 @@
...
@@ -17,4 +17,7 @@
<string
name=
"rp_500_000"
>
Rp. 500.000
</string>
<string
name=
"rp_500_000"
>
Rp. 500.000
</string>
<string
name=
"pay"
>
Pay
</string>
<string
name=
"pay"
>
Pay
</string>
<string
name=
"checkout"
>
Checkout
</string>
<string
name=
"checkout"
>
Checkout
</string>
<string
name=
"deskripsi"
>
Burger medium with tomato and meet.
</string>
<string
name=
"name"
>
Burger Medium
</string>
<string
name=
"price"
>
$600.00
</string>
</resources>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment