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
57c631b0
Commit
57c631b0
authored
Sep 02, 2020
by
Ahmad Abi Mulya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue double category and add all category filter
parent
17865116
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
12 deletions
+54
-12
CartActivity.java
.../com/example/yourcashiertest/activities/CartActivity.java
+14
-4
MainActivity.java
.../com/example/yourcashiertest/activities/MainActivity.java
+4
-3
ProductActivity.java
...m/example/yourcashiertest/activities/ProductActivity.java
+1
-1
RegisterActivity.java
.../example/yourcashiertest/activities/RegisterActivity.java
+0
-2
activity_main.xml
app/src/main/res/layout/activity_main.xml
+35
-2
No files found.
app/src/main/java/com/example/yourcashiertest/activities/CartActivity.java
View file @
57c631b0
...
...
@@ -8,7 +8,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.Toast
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.adapters.CartAdapter
;
...
...
@@ -61,9 +63,17 @@ public class CartActivity extends AppCompatActivity {
adapter
.
setCartListener
(
new
CartAdapter
.
CartListener
()
{
@Override
public
void
onIncrease
(
Cart
cart
)
{
Log
.
d
(
"stock1"
,
""
+
product
.
getQuantity
());
Log
.
d
(
"qty1"
,
""
+
cart
.
getQty
());
if
(
product
.
getQuantity
()
<
cart
.
getQty
()){
Log
.
d
(
"stock2"
,
""
+
product
.
getQuantity
());
Log
.
d
(
"qty2"
,
""
+
cart
.
getQty
());
cart
.
setQty
(
cart
.
getQty
()
+
1
);
cart
.
setPrice
(
cart
.
getRealPrice
()
*
cart
.
getQty
());
cartViewModel
.
updateCart
(
cart
);
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"Product stock is not enough"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@Override
...
...
@@ -71,7 +81,7 @@ public class CartActivity extends AppCompatActivity {
cart
.
setQty
(
cart
.
getQty
()
-
1
);
cart
.
setPrice
(
cart
.
getRealPrice
()
*
cart
.
getQty
());
cartViewModel
.
updateCart
(
cart
);
if
(
cart
.
getQty
()
<
=
0
){
if
(
cart
.
getQty
()
<
1
){
cartViewModel
.
deleteCart
(
cart
);
}
}
...
...
app/src/main/java/com/example/yourcashiertest/activities/MainActivity.java
View file @
57c631b0
...
...
@@ -19,6 +19,7 @@ import android.os.Bundle;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.View
;
import
android.widget.PopupMenu
;
import
android.widget.Toast
;
...
...
@@ -134,12 +135,11 @@ public class MainActivity extends AppCompatActivity {
Set
<
String
>
set
=
new
HashSet
<>();
List
<
String
>
category
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
product
.
size
();
i
++){
set
.
add
(
product
.
get
(
i
).
getCategory
());
set
.
add
(
product
.
get
(
i
).
getCategory
()
.
toLowerCase
()
);
}
category
.
addAll
(
set
);
categoryAdapter
.
setCategories
(
category
);
categoryAdapter
.
setListener
(
c
->
viewModel
.
filter
(
c
.
toLowerCase
()));
categoryAdapter
.
setListener
(
c
->
viewModel
.
filter
(
c
));
adapter
.
setListener
(
new
ProductAdapter
.
ProductListener
()
{
@Override
public
void
onUpdate
(
Product
product
)
{
...
...
@@ -229,4 +229,5 @@ public class MainActivity extends AppCompatActivity {
super
.
onDestroy
();
binding
=
null
;
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/activities/ProductActivity.java
View file @
57c631b0
...
...
@@ -67,7 +67,7 @@ public class ProductActivity extends AppCompatActivity{
fixProduct
.
setPhoto
(
file
.
getAbsolutePath
());
}
fixProduct
.
setName
(
binding
.
etProduct
.
getText
().
toString
());
fixProduct
.
setCategory
(
binding
.
etCategory
.
getText
().
toString
());
fixProduct
.
setCategory
(
binding
.
etCategory
.
getText
().
toString
()
.
toLowerCase
()
);
fixProduct
.
setDescription
(
binding
.
etDescription
.
getText
().
toString
());
fixProduct
.
setPrice
(
Long
.
parseLong
(
TextUtils
.
isEmpty
(
binding
.
etPrice
.
getText
().
toString
())
?
"0"
:
binding
.
etPrice
.
getText
().
toString
()));
...
...
app/src/main/java/com/example/yourcashiertest/activities/RegisterActivity.java
View file @
57c631b0
...
...
@@ -36,8 +36,6 @@ public class RegisterActivity extends AppCompatActivity {
if
(
binding
.
etUsername
.
getText
().
toString
().
length
()
==
0
||
binding
.
etPassword
.
getText
().
toString
().
length
()
==
0
||
binding
.
etEmail
.
getText
().
toString
().
length
()
==
0
||
binding
.
etPhoneNumber
.
getText
().
toString
().
length
()
==
0
){
Toast
.
makeText
(
getApplicationContext
(),
"Please input All Required Data"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
if
(!
binding
.
etPassword
.
getText
().
toString
().
matches
(
"[A-Za-z0-9]+"
)){
binding
.
etPassword
.
setError
(
"Passwords can only contain Alphanumeric"
);
}
else
if
(
binding
.
etPassword
.
getText
().
toString
().
length
()
<
8
)
{
binding
.
etPassword
.
setError
(
"Password length cannot be less than 8 characters"
);
}
else
if
(!
binding
.
etPassword
.
getText
().
toString
().
equals
(
binding
.
etConfirmPassword
.
getText
().
toString
())){
...
...
app/src/main/res/layout/activity_main.xml
View file @
57c631b0
...
...
@@ -126,11 +126,44 @@
android:imeOptions=
"actionSearch"
android:inputType=
"textCapWords"
android:textSize=
"@dimen/text_default"
/>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvAllCategory"
android:layout_width=
"wrap_content"
android:layout_height=
"30dp"
android:backgroundTint=
"@color/colorPrimaryDark"
android:layout_marginLeft=
"15dp"
android:checkable=
"true"
android:clickable=
"true"
android:clipToPadding=
"true"
android:focusable=
"true"
app:cardCornerRadius=
"10dp"
app:layout_constraintBottom_toTopOf=
"@id/rvProducts"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/rectangle_4"
>
<RelativeLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingHorizontal=
"15dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
android:gravity=
"center"
android:text=
"all"
android:textColor=
"#fff"
android:textSize=
"18sp"
tools:text=
"@tools:sample/lorem"
/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rvCategory"
android:layout_width=
"
match_parent
"
android:layout_width=
"
300dp
"
android:layout_height=
"wrap_content"
app:layout_constraintStart_toStartOf=
"parent"
android:layout_marginStart=
"8dp"
app:layout_constraintStart_toEndOf=
"@id/cvAllCategory"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/rectangle_4"
app:layout_constraintBottom_toTopOf=
"@id/rvProducts"
...
...
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