Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
meser
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
Muhammad Suryono
meser
Commits
65360fc4
Commit
65360fc4
authored
Sep 03, 2020
by
Muhammad Suryono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update cart
parent
bf527c11
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
25 deletions
+48
-25
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+11
-2
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+15
-15
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+1
-2
RegisterState.java
app/src/main/java/com/yono/messeripos/RegisterState.java
+5
-1
ProductAdapter.java
...main/java/com/yono/messeripos/adapter/ProductAdapter.java
+1
-1
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+2
-1
ProductCartModels.java
...in/java/com/yono/messeripos/models/ProductCartModels.java
+12
-2
Utils.java
app/src/main/java/com/yono/messeripos/utils/Utils.java
+1
-1
No files found.
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
65360fc4
...
@@ -167,8 +167,17 @@ public class CartActivity extends AppCompatActivity {
...
@@ -167,8 +167,17 @@ public class CartActivity extends AppCompatActivity {
@Override
@Override
public
void
onUpdateQuantityPlus
(
ProductCartModels
productCartModels
)
{
public
void
onUpdateQuantityPlus
(
ProductCartModels
productCartModels
)
{
productCartModels
.
setQuantity_orders
(
productCartModels
.
getQuantity_orders
()
+
1
);
if
(!((
productCartModels
.
getQuantity_orders
()
+
1
)
>
productCartModels
.
getQuantity_stock
())){
modelsCart
.
updateCart
(
productCartModels
);
productCartModels
.
setQuantity_orders
(
productCartModels
.
getQuantity_orders
()
+
1
);
modelsCart
.
updateCart
(
productCartModels
);
}
else
{
utils
.
dialog
(
CartActivity
.
this
,
true
,
getLayoutInflater
().
inflate
(
R
.
layout
.
alert_dialog
,
null
),
"Warning"
,
"Item stock does not meet"
).
show
();
}
}
}
@Override
@Override
...
...
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
65360fc4
...
@@ -61,6 +61,7 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -61,6 +61,7 @@ public class FormProductActivity extends AppCompatActivity {
MainViewModels
mainViewModels
;
MainViewModels
mainViewModels
;
MaterialSpinner
spinner
;
MaterialSpinner
spinner
;
List
<
String
>
categoryModels
;
List
<
String
>
categoryModels
;
List
<
String
>
str
=
new
ArrayList
<>();
private
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_PERMISSIONS
=
448
;
private
static
final
int
REQUEST_PERMISSIONS
=
448
;
private
boolean
isUpdate
=
false
;
private
boolean
isUpdate
=
false
;
...
@@ -75,7 +76,7 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -75,7 +76,7 @@ public class FormProductActivity extends AppCompatActivity {
ProgressDialog
progressDialog
;
ProgressDialog
progressDialog
;
Client
client
=
new
Client
();
Client
client
=
new
Client
();
ProductModels
productModelsIntent
;
ProductModels
productModelsIntent
;
List
<
String
>
categorySelect
=
new
ArrayList
<>();
List
<
Integer
>
categorySelect
=
new
ArrayList
<>();
FormCategory
formCategory
;
FormCategory
formCategory
;
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
...
@@ -180,7 +181,8 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -180,7 +181,8 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
listCategory
.
setOnItemSelectedListener
(
new
MaterialSpinner
.
OnItemSelectedListener
()
{
binding
.
listCategory
.
setOnItemSelectedListener
(
new
MaterialSpinner
.
OnItemSelectedListener
()
{
@Override
@Override
public
void
onItemSelected
(
MaterialSpinner
view
,
int
position
,
long
id
,
Object
item
)
{
public
void
onItemSelected
(
MaterialSpinner
view
,
int
position
,
long
id
,
Object
item
)
{
categorySelect
.
add
(
item
.
toString
());
progressDialog
.
show
();
getCategory
(
item
.
toString
());
}
}
});
});
}
}
...
@@ -189,17 +191,15 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -189,17 +191,15 @@ public class FormProductActivity extends AppCompatActivity {
private
void
setSpinner
(
String
s
)
{
private
void
setSpinner
(
String
s
)
{
progressDialog
.
show
();
progressDialog
.
show
();
HashSet
<
String
>
set
=
new
HashSet
<>();
HashSet
<
String
>
set
=
new
HashSet
<>();
List
<
String
>
str
=
new
ArrayList
<>();
categoryModels
=
new
ArrayList
<>();
categoryModels
=
new
ArrayList
<>();
Log
.
i
(
"GET_CATEGORY"
,
"setSpinner: "
+
utils
.
convertGson
(
productModelsIntent
));
Log
.
i
(
"GET_CATEGORY"
,
"setSpinner: "
+
utils
.
convertGson
(
productModelsIntent
));
// if (productModelsIntent == null){
if
(
productModelsIntent
==
null
){
// str.add("SELECT CATEGORY");
str
.
add
(
"SELECT CATEGORY"
);
// }else{
}
else
{
// getCategoryById(productModelsIntent.getIdProduct());
getCategoryById
(
productModelsIntent
.
getIdProduct
());
// categoryName = ""
categorySelect
.
add
(
0
,
productModelsIntent
.
getCategoryProduct
());
// str.add(categoryName);
}
// }
// str.add("SELECT CATEGORY");
str
.
add
(
"SELECT CATEGORY"
);
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
for
(
CategoryModels
cd:
listDataResponse
.
getData
()){
for
(
CategoryModels
cd:
listDataResponse
.
getData
()){
...
@@ -228,7 +228,7 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -228,7 +228,7 @@ public class FormProductActivity extends AppCompatActivity {
productModelsSave
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
productModelsSave
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
productModelsSave
.
setPriceProduct
(
Integer
.
parseInt
(
binding
.
etPrice
.
getText
().
toString
()));
productModelsSave
.
setPriceProduct
(
Integer
.
parseInt
(
binding
.
etPrice
.
getText
().
toString
()));
productModelsSave
.
setStockProduct
(
Integer
.
parseInt
(
binding
.
etStock
.
getText
().
toString
()));
productModelsSave
.
setStockProduct
(
Integer
.
parseInt
(
binding
.
etStock
.
getText
().
toString
()));
productModelsSave
.
setCategoryProduct
(
getCategory
(
categorySelect
.
get
(
0
)
));
productModelsSave
.
setCategoryProduct
(
categorySelect
.
get
(
0
));
if
(
productModelsIntent
==
null
){
if
(
productModelsIntent
==
null
){
productModelsSave
.
setImageProduct
(
productModels
.
getImageProduct
());
productModelsSave
.
setImageProduct
(
productModels
.
getImageProduct
());
}
else
{
}
else
{
...
@@ -346,6 +346,8 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -346,6 +346,8 @@ public class FormProductActivity extends AppCompatActivity {
Log
.
i
(
"CHDJHD"
,
"getCategory: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"CHDJHD"
,
"getCategory: "
+
utils
.
convertGson
(
response
.
body
()));
id
=
response
.
body
().
getData
().
get
(
0
).
getIdCategory
();
id
=
response
.
body
().
getData
().
get
(
0
).
getIdCategory
();
productModels
.
setCategoryProduct
(
id
);
productModels
.
setCategoryProduct
(
id
);
categorySelect
.
add
(
0
,
id
);
progressDialog
.
dismiss
();
}
}
@Override
@Override
...
@@ -362,9 +364,7 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -362,9 +364,7 @@ public class FormProductActivity extends AppCompatActivity {
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
Log
.
i
(
"ER"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"ER"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
categoryName
.
isEmpty
()){
str
.
add
(
response
.
body
().
getData
().
getNameCategory
());
categoryName
=
response
.
body
().
getData
().
getNameCategory
();
}
}
}
@Override
@Override
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
65360fc4
...
@@ -201,7 +201,6 @@ public class MainActivity extends AppCompatActivity {
...
@@ -201,7 +201,6 @@ public class MainActivity extends AppCompatActivity {
});
});
}
}
private
void
mainViewModelsGettCategory
()
{
private
void
mainViewModelsGettCategory
()
{
mainViewModels
.
getCategory
().
observe
(
this
,
new
Observer
<
DataResponse
<
List
<
CategoryModels
>>>()
{
mainViewModels
.
getCategory
().
observe
(
this
,
new
Observer
<
DataResponse
<
List
<
CategoryModels
>>>()
{
@Override
@Override
...
@@ -339,7 +338,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -339,7 +338,7 @@ public class MainActivity extends AppCompatActivity {
product
.
getIdProduct
(),
product
.
getIdProduct
(),
product
.
getProductName
(),
product
.
getProductName
(),
product
.
getPriceProduct
(),
product
.
getPriceProduct
(),
0
product
.
getStockProduct
()
));
));
// Log.d("order_id_create", "onChanged: "+orderId);
// Log.d("order_id_create", "onChanged: "+orderId);
...
...
app/src/main/java/com/yono/messeripos/RegisterState.java
View file @
65360fc4
...
@@ -5,6 +5,8 @@ import android.content.Context;
...
@@ -5,6 +5,8 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -89,7 +91,9 @@ public class RegisterState extends BottomSheetDialogFragment {
...
@@ -89,7 +91,9 @@ public class RegisterState extends BottomSheetDialogFragment {
registerButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
registerButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
mainViewModels
.
postRegis
(
new
UsersModels
(
username
.
getText
().
toString
(),
email
.
getText
().
toString
(),
password
.
getText
().
toString
(),
repassword
.
getText
().
toString
()));
mainViewModels
.
postRegis
(
new
UsersModels
(
username
.
getText
().
toString
(),
email
.
getText
().
toString
(),
password
.
getText
().
toString
(),
repassword
.
getText
().
toString
()));
}
}
});
});
...
...
app/src/main/java/com/yono/messeripos/adapter/ProductAdapter.java
View file @
65360fc4
...
@@ -138,7 +138,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
...
@@ -138,7 +138,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
binding
.
materialBtnAddCart
.
setVisibility
(
View
.
GONE
);
binding
.
materialBtnAddCart
.
setVisibility
(
View
.
GONE
);
}
}
if
(
products
.
getStockProduct
()
==
0
)
{
if
(
products
.
getStockProduct
()
<=
1
)
{
statusProduct
=
"Not Available"
;
statusProduct
=
"Not Available"
;
binding
.
status
.
setBackgroundColor
(
0x55FF0000
);
binding
.
status
.
setBackgroundColor
(
0x55FF0000
);
binding
.
setStatus
(
statusProduct
);
binding
.
setStatus
(
statusProduct
);
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
65360fc4
...
@@ -187,7 +187,8 @@ public class MainViewModels extends ViewModel {
...
@@ -187,7 +187,8 @@ public class MainViewModels extends ViewModel {
usersService
.
postRegister
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
usersService
.
postRegister
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
Log
.
i
(
"REGISTER"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
usersRegister
.
setValue
(
response
.
body
());
}
}
@Override
@Override
...
...
app/src/main/java/com/yono/messeripos/models/ProductCartModels.java
View file @
65360fc4
...
@@ -20,6 +20,9 @@ public class ProductCartModels implements Parcelable {
...
@@ -20,6 +20,9 @@ public class ProductCartModels implements Parcelable {
@SerializedName
(
"quantity"
)
@SerializedName
(
"quantity"
)
private
long
quantity_orders
;
private
long
quantity_orders
;
@SerializedName
(
"quantity_stock"
)
private
long
quantity_stock
;
@SerializedName
(
"product_id"
)
@SerializedName
(
"product_id"
)
private
int
id_product_orders
;
private
int
id_product_orders
;
...
@@ -41,13 +44,13 @@ public class ProductCartModels implements Parcelable {
...
@@ -41,13 +44,13 @@ public class ProductCartModels implements Parcelable {
int
id_product_orders
,
int
id_product_orders
,
String
product_name_orders
,
String
product_name_orders
,
long
price_orders
,
long
price_orders
,
int
grand_total_orders
)
{
int
quantity_stock
)
{
this
.
id_orders
=
id_orders
;
this
.
id_orders
=
id_orders
;
this
.
quantity_orders
=
quantity_orders
;
this
.
quantity_orders
=
quantity_orders
;
this
.
id_product_orders
=
id_product_orders
;
this
.
id_product_orders
=
id_product_orders
;
this
.
product_name_orders
=
product_name_orders
;
this
.
product_name_orders
=
product_name_orders
;
this
.
price_orders
=
price_orders
;
this
.
price_orders
=
price_orders
;
this
.
grand_total_orders
=
grand_total_orders
;
this
.
quantity_stock
=
quantity_stock
;
}
}
protected
ProductCartModels
(
Parcel
in
)
{
protected
ProductCartModels
(
Parcel
in
)
{
...
@@ -143,4 +146,11 @@ public class ProductCartModels implements Parcelable {
...
@@ -143,4 +146,11 @@ public class ProductCartModels implements Parcelable {
this
.
grand_total_orders
=
grand_total_orders
;
this
.
grand_total_orders
=
grand_total_orders
;
}
}
public
long
getQuantity_stock
()
{
return
quantity_stock
;
}
public
void
setQuantity_stock
(
long
quantity_stock
)
{
this
.
quantity_stock
=
quantity_stock
;
}
}
}
app/src/main/java/com/yono/messeripos/utils/Utils.java
View file @
65360fc4
...
@@ -270,7 +270,7 @@ public class Utils {
...
@@ -270,7 +270,7 @@ public class Utils {
AlertDialog
dialog
=
builder
.
create
();
AlertDialog
dialog
=
builder
.
create
();
dialog
.
getWindow
().
getAttributes
().
windowAnimations
=
R
.
style
.
DialogAnimation
;
dialog
.
getWindow
().
getAttributes
().
windowAnimations
=
R
.
style
.
DialogAnimation
;
bt
n
Card
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
btCard
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
return
dialog
;
return
dialog
;
}
}
...
...
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