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
700f1ea0
Commit
700f1ea0
authored
Aug 31, 2020
by
iman Fauzi
Browse files
Options
Browse Files
Download
Plain Diff
:collision: fix conflict
parents
7c720a08
e58d1735
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
206 additions
and
119 deletions
+206
-119
BottomSheets.java
app/src/main/java/com/yono/messeripos/BottomSheets.java
+11
-6
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+29
-33
FormCategory.java
app/src/main/java/com/yono/messeripos/FormCategory.java
+8
-0
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+8
-15
HistoryActivity.java
app/src/main/java/com/yono/messeripos/HistoryActivity.java
+4
-2
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+17
-5
PaymentActivity.java
app/src/main/java/com/yono/messeripos/PaymentActivity.java
+53
-52
CategoryAdapter.java
...ain/java/com/yono/messeripos/adapter/CategoryAdapter.java
+20
-0
CategoryServise.java
...java/com/yono/messeripos/api/service/CategoryServise.java
+5
-0
OrdersService.java
...n/java/com/yono/messeripos/api/service/OrdersService.java
+1
-1
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+20
-0
activity_q_r_code.xml
app/src/main/res/layout/activity_q_r_code.xml
+3
-1
form_category.xml
app/src/main/res/layout/form_category.xml
+1
-1
item_category.xml
app/src/main/res/layout/item_category.xml
+24
-2
item_list.xml
app/src/main/res/layout/item_list.xml
+1
-1
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/src/main/java/com/yono/messeripos/BottomSheets.java
View file @
700f1ea0
package
com
.
yono
.
messeripos
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextUtils
;
import
android.text.TextWatcher
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -31,6 +33,7 @@ import retrofit2.Callback;
import
retrofit2.Response
;
import
static
com
.
yono
.
messeripos
.
MainActivity
.
CHECKOUT
;
import
static
com
.
yono
.
messeripos
.
MainActivity
.
ORDER_ID
;
import
static
com
.
yono
.
messeripos
.
MainActivity
.
orderId
;
public
class
BottomSheets
extends
BottomSheetDialogFragment
{
...
...
@@ -43,7 +46,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
Client
client
=
new
Client
();
public
static
long
grossAmount
;
SharedPreferences
sharedPreferences
;
BottomSheetBehavior
bottomSheetBehavior
;
public
static
BottomSheetBehavior
bottomSheetBehavior
;
RelativeLayout
layoutFormCash
;
PaymentsModels
paymentsModels
;
...
...
@@ -76,9 +79,10 @@ public class BottomSheets extends BottomSheetDialogFragment {
btnCash
=
v
.
findViewById
(
R
.
id
.
btnCash
);
totalHarga
=
v
.
findViewById
(
R
.
id
.
totalHarga
);
utils
=
new
Utils
();
// bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
// sharedPreferences = getActivity().getSharedPreferences(MainActivity.ORDER_ID, Context.MODE_PRIVATE);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
bottomSheetBehavior
=
BottomSheetBehavior
.
from
(
layoutFormCash
);
sharedPreferences
=
getActivity
().
getSharedPreferences
(
MainActivity
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
bottomSheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_COLLAPSED
);
long
ga
=
paymentsModels
.
getGrossAmount
();
String
setCurrency
=
utils
.
convertPrice
(
"Rp."
,
ga
);
...
...
@@ -145,7 +149,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
// String orderId, String paymentType, String bank, long grossAmount
PaymentsModels
paymentsModels
=
new
PaymentsModels
(
MainActivity
.
orderId
,
sharedPreferences
.
getString
(
ORDER_ID
,
""
)
,
"cash"
,
"none"
,
grossAmount
...
...
@@ -155,10 +159,11 @@ public class BottomSheets extends BottomSheetDialogFragment {
paymentService
.
postFromCart
(
paymentsModels
).
enqueue
(
new
Callback
<
DataResponse
<
PaymentsModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
PaymentsModels
>>
call
,
Response
<
DataResponse
<
PaymentsModels
>>
response
)
{
Log
.
i
(
"CASH"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
){
SharedPreferences
.
Editor
editor
=
PaymentActivity
.
sharedPreferences
.
edit
();
editor
.
putBoolean
(
CHECKOUT
,
false
);
editor
.
putString
(
orderId
,
""
);
editor
.
putString
(
ORDER_ID
,
""
);
if
(
editor
.
commit
()){
Intent
i
=
new
Intent
(
getActivity
(),
MainActivity
.
class
);
view
.
getContext
().
startActivity
(
i
);
...
...
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
700f1ea0
...
...
@@ -65,6 +65,7 @@ public class CartActivity extends AppCompatActivity {
Button
btnCheckout
;
CardView
cardView
;
PaymentsModels
paymentsModelsIntent
;
public
static
final
String
CODE_SEND_CHECKOUT_HISTORY
=
"data_hcheckout_history"
;
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@Override
...
...
@@ -116,14 +117,17 @@ public class CartActivity extends AppCompatActivity {
Log
.
i
(
"GET CART"
,
"onCreate: "
+
paymentsModelsIntent
);
if
(
paymentsModelsIntent
==
null
){
modelsCart
=
new
ViewModelProvider
(
this
).
get
(
MainViewModelsCart
.
class
);
modelsCart
.
getCartById
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
modelsCart
.
getCartById
(
sharedPreferences
.
getString
(
ORDER_ID
,
""
)
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
Log
.
i
(
"TAG"
,
"onChanged: "
+
utils
.
convertGson
(
productCartModels
));
if
(!
productCartModels
.
isEmpty
())
{
Log
.
i
(
"TAG_DALAM"
,
"onChanged: "
+
sharedPreferences
.
getString
(
ORDER_ID
,
""
));
dataCart
=
productCartModels
;
cartAdapter
.
setCartAdapter
(
CartActivity
.
this
,
productCartModels
);
recyclerView
.
setAdapter
(
cartAdapter
);
}
else
{
Log
.
i
(
"TAG_LUAR"
,
"onChanged: "
+
utils
.
convertGson
(
productCartModels
));
cartEmptyText
.
setVisibility
(
View
.
VISIBLE
);
cartEmptyImage
.
setVisibility
(
View
.
VISIBLE
);
cardView
.
setVisibility
(
View
.
GONE
);
...
...
@@ -133,38 +137,23 @@ public class CartActivity extends AppCompatActivity {
});
}
else
{
Log
.
i
(
"ADA_DATA"
,
"onCreate: "
+
utils
.
convertGson
(
paymentsModelsIntent
));
Client
client
=
new
Client
();
OrdersService
ordersService
=
client
.
Client
(
OrdersService
.
class
);
// modelsCart = new ViewModelProvider(this).get(MainViewModelsCart.class);
// modelsCart.getCartById(paymentsModelsIntent.getOrderId()).observe(this, new Observer<List<ProductCartModels>>() {
// @Override
// public void onChanged(List<ProductCartModels> productCartModels) {
// Log.i("ADA_DATA1", "onCreate: "+utils.convertGson(paymentsModelsIntent.getOrderId()));
// Log.i("ADA_DATA2", "onCreate: "+utils.convertGson(productCartModels));
// if (!productCartModels.isEmpty()) {
// dataCart = productCartModels;
// cartAdapter.setCartAdapter(CartActivity.this, productCartModels);
// recyclerView.setAdapter(cartAdapter);
// }else {
// cartEmptyText.setVisibility(View.VISIBLE);
// cartEmptyImage.setVisibility(View.VISIBLE);
// cardView.setVisibility(View.GONE);
// recyclerView.setVisibility(View.GONE);
// }
// }
// });
ordersService
.
getOrdersProductById
(
paymentsModelsIntent
.
getOrderId
()).
enqueue
(
new
Callback
<
DataResponse
<
OrdersResponse
<
List
<
ProductModels
>>>>()
{
modelsCart
.
getCartById
(
paymentsModelsIntent
.
getOrderId
()).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
OrdersResponse
<
List
<
ProductModels
>>>>
call
,
Response
<
DataResponse
<
OrdersResponse
<
List
<
ProductModels
>>>>
response
)
{
Log
.
i
(
"TAG"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
().
getData
()));
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
if
(!
productCartModels
.
isEmpty
())
{
dataCart
=
productCartModels
;
cartAdapter
.
setCartAdapter
(
CartActivity
.
this
,
productCartModels
);
recyclerView
.
setAdapter
(
cartAdapter
);
}
else
{
cartEmptyText
.
setVisibility
(
View
.
VISIBLE
);
cartEmptyImage
.
setVisibility
(
View
.
VISIBLE
);
cardView
.
setVisibility
(
View
.
GONE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
OrdersResponse
<
List
<
ProductModels
>>>>
call
,
Throwable
t
)
{
Log
.
e
(
"error"
,
"onFailure: "
+
t
.
getMessage
(),
t
);
}
});
}
...
...
@@ -215,10 +204,16 @@ public class CartActivity extends AppCompatActivity {
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
MainActivity
.
CHECKOUT
,
true
);
if
(
editor
.
commit
()){
Log
.
i
(
"FROM_CHECKOUT_INTENT"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModelsIntent
));
if
(
paymentsModelsIntent
!=
null
){
startActivity
(
new
Intent
(
CartActivity
.
this
,
PaymentActivity
.
class
)
.
putExtra
(
CODE_SEND_CHECKOUT_HISTORY
,
paymentsModelsIntent
));
}
else
{
startActivity
(
new
Intent
(
CartActivity
.
this
,
PaymentActivity
.
class
));
finish
();
}
}
}
});
}
...
...
@@ -236,9 +231,10 @@ public class CartActivity extends AppCompatActivity {
grossAmount
=
grossAmount
+
(
pd
.
getQuantity_orders
()*
pd
.
getPrice_orders
());
paymentsModels
.
setGrossAmount
(
grossAmount
);
}
Log
.
i
(
"ORDER_ID_SAVE"
,
"onCreate: "
+
sharedPreferences
.
getString
(
ORDER_ID
,
""
).
toString
());
paymentsModels
.
setBank
(
""
);
paymentsModels
.
setPaymentType
(
"pending"
);
paymentsModels
.
setOrderId
(
orderId
);
paymentsModels
.
setOrderId
(
sharedPreferences
.
getString
(
ORDER_ID
,
""
)
);
paymentsModels
.
setTransactionStatus
(
"pending"
);
Log
.
i
(
"Convert Input"
,
"onChanged: "
+
utils
.
convertGson
(
paymentsModels
));
PaymentService
paymentService
=
client
.
Client
(
PaymentService
.
class
);
...
...
app/src/main/java/com/yono/messeripos/FormCategory.java
View file @
700f1ea0
...
...
@@ -7,10 +7,15 @@ import android.view.ViewGroup;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.MainViewModelsCart
;
public
class
FormCategory
extends
BottomSheetDialogFragment
{
MainViewModels
mainViewModels
;
public
FormCategory
()
{
}
...
...
@@ -21,6 +26,9 @@ public class FormCategory extends BottomSheetDialogFragment {
View
v
=
inflater
.
inflate
(
R
.
layout
.
form_category
,
container
,
false
);
mainViewModels
=
new
ViewModelProvider
(
getActivity
()).
get
(
MainViewModels
.
class
);
return
v
;
}
}
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
700f1ea0
...
...
@@ -69,6 +69,7 @@ public class FormProductActivity extends AppCompatActivity {
ProgressDialog
progressDialog
;
Client
client
=
new
Client
();
ProductModels
productModelsIntent
;
List
<
String
>
categorySelect
=
new
ArrayList
<>();
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -118,13 +119,13 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
cvProduct
.
setOnClickListener
(
view
->
openFile
());
binding
.
btnAdd
.
setOnClickListener
(
view
->
saveProduct
());
binding
.
btnAddCategory
.
setOnClickListener
(
view
->
addCategory
());
//spinner
categoryModels
=
new
ArrayList
<>();
categoryModels
.
add
(
"SELECT CATEGORY"
);
setSpinner
();
setSelectedSpinner
();
addCategory
();
}
private
void
addCategory
()
{
...
...
@@ -137,19 +138,7 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
listCategory
.
setOnItemSelectedListener
(
new
MaterialSpinner
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
MaterialSpinner
view
,
int
position
,
long
id
,
Object
item
)
{
utils
.
toastMessage
(
FormProductActivity
.
this
,
""
+
position
);
Log
.
i
(
"Object"
,
"onItemSelected: "
+
item
);
mainViewModels
.
getCategory
().
observe
(
FormProductActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
CategoryModels
>>>()
{
@Override
public
void
onChanged
(
DataResponse
<
List
<
CategoryModels
>>
listDataResponse
)
{
List
<
CategoryModels
>
cat
=
listDataResponse
.
getData
();
for
(
CategoryModels
cM
:
cat
){
if
(
cM
.
getNameCategory
()
==
item
){
idCategorySelected
=
cM
.
getIdCategory
();
}
}
}
});
categorySelect
.
add
(
item
.
toString
());
}
});
}
...
...
@@ -174,7 +163,7 @@ public class FormProductActivity extends AppCompatActivity {
productModels
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
productModels
.
setPriceProduct
(
Integer
.
parseInt
(
binding
.
etPrice
.
getText
().
toString
()));
productModels
.
setStockProduct
(
Integer
.
parseInt
(
binding
.
etStock
.
getText
().
toString
()));
productModels
.
setCategoryProduct
(
binding
.
listCategory
.
getSelectedIndex
(
));
productModels
.
setCategoryProduct
(
getCategory
(
categoryModels
.
get
(
0
)
));
if
(
isUpdate
){
...
...
@@ -271,6 +260,10 @@ public class FormProductActivity extends AppCompatActivity {
}
}
private
int
getCategory
(
String
s
)
{
return
1
;
}
private
void
openFile
(){
requestPermissions
(
permissions
,
REQUEST_PERMISSIONS
);
Intent
i
=
new
Intent
(
Intent
.
ACTION_PICK
,
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
...
...
app/src/main/java/com/yono/messeripos/HistoryActivity.java
View file @
700f1ea0
...
...
@@ -85,11 +85,13 @@ public class HistoryActivity extends AppCompatActivity {
transactionAdapter
.
setListener
(
new
TransactionAdapter
.
TransactionListener
()
{
@Override
public
void
onShowDetail
(
PaymentsModels
paymentsModels
)
{
if
(
paymentsModels
.
getPaymentType
().
equals
(
"bank_transfer"
)
&&
paymentsModels
.
getTransactionStatus
().
equals
(
"settlement"
)){
if
(
paymentsModels
.
getPaymentType
().
equals
(
"bank_transfer"
)
&&
paymentsModels
.
getTransactionStatus
().
equals
(
"settlement"
)){
new
AlertDialog
.
Builder
(
HistoryActivity
.
this
)
.
setTitle
(
"Transaction"
)
.
setMessage
(
"Transaction success!"
).
show
();
}
else
if
(
paymentsModels
.
getPaymentType
().
equals
(
"bank_transfer"
)
&&
paymentsModels
.
getTransactionStatus
().
equals
(
"pending"
)){
}
else
if
(
paymentsModels
.
getPaymentType
().
equals
(
"bank_transfer"
)
&&
paymentsModels
.
getTransactionStatus
().
equals
(
"pending"
)){
new
AlertDialog
.
Builder
(
HistoryActivity
.
this
)
.
setTitle
(
"Transaction"
)
.
setMessage
(
"Waiting payment!"
).
show
();
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
700f1ea0
...
...
@@ -77,7 +77,7 @@ public class MainActivity extends AppCompatActivity {
Client
client
=
new
Client
();
public
static
ArrayList
<
ProductModels
>
productModelsArrayList
=
new
ArrayList
<>();
public
static
final
String
DATA_PRODUCT
=
"DATA_PRODUCT"
;
public
static
final
String
MY_SHARED_PREFERENCES
=
"m
y_shared_preferences
"
;
public
static
final
String
MY_SHARED_PREFERENCES
=
"m
ain_sahred
"
;
ProgressDialog
progressDialog
;
MaterialButton
btnAddCart
;
SkeletonScreen
skeletonCategory
;
...
...
@@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity {
orderId
=
sharedPreferences
.
getString
(
ORDER_ID
,
""
);
progressDialog
=
new
ProgressDialog
(
MainActivity
.
this
);
progressDialog
.
setMessage
(
"Loading..."
);
Log
.
i
(
"ORDER ID"
,
"onCreate: "
+
orderId
);
Log
.
i
(
"ORDER ID"
,
"onCreate: "
+
sharedPreferences
.
getString
(
ORDER_ID
,
""
).
toString
()
);
toolbar
=
findViewById
(
R
.
id
.
topAppBar
);
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
...
...
@@ -116,7 +116,8 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
ORDER_ID
,
"MES-ORDER"
+
utils
.
timeStamp
());
if
(
editor
.
commit
()){
// Toast.makeText(MainActivity.this, orderId, Toast.LENGTH_LONG).show();
Log
.
i
(
"ORDER ID"
,
"onCreate: "
+
sharedPreferences
.
getString
(
ORDER_ID
,
""
).
toString
());
Toast
.
makeText
(
MainActivity
.
this
,
sharedPreferences
.
getString
(
ORDER_ID
,
""
).
toString
(),
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
@@ -149,8 +150,8 @@ public class MainActivity extends AppCompatActivity {
}
else
if
(
id
==
R
.
id
.
update
){
status_update
=
true
;
// binding.topAppBar.setVisibility(View.GONE);
binding
.
tvCategory
.
setVisibility
(
View
.
GONE
);
binding
.
rvCategory
.
setVisibility
(
View
.
GONE
);
//
binding.tvCategory.setVisibility(View.GONE);
//
binding.rvCategory.setVisibility(View.GONE);
// binding.appBarUpdate.setVisibility(View.VISIBLE);
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
topAppBar
);
...
...
@@ -161,6 +162,7 @@ public class MainActivity extends AppCompatActivity {
toolbars
.
setNavigationOnClickListener
(
view
->
updateFinish
());
productAdapter
.
notifyDataSetChanged
();
categoryAdapter
.
notifyDataSetChanged
();
}
else
if
(
id
==
R
.
id
.
create
)
{
startActivity
(
new
Intent
(
getApplicationContext
(),
FormProductActivity
.
class
));
}
else
if
(
id
==
R
.
id
.
allTransaction
){
...
...
@@ -398,6 +400,16 @@ public class MainActivity extends AppCompatActivity {
});
}
}
@Override
public
void
onUpdateCategory
(
CategoryModels
categoryModels
)
{
}
@Override
public
void
onDeleteCategory
(
CategoryModels
categoryModels
)
{
}
});
}
...
...
app/src/main/java/com/yono/messeripos/PaymentActivity.java
View file @
700f1ea0
...
...
@@ -68,8 +68,8 @@ public class PaymentActivity extends AppCompatActivity {
Button
cashBtn
;
ProgressDialog
progressDialog
;
BottomSheetBehavior
bottomSheetBank
;
//
RelativeLayout qrcodeLayoutBank;
RelativeLayout
qrcodeLayoutBank
;
PaymentsModels
paymentsModelsIntent
;
@Override
...
...
@@ -84,13 +84,12 @@ public class PaymentActivity extends AppCompatActivity {
}
sharedPreferences
=
getSharedPreferences
(
MainActivity
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
paymentsModelsIntent
=
getIntent
().
getParcelableExtra
(
CartActivity
.
CODE_SEND_CHECKOUT_HISTORY
);
paymentsModels
=
new
PaymentsModels
();
checkoutAdapter
=
new
CheckoutAdapter
();
recyclerView
=
findViewById
(
R
.
id
.
rvItem
);
grandTotal
=
findViewById
(
R
.
id
.
grand_total
);
// qrcodeLayoutBank = findViewById(R.id.qrCodeForm);
// bottomSheetBank = BottomSheetBehavior.from(qrcodeLayoutBank);
progressDialog
=
new
ProgressDialog
(
PaymentActivity
.
this
);
progressDialog
.
setMessage
(
"Loading..."
);
progressDialog
.
setCancelable
(
false
);
...
...
@@ -99,7 +98,11 @@ public class PaymentActivity extends AppCompatActivity {
setSupportActionBar
(
toolbars
);
DividerItemDecoration
dividerItemDecoration
=
new
DividerItemDecoration
(
this
,
DividerItemDecoration
.
VERTICAL
);
mainViewModels
=
new
ViewModelProvider
(
PaymentActivity
.
this
).
get
(
MainViewModelsCart
.
class
);
mainViewModels
.
getCartById
(
orderId
).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
Log
.
i
(
"IN_HISTORY"
,
"onCreate: "
+
utils
.
convertGson
(
paymentsModelsIntent
));
if
(
paymentsModelsIntent
==
null
){
mainViewModels
.
getCartById
(
sharedPreferences
.
getString
(
ORDER_ID
,
""
)).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
String
js
=
new
Gson
().
toJson
(
productCartModels
);
...
...
@@ -109,6 +112,7 @@ public class PaymentActivity extends AppCompatActivity {
total
=
total
+
pd
.
getPrice_orders
()*
pd
.
getQuantity_orders
();
}
if
(
productCartModels
.
size
()
!=
0
){
getSupportActionBar
().
setTitle
(
productCartModels
.
get
(
0
).
getId_orders
());
paymentsModels
.
setOrderId
(
productCartModels
.
get
(
0
).
getId_orders
());
paymentsModels
.
setGrossAmount
(
total
);
...
...
@@ -118,10 +122,35 @@ public class PaymentActivity extends AppCompatActivity {
recyclerView
.
addItemDecoration
(
dividerItemDecoration
);
grandTotal
.
setText
(
utils
.
convertPrice
(
"Rp. "
,
total
));
}
}
});
}
else
{
mainViewModels
.
getCartById
(
paymentsModelsIntent
.
getOrderId
()).
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
public
void
onChanged
(
List
<
ProductCartModels
>
productCartModels
)
{
String
js
=
new
Gson
().
toJson
(
productCartModels
);
Log
.
i
(
"On Intent_CHANGE"
,
"onChanged: "
+
paymentsModels
.
getOrderId
());
bottomSheet
=
new
BottomSheets
(
paymentsModels
);
for
(
ProductCartModels
pd
:
productCartModels
){
total
=
total
+
pd
.
getPrice_orders
()*
pd
.
getQuantity_orders
();
}
if
(
productCartModels
.
size
()
!=
0
){
getSupportActionBar
().
setTitle
(
productCartModels
.
get
(
0
).
getId_orders
());
paymentsModels
.
setOrderId
(
productCartModels
.
get
(
0
).
getId_orders
());
paymentsModels
.
setGrossAmount
(
total
);
checkoutAdapter
.
setCheckoutAdapter
(
PaymentActivity
.
this
,
productCartModels
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
PaymentActivity
.
this
,
RecyclerView
.
VERTICAL
,
false
));
recyclerView
.
setAdapter
(
checkoutAdapter
);
recyclerView
.
addItemDecoration
(
dividerItemDecoration
);
grandTotal
.
setText
(
utils
.
convertPrice
(
"Rp. "
,
total
));
}
}
});
}
bottomSheet
=
new
BottomSheets
(
paymentsModels
);
RecyclerView
rvPayment
=
findViewById
(
R
.
id
.
rvPayment
);
...
...
@@ -143,35 +172,6 @@ public class PaymentActivity extends AppCompatActivity {
btnPay
.
setEnabled
(
true
);
});
// bottomSheetBank.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
// @Override
// public void onStateChanged(@NonNull View bottomSheet, int newState) {
// switch (newState) {
// case BottomSheetBehavior.STATE_HIDDEN:
// break;
// case BottomSheetBehavior.STATE_EXPANDED:
// break;
// case BottomSheetBehavior.STATE_COLLAPSED:
// break;
// case BottomSheetBehavior.STATE_DRAGGING:
// break;
// case BottomSheetBehavior.STATE_SETTLING:
// break;
// }
// }
//
// @Override
// public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// if (bottomSheetBank.getState() != BottomSheetBehavior.STATE_EXPANDED) {
// bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// } else {
// bottomSheetBank.setState(BottomSheetBehavior.STATE_COLLAPSED);
// }
// }
// });
btnPay
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
...
...
@@ -180,11 +180,12 @@ public class PaymentActivity extends AppCompatActivity {
Log
.
i
(
"CASH"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModels
));
bottomSheet
=
new
BottomSheets
(
paymentsModels
);
bottomSheet
.
setCancelable
(
false
);
bottomSheet
.
show
(
getSupportFragmentManager
(),
"ModalBottomSheet"
);
}
else
{
bottomSheetBank
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
//
bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// progressDialog.show();
// Client client = new Client();
// paymentsModels.setPaymentType("bank_transfer");
...
...
app/src/main/java/com/yono/messeripos/adapter/CategoryAdapter.java
View file @
700f1ea0
...
...
@@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import
androidx.databinding.DataBindingUtil
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.yono.messeripos.MainActivity
;
import
com.yono.messeripos.R
;
import
com.yono.messeripos.databinding.ItemCategoryBinding
;
import
com.yono.messeripos.models.CategoryModels
;
...
...
@@ -24,6 +25,10 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.MyView
public
interface
CategoryListener
{
void
onGetProduct
(
CategoryModels
categoryModels
);
void
onUpdateCategory
(
CategoryModels
categoryModels
);
void
onDeleteCategory
(
CategoryModels
categoryModels
);
}
private
CategoryListener
listener
;
...
...
@@ -73,6 +78,21 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.MyView
binding
.
setCategory
(
categoryModels
);
binding
.
cvCategory
.
setOnClickListener
(
view
->
listener
.
onGetProduct
(
categoryModels
));
binding
.
categoryDelete
.
setOnClickListener
(
view
->
listener
.
onDeleteCategory
(
categoryModels
));
binding
.
categoryUpdate
.
setOnClickListener
(
view
->
listener
.
onUpdateCategory
(
categoryModels
));
if
(!
MainActivity
.
status_update
)
{
binding
.
categoryDelete
.
setVisibility
(
View
.
GONE
);
binding
.
categoryUpdate
.
setVisibility
(
View
.
GONE
);
}
else
{
if
(
getAdapterPosition
()
==
0
){
binding
.
categoryUpdate
.
setVisibility
(
View
.
GONE
);
binding
.
categoryDelete
.
setVisibility
(
View
.
GONE
);
}
else
{
binding
.
categoryUpdate
.
setVisibility
(
View
.
VISIBLE
);
binding
.
categoryDelete
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
}
}
app/src/main/java/com/yono/messeripos/api/service/CategoryServise.java
View file @
700f1ea0
...
...
@@ -8,7 +8,9 @@ import com.yono.messeripos.response.DataResponse;
import
java.util.List
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.GET
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
...
...
@@ -18,4 +20,7 @@ public interface CategoryServise {
@GET
(
ApiHelper
.
VERSI_API_1
+
"product-category-id/{id}"
)
Call
<
DataResponse
<
List
<
ProductModels
>>>
getCategoryById
(
@Path
(
"id"
)
int
id
);
@POST
(
ApiHelper
.
VERSI_API_1
+
"category"
)
Call
<
DataResponse
<
CategoryModels
>>
addCategory
(
@Body
CategoryModels
categoryModels
);
}
app/src/main/java/com/yono/messeripos/api/service/OrdersService.java
View file @
700f1ea0
...
...
@@ -19,5 +19,5 @@ public interface OrdersService {
Call
<
DataResponse
>
postOrders
(
@Body
OrdersResponse
cartPost
);
@GET
(
ApiHelper
.
VERSI_API_1
+
"order-products/{id}"
)
Call
<
DataResponse
<
OrdersResponse
<
List
<
ProductModels
>
>>>
getOrdersProductById
(
@Path
(
"id"
)
String
id
);
Call
<
DataResponse
<
List
<
ProductModels
>>>
getOrdersProductById
(
@Path
(
"id"
)
String
id
);
}
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
700f1ea0
...
...
@@ -54,6 +54,10 @@ public class MainViewModels extends ViewModel {
return
categoryList
;
}
public
void
postCategory
(
CategoryModels
categoryModels
){
saveCategory
(
categoryModels
);
}
public
LiveData
<
DataResponse
<
List
<
ProductModels
>>>
getProductByCategory
(
int
id
){
getDataProductByCategory
(
id
);
return
productByCategory
;
...
...
@@ -64,6 +68,22 @@ public class MainViewModels extends ViewModel {
return
transactions
;
}
private
void
saveCategory
(
CategoryModels
categoryModels
)
{
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
categoryServise
.
addCategory
(
categoryModels
).
enqueue
(
new
Callback
<
DataResponse
<
CategoryModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
Log
.
i
(
"Add Categiry"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"error add"
,
"onFailure: "
,
t
);
}
});
}
public
void
deleteProducts
(
int
id
){
ProductService
productService
=
client
.
Client
(
ProductService
.
class
);
productService
.
deleteProducts
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
ProductModels
>>()
{
...
...
app/src/main/res/layout/activity_q_r_code.xml
View file @
700f1ea0
...
...
@@ -5,7 +5,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"
380dp
"
android:layout_height=
"
wrap_content
"
app:behavior_hideable=
"true"
app:behavior_peekHeight=
"56dp"
android:background=
"#efefef"
...
...
@@ -26,6 +26,8 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Va_Text"
android:textSize=
"20sp"
android:textStyle=
"bold"
android:layout_below=
"@id/qr_image"
android:layout_centerInParent=
"true"
/>
...
...
app/src/main/res/layout/form_category.xml
View file @
700f1ea0
...
...
@@ -22,7 +22,7 @@
android:layout_height=
"wrap_content"
android:layout_below=
"@id/tvAddCategory"
android:hint=
"Category Name"
android:inputType=
"
number
"
android:inputType=
"
text
"
android:imeOptions=
"actionDone"
/>
<Button
...
...
app/src/main/res/layout/item_category.xml
View file @
700f1ea0
...
...
@@ -12,7 +12,6 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:paddingVertical=
"10dp"
android:layout_marginHorizontal=
"3dp"
>
<com.google.android.material.card.MaterialCardView
...
...
@@ -26,7 +25,6 @@
android:clipToPadding=
"true"
android:background=
"@drawable/ic_rounded_circle"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
>
...
...
@@ -58,6 +56,30 @@
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/categoryDelete"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:text=
"DELETE"
android:textSize=
"10sp"
android:textAlignment=
"textStart"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
android:backgroundTint=
"@android:color/holo_red_dark"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/categoryUpdate"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:text=
"UPDATE"
android:textSize=
"10sp"
android:textAlignment=
"textEnd"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
android:backgroundTint=
"@color/colorGreen"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
app/src/main/res/layout/item_list.xml
View file @
700f1ea0
...
...
@@ -66,7 +66,7 @@
android:layout_marginEnd=
"10dp"
app:layout_constraintBottom_toTopOf=
"@id/btnDelete"
app:layout_constraintEnd_toEndOf=
"parent"
android:backgroundTint=
"
#4CAF50
"
android:backgroundTint=
"
@color/colorGreen
"
android:text=
"UPDATE"
/>
<TextView
...
...
app/src/main/res/values/colors.xml
View file @
700f1ea0
...
...
@@ -11,4 +11,5 @@
<color
name=
"badge_available"
>
#9DED87
</color>
<color
name=
"colorLine"
>
#dfdfdf
</color>
<color
name=
"colorRed"
>
#F81A1A
</color>
<color
name=
"colorGreen"
>
#4CAF50
</color>
</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