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
e3c02909
Commit
e3c02909
authored
Aug 27, 2020
by
Muhammad Suryono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix payment
parent
d0f84c04
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
460 additions
and
174 deletions
+460
-174
Project.xml
.idea/codeStyles/Project.xml
+0
-24
misc.xml
.idea/misc.xml
+1
-1
build.gradle
app/build.gradle
+1
-1
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+3
-2
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+5
-0
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+73
-30
PaymentActivity.java
app/src/main/java/com/yono/messeripos/PaymentActivity.java
+40
-3
SplashScreen.java
app/src/main/java/com/yono/messeripos/SplashScreen.java
+0
-3
CartAdapter.java
...rc/main/java/com/yono/messeripos/adapter/CartAdapter.java
+12
-5
CheckoutAdapter.java
...ain/java/com/yono/messeripos/adapter/CheckoutAdapter.java
+71
-0
PaymentService.java
.../java/com/yono/messeripos/api/service/PaymentService.java
+11
-0
PaymentsModels.java
.../main/java/com/yono/messeripos/models/PaymentsModels.java
+53
-1
Utils.java
app/src/main/java/com/yono/messeripos/utils/Utils.java
+7
-0
activity_cart.xml
app/src/main/res/layout/activity_cart.xml
+8
-5
activity_payment.xml
app/src/main/res/layout/activity_payment.xml
+110
-97
item_checkout.xml
app/src/main/res/layout/item_checkout.xml
+64
-0
styles.xml
app/src/main/res/values/styles.xml
+1
-2
No files found.
.idea/codeStyles/Project.xml
View file @
e3c02909
<component
name=
"ProjectCodeStyleConfiguration"
>
<code_scheme
name=
"Project"
version=
"173"
>
<DBN-PSQL>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
/>
</DBN-PSQL>
<DBN-SQL>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
>
<option
name=
"STATEMENT_SPACING"
value=
"one_line"
/>
<option
name=
"CLAUSE_CHOP_DOWN"
value=
"chop_down_if_statement_long"
/>
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options
enabled=
"true"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
...
...
.idea/misc.xml
View file @
e3c02909
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"
JDK
"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"
1.8
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/build.gradle
View file @
e3c02909
...
...
@@ -6,7 +6,7 @@ android {
defaultConfig
{
applicationId
"com.yono.messeripos"
minSdkVersion
2
2
minSdkVersion
2
3
targetSdkVersion
30
versionCode
1
versionName
"1.0"
...
...
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
e3c02909
...
...
@@ -11,6 +11,7 @@ import android.view.View;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.ListView
;
import
androidx.annotation.RequiresApi
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -59,9 +60,9 @@ public class CartActivity extends AppCompatActivity {
toolbars
.
setNavigationOnClickListener
(
view
->
onBackPressed
());
recyclerView
=
findViewById
(
R
.
id
.
rvCart
);
cartAdapter
=
new
CartAdapter
();
btnCheckout
=
findViewById
(
R
.
id
.
btCheckout
);
cartAdapter
=
new
CartAdapter
();
LinearLayoutManager
llm
=
new
LinearLayoutManager
(
this
);
recyclerView
.
setLayoutManager
(
llm
);
...
...
@@ -126,7 +127,7 @@ public class CartActivity extends AppCompatActivity {
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
SplashScreen
.
CHECKOUT
,
true
);
editor
.
putBoolean
(
MainActivity
.
CHECKOUT
,
true
);
if
(
editor
.
commit
()){
startActivity
(
new
Intent
(
CartActivity
.
this
,
PaymentActivity
.
class
));
finish
();
...
...
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
e3c02909
package
com
.
yono
.
messeripos
;
import
android.Manifest
;
import
android.content.CursorLoader
;
import
android.content.Intent
;
import
android.database.Cursor
;
...
...
@@ -61,6 +62,9 @@ public class FormProductActivity extends AppCompatActivity {
"Oreo"
};
private
String
[]
permissions
=
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -68,6 +72,7 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
btnAdd
.
setText
(
"Add New Prooduct"
);
productModels
=
new
ProductModels
();
requestPermissions
(
permissions
,
REQUEST_PERMISSIONS
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
e3c02909
...
...
@@ -57,23 +57,29 @@ public class MainActivity extends AppCompatActivity {
MainViewModelsCart
mainViewModelsCart
;
public
static
Boolean
cartIsEmpty
;
SharedPreferences
sharedPreferences
;
public
static
final
String
CHECKOUT
=
"checkout"
;
public
static
Boolean
checkout
;
public
static
Boolean
selectCategory
=
false
;
@SuppressLint
(
"LongLogTag"
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
binding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_main
);
ProductAdapter
adapter
=
new
ProductAdapter
();
binding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_main
);
binding
.
rvProduct
.
setAdapter
(
adapter
);
binding
.
appBarUpdate
.
setVisibility
(
View
.
GONE
);
Log
.
i
(
"Status Checkout main activity"
,
"onCreate: "
+
SplashScreen
.
checkout
);
showLoading
(
true
);
categoryAdapter
=
new
CategoryAdapter
();
productAdapter
=
new
ProductAdapter
();
mainViewModelsCart
=
new
ViewModelProvider
(
MainActivity
.
this
).
get
(
MainViewModelsCart
.
class
);
sharedPreferences
=
getSharedPreferences
(
SplashScreen
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
checkout
=
sharedPreferences
.
getBoolean
(
CHECKOUT
,
false
);
toolbar
=
findViewById
(
R
.
id
.
topAppBar
);
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
...
...
@@ -81,13 +87,12 @@ public class MainActivity extends AppCompatActivity {
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
}
toolbar
=
findViewById
(
R
.
id
.
topAppBar
);
toolbar
.
setOnMenuItemClickListener
(
new
Toolbar
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
int
id
=
item
.
getItemId
();
if
(
id
==
R
.
id
.
menu_cart
)
{
if
(
SplashScreen
.
checkout
){
if
(
checkout
){
startActivity
(
new
Intent
(
getApplicationContext
(),
PaymentActivity
.
class
));
}
else
{
startActivity
(
new
Intent
(
getApplicationContext
(),
CartActivity
.
class
));
...
...
@@ -112,15 +117,18 @@ public class MainActivity extends AppCompatActivity {
}
});
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
mainViewModels
.
getCategory
().
observe
(
this
,
new
Observer
<
DataResponse
<
List
<
CategoryModels
>>>()
{
@Override
public
void
onChanged
(
DataResponse
<
List
<
CategoryModels
>>
listDataResponse
)
{
if
(
listDataResponse
!=
null
)
{
CategoryModels
caModels
=
new
CategoryModels
();
caModels
.
setNameCategory
(
"All"
);
caModels
.
setIdCategory
(
0
);
List
<
CategoryModels
>
categoryModels
=
listDataResponse
.
getData
();
ArrayList
<
CategoryModels
>
categoryModelsArrayList
=
new
ArrayList
<>();
categoryModels
.
add
(
0
,
caModels
);
categoryModelsArrayList
.
addAll
(
categoryModels
);
categoryAdapter
.
setCategoriAdapter
(
MainActivity
.
this
,
categoryModelsArrayList
);
binding
.
rvCategory
.
setLayoutManager
(
new
LinearLayoutManager
(
MainActivity
.
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
));
...
...
@@ -133,8 +141,6 @@ public class MainActivity extends AppCompatActivity {
}
});
mainViewModels
=
ViewModelProviders
.
of
(
this
).
get
(
MainViewModels
.
class
);
binding
.
imgEmpty
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
...
...
@@ -244,9 +250,45 @@ public class MainActivity extends AppCompatActivity {
showLoading
(
true
);
ProgressDialog
progressDialog
=
new
ProgressDialog
(
MainActivity
.
this
);
progressDialog
.
setMessage
(
"Loading..."
);
Log
.
i
(
"diluar if"
,
"onGetProduct: "
+
selectCategory
);
if
(!
selectCategory
){
progressDialog
.
show
();
}
selectCategory
=
true
;
Log
.
i
(
"setelah if"
,
"onGetProduct: "
+
selectCategory
);
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
if
(
categoryModels
.
getIdCategory
()
==
0
){
mainViewModels
.
getProduct
().
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
@Override
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>
listDataResponse
)
{
if
(
listDataResponse
!=
null
)
{
ArrayList
<
ProductModels
>
productModelsArrayList
=
new
ArrayList
<>();
productModelsArrayList
.
addAll
(
listDataResponse
.
getData
());
progressDialog
.
dismiss
();
showLoading
(
false
);
if
(
productModelsArrayList
.
isEmpty
())
{
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
VISIBLE
);
binding
.
imgEmpty
.
bringToFront
();
selectCategory
=
false
;
Log
.
i
(
"daidalam get if"
,
"onGetProduct: "
+
selectCategory
);
}
else
{
binding
.
rvProduct
.
setVisibility
(
View
.
VISIBLE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
GONE
);
productAdapter
.
setProduct
(
MainActivity
.
this
,
productModelsArrayList
);
binding
.
rvProduct
.
setLayoutManager
(
new
GridLayoutManager
(
MainActivity
.
this
,
2
));
binding
.
rvProduct
.
setAdapter
(
productAdapter
);
selectCategory
=
false
;
Log
.
i
(
"daidalam get else"
,
"onGetProduct: "
+
selectCategory
);
// productAdapter.notifyDataSetChanged();
}
}
}
});
selectCategory
=
false
;
}
else
{
mainViewModels
.
getProductByCategory
(
categoryModels
.
getIdCategory
()).
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
>>>()
{
@Override
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
>>
listDataResponse
)
{
...
...
@@ -266,12 +308,13 @@ public class MainActivity extends AppCompatActivity {
productAdapter
.
setProduct
(
MainActivity
.
this
,
productModelsArrayList
);
binding
.
rvProduct
.
setLayoutManager
(
new
GridLayoutManager
(
MainActivity
.
this
,
2
));
binding
.
rvProduct
.
setAdapter
(
productAdapter
);
productAdapter
.
notifyDataSetChanged
();
//
productAdapter.notifyDataSetChanged();
}
}
}
});
}
}
});
}
...
...
app/src/main/java/com/yono/messeripos/PaymentActivity.java
View file @
e3c02909
...
...
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
androidx.lifecycle.ViewModelProviders
;
import
androidx.recyclerview.widget.DividerItemDecoration
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
...
...
@@ -15,41 +16,59 @@ import android.view.View;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toolbar
;
import
com.google.android.material.appbar.MaterialToolbar
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.google.gson.Gson
;
import
com.yono.messeripos.adapter.CartAdapter
;
import
com.yono.messeripos.adapter.CheckoutAdapter
;
import
com.yono.messeripos.adapter.PaymentAdapter
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.MainViewModelsCart
;
import
com.yono.messeripos.models.PaymentsModels
;
import
com.yono.messeripos.models.ProductCartModels
;
import
com.yono.messeripos.response.PaymentResponse
;
import
com.yono.messeripos.utils.Utils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
yono
.
messeripos
.
MainActivity
.
checkout
;
public
class
PaymentActivity
extends
AppCompatActivity
{
private
ArrayList
<
PaymentResponse
>
paymentResponses
=
new
ArrayList
<>();
public
static
String
methodPay
=
""
;
private
Button
btnPay
;
private
MainViewModelsCart
mainViewModels
;
private
PaymentsModels
paymentsModels
;
private
long
total
=
0
;
private
Utils
utils
=
new
Utils
();
private
RecyclerView
recyclerView
;
private
CheckoutAdapter
checkoutAdapter
;
private
TextView
grandTotal
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_payment
);
Log
.
i
(
"Status Checkout payment"
,
"onCreate: "
+
SplashScreen
.
checkout
);
Log
.
i
(
"Status Checkout payment"
,
"onCreate: "
+
checkout
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
}
paymentsModels
=
new
PaymentsModels
();
checkoutAdapter
=
new
CheckoutAdapter
();
recyclerView
=
findViewById
(
R
.
id
.
rvItem
);
grandTotal
=
findViewById
(
R
.
id
.
grand_total
);
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
appbar
);
setSupportActionBar
(
toolbars
);
DividerItemDecoration
dividerItemDecoration
=
new
DividerItemDecoration
(
this
,
DividerItemDecoration
.
VERTICAL
);
mainViewModels
=
new
ViewModelProvider
(
PaymentActivity
.
this
).
get
(
MainViewModelsCart
.
class
);
mainViewModels
.
getCartProduct
().
observe
(
this
,
new
Observer
<
List
<
ProductCartModels
>>()
{
@Override
...
...
@@ -57,7 +76,18 @@ public class PaymentActivity extends AppCompatActivity {
String
js
=
new
Gson
().
toJson
(
productCartModels
);
Log
.
i
(
"On payment"
,
"onChanged: "
+
js
);
for
(
ProductCartModels
pd
:
productCartModels
){
total
=
total
+
pd
.
getPrice_orders
()*
pd
.
getQuantity_orders
();
}
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
));
}
});
...
...
@@ -85,7 +115,14 @@ public class PaymentActivity extends AppCompatActivity {
btnPay
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Toast
.
makeText
(
getApplicationContext
(),
methodPay
,
Toast
.
LENGTH_LONG
).
show
();
if
(
methodPay
.
equals
(
"cash"
)){
paymentsModels
.
setPaymentType
(
"cash"
);
Log
.
i
(
"CASH"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModels
));
}
else
{
paymentsModels
.
setPaymentType
(
"bank_transfer"
);
paymentsModels
.
setBank
(
methodPay
);
Log
.
i
(
"BANK"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModels
));
}
}
});
}
...
...
app/src/main/java/com/yono/messeripos/SplashScreen.java
View file @
e3c02909
...
...
@@ -24,9 +24,7 @@ public class SplashScreen extends AppCompatActivity {
SharedPreferences
sharedPreferences
;
public
static
final
String
MY_SHARED_PREFERENCES
=
"my_shared_preferences"
;
public
static
final
String
SESSION
=
"session"
;
public
static
final
String
CHECKOUT
=
"checkout"
;
public
static
Boolean
session
;
public
static
Boolean
checkout
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -50,7 +48,6 @@ public class SplashScreen extends AppCompatActivity {
},
700
);
sharedPreferences
=
getSharedPreferences
(
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
session
=
sharedPreferences
.
getBoolean
(
SESSION
,
false
);
checkout
=
sharedPreferences
.
getBoolean
(
CHECKOUT
,
false
);
...
...
app/src/main/java/com/yono/messeripos/adapter/CartAdapter.java
View file @
e3c02909
...
...
@@ -15,6 +15,7 @@ import com.google.gson.Gson;
import
com.yono.messeripos.CartActivity
;
import
com.yono.messeripos.R
;
import
com.yono.messeripos.databinding.ItemCartBinding
;
import
com.yono.messeripos.databinding.ItemCheckoutBinding
;
import
com.yono.messeripos.models.CartModels
;
import
com.yono.messeripos.models.CategoryModels
;
import
com.yono.messeripos.models.ProductCartModels
;
...
...
@@ -66,6 +67,7 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
parent
,
false
);
return
new
MyViewHolder
(
itemCartBinding
);
}
...
...
@@ -90,17 +92,17 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
@SuppressLint
(
"SetTextI18n"
)
public
void
bindData
(
ProductCartModels
cartModels
)
{
binding
.
setCarts
(
cartModels
);
binding
.
setPrice
(
utils
.
convertPrice
(
"Rp. "
,
cartModels
.
getPrice_orders
()));
/*
* Data binding for itemCart in cart activity
* */
subtotal
=
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
();
binding
.
setCarts
(
cartModels
);
binding
.
setPrice
(
utils
.
convertPrice
(
"Rp. "
,
cartModels
.
getPrice_orders
()));
binding
.
setSubTotal
(
utils
.
convertPrice
(
"Rp. "
,
subtotal
));
binding
.
etQty
.
setText
(
Long
.
toString
(
cartModels
.
getQuantity_orders
()));
binding
.
btDelete
.
setOnClickListener
(
view
->
{
listener
.
onDelete
(
cartModels
);
});
// set edit text qty
binding
.
etQty
.
setText
(
Long
.
toString
(
cartModels
.
getQuantity_orders
()));
...
...
@@ -113,6 +115,11 @@ public class CartAdapter extends RecyclerView.Adapter<CartAdapter.MyViewHolder>
listener
.
onUpdateQuantityMinus
(
cartModels
);
});
binding
.
btDelete
.
setOnClickListener
(
view
->
{
listener
.
onDelete
(
cartModels
);
});
}
}
...
...
app/src/main/java/com/yono/messeripos/adapter/CheckoutAdapter.java
0 → 100644
View file @
e3c02909
package
com
.
yono
.
messeripos
.
adapter
;
import
android.content.Context
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.yono.messeripos.R
;
import
com.yono.messeripos.databinding.ItemCartBinding
;
import
com.yono.messeripos.databinding.ItemCheckoutBinding
;
import
com.yono.messeripos.models.ProductCartModels
;
import
com.yono.messeripos.utils.Utils
;
import
java.util.List
;
public
class
CheckoutAdapter
extends
RecyclerView
.
Adapter
<
CheckoutAdapter
.
MyViewHolder
>
{
private
List
<
ProductCartModels
>
cartModels
;
private
int
price
;
Context
context
;
Utils
utils
=
new
Utils
();
public
void
setCheckoutAdapter
(
Context
context
,
List
<
ProductCartModels
>
cartModels
)
{
this
.
cartModels
=
cartModels
;
this
.
context
=
context
;
Log
.
d
(
"Checkout Adapter: "
,
String
.
valueOf
(
this
.
cartModels
));
notifyDataSetChanged
();
}
@NonNull
@Override
public
CheckoutAdapter
.
MyViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
ItemCheckoutBinding
itemCheckoutBinding
=
DataBindingUtil
.
inflate
(
LayoutInflater
.
from
(
parent
.
getContext
()),
R
.
layout
.
item_checkout
,
parent
,
false
);
return
new
MyViewHolder
(
itemCheckoutBinding
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
CheckoutAdapter
.
MyViewHolder
holder
,
int
position
)
{
holder
.
binData
(
cartModels
.
get
(
position
));
}
@Override
public
int
getItemCount
()
{
return
cartModels
.
size
();
}
public
class
MyViewHolder
extends
RecyclerView
.
ViewHolder
{
private
long
subtotal
=
0
;
private
ItemCheckoutBinding
itemCheckoutBinding
;
public
MyViewHolder
(
@NonNull
ItemCheckoutBinding
itemView
)
{
super
(
itemView
.
getRoot
());
this
.
itemCheckoutBinding
=
itemView
;
}
public
void
binData
(
ProductCartModels
cartModels
){
subtotal
=
cartModels
.
getPrice_orders
()
*
cartModels
.
getQuantity_orders
();
itemCheckoutBinding
.
setCheckout
(
cartModels
);
itemCheckoutBinding
.
setSubtotal
(
utils
.
convertPrice
(
"Rp. "
,
subtotal
));
}
}
}
app/src/main/java/com/yono/messeripos/api/service/PaymentService.java
0 → 100644
View file @
e3c02909
package
com
.
yono
.
messeripos
.
api
.
service
;
import
com.yono.messeripos.api.ApiHelper
;
import
retrofit2.Call
;
import
retrofit2.http.POST
;
public
interface
PaymentService
{
// @POST(ApiHelper.VERSI_API_1+"payment")
// Call
}
app/src/main/java/com/yono/messeripos/models/PaymentsModels.java
View file @
e3c02909
...
...
@@ -3,5 +3,57 @@ package com.yono.messeripos.models;
import
com.google.gson.annotations.SerializedName
;
public
class
PaymentsModels
{
// @SerializedName("")
@SerializedName
(
"order_code"
)
private
String
orderId
;
@SerializedName
(
"payment_type"
)
private
String
paymentType
;
@SerializedName
(
"bank"
)
private
String
bank
;
@SerializedName
(
"gross_amount"
)
private
long
grossAmount
;
public
PaymentsModels
()
{
}
public
PaymentsModels
(
String
orderId
,
String
paymentType
,
String
bank
,
long
grossAmount
)
{
this
.
orderId
=
orderId
;
this
.
paymentType
=
paymentType
;
this
.
bank
=
bank
;
this
.
grossAmount
=
grossAmount
;
}
public
String
getOrderId
()
{
return
orderId
;
}
public
void
setOrderId
(
String
orderId
)
{
this
.
orderId
=
orderId
;
}
public
String
getPaymentType
()
{
return
paymentType
;
}
public
void
setPaymentType
(
String
paymentType
)
{
this
.
paymentType
=
paymentType
;
}
public
String
getBank
()
{
return
bank
;
}
public
void
setBank
(
String
bank
)
{
this
.
bank
=
bank
;
}
public
long
getGrossAmount
()
{
return
grossAmount
;
}
public
void
setGrossAmount
(
long
grossAmount
)
{
this
.
grossAmount
=
grossAmount
;
}
}
app/src/main/java/com/yono/messeripos/utils/Utils.java
View file @
e3c02909
package
com
.
yono
.
messeripos
.
utils
;
import
com.google.gson.Gson
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.text.SimpleDateFormat
;
...
...
@@ -36,4 +38,9 @@ public class Utils {
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
return
timeStamp
;
}
public
String
convertGson
(
Object
object
){
String
js
=
new
Gson
().
toJson
(
object
);
return
js
;
}
}
app/src/main/res/layout/activity_cart.xml
View file @
e3c02909
...
...
@@ -16,12 +16,14 @@
android:id=
"@+id/rvCart"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@id/cAppBar"
android:overScrollMode=
"never"
android:padding=
"1
2
sp"
android:padding=
"1sp"
app:layoutManager=
"androidx.recyclerview.widget.GridLayoutManager"
tools:listitem=
"@layout/item_cart"
/>
app:layout_constraintBottom_toTopOf=
"@id/btCheckout"
app:layout_constraintTop_toBottomOf=
"@id/cAppBar"
app:layout_constraintVertical_bias=
"0.0"
tools:layout_editor_absoluteX=
"0dp"
tools:listitem=
"@layout/item_cart"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btCheckout"
...
...
@@ -30,9 +32,10 @@
android:text=
"@string/title_checkout"
android:padding=
"15dp"
android:textSize=
"16sp"
android:layout_
margin=
"10dp
"
android:layout_
alignParentBottom=
"true
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_payment.xml
View file @
e3c02909
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
...
...
@@ -16,100 +17,102 @@
app:layout_constraintEnd_toEndOf=
"parent"
/>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"600dp"
android:layout_marginBottom=
"5dp"
app:layout_constraintBottom_toTopOf=
"@id/btnPay"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/appbar"
app:layout_constraintVertical_bias=
"0.181"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvInvoice"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_cont
ent"
android:padding=
"18
dp"
android:layout_height=
"match_par
ent"
android:layout_marginTop=
"10
dp"
android:layout_marginBottom=
"10dp"
android:layout_margin=
"16dp"
app:cardCornerRadius=
"20dp"
android:padding=
"18dp"
android:scrollbars=
"vertical"
app:layout_constraintTop_toBottomOf=
"@+id/appbar"
tools:ignore=
"MissingConstraints"
>
app:cardCornerRadius=
"3dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintBottom_toTopOf=
"@id/btnPay"
tools:ignore=
"MissingConstraints,NotSibling"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"300dp
"
>
android:layout_height=
"wrap_content
"
android:padding=
"10dp"
>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvBilling"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:text=
"Billing "
android:textAlignment=
"center"
android:textSize=
"24sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.099"
app:layout_constraintStart_toStartOf=
"parent"
android:text=
"Billing "
/>
tools:layout_editor_absoluteY=
"-4dp"
/>
<ImageView
android:id=
"@+id/image_splash"
android:layout_width=
"50dp"
android:layout_height=
"50dp"
android:layout_marginTop=
"8dp"
android:src=
"@drawable/bill"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.13"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tvBilling"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvBillingProduct"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:textAlignment=
"center"
android:textSize=
"14sp"
app:layout_constraintTop_toBottomOf=
"@+id/image_splash"
android:text=
"@string/hint_product_name"
/>
app:layout_constraintTop_toBottomOf=
"@id/tvBilling"
/>
<com.google.android.material.textview.Material
TextView
android:id=
"@+id/tvBillingPrice
"
android:layout_width=
"wrap_content
"
<
TextView
android:id=
"@+id/grand_total
"
android:layout_width=
"300dp
"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:textAlignment=
"center"
android:textSize=
"14sp"
app:layout_constraintTop_toBottomOf=
"@+id/tvBillingProduct"
android:text=
"@string/hint_price"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvBillingQuantity"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:textAlignment=
"center"
android:textSize=
"14sp"
app:layout_constraintTop_toBottomOf=
"@+id/tvBillingPrice"
android:text=
"@string/hint_quantity"
/>
android:layout_marginTop=
"24dp"
android:text=
""
android:textColor=
"@android:color/black"
android:textSize=
"30sp"
android:textAlignment=
"textEnd"
app:layout_constraintBottom_toBottomOf=
"@id/image_splash"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.99"
app:layout_constraintStart_toEndOf=
"@id/image_splash"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.568"
tools:text=
"@tools:sample/full_names"
/>
<com.google.android.material.textview.Material
TextView
android:id=
"@+id/tvBillingCategory
"
android:layout_width=
"wrap_content
"
<
TextView
android:id=
"@+id/title_item
"
android:layout_width=
"200dp
"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:textAlignment=
"center"
android:textSize=
"14sp"
app:layout_constraintTop_toBottomOf=
"@+id/tvBillingQuantity"
android:text=
"@string/hint_category"
/>
android:layout_marginTop=
"10dp"
android:textColor=
"@android:color/black"
android:text=
"ITEM CHECKOUT"
android:textSize=
"20sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/image_splash"
tools:text=
"@tools:sample/full_names"
/>
<com.google.android.material.textview.MaterialText
View
android:id=
"@+id/tvBillingDesc
"
android:layout_width=
"wrap_cont
ent"
<androidx.recyclerview.widget.Recycler
View
android:id=
"@+id/rvItem
"
android:layout_width=
"match_par
ent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:fontFamily=
"@font/roboto"
android:textAlignment=
"center"
android:textSize=
"14sp"
app:layout_constraintTop_toBottomOf=
"@+id/tvBillingCategory"
android:text=
"@string/hint_description"
/>
android:layout_margin=
"0dp"
android:layout_marginTop=
"20dp"
app:layout_constraintTop_toBottomOf=
"@id/title_item"
tools:layout_editor_absoluteX=
"10dp"
tools:listitem=
"@layout/item_checkout"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
...
...
@@ -118,8 +121,17 @@
android:id=
"@+id/rvPayment"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:overScrollMode=
"ifContentScrolls "
app:layout_constraintTop_toBottomOf=
"@id/cvInvoice"
/>
android:layout_margin=
"10dp"
android:layout_marginTop=
"10dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cvInvoice"
tools:layout_editor_absoluteX=
"10dp"
tools:listitem=
"@layout/payment_list"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnPay"
...
...
@@ -130,6 +142,7 @@
android:textSize=
"16sp"
android:enabled=
"false"
android:layout_margin=
"10dp"
android:layout_alignParentBottom=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
...
...
app/src/main/res/layout/item_checkout.xml
0 → 100644
View file @
e3c02909
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
<variable
name=
"checkout"
type=
"com.yono.messeripos.models.ProductCartModels"
/>
<variable
name=
"subtotal"
type=
"String"
/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<com.google.android.material.card.MaterialCardView
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_margin=
"10dp"
>
<TextView
android:id=
"@+id/itemCheckout"
android:layout_width=
"200dp"
android:layout_height=
"wrap_content"
tools:text=
"@tools:sample/full_names"
android:textSize=
"20sp"
android:lines=
"3"
android:text=
"@{checkout.product_name_orders+` x `+checkout.quantity_orders}"
android:layout_margin=
"10dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/itemSubTotal"
android:layout_width=
"200dp"
android:layout_height=
"wrap_content"
tools:text=
"@tools:sample/full_names"
android:textSize=
"20sp"
android:text=
"@{subtotal}"
android:textColor=
"@android:color/black"
android:layout_margin=
"10dp"
app:layout_constraintStart_toEndOf=
"@id/itemCheckout"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
android:textAlignment=
"textEnd"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
e3c02909
...
...
@@ -6,7 +6,6 @@
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
<item
name=
"android:fontFamily"
>
@font/roboto
</item>
<item
name=
"android:windowLightStatusBar"
>
false
</item>
<item
name=
"android:actionBarStyle"
>
@style/ThemeActionBar
</item>
<item
name=
"android:windowActionBarOverlay"
>
false
</item>
<item
name=
"android:windowTranslucentStatus"
>
true
</item>
...
...
@@ -18,12 +17,12 @@
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
<item
name=
"android:windowLightStatusBar"
>
false
</item>
<item
name=
"android:actionBarStyle"
>
@style/ThemeActionBar
</item>
<item
name=
"android:windowActionBarOverlay"
>
false
</item>
<item
name=
"android:windowTranslucentStatus"
>
true
</item>
<item
name=
"android:windowTranslucentNavigation"
>
true
</item>
<item
name=
"windowActionBarOverlay"
>
true
</item>
<item
name=
"android:fontFamily"
>
@font/poppins_medium
</item>
<item
name=
"actionBarStyle"
>
@style/ThemeActionBar
</item>
</style>
...
...
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