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
5ce1aee8
Commit
5ce1aee8
authored
Aug 31, 2020
by
Ahmad Abi Mulya
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.mdd.co.id:44195/abimulya/your-cashier
parents
0020fa87
d5c598da
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
158 additions
and
51 deletions
+158
-51
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+15
-12
CartActivity.java
.../com/example/yourcashiertest/activities/CartActivity.java
+0
-1
ForgetPassword.java
...om/example/yourcashiertest/activities/ForgetPassword.java
+0
-4
MainActivity.java
.../com/example/yourcashiertest/activities/MainActivity.java
+17
-2
CategoryAdapter.java
...com/example/yourcashiertest/adapters/CategoryAdapter.java
+72
-0
ProductAdapter.java
.../com/example/yourcashiertest/adapters/ProductAdapter.java
+10
-0
ProductDao.java
...ain/java/com/example/yourcashiertest/daos/ProductDao.java
+1
-1
ProductViewModel.java
.../example/yourcashiertest/viewmodels/ProductViewModel.java
+1
-1
activity_main.xml
app/src/main/res/layout/activity_main.xml
+11
-12
category_item.xml
app/src/main/res/layout/category_item.xml
+6
-7
item_list.xml
app/src/main/res/layout/item_list.xml
+24
-10
colors.xml
app/src/main/res/values/colors.xml
+1
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
5ce1aee8
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.yourcashiertest"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-feature
android:name=
"android.hardware.camera"
android:required=
"true"
/>
...
...
@@ -19,23 +21,23 @@
android:theme=
"@style/AppTheme2"
>
<activity
android:name=
".activities.SkActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.WelcomeActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.ForgetPassword"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.RegisterActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.StatusPayment"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.SplashActivity"
android:
theme=
"@style/AppTheme2
"
android:
screenOrientation=
"portrait
"
>
android:
screenOrientation=
"portrait
"
android:
theme=
"@style/AppTheme2
"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -44,19 +46,20 @@
</activity>
<activity
android:name=
".activities.PaymentActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.CartActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.MainActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.ProductActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".activities.LoginActivity"
android:screenOrientation=
"portrait"
/>
android:screenOrientation=
"portrait"
/>
<provider
android:name=
"androidx.core.content.FileProvider"
android:authorities=
"com.example.yourcashiertest.fileprovider"
...
...
app/src/main/java/com/example/yourcashiertest/activities/CartActivity.java
View file @
5ce1aee8
...
...
@@ -2,7 +2,6 @@ package com.example.yourcashiertest.activities;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
...
...
app/src/main/java/com/example/yourcashiertest/activities/ForgetPassword.java
View file @
5ce1aee8
...
...
@@ -14,12 +14,8 @@ import android.widget.Toast;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.databinding.ActivityForgetPasswordBinding
;
import
com.example.yourcashiertest.models.Password
;
import
com.example.yourcashiertest.models.User
;
import
com.example.yourcashiertest.utils.ViewUtil
;
import
com.example.yourcashiertest.viewmodels.UserViewModel
;
import
java.util.List
;
public
class
ForgetPassword
extends
AppCompatActivity
{
ActivityForgetPasswordBinding
binding
;
...
...
app/src/main/java/com/example/yourcashiertest/activities/MainActivity.java
View file @
5ce1aee8
...
...
@@ -19,6 +19,7 @@ import android.widget.PopupMenu;
import
android.widget.Toast
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.adapters.CategoryAdapter
;
import
com.example.yourcashiertest.adapters.ProductAdapter
;
import
com.example.yourcashiertest.databinding.ActivityMainBinding
;
import
com.example.yourcashiertest.entities.Cart
;
...
...
@@ -26,6 +27,7 @@ import com.example.yourcashiertest.entities.Product;
import
com.example.yourcashiertest.viewmodels.CartViewModel
;
import
com.example.yourcashiertest.viewmodels.ProductViewModel
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -55,6 +57,7 @@ public class MainActivity extends AppCompatActivity {
prefManager
=
new
PrefManager
(
this
);
ProductAdapter
adapter
=
new
ProductAdapter
();
CategoryAdapter
categoryAdapter
=
new
CategoryAdapter
();
binding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_main
);
cartViewModel
=
new
ViewModelProvider
(
this
).
get
(
CartViewModel
.
class
);
...
...
@@ -109,10 +112,22 @@ public class MainActivity extends AppCompatActivity {
popupMenu
.
show
();
});
// binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
binding
.
rvCategory
.
setLayoutManager
(
new
LinearLayoutManager
(
MainActivity
.
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
));
binding
.
rvCategory
.
setAdapter
(
categoryAdapter
);
binding
.
rvProducts
.
setAdapter
(
adapter
);
viewModel
=
new
ViewModelProvider
(
this
).
get
(
ProductViewModel
.
class
);
viewModel
.
getProducts
().
observe
(
this
,
adapter:
:
setProducts
);
viewModel
.
getProducts
().
observe
(
this
,
products
->
{
adapter
.
setProducts
(
products
);
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
products
.
size
();
i
++){
list
.
add
(
products
.
get
(
i
).
getCategory
());
}
categoryAdapter
.
setCategories
(
list
);
});
categoryAdapter
.
setListener
(
category
->
viewModel
.
filter
(
category
));
adapter
.
setListener
(
new
ProductAdapter
.
ProductListener
()
{
@Override
...
...
app/src/main/java/com/example/yourcashiertest/adapters/CategoryAdapter.java
0 → 100644
View file @
5ce1aee8
package
com
.
example
.
yourcashiertest
.
adapters
;
import
android.view.LayoutInflater
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.databinding.CategoryItemBinding
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
CategoryAdapter
extends
RecyclerView
.
Adapter
<
CategoryAdapter
.
ViewHolder
>
{
List
<
String
>
categories
=
new
ArrayList
<>();
public
interface
CategoryListener
{
void
onClickItem
(
String
category
);
}
private
CategoryListener
listener
;
public
void
setListener
(
CategoryListener
listener
){
this
.
listener
=
listener
;
}
public
void
setCategories
(
List
<
String
>
categories
)
{
this
.
categories
=
categories
;
notifyDataSetChanged
();
}
@NonNull
@Override
public
ViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
return
new
CategoryAdapter
.
ViewHolder
(
DataBindingUtil
.
inflate
(
LayoutInflater
.
from
(
parent
.
getContext
()),
R
.
layout
.
category_item
,
parent
,
false
)
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
ViewHolder
holder
,
int
position
)
{
holder
.
bindData
(
categories
.
get
(
position
),
listener
);
}
@Override
public
int
getItemCount
()
{
return
categories
.
size
();
}
public
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
CategoryItemBinding
binding
;
public
ViewHolder
(
@NonNull
CategoryItemBinding
binding
)
{
super
(
binding
.
getRoot
());
this
.
binding
=
binding
;
}
public
void
bindData
(
String
category
,
CategoryListener
listener
){
binding
.
setCategory
(
category
);
binding
.
cvCategory
.
setOnClickListener
(
v
->
listener
.
onClickItem
(
category
));
}
}
}
app/src/main/java/com/example/yourcashiertest/adapters/ProductAdapter.java
View file @
5ce1aee8
package
com
.
example
.
yourcashiertest
.
adapters
;
import
android.graphics.Color
;
import
android.view.LayoutInflater
;
import
android.view.ViewGroup
;
...
...
@@ -87,6 +88,15 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ViewHold
rupiah
.
setDecimalFormatSymbols
(
format
);
binding
.
setPrice
(
rupiah
.
format
(
product
.
getPrice
()));
if
(
product
.
getQuantity
()
>
0
)
{
binding
.
setStock
(
"Available"
);
binding
.
tvStock
.
setTextColor
(
Color
.
parseColor
(
"#009688"
));
}
else
{
binding
.
setStock
(
"Sold Out"
);
binding
.
tvStock
.
setTextColor
(
Color
.
parseColor
(
"#BD0303"
));
binding
.
vAdd
.
setEnabled
(
false
);
}
binding
.
ivUpdate
.
setOnClickListener
(
view
->
listener
.
onUpdate
(
product
));
binding
.
ivDelete
.
setOnClickListener
(
view
->
listener
.
onDelete
(
product
));
...
...
app/src/main/java/com/example/yourcashiertest/daos/ProductDao.java
View file @
5ce1aee8
...
...
@@ -17,7 +17,7 @@ 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"
)
@Query
(
"SELECT * FROM products WHERE name LIKE :query OR
category LIKE:query OR
DER BY id DESC"
)
public
LiveData
<
List
<
Product
>>
getFilteredProducts
(
String
query
);
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
...
...
app/src/main/java/com/example/yourcashiertest/viewmodels/ProductViewModel.java
View file @
5ce1aee8
...
...
@@ -19,6 +19,7 @@ public class ProductViewModel extends AndroidViewModel {
private
MutableLiveData
<
String
>
photo
=
new
MutableLiveData
<>(
""
);
private
MutableLiveData
<
String
>
query
=
new
MutableLiveData
<>(
"%"
);
private
MutableLiveData
<
String
>
category
=
new
MutableLiveData
<>(
"%"
);
private
MutableLiveData
<
Product
>
product
=
new
MutableLiveData
<>();
private
LiveData
<
List
<
Product
>>
products
;
...
...
@@ -44,7 +45,6 @@ public class ProductViewModel extends AndroidViewModel {
super
(
application
);
repository
=
new
ProductRepository
(
application
);
products
=
Transformations
.
switchMap
(
query
,
s
->
repository
.
filteredProducts
(
s
));
}
...
...
app/src/main/res/layout/activity_main.xml
View file @
5ce1aee8
...
...
@@ -128,22 +128,21 @@
android:imeOptions=
"actionSearch"
android:inputType=
"textCapWords"
android:textSize=
"@dimen/text_default"
/>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rvCategory"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- tools:listitem="@layout/category_item"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/rectangle_4"-->
<!-- app:layout_constraintBottom_toTopOf="@id/rvProducts"--
>
<!-- />-->
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rvCategory"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/rectangle_4"
app:layout_constraintBottom_toTopOf=
"@id/rvProducts"
/
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rvProducts"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginVertical=
"15dp"
app:layout_constraintTop_toBottomOf=
"@id/rectangle_4"
app:layout_constraintTop_toBottomOf=
"@id/rvCategory"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
app/src/main/res/layout/category_item.xml
View file @
5ce1aee8
...
...
@@ -17,7 +17,7 @@
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvCategory"
android:layout_width=
"
match_par
ent"
android:layout_width=
"
wrap_cont
ent"
android:layout_height=
"wrap_content"
android:backgroundTint=
"@color/colorPrimaryDark"
android:clickable=
"true"
...
...
@@ -31,17 +31,16 @@
app:layout_constraintEnd_toEndOf=
"parent"
>
<RelativeLayout
android:layout_width=
"
match_par
ent"
android:layout_width=
"
wrap_cont
ent"
android:layout_height=
"wrap_content"
android:paddingHorizontal=
"
20
dp"
>
android:paddingHorizontal=
"
15
dp"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
Example
"
android:textS
tyle=
"bold
"
android:textSize=
"20sp
"
android:text=
"
@{category}
"
android:textS
ize=
"18sp
"
tools:text=
"@tools:sample/lorem
"
android:textColor=
"#fff"
tools:text=
"elizabeth"
android:layout_centerInParent=
"true"
/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
...
...
app/src/main/res/layout/item_list.xml
View file @
5ce1aee8
...
...
@@ -16,6 +16,10 @@
<variable
name=
"visibility"
type=
"boolean"
/>
<variable
name=
"stock"
type=
"String"
/>
</data>
<com.google.android.material.card.MaterialCardView
...
...
@@ -79,6 +83,7 @@
android:layout_marginTop=
"8dp"
android:maxLength=
"20"
android:maxLines=
"1"
tools:text=
"Burger mekdi bk"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.45"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -91,15 +96,12 @@
android:layout_height=
"wrap_content"
android:text=
"@{product.description}"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"
8dp
"
android:layout_marginBottom=
"
@dimen/space_default
"
android:maxLength=
"40"
android:maxLines=
"2"
tools:text=
"@tools:sample/lorem"
app:layout_constraintTop_toBottomOf=
"@id/tv_name"
app:layout_constraintBottom_toTopOf=
"@id/tv_price"
app:layout_constraintEnd_toEndOf=
"@+id/tv_name"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"@+id/tv_name"
app:layout_constraintVertical_bias=
"0.045"
/>
app:layout_constraintBottom_toTopOf=
"@id/tv_price"
/>
<TextView
android:id=
"@+id/tv_price"
...
...
@@ -107,11 +109,22 @@
android:layout_height=
"wrap_content"
android:text=
"@{price}"
android:textStyle=
"bold"
tools:text=
"rp.200000"
android:layout_marginTop=
"@dimen/space_default"
app:layout_constraintTop_toBottomOf=
"@id/tv_desc"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintVertical_bias=
"0.0"
/>
<TextView
android:id=
"@+id/tvStock"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@{stock}"
android:textStyle=
"bold"
tools:text=
"Available"
android:layout_marginTop=
"8dp"
app:layout_constraint
Bottom_toTopOf=
"@id/v_add
"
app:layout_constraint
Top_toBottomOf=
"@+id/tv_price
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"@+id/tv_desc"
app:layout_constraintVertical_bias=
"0.0"
/>
<com.google.android.material.button.MaterialButton
...
...
@@ -120,7 +133,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
android:padding=
"5dp"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"@dimen/space_default"
app:layout_constraintTop_toBottomOf=
"@+id/tvStock"
app:cornerRadius=
"5dp"
app:icon=
"@drawable/ic_baseline_add_shopping_cart_24"
app:iconGravity=
"textStart"
...
...
app/src/main/res/values/colors.xml
View file @
5ce1aee8
...
...
@@ -23,7 +23,7 @@
<color
name=
"dot_light_screen2"
>
#A9A9A9
</color>
<color
name=
"dot_light_screen3"
>
#A9A9A9
</color>
<color
name=
"dot_light_screen4"
>
#A9A9A9
</color>
<array
name=
"array_dot_active"
>
<item>
@color/dot_light_screen1
</item>
<item>
@color/dot_light_screen2
</item>
...
...
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