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
e6e8c712
Commit
e6e8c712
authored
Aug 28, 2020
by
Muhammad Suryono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check order cart
parent
8c179cce
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
9 deletions
+17
-9
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+10
-2
CartDaos.java
app/src/main/java/com/yono/messeripos/daos/CartDaos.java
+2
-2
MainViewModelsCart.java
...n/java/com/yono/messeripos/models/MainViewModelsCart.java
+4
-4
CartRepositories.java
...va/com/yono/messeripos/repositories/CartRepositories.java
+1
-1
No files found.
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
e6e8c712
...
...
@@ -13,6 +13,7 @@ import android.view.View;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.Toast
;
import
androidx.annotation.RequiresApi
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -79,6 +80,13 @@ public class CartActivity extends AppCompatActivity {
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
Log
.
i
(
"Id Order on acart"
,
"onCreate: "
+
orderId
);
if
(
orderId
.
isEmpty
()){
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
ORDER_ID
,
"MES-ORDER"
+
utils
.
timeStamp
());
if
(
editor
.
commit
()){
Toast
.
makeText
(
CartActivity
.
this
,
orderId
,
Toast
.
LENGTH_LONG
).
show
();
}
}
// Toolbars
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
cAppBar
);
setSupportActionBar
(
toolbars
);
...
...
@@ -99,7 +107,7 @@ public class CartActivity extends AppCompatActivity {
modelsCart
=
new
ViewModelProvider
(
this
).
get
(
MainViewModelsCart
.
class
);
modelsCart
.
getCartBy
Order
Id
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
modelsCart
.
getCartById
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
if
(
productCartModels
!=
null
)
{
...
...
@@ -171,7 +179,7 @@ public class CartActivity extends AppCompatActivity {
private
void
actionSaveCart
()
{
Client
client
=
new
Client
();
modelsCart
.
getCartBy
Order
Id
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
modelsCart
.
getCartById
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
long
grossAmount
=
0
;
...
...
app/src/main/java/com/yono/messeripos/daos/CartDaos.java
View file @
e6e8c712
...
...
@@ -18,8 +18,8 @@ public interface CartDaos {
@Query
(
"SELECT * FROM carts ORDER BY id DESC"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCart
();
@Query
(
"SELECT * FROM carts WHERE id_
product_
orders = :idCart"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
lo
ng
idCart
);
@Query
(
"SELECT * FROM carts WHERE id_orders = :idCart"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
Stri
ng
idCart
);
@Query
(
"SELECT * FROM carts WHERE id_orders = :orderId AND id_product_orders = :idOrders"
)
public
LiveData
<
List
<
ProductCartModels
>>
getCartByOrderId
(
String
orderId
,
long
idOrders
);
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModelsCart.java
View file @
e6e8c712
...
...
@@ -107,7 +107,7 @@ public class MainViewModelsCart extends AndroidViewModel {
});
}
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
lo
ng
id
){
public
LiveData
<
List
<
ProductCartModels
>>
getCartById
(
Stri
ng
id
){
return
cartRepositories
.
getDataById
(
id
);
}
...
...
@@ -115,9 +115,9 @@ public class MainViewModelsCart extends AndroidViewModel {
return
cartRepositories
.
getCartByOrderId
(
idOrders
,
idProduct
);
}
public
LiveData
<
List
<
ProductCartModels
>>
getCartByOrderId
(
long
id
){
return
cartRepositories
.
getDataById
(
id
);
}
//
public LiveData<List<ProductCartModels>> getCartByOrderId(long id){
//
return cartRepositories.getDataById(id);
//
}
public
MutableLiveData
<
ProductCartModels
>
getCart
(){
// String js = new Gson().toJson(cartRepositories.getDataCart());
...
...
app/src/main/java/com/yono/messeripos/repositories/CartRepositories.java
View file @
e6e8c712
...
...
@@ -42,7 +42,7 @@ public class CartRepositories {
LocalDatabase
.
databaseWriterExecutor
.
execute
(()
->
cartDaos
.
updateCart
(
qty
,
id
));
}
public
LiveData
<
List
<
ProductCartModels
>>
getDataById
(
lo
ng
id
){
public
LiveData
<
List
<
ProductCartModels
>>
getDataById
(
Stri
ng
id
){
return
cartDaos
.
getCartById
(
id
);
}
...
...
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