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
8489d46d
Commit
8489d46d
authored
Aug 31, 2020
by
Alfansyah Fadlian
Browse files
Options
Browse Files
Download
Plain Diff
from dev
parents
2dfa5897
5b656e25
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
395 additions
and
206 deletions
+395
-206
BottomSheets.java
app/src/main/java/com/yono/messeripos/BottomSheets.java
+34
-33
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+0
-6
FormCategory.java
app/src/main/java/com/yono/messeripos/FormCategory.java
+55
-1
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+43
-7
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+65
-3
PaymentActivity.java
app/src/main/java/com/yono/messeripos/PaymentActivity.java
+46
-40
QRCode.java
app/src/main/java/com/yono/messeripos/QRCode.java
+31
-10
ToolbarApp.java
app/src/main/java/com/yono/messeripos/ToolbarApp.java
+0
-11
CategoryAdapter.java
...ain/java/com/yono/messeripos/adapter/CategoryAdapter.java
+2
-2
CategoryServise.java
...java/com/yono/messeripos/api/service/CategoryServise.java
+8
-0
activity_bottom_sheets.xml
app/src/main/res/layout/activity_bottom_sheets.xml
+56
-50
activity_login.xml
app/src/main/res/layout/activity_login.xml
+0
-10
activity_login_m.xml
app/src/main/res/layout/activity_login_m.xml
+1
-1
activity_payment.xml
app/src/main/res/layout/activity_payment.xml
+1
-0
activity_q_r_code.xml
app/src/main/res/layout/activity_q_r_code.xml
+16
-17
form_category.xml
app/src/main/res/layout/form_category.xml
+3
-3
item_cart.xml
app/src/main/res/layout/item_cart.xml
+2
-0
item_category.xml
app/src/main/res/layout/item_category.xml
+14
-12
styles.xml
app/src/main/res/values/styles.xml
+18
-0
No files found.
app/src/main/java/com/yono/messeripos/BottomSheets.java
View file @
8489d46d
...
...
@@ -18,19 +18,16 @@ import android.widget.TextView;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.
lifecycle.ViewModelProvider
;
import
androidx.
fragment.app.DialogFragment
;
import
com.google.android.material.bottomsheet.BottomSheetBehavior
;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.yono.messeripos.adapter.ProductAdapter
;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.PaymentService
;
import
com.yono.messeripos.models.PaymentsModels
;
import
com.yono.messeripos.models.ProductModels
;
import
com.yono.messeripos.response.DataResponse
;
import
com.yono.messeripos.utils.Utils
;
import
okhttp3.internal.Util
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
...
...
@@ -53,6 +50,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
RelativeLayout
layoutFormCash
;
PaymentsModels
paymentsModels
;
public
BottomSheets
(
PaymentsModels
paymentsModels
)
{
this
.
paymentsModels
=
paymentsModels
;
}
...
...
@@ -71,6 +69,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
activity_bottom_sheets
,
container
,
false
);
...
...
@@ -80,41 +79,42 @@ public class BottomSheets extends BottomSheetDialogFragment {
btnCash
=
v
.
findViewById
(
R
.
id
.
btnCash
);
totalHarga
=
v
.
findViewById
(
R
.
id
.
totalHarga
);
utils
=
new
Utils
();
bottomSheetBehavior
=
BottomSheetBehavior
.
from
(
layoutFormCash
);
//
bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
sharedPreferences
=
getActivity
().
getSharedPreferences
(
MainActivity
.
MY_SHARED_PREFERENCES
,
Context
.
MODE_PRIVATE
);
bottomSheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_COLLAPSED
);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
long
ga
=
paymentsModels
.
getGrossAmount
();
String
setCurrency
=
utils
.
convertPrice
(
"Rp."
,
ga
);
totalHarga
.
setText
(
setCurrency
);
hargaChange
.
setText
(
defaultText
);
bottomSheetBehavior
.
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
(
bottomSheetBehavior
.
getState
()
!=
BottomSheetBehavior
.
STATE_EXPANDED
)
{
bottomSheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
}
else
{
bottomSheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_COLLAPSED
);
}
}
});
//
bottomSheetBehavior.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 (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
//
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
//
} else {
//
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
//
}
//
}
//
});
inputAmount
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
...
...
@@ -124,7 +124,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
@Override
public
void
onTextChanged
(
CharSequence
charSequence
,
int
i
,
int
i1
,
int
i2
)
{
if
(
TextUtils
.
isEmpty
(
charSequence
))
inputAmount
.
setText
(
"
0
"
);
if
(
TextUtils
.
isEmpty
(
charSequence
))
inputAmount
.
setText
(
""
);
grossAmount
=
paymentsModels
.
getGrossAmount
();
long
input
=
Long
.
parseLong
(
inputAmount
.
getText
().
toString
());
...
...
@@ -146,6 +146,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
}
private
void
bayar
(
View
view
)
{
// String orderId, String paymentType, String bank, long grossAmount
PaymentsModels
paymentsModels
=
new
PaymentsModels
(
sharedPreferences
.
getString
(
ORDER_ID
,
""
),
...
...
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
8489d46d
...
...
@@ -3,7 +3,6 @@ package com.yono.messeripos;
import
android.app.AlertDialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Build
;
...
...
@@ -12,11 +11,8 @@ import android.util.Log;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.Toast
;
import
androidx.annotation.RequiresApi
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -34,7 +30,6 @@ import com.yono.messeripos.adapter.CartAdapter;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.OrdersService
;
import
com.yono.messeripos.api.service.PaymentService
;
import
com.yono.messeripos.api.service.ProductService
;
import
com.yono.messeripos.models.MainViewModelsCart
;
import
com.yono.messeripos.models.PaymentsModels
;
import
com.yono.messeripos.models.ProductCartModels
;
...
...
@@ -50,7 +45,6 @@ import retrofit2.Call;
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
;
...
...
app/src/main/java/com/yono/messeripos/FormCategory.java
View file @
8489d46d
...
...
@@ -4,31 +4,85 @@ import android.os.Bundle;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.google.android.material.button.MaterialButton
;
import
com.yono.messeripos.adapter.CategoryAdapter
;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.CategoryServise
;
import
com.yono.messeripos.models.CategoryModels
;
import
com.yono.messeripos.models.MainViewModels
;
import
com.yono.messeripos.models.MainViewModelsCart
;
import
com.yono.messeripos.response.DataResponse
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
FormCategory
extends
BottomSheetDialogFragment
{
MainViewModels
mainViewModels
;
public
EditText
etCategoryName
;
public
MaterialButton
btnAddCategory
;
CategoryModels
categoryModelsEdit
;
Boolean
updateCategory
=
false
;
public
FormCategory
()
{
}
public
interface
FormCategoryListener
{
void
onAddCategory
(
CategoryModels
categoryModels
);
void
onUpdateCategory
(
CategoryModels
categoryModels
);
}
private
FormCategoryListener
listener
;
public
void
setListener
(
FormCategoryListener
listener
)
{
this
.
listener
=
listener
;
}
public
void
EditFormCategory
(
CategoryModels
categoryModels
){
this
.
updateCategory
=
true
;
this
.
categoryModelsEdit
=
categoryModels
;
}
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
form_category
,
container
,
false
);
etCategoryName
=
v
.
findViewById
(
R
.
id
.
etCategoryName
);
btnAddCategory
=
v
.
findViewById
(
R
.
id
.
btnAddCategory
);
mainViewModels
=
new
ViewModelProvider
(
getActivity
()).
get
(
MainViewModels
.
class
);
if
(!
updateCategory
){
etCategoryName
.
setText
(
""
);
}
else
{
etCategoryName
.
setText
(
categoryModelsEdit
.
getNameCategory
());
btnAddCategory
.
setText
(
"Update Category"
);
}
btnAddCategory
.
setOnClickListener
(
view
->
addCategory
());
return
v
;
}
private
void
addCategory
()
{
if
(!
updateCategory
){
CategoryModels
categoryModels
=
new
CategoryModels
();
categoryModels
.
setNameCategory
(
etCategoryName
.
getText
().
toString
());
listener
.
onAddCategory
(
categoryModels
);
}
else
{
CategoryModels
categoryModels
=
new
CategoryModels
();
categoryModels
.
setNameCategory
(
etCategoryName
.
getText
().
toString
());
categoryModels
.
setIdCategory
(
categoryModelsEdit
.
getIdCategory
());
listener
.
onUpdateCategory
(
categoryModels
);
}
}
}
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
8489d46d
...
...
@@ -31,6 +31,7 @@ import com.google.android.material.appbar.MaterialToolbar;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.jaredrummler.materialspinner.MaterialSpinner
;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.CategoryServise
;
import
com.yono.messeripos.api.service.ProductService
;
import
com.yono.messeripos.databinding.FormProductBinding
;
import
com.yono.messeripos.models.CategoryModels
;
...
...
@@ -70,6 +71,7 @@ public class FormProductActivity extends AppCompatActivity {
Client
client
=
new
Client
();
ProductModels
productModelsIntent
;
List
<
String
>
categorySelect
=
new
ArrayList
<>();
FormCategory
formCategory
;
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -89,7 +91,7 @@ public class FormProductActivity extends AppCompatActivity {
}
productModelsIntent
=
getIntent
().
getParcelableExtra
(
MainActivity
.
DATA_PRODUCT
);
formCategory
=
new
FormCategory
();
MaterialToolbar
toolbars
=
findViewById
(
R
.
id
.
topAppBarForm
);
setSupportActionBar
(
toolbars
);
...
...
@@ -122,14 +124,45 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
btnAddCategory
.
setOnClickListener
(
view
->
addCategory
());
//spinner
categoryModels
=
new
ArrayList
<>();
categoryModels
.
add
(
"SELECT CATEGORY"
);
setSpinner
();
setSpinner
(
""
);
setSelectedSpinner
();
setAddListenerCategory
();
}
private
void
setAddListenerCategory
()
{
formCategory
.
setListener
(
new
FormCategory
.
FormCategoryListener
()
{
@Override
public
void
onAddCategory
(
CategoryModels
categoryModels
)
{
progressDialog
.
show
();
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
)
{
if
(
response
.
body
().
getStatusData
()){
progressDialog
.
dismiss
();
setSpinner
(
"post"
);
formCategory
.
dismiss
();
formCategory
.
etCategoryName
.
setText
(
""
);
}
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
new
AlertDialog
.
Builder
(
FormProductActivity
.
this
)
.
setTitle
(
"Add Category failed!"
)
.
setMessage
(
"Add category failed, try again!"
).
show
();
}
});
}
@Override
public
void
onUpdateCategory
(
CategoryModels
categoryModels
)
{
}
});
}
private
void
addCategory
()
{
FormCategory
formCategory
=
new
FormCategory
();
formCategory
.
show
(
getSupportFragmentManager
(),
"ModalFormCategory"
);
}
...
...
@@ -143,10 +176,13 @@ public class FormProductActivity extends AppCompatActivity {
});
}
private
void
setSpinner
()
{
private
void
setSpinner
(
String
s
)
{
categoryModels
=
new
ArrayList
<>();
categoryModels
.
add
(
"SELECT CATEGORY"
);
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
List
<
CategoryModels
>
cate
=
listDataResponse
.
getData
();
for
(
CategoryModels
cd:
cate
){
categoryModels
.
add
(
cd
.
getNameCategory
());
}
...
...
@@ -163,7 +199,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
(
getCategory
(
category
Models
.
get
(
0
)));
productModels
.
setCategoryProduct
(
getCategory
(
category
Select
.
get
(
0
)));
if
(
isUpdate
){
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
8489d46d
package
com
.
yono
.
messeripos
;
import
android.annotation.SuppressLint
;
import
android.app.AlertDialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.Intent
;
...
...
@@ -41,6 +42,7 @@ import com.google.gson.Gson;
import
com.yono.messeripos.adapter.CategoryAdapter
;
import
com.yono.messeripos.adapter.ProductAdapter
;
import
com.yono.messeripos.api.client.Client
;
import
com.yono.messeripos.api.service.CategoryServise
;
import
com.yono.messeripos.api.service.ProductService
;
import
com.yono.messeripos.databinding.ActivityMainBinding
;
import
com.yono.messeripos.models.CategoryModels
;
...
...
@@ -76,11 +78,13 @@ public class MainActivity extends AppCompatActivity {
public
static
final
String
ORDER_ID
=
"orderId"
;
Client
client
=
new
Client
();
public
static
ArrayList
<
ProductModels
>
productModelsArrayList
=
new
ArrayList
<>();
public
static
ArrayList
<
CategoryModels
>
categoryModelsArrayList
=
new
ArrayList
<>();
public
static
final
String
DATA_PRODUCT
=
"DATA_PRODUCT"
;
public
static
final
String
MY_SHARED_PREFERENCES
=
"main_sahred"
;
ProgressDialog
progressDialog
;
MaterialButton
btnAddCart
;
SkeletonScreen
skeletonCategory
;
FormCategory
formCategory
;
...
...
@@ -98,6 +102,7 @@ public class MainActivity extends AppCompatActivity {
btnAddCart
=
findViewById
(
R
.
id
.
materialBtnAddCart
);
binding
.
tvProduct
.
setVisibility
(
View
.
GONE
);
formCategory
=
new
FormCategory
();
categoryAdapter
=
new
CategoryAdapter
();
productAdapter
=
new
ProductAdapter
();
mainViewModelsCart
=
new
ViewModelProvider
(
MainActivity
.
this
).
get
(
MainViewModelsCart
.
class
);
...
...
@@ -133,6 +138,7 @@ public class MainActivity extends AppCompatActivity {
mainViewModelsGetProduct
();
productAdapterListener
();
categoryAdapterListener
();
formCategoryListener
();
}
private
void
toolbarSetOnItemClicked
()
{
...
...
@@ -183,7 +189,7 @@ public class MainActivity extends AppCompatActivity {
caModels
.
setIdCategory
(
0
);
List
<
CategoryModels
>
categoryModels
=
listDataResponse
.
getData
();
ArrayList
<
CategoryModels
>
categoryModelsArrayList
=
new
ArrayList
<>();
categoryModelsArrayList
=
new
ArrayList
<>();
categoryModels
.
add
(
0
,
caModels
);
categoryModelsArrayList
.
addAll
(
categoryModels
);
...
...
@@ -335,6 +341,43 @@ public class MainActivity extends AppCompatActivity {
});
}
private
void
formCategoryListener
()
{
formCategory
.
setListener
(
new
FormCategory
.
FormCategoryListener
()
{
@Override
public
void
onAddCategory
(
CategoryModels
categoryModels
)
{
}
@Override
public
void
onUpdateCategory
(
CategoryModels
categoryModels
)
{
progressDialog
.
show
();
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
categoryServise
.
updateCategory
(
categoryModels
.
getIdCategory
(),
categoryModels
).
enqueue
(
new
Callback
<
DataResponse
<
CategoryModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
progressDialog
.
dismiss
();
Log
.
i
(
"Update"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
&&
response
.
body
().
getMessageData
()
!=
"Parameter not found!"
){
categoryAdapter
.
notifyDataSetChanged
();
formCategory
.
dismiss
();
}
else
{
new
AlertDialog
.
Builder
(
MainActivity
.
this
)
.
setTitle
(
"Update Category failed!"
)
.
setMessage
(
response
.
body
().
getMessageData
()).
show
();
}
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
new
AlertDialog
.
Builder
(
MainActivity
.
this
)
.
setTitle
(
"Update Category failed!"
)
.
setMessage
(
"Update category failed, try again!"
).
show
();
}
});
}
});
}
private
void
categoryAdapterListener
()
{
categoryAdapter
.
setListener
(
new
CategoryAdapter
.
CategoryListener
()
{
@Override
...
...
@@ -401,15 +444,34 @@ public class MainActivity extends AppCompatActivity {
@Override
public
void
onUpdateCategory
(
CategoryModels
categoryModels
)
{
formCategory
.
EditFormCategory
(
categoryModels
);
formCategory
.
show
(
getSupportFragmentManager
(),
"ModalFormCategory"
);
}
@Override
public
void
onDeleteCategory
(
CategoryModels
categoryModels
,
int
position
)
{
progressDialog
.
show
();
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
categoryServise
.
deleteCategory
(
categoryModels
.
getIdCategory
()).
enqueue
(
new
Callback
<
DataResponse
<
CategoryModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
progressDialog
.
dismiss
();
categoryModelsArrayList
.
remove
(
position
);
Log
.
i
(
"KAAAA"
,
"onResponse: "
+
utils
.
convertGson
(
categoryModelsArrayList
));
// binding.rvCategory.removeViewAt(position);
categoryAdapter
.
notifyItemRemoved
(
position
);
categoryAdapter
.
notifyItemRangeChanged
(
position
,
categoryModelsArrayList
.
size
());
}
@Override
public
void
onDeleteCategory
(
CategoryModels
categoryModels
)
{
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
}
});
}
});
}
private
void
functionSearch
()
{
binding
.
etSearchProduct
.
addTextChangedListener
(
new
TextWatcher
()
{
...
...
app/src/main/java/com/yono/messeripos/PaymentActivity.java
View file @
8489d46d
...
...
@@ -64,6 +64,7 @@ public class PaymentActivity extends AppCompatActivity {
private
CheckoutAdapter
checkoutAdapter
;
private
TextView
grandTotal
;
public
static
BottomSheets
bottomSheet
;
public
static
QRCode
qrCode
;
public
static
SharedPreferences
sharedPreferences
;
Button
cashBtn
;
ProgressDialog
progressDialog
;
...
...
@@ -72,11 +73,11 @@ public class PaymentActivity extends AppCompatActivity {
PaymentsModels
paymentsModelsIntent
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_payment
);
Log
.
i
(
"Status Checkout payment"
,
"onCreate: "
+
checkout
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
Window
w
=
getWindow
();
...
...
@@ -172,7 +173,6 @@ public class PaymentActivity extends AppCompatActivity {
btnPay
.
setEnabled
(
true
);
});
btnPay
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
...
...
@@ -181,50 +181,56 @@ public class PaymentActivity extends AppCompatActivity {
Log
.
i
(
"CASH"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModels
));
bottomSheet
=
new
BottomSheets
(
paymentsModels
);
bottomSheet
.
setCancelable
(
fals
e
);
bottomSheet
.
setCancelable
(
tru
e
);
bottomSheet
.
show
(
getSupportFragmentManager
(),
"ModalBottomSheet"
);
}
else
{
progressDialog
.
show
();
// bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// progressDialog.show();
// Client client = new Client();
// paymentsModels.setPaymentType("bank_transfer");
// paymentsModels.setBank(methodPay);
// paymentsModels.setOrderId(orderId);
// Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
// PaymentService paymentService = client.Client(PaymentService.class);
// paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() {
// @Override
// public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) {
// Log.i("Paymen_bank", "onResponse: "+utils.convertGson(response.body()));
// if (response.body() != null){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString(ORDER_ID, "");
// editor.putBoolean(CHECKOUT, false);
// progressDialog.dismiss();
// if (editor.commit()){
// startActivity(new Intent(PaymentActivity.this, MainActivity.class));
// finish();
// }
// }else{
// progressDialog.dismiss();
// new AlertDialog.Builder(PaymentActivity.this)
// .setTitle("Payment Order")
// .setMessage("Erorr save!").show();
// }
// }
//
// @Override
// public void onFailure(Call<DataResponse<PaymentsModels>> call, Throwable t) {
// progressDialog.dismiss();
// new AlertDialog.Builder(PaymentActivity.this)
// .setCancelable(false)
// .setTitle("Payment Order")
// .setMessage("Add new payment failed, try again!").show();
// }
// });
Client
client
=
new
Client
();
paymentsModels
.
setPaymentType
(
"bank_transfer"
);
paymentsModels
.
setBank
(
methodPay
);
paymentsModels
.
setOrderId
(
orderId
);
Log
.
i
(
"BANK"
,
"onClick: "
+
utils
.
convertGson
(
paymentsModels
));
PaymentService
paymentService
=
client
.
Client
(
PaymentService
.
class
);
paymentService
.
postFromCart
(
paymentsModels
).
enqueue
(
new
Callback
<
DataResponse
<
PaymentsModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
PaymentsModels
>>
call
,
Response
<
DataResponse
<
PaymentsModels
>>
response
)
{
Log
.
i
(
"Paymen_bank"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
){
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
ORDER_ID
,
""
);
editor
.
putBoolean
(
CHECKOUT
,
false
);
progressDialog
.
dismiss
();
if
(
editor
.
commit
()){
qrCode
=
new
QRCode
(
response
.
body
());
qrCode
.
show
(
getSupportFragmentManager
(),
"QRCode"
);
}
}
else
{
progressDialog
.
dismiss
();
new
AlertDialog
.
Builder
(
PaymentActivity
.
this
)
.
setTitle
(
"Payment Order"
)
.
setMessage
(
"Erorr save!"
).
show
();
}
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
PaymentsModels
>>
call
,
Throwable
t
)
{
progressDialog
.
dismiss
();
new
AlertDialog
.
Builder
(
PaymentActivity
.
this
)
.
setCancelable
(
false
)
.
setTitle
(
"Payment Order"
)
.
setMessage
(
"Add new payment failed, try again!"
).
show
();
}
});
}
}
});
...
...
app/src/main/java/com/yono/messeripos/QRCode.java
View file @
8489d46d
package
com
.
yono
.
messeripos
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Point
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
;
import
com.google.android.material.textview.MaterialTextView
;
import
com.google.zxing.WriterException
;
import
com.yono.messeripos.models.PaymentsModels
;
import
com.yono.messeripos.response.DataResponse
;
import
androidmads.library.qrgenearator.QRGContents
;
import
androidmads.library.qrgenearator.QRGEncoder
;
public
class
QRCode
extends
AppCompatActivity
{
public
class
QRCode
extends
BottomSheetDialogFragment
{
ImageView
qrCode
;
MaterialTextView
vaText
;
QRGEncoder
qrgEncoder
;
String
inputValue
;
Bitmap
bitmap
;
DataResponse
<
PaymentsModels
>
paymentsModels
;
public
QRCode
(
DataResponse
<
PaymentsModels
>
paymentsModels
)
{
this
.
paymentsModels
=
paymentsModels
;
Log
.
d
(
"TAG"
,
"QRCode: "
+
paymentsModels
);
}
@Nullable
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_q_r_code
);
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
activity_q_r_code
,
container
,
false
);
qrCode
=
findViewById
(
R
.
id
.
qr_image
);
vaText
=
findViewById
(
R
.
id
.
etVA
);
generateQrCode
();
qrCode
=
v
.
findViewById
(
R
.
id
.
qr_image
);
vaText
=
v
.
findViewById
(
R
.
id
.
etVA
);
}
WindowManager
manager
=
(
WindowManager
)
getActivity
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
private
void
generateQrCode
()
{
WindowManager
manager
=
(
WindowManager
)
getSystemService
(
WINDOW_SERVICE
);
Display
display
=
manager
.
getDefaultDisplay
();
Point
point
=
new
Point
();
display
.
getSize
(
point
);
...
...
@@ -57,5 +74,9 @@ public class QRCode extends AppCompatActivity {
}
catch
(
Exception
e
)
{
Log
.
d
(
"onCreate: "
,
e
.
toString
());
}
return
v
;
}
}
\ No newline at end of file
app/src/main/java/com/yono/messeripos/ToolbarApp.java
deleted
100644 → 0
View file @
2dfa5897
package
com
.
yono
.
messeripos
;
import
android.content.Context
;
import
com.google.android.material.appbar.MaterialToolbar
;
public
class
ToolbarApp
{
}
app/src/main/java/com/yono/messeripos/adapter/CategoryAdapter.java
View file @
8489d46d
...
...
@@ -28,7 +28,7 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.MyView
void
onUpdateCategory
(
CategoryModels
categoryModels
);
void
onDeleteCategory
(
CategoryModels
categoryModels
);
void
onDeleteCategory
(
CategoryModels
categoryModels
,
int
position
);
}
private
CategoryListener
listener
;
...
...
@@ -78,7 +78,7 @@ 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
.
categoryDelete
.
setOnClickListener
(
view
->
listener
.
onDeleteCategory
(
categoryModels
,
getAdapterPosition
()
));
binding
.
categoryUpdate
.
setOnClickListener
(
view
->
listener
.
onUpdateCategory
(
categoryModels
));
if
(!
MainActivity
.
status_update
)
{
...
...
app/src/main/java/com/yono/messeripos/api/service/CategoryServise.java
View file @
8489d46d
...
...
@@ -9,8 +9,10 @@ import java.util.List;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.DELETE
;
import
retrofit2.http.GET
;
import
retrofit2.http.POST
;
import
retrofit2.http.PUT
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
...
...
@@ -23,4 +25,10 @@ public interface CategoryServise {
@POST
(
ApiHelper
.
VERSI_API_1
+
"category"
)
Call
<
DataResponse
<
CategoryModels
>>
addCategory
(
@Body
CategoryModels
categoryModels
);
@DELETE
(
ApiHelper
.
VERSI_API_1
+
"category/{id}"
)
Call
<
DataResponse
<
CategoryModels
>>
deleteCategory
(
@Path
(
"id"
)
int
id
);
@PUT
(
ApiHelper
.
VERSI_API_1
+
"category/{id}"
)
Call
<
DataResponse
<
CategoryModels
>>
updateCategory
(
@Path
(
"id"
)
int
id
,
@Body
CategoryModels
categoryModels
);
}
app/src/main/res/layout/activity_bottom_sheets.xml
View file @
8489d46d
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/form_cash"
android:layout_width=
"match_parent"
android:layout_height=
"
match_par
ent"
android:layout_height=
"
wrap_cont
ent"
android:gravity=
"center_horizontal"
android:orientation=
"vertical"
style=
"@style/AppModalStyle"
android:padding=
"16dp"
>
app:behavior_hideable=
"true"
android:backgroundTint=
"#333"
app:behavior_peekHeight=
"60dp"
style=
"@style/Widget.Rounded.BottomSheet"
android:padding=
"16dp"
app:layout_behavior=
"com.google.android.material.bottomsheet.BottomSheetBehavior"
>
<TextView
android:id=
"@+id/totalText"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Total"
android:textSize=
"30
d
p"
android:textSize=
"30
s
p"
android:textFontWeight=
"600"
android:layout_alignParentStart=
"true"
/>
<TextView
android:id=
"@+id/
changeText
"
android:id=
"@+id/
totalHarga
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"
Change
"
android:textSize=
"
20s
p"
android:text=
"
Rp. 600.000
"
android:textSize=
"
30d
p"
android:textFontWeight=
"600"
android:layout_below=
"@id/totalText"
android:layout_alignParentStart=
"true"
/>
android:layout_alignParentEnd=
"true"
/>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:layout_below=
"@id/totalHarga"
>
<TextView
android:id=
"@+id/totalHarga
"
android:id=
"@+id/changeText
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Rp. 600.000
"
android:textSize=
"30d
p"
android:text=
"Change
"
android:textSize=
"20s
p"
android:textFontWeight=
"600"
android:layout_alignParentEnd
=
"true"
/>
android:layout_alignParentStart
=
"true"
/>
<TextView
android:id=
"@+id/hargaChange"
...
...
@@ -49,7 +55,6 @@
android:text=
"Rp. 600.000"
android:textSize=
"20sp"
android:textFontWeight=
"600"
android:layout_below=
"@id/totalHarga"
android:layout_alignParentEnd=
"true"
/>
<TextView
...
...
@@ -57,6 +62,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"Bayar"
android:layout_marginTop=
"10dp"
android:textFontWeight=
"600"
android:layout_below=
"@id/changeText"
/>
...
...
@@ -77,8 +83,8 @@
android:hint=
"Insert Money"
android:layout_below=
"@id/etBayar"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
</RelativeLayout>
app/src/main/res/layout/activity_login.xml
deleted
100644 → 0
View file @
2dfa5897
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/colorPrimaryDark"
>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_login_m.xml
View file @
8489d46d
...
...
@@ -121,6 +121,7 @@
app:layout_constraintTop_toBottomOf=
"@id/tfPassword"
app:layout_constraintVertical_bias=
"0.01999998"
/>
<com.google.android.material.textview.MaterialTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -131,7 +132,6 @@
android:textColor=
"@color/colorWhite"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/btnLogin"
/>
<ProgressBar
android:id=
"@+id/progressBar"
style=
"?android:attr/progressBarStyle"
...
...
app/src/main/res/layout/activity_payment.xml
View file @
8489d46d
...
...
@@ -85,6 +85,7 @@
android:layout_alignParentStart=
"true"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
app/src/main/res/layout/activity_q_r_code.xml
View file @
8489d46d
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id=
"@+id/qrCodeForm"
xmlns:android=
"http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height=
"match_parent"
android:layout_width=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:behavior_hideable=
"true"
app:behavior_peekHeight=
"56dp"
android:background=
"#efefef"
style=
"@style/Widget.Rounded.BottomSheet"
app:layout_behavior=
"com.google.android.material.bottomsheet.BottomSheetBehavior"
tools:context=
".QRCode
"
>
xmlns:android=
"http://schemas.android.com/apk/res/android
"
>
<ImageView
android:id=
"@+id/qr_image"
android:layout_width=
"
2
00dp"
android:layout_height=
"
2
00dp"
android:layout_width=
"
3
00dp"
android:layout_height=
"
3
00dp"
android:backgroundTint=
"#333"
android:src=
"@mipmap/ic_launcher"
android:layout_centerInParent=
"true"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
<com.google.android.material.textview.MaterialTextView
...
...
@@ -28,10 +27,10 @@
android:text=
"Va_Text"
android:textSize=
"20sp"
android:textStyle=
"bold"
android:layout_below=
"@id/qr_image"
android:layout_centerInParent=
"true"
/>
app:layout_constraintTop_toBottomOf=
"@id/qr_image"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
</RelativeLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/form_category.xml
View file @
8489d46d
...
...
@@ -17,7 +17,7 @@
android:layout_alignParentStart=
"true"
/>
<EditText
android:id=
"@+id/et
Bayar
"
android:id=
"@+id/et
CategoryName
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/tvAddCategory"
...
...
@@ -26,12 +26,12 @@
android:imeOptions=
"actionDone"
/>
<Button
android:id=
"@+id/btn
Cash
"
android:id=
"@+id/btn
AddCategory
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/text_new_category"
android:hint=
"Insert Money"
android:layout_below=
"@id/et
Bayar
"
/>
android:layout_below=
"@id/et
CategoryName
"
/>
</RelativeLayout>
...
...
app/src/main/res/layout/item_cart.xml
View file @
8489d46d
...
...
@@ -102,6 +102,7 @@
android:layout_marginTop=
"20dp"
android:background=
"@drawable/ic_rounded_circle"
android:padding=
"10dp"
android:tint=
"@color/colorWhite"
android:src=
"@drawable/ic_baseline_minus_24"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tvPrice"
/>
...
...
@@ -130,6 +131,7 @@
android:layout_height=
"wrap_content"
android:background=
"@drawable/ic_rounded_circle"
android:padding=
"10dp"
android:tint=
"@color/colorWhite"
android:src=
"@drawable/ic_baseline_plus_24"
app:layout_constraintBottom_toBottomOf=
"@id/tiQty"
app:layout_constraintStart_toEndOf=
"@id/tiQty"
/>
...
...
app/src/main/res/layout/item_category.xml
View file @
8489d46d
...
...
@@ -58,27 +58,29 @@
<com.google.android.material.button.MaterialButton
android:id=
"@+id/categoryDelete"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_width=
"70dp"
android:layout_height=
"40dp"
android:backgroundTint=
"@android:color/holo_red_dark"
android:text=
"DELETE"
android:textSize=
"10sp"
android:textAlignment=
"textStart"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
android:backgroundTint=
"@android:color/holo_red_dark"
android:textSize=
"10sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
/>
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
app:layout_constraintVertical_bias=
"0.0"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/categoryUpdate"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_width=
"70dp"
android:layout_height=
"40dp"
android:backgroundTint=
"@color/colorGreen"
android:text=
"UPDATE"
android:textSize=
"10sp"
android:textAlignment=
"textEnd"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
android:backgroundTint=
"@color/colorGreen"
android:textSize=
"10sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cvCategory"
app:layout_constraintVertical_bias=
"0.0"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
...
...
app/src/main/res/values/styles.xml
View file @
8489d46d
...
...
@@ -24,6 +24,8 @@
<item
name=
"windowActionBarOverlay"
>
true
</item>
<item
name=
"android:fontFamily"
>
@font/roboto
</item>
<item
name=
"actionBarStyle"
>
@style/ThemeActionBar
</item>
<item
name=
"bottomSheetDialogTheme"
>
@style/ThemeOverlay.Rounded.BottomSheetDialog
</item>
</style>
<style
name=
"AppTheme.my.a"
parent=
"Theme.MaterialComponents.Light.NoActionBar"
>
...
...
@@ -73,6 +75,22 @@
<item
name=
"android:hint"
>
Select kategori
</item>
</style>
<style
name=
"ShapeAppearanceOverlay.Rounded.top"
parent=
""
>
<item
name=
"cornerSizeTopLeft"
>
10dp
</item>
<item
name=
"cornerSizeTopRight"
>
10dp
</item>
<item
name=
"cornerFamily"
>
rounded
</item>
</style>
<style
name=
"ThemeOverlay.Rounded.BottomSheetDialog"
parent=
"@style/ThemeOverlay.MaterialComponents.BottomSheetDialog"
>
<item
name=
"bottomSheetStyle"
>
@style/Widget.Rounded.BottomSheet
</item>
</style>
<style
name=
"Widget.Rounded.BottomSheet"
parent=
"Widget.MaterialComponents.BottomSheet"
>
<item
name=
"shapeAppearanceOverlay"
>
@style/ShapeAppearanceOverlay.Rounded.top
</item>
</style>
<style
name=
"AppModalStyle"
parent=
"Widget.Design.BottomSheet.Modal"
>
<item
name=
"android:background"
>
@drawable/round_corner_sheet
</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