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
5a2fa6a8
Commit
5a2fa6a8
authored
Sep 03, 2020
by
Muhammad Fahrul
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into forgot-password
parents
0ff95782
572dbee8
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
279 additions
and
124 deletions
+279
-124
CartActivity.java
app/src/main/java/com/yono/messeripos/CartActivity.java
+11
-29
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+15
-15
LoginActivity.java
app/src/main/java/com/yono/messeripos/LoginActivity.java
+7
-0
LoginState.java
app/src/main/java/com/yono/messeripos/LoginState.java
+94
-60
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+7
-2
RegisterState.java
app/src/main/java/com/yono/messeripos/RegisterState.java
+5
-1
ProductAdapter.java
...main/java/com/yono/messeripos/adapter/ProductAdapter.java
+1
-1
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+2
-1
MainViewModelsCart.java
...n/java/com/yono/messeripos/models/MainViewModelsCart.java
+3
-0
ProductCartModels.java
...in/java/com/yono/messeripos/models/ProductCartModels.java
+12
-2
Utils.java
app/src/main/java/com/yono/messeripos/utils/Utils.java
+69
-4
alert_dialog.xml
app/src/main/res/layout/alert_dialog.xml
+44
-9
dashboard_login.xml
app/src/main/res/layout/dashboard_login.xml
+9
-0
No files found.
app/src/main/java/com/yono/messeripos/CartActivity.java
View file @
5a2fa6a8
...
...
@@ -167,8 +167,17 @@ public class CartActivity extends AppCompatActivity {
@Override
public
void
onUpdateQuantityPlus
(
ProductCartModels
productCartModels
)
{
if
(!((
productCartModels
.
getQuantity_orders
()
+
1
)
>
productCartModels
.
getQuantity_stock
()
-
1
)){
productCartModels
.
setQuantity_orders
(
productCartModels
.
getQuantity_orders
()
+
1
);
modelsCart
.
updateCart
(
productCartModels
);
}
else
{
utils
.
dialog
(
CartActivity
.
this
,
true
,
getLayoutInflater
().
inflate
(
R
.
layout
.
alert_dialog
,
null
),
"Warning"
,
"Item stock does not meet"
).
show
();
}
}
@Override
...
...
@@ -239,34 +248,7 @@ public class CartActivity extends AppCompatActivity {
paymentsModels
.
setOrderId
(
sharedPreferences
.
getString
(
ORDER_ID
,
""
));
paymentsModels
.
setTransactionStatus
(
"pending"
);
Log
.
i
(
"Convert Input"
,
"onChanged: "
+
utils
.
convertGson
(
paymentsModels
));
PaymentService
paymentService
=
client
.
Client
(
PaymentService
.
class
);
paymentService
.
postFromCart
(
paymentsModels
).
enqueue
(
new
Callback
<
DataResponse
<
PaymentsModels
<
List
<
VaNumberModels
>>>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
PaymentsModels
<
List
<
VaNumberModels
>>>>
call
,
Response
<
DataResponse
<
PaymentsModels
<
List
<
VaNumberModels
>>>>
response
)
{
Log
.
i
(
"Response simpan_cart"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
){
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
ORDER_ID
,
""
);
if
(
editor
.
commit
()){
startActivity
(
new
Intent
(
CartActivity
.
this
,
MainActivity
.
class
));
finish
();
}
}
else
{
new
AlertDialog
.
Builder
(
CartActivity
.
this
)
.
setCancelable
(
false
)
.
setTitle
(
"Save new Order"
)
.
setMessage
(
"Erorr save!"
).
show
();
}
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
PaymentsModels
<
List
<
VaNumberModels
>>>>
call
,
Throwable
t
)
{
new
AlertDialog
.
Builder
(
CartActivity
.
this
)
.
setCancelable
(
false
)
.
setTitle
(
"Save new Order"
)
.
setMessage
(
"Add new order failed, try again!"
).
show
();
}
});
}
});
...
...
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
5a2fa6a8
...
...
@@ -61,6 +61,7 @@ public class FormProductActivity extends AppCompatActivity {
MainViewModels
mainViewModels
;
MaterialSpinner
spinner
;
List
<
String
>
categoryModels
;
List
<
String
>
str
=
new
ArrayList
<>();
private
static
final
int
REQUEST_IMAGE_CAPTURE
=
1
;
private
static
final
int
REQUEST_PERMISSIONS
=
448
;
private
boolean
isUpdate
=
false
;
...
...
@@ -75,7 +76,7 @@ public class FormProductActivity extends AppCompatActivity {
ProgressDialog
progressDialog
;
Client
client
=
new
Client
();
ProductModels
productModelsIntent
;
List
<
String
>
categorySelect
=
new
ArrayList
<>();
List
<
Integer
>
categorySelect
=
new
ArrayList
<>();
FormCategory
formCategory
;
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
...
...
@@ -180,7 +181,8 @@ public class FormProductActivity extends AppCompatActivity {
binding
.
listCategory
.
setOnItemSelectedListener
(
new
MaterialSpinner
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
MaterialSpinner
view
,
int
position
,
long
id
,
Object
item
)
{
categorySelect
.
add
(
item
.
toString
());
progressDialog
.
show
();
getCategory
(
item
.
toString
());
}
});
}
...
...
@@ -189,17 +191,15 @@ public class FormProductActivity extends AppCompatActivity {
private
void
setSpinner
(
String
s
)
{
progressDialog
.
show
();
HashSet
<
String
>
set
=
new
HashSet
<>();
List
<
String
>
str
=
new
ArrayList
<>();
categoryModels
=
new
ArrayList
<>();
Log
.
i
(
"GET_CATEGORY"
,
"setSpinner: "
+
utils
.
convertGson
(
productModelsIntent
));
// if (productModelsIntent == null){
// str.add("SELECT CATEGORY");
// }else{
// getCategoryById(productModelsIntent.getIdProduct());
// categoryName = ""
// str.add(categoryName);
// }
if
(
productModelsIntent
==
null
){
str
.
add
(
"SELECT CATEGORY"
);
}
else
{
getCategoryById
(
productModelsIntent
.
getIdProduct
());
categorySelect
.
add
(
0
,
productModelsIntent
.
getCategoryProduct
());
}
// str.add("SELECT CATEGORY");
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
progressDialog
.
dismiss
();
for
(
CategoryModels
cd:
listDataResponse
.
getData
()){
...
...
@@ -228,7 +228,7 @@ public class FormProductActivity extends AppCompatActivity {
productModelsSave
.
setProductName
(
binding
.
etName
.
getText
().
toString
());
productModelsSave
.
setPriceProduct
(
Integer
.
parseInt
(
binding
.
etPrice
.
getText
().
toString
()));
productModelsSave
.
setStockProduct
(
Integer
.
parseInt
(
binding
.
etStock
.
getText
().
toString
()));
productModelsSave
.
setCategoryProduct
(
getCategory
(
categorySelect
.
get
(
0
)
));
productModelsSave
.
setCategoryProduct
(
categorySelect
.
get
(
0
));
if
(
productModelsIntent
==
null
){
productModelsSave
.
setImageProduct
(
productModels
.
getImageProduct
());
}
else
{
...
...
@@ -346,6 +346,8 @@ public class FormProductActivity extends AppCompatActivity {
Log
.
i
(
"CHDJHD"
,
"getCategory: "
+
utils
.
convertGson
(
response
.
body
()));
id
=
response
.
body
().
getData
().
get
(
0
).
getIdCategory
();
productModels
.
setCategoryProduct
(
id
);
categorySelect
.
add
(
0
,
id
);
progressDialog
.
dismiss
();
}
@Override
...
...
@@ -362,9 +364,7 @@ public class FormProductActivity extends AppCompatActivity {
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
Log
.
i
(
"ER"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
categoryName
.
isEmpty
()){
categoryName
=
response
.
body
().
getData
().
getNameCategory
();
}
str
.
add
(
response
.
body
().
getData
().
getNameCategory
());
}
@Override
...
...
app/src/main/java/com/yono/messeripos/LoginActivity.java
View file @
5a2fa6a8
package
com
.
yono
.
messeripos
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
...
...
@@ -41,6 +42,10 @@ public class LoginActivity extends AppCompatActivity {
MaterialButton
btnSignin
;
MaterialButton
btnSignup
,
btnSignIn
;
public
static
View
invalidUser
;
public
static
View
activateEmail
;
Utils
utils
;
MaterialTextView
tvForgotPassword
;
...
...
@@ -100,6 +105,7 @@ public class LoginActivity extends AppCompatActivity {
@Override
public
void
onClick
(
View
v
)
{
loginState
=
new
LoginState
(
LoginActivity
.
this
,
mainViewModels
);
loginState
.
setCancelable
(
false
);
loginState
.
show
(
getSupportFragmentManager
(),
loginState
.
getTag
());
}
});
...
...
@@ -108,6 +114,7 @@ public class LoginActivity extends AppCompatActivity {
@Override
public
void
onClick
(
View
view
)
{
registerState
=
new
RegisterState
(
LoginActivity
.
this
,
mainViewModels
);
registerState
.
setCancelable
(
false
);
registerState
.
show
(
getSupportFragmentManager
(),
registerState
.
getTag
());
}
});
...
...
app/src/main/java/com/yono/messeripos/LoginState.java
View file @
5a2fa6a8
...
...
@@ -10,6 +10,7 @@ import android.content.Intent;
import
android.content.SharedPreferences
;
import
android.content.res.Resources
;
import
android.os.Bundle
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.KeyEvent
;
...
...
@@ -52,8 +53,7 @@ public class LoginState extends BottomSheetDialogFragment {
SharedPreferences
sharedPreferences
;
Utils
utils
;
ProgressBar
bar
;
AlertDialog
.
Builder
builder
;
View
view
;
ProgressDialog
dialog
;
public
LoginState
(
Context
context
,
MainViewModels
mainViewModels
)
{
...
...
@@ -70,7 +70,7 @@ public class LoginState extends BottomSheetDialogFragment {
dialog
=
new
ProgressDialog
(
context
);
// inflating layout
View
view
=
View
.
inflate
(
getContext
(),
R
.
layout
.
login_form
,
null
);
view
=
View
.
inflate
(
getContext
(),
R
.
layout
.
login_form
,
null
);
// bindUI
loginLayout
=
view
.
findViewById
(
R
.
id
.
LoginLayout
);
...
...
@@ -112,6 +112,7 @@ public class LoginState extends BottomSheetDialogFragment {
}
private
void
loginAuth
(
View
v
)
{
if
(
TextUtils
.
isEmpty
(
username
.
getText
().
toString
())
&&
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
username
.
setError
(
"This field can't empty"
);
...
...
@@ -121,87 +122,120 @@ public class LoginState extends BottomSheetDialogFragment {
username
.
setError
(
"This field can't empty"
);
}
else
if
(
TextUtils
.
isEmpty
(
password
.
getText
().
toString
())){
password
.
setError
(
"This field can't empty"
);
}
else
{
/**
* Jika tombol sign in ditekan
*
* nonaktifkan semua form */
bar
.
setVisibility
(
View
.
VISIBLE
);
loginButton
.
setText
(
""
);
sheetDialog
.
setCancelable
(
false
);
}
else
{
username
.
setEnabled
(
false
);
password
.
setEnabled
(
false
);
loginButton
.
setEnabled
(
false
);
closeBtn
.
setEnabled
(
false
);
setAllLayoutToFalse
();
// buat checking login
mainViewModels
.
checkLogin
(
new
UsersModels
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
()))
.
observe
((
LifecycleOwner
)
context
,
usersModelsDataResponse
->
{
if
(
usersModelsDataResponse
!=
null
)
{
/**
* Jika response atau data ada dan cocok
*/
final
View
customLayout
=
getLayoutInflater
()
.
inflate
(
R
.
layout
.
alert_dialog
,
null
);
switch
(
usersModelsDataResponse
.
getMessageData
().
toLowerCase
())
{
case
"invalid username or password"
:
setAllLayoutToTrue
();
errUserPass
(
customLayout
);
break
;
case
"please activate your email first"
:
setAllLayoutToTrue
();
activateEmail
(
customLayout
);
default
:
break
;
}
if
(
usersModelsDataResponse
.
getStatusData
())
{
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putBoolean
(
SplashScreen
.
SESSION
,
true
);
sheetDialog
.
dismiss
();
if
(
editor
.
commit
()){
startActivity
(
new
Intent
(
context
,
MainActivity
.
class
));
getActivity
().
finish
();
}
// redirect ke home
setAllLayoutToTrue
();
// set progress bar jadi nonaktif
bar
.
setVisibility
(
View
.
GONE
);
// munculkan tulisan default di button sign in
}
}
else
{
bar
.
setVisibility
(
View
.
VISIBLE
);
utils
.
snackBar
(
v
,
"Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください"
).
show
();
}
});
}
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
}
// ubah sheet dialog jadi tidak bisa di slide atau cancel
private
void
setAllLayoutToTrue
()
{
bar
.
setVisibility
(
View
.
GONE
);
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
sheetDialog
.
setCancelable
(
true
);
// set form jadi enable
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
}
}
else
{
/**
* Jika response atau data tidak cocok
*/
private
void
setAllLayoutToFalse
()
{
bar
.
setVisibility
(
View
.
VISIBLE
);
loginButton
.
setText
(
""
);
sheetDialog
.
setCancelable
(
false
);
username
.
setEnabled
(
false
);
password
.
setEnabled
(
false
);
loginButton
.
setEnabled
(
false
);
closeBtn
.
setEnabled
(
false
);
}
bar
.
setVisibility
(
View
.
GONE
);
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
private
void
activateEmail
(
View
customLayout
)
{
sheetDialog
.
setCancelable
(
true
);
utils
=
new
Utils
(
customLayout
);
utils
.
dialog
(
context
,
false
,
customLayout
,
"Please Verifiy Email"
,
"Please verify your email before login"
,
"close"
,
"verify"
)
.
show
();
utils
.
setListener
(
new
Utils
.
DialogListener
()
{
@Override
public
void
onClickDisimiss
(
AlertDialog
alertDialog
)
{
alertDialog
.
dismiss
();
}
final
View
customLayout
=
getLayoutInflater
()
.
inflate
(
R
.
layout
.
alert_dialog
,
null
);
@Override
public
void
onClickLink
(
AlertDialog
alertDialog
)
{
Intent
pm
=
getActivity
().
getPackageManager
().
getLaunchIntentForPackage
(
"com.google.android.gm"
);
if
(
pm
!=
null
)
{
startActivity
(
pm
);
getActivity
().
finish
();
}
}
});
}
private
void
errUserPass
(
View
customLayout
)
{
// tampilkan alert dialog
utils
=
new
Utils
(
customLayout
);
utils
.
dialog
(
context
,
false
,
customLayout
,
"Wrong Username or Password"
,
"The username or password is incorrect. Please try again!"
,
"Try Again"
)
.
show
();
utils
.
setListener
(
Dialog:
:
dismiss
);
username
.
setEnabled
(
true
);
password
.
setEnabled
(
true
);
loginButton
.
setEnabled
(
true
);
closeBtn
.
setEnabled
(
true
);
}
}
else
{
bar
.
setVisibility
(
View
.
VISIBLE
);
utils
.
snackBar
(
v
,
"Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください"
).
show
();
utils
.
setListener
(
new
Utils
.
DialogListener
()
{
@Override
public
void
onClickDisimiss
(
AlertDialog
alertDialog
)
{
alertDialog
.
dismiss
();
}
});
@Override
public
void
onClickLink
(
AlertDialog
alertDialog
)
{
}
loginButton
.
setText
(
DEFAULT_LOGIN_NAME
);
});
}
}
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
5a2fa6a8
...
...
@@ -201,7 +201,6 @@ public class MainActivity extends AppCompatActivity {
});
}
private
void
mainViewModelsGettCategory
()
{
mainViewModels
.
getCategory
().
observe
(
this
,
new
Observer
<
DataResponse
<
List
<
CategoryModels
>>>()
{
@Override
...
...
@@ -339,7 +338,7 @@ public class MainActivity extends AppCompatActivity {
product
.
getIdProduct
(),
product
.
getProductName
(),
product
.
getPriceProduct
(),
0
product
.
getStockProduct
()
));
// Log.d("order_id_create", "onChanged: "+orderId);
...
...
@@ -551,4 +550,10 @@ public class MainActivity extends AppCompatActivity {
binding
.
pbLoading
.
setVisibility
(
View
.
GONE
);
}
}
@Override
public
void
onBackPressed
()
{
super
.
onBackPressed
();
finish
();
}
}
\ No newline at end of file
app/src/main/java/com/yono/messeripos/RegisterState.java
View file @
5a2fa6a8
...
...
@@ -5,6 +5,8 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.content.res.Resources
;
import
android.os.Bundle
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
...
...
@@ -89,7 +91,9 @@ public class RegisterState extends BottomSheetDialogFragment {
registerButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
mainViewModels
.
postRegis
(
new
UsersModels
(
username
.
getText
().
toString
(),
email
.
getText
().
toString
(),
password
.
getText
().
toString
(),
repassword
.
getText
().
toString
()));
mainViewModels
.
postRegis
(
new
UsersModels
(
username
.
getText
().
toString
(),
email
.
getText
().
toString
(),
password
.
getText
().
toString
(),
repassword
.
getText
().
toString
()));
}
});
...
...
app/src/main/java/com/yono/messeripos/adapter/ProductAdapter.java
View file @
5a2fa6a8
...
...
@@ -138,7 +138,7 @@ public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHo
binding
.
materialBtnAddCart
.
setVisibility
(
View
.
GONE
);
}
if
(
products
.
getStockProduct
()
==
0
)
{
if
(
products
.
getStockProduct
()
<=
1
)
{
statusProduct
=
"Not Available"
;
binding
.
status
.
setBackgroundColor
(
0x55FF0000
);
binding
.
setStatus
(
statusProduct
);
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
5a2fa6a8
...
...
@@ -187,7 +187,8 @@ public class MainViewModels extends ViewModel {
usersService
.
postRegister
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
Log
.
i
(
"REGISTER"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
usersRegister
.
setValue
(
response
.
body
());
}
@Override
...
...
app/src/main/java/com/yono/messeripos/models/MainViewModelsCart.java
View file @
5a2fa6a8
...
...
@@ -19,6 +19,7 @@ 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.repositories.CartRepositories
;
import
com.yono.messeripos.repositories.PaymentPendingRepositories
;
import
com.yono.messeripos.response.DataResponse
;
import
com.yono.messeripos.response.OrdersResponse
;
...
...
@@ -36,6 +37,7 @@ public class MainViewModelsCart extends AndroidViewModel {
private
Client
client
;
private
CartRepositories
cartRepositories
;
private
PaymentPendingRepositories
paymentPendingRepositories
;
public
void
setCart
(
ProductCartModels
product
){
this
.
cart
.
setValue
(
product
);}
...
...
@@ -47,6 +49,7 @@ public class MainViewModelsCart extends AndroidViewModel {
super
(
application
);
cartRepositories
=
new
CartRepositories
(
application
);
paymentPendingRepositories
=
new
PaymentPendingRepositories
(
application
);
productsLive
=
cartRepositories
.
getDataCart
();
client
=
new
Client
();
...
...
app/src/main/java/com/yono/messeripos/models/ProductCartModels.java
View file @
5a2fa6a8
...
...
@@ -20,6 +20,9 @@ public class ProductCartModels implements Parcelable {
@SerializedName
(
"quantity"
)
private
long
quantity_orders
;
@SerializedName
(
"quantity_stock"
)
private
long
quantity_stock
;
@SerializedName
(
"product_id"
)
private
int
id_product_orders
;
...
...
@@ -41,13 +44,13 @@ public class ProductCartModels implements Parcelable {
int
id_product_orders
,
String
product_name_orders
,
long
price_orders
,
int
grand_total_orders
)
{
int
quantity_stock
)
{
this
.
id_orders
=
id_orders
;
this
.
quantity_orders
=
quantity_orders
;
this
.
id_product_orders
=
id_product_orders
;
this
.
product_name_orders
=
product_name_orders
;
this
.
price_orders
=
price_orders
;
this
.
grand_total_orders
=
grand_total_orders
;
this
.
quantity_stock
=
quantity_stock
;
}
protected
ProductCartModels
(
Parcel
in
)
{
...
...
@@ -143,4 +146,11 @@ public class ProductCartModels implements Parcelable {
this
.
grand_total_orders
=
grand_total_orders
;
}
public
long
getQuantity_stock
()
{
return
quantity_stock
;
}
public
void
setQuantity_stock
(
long
quantity_stock
)
{
this
.
quantity_stock
=
quantity_stock
;
}
}
app/src/main/java/com/yono/messeripos/utils/Utils.java
View file @
5a2fa6a8
...
...
@@ -46,6 +46,7 @@ public class Utils {
public
interface
DialogListener
{
void
onClickDisimiss
(
AlertDialog
alertDialog
);
void
onClickLink
(
AlertDialog
alertDialog
);
}
private
DialogListener
listener
;
...
...
@@ -270,16 +271,67 @@ public class Utils {
AlertDialog
dialog
=
builder
.
create
();
dialog
.
getWindow
().
getAttributes
().
windowAnimations
=
R
.
style
.
DialogAnimation
;
bt
n
Card
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
btCard
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
return
dialog
;
}
public
AlertDialog
dialog
(
Context
context
,
Boolean
cancelable
,
View
view
,
@Nullable
String
titles
,
@Nullable
String
messages
,
@Nullable
String
buttons
)
{
public
AlertDialog
dialog
(
Context
context
,
Boolean
cancelable
,
View
view
,
@Nullable
String
titles
,
@Nullable
String
messages
,
@Nullable
String
dismiss
)
{
TextView
title
=
view
.
findViewById
(
R
.
id
.
alertTitles
);
TextView
message
=
view
.
findViewById
(
R
.
id
.
alertBody
);
TextView
button2
=
view
.
findViewById
(
R
.
id
.
tvTextBtn2
);
CardView
btnCard2
=
view
.
findViewById
(
R
.
id
.
cvAlertOnClick2
);
// set title and message
if
(
titles
!=
null
){
title
.
setText
(
titles
);
}
if
(
message
!=
null
){
message
.
setText
(
messages
);
}
if
(
button2
!=
null
){
btnCard2
.
setVisibility
(
View
.
VISIBLE
);
button2
.
setText
(
dismiss
);
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
)
.
setCancelable
(
cancelable
)
.
setView
(
view
);
AlertDialog
dialog
=
builder
.
create
();
dialog
.
getWindow
().
getAttributes
().
windowAnimations
=
R
.
style
.
DialogAnimation
;
btnCard2
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
return
dialog
;
}
public
AlertDialog
dialog
(
Context
context
,
Boolean
cancelable
,
View
view
,
@Nullable
String
titles
,
@Nullable
String
messages
,
@Nullable
String
dismiss
,
@Nullable
String
link
)
{
/**
* Button1 untuk dismiss
* Button2 untuk link
*/
TextView
title
=
view
.
findViewById
(
R
.
id
.
alertTitles
);
TextView
message
=
view
.
findViewById
(
R
.
id
.
alertBody
);
TextView
button
=
view
.
findViewById
(
R
.
id
.
tvTextBtn
);
TextView
button2
=
view
.
findViewById
(
R
.
id
.
tvTextBtn2
);
CardView
btnCard
=
view
.
findViewById
(
R
.
id
.
cvAlertOnClick
);
CardView
btnCard2
=
view
.
findViewById
(
R
.
id
.
cvAlertOnClick2
);
// set title and message
if
(
titles
!=
null
){
...
...
@@ -291,7 +343,13 @@ public class Utils {
}
if
(
button
!=
null
){
button
.
setText
(
buttons
);
btnCard
.
setVisibility
(
View
.
VISIBLE
);
button
.
setText
(
link
);
}
if
(
button2
!=
null
)
{
btnCard2
.
setVisibility
(
View
.
VISIBLE
);
button2
.
setText
(
dismiss
);
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
context
)
...
...
@@ -300,7 +358,14 @@ public class Utils {
AlertDialog
dialog
=
builder
.
create
();
dialog
.
getWindow
().
getAttributes
().
windowAnimations
=
R
.
style
.
DialogAnimation
;
btnCard
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
btnCard
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
listener
.
onClickLink
(
dialog
);
}
});
btnCard2
.
setOnClickListener
(
view1
->
listener
.
onClickDisimiss
(
dialog
));
return
dialog
;
}
...
...
app/src/main/res/layout/alert_dialog.xml
View file @
5a2fa6a8
...
...
@@ -15,7 +15,7 @@
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintBottom_toTopOf=
"@id/
divider
"
app:layout_constraintBottom_toTopOf=
"@id/
cvAlertDialog
"
>
<LinearLayout
...
...
@@ -45,32 +45,67 @@
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
app:layout_constraintTop_toBottomOf=
"@id/cvAlertDialog"
>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvAlertOnClick"
app:cardCornerRadius=
"0dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
android:clickable=
"true"
android:focusable=
"true"
>
<View
android:id=
"@+id/divider"
android:layout_marginTop=
"10dp"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
style=
"@style/Divider.Horizontal"
app:layout_constraintTop_toBottomOf=
"@id/cvAlertDialog"
/>
style=
"@style/Divider.Horizontal"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvTextBtn"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Coba Lagi"
android:textSize=
"18sp"
android:textColor=
"#3949AB"
android:textFontWeight=
"600"
android:paddingVertical=
"15dp"
android:gravity=
"center"
/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id=
"@+id/cvAlertOnClick"
android:id=
"@+id/cvAlertOnClick
2
"
app:cardCornerRadius=
"0dp"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:clickable=
"true"
android:focusable=
"true"
app:layout_constraintTop_toBottomOf=
"@id/divider"
>
android:visibility=
"gone"
android:focusable=
"true"
>
<View
android:id=
"@+id/divider2"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
style=
"@style/Divider.Horizontal"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvTextBtn"
android:id=
"@+id/tvTextBtn
2
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Coba Lagi"
android:textSize=
"18sp"
android:textFontWeight=
"600"
android:paddingVertical=
"15dp"
android:gravity=
"center"
/>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/dashboard_login.xml
View file @
5a2fa6a8
...
...
@@ -20,6 +20,7 @@
android:layout_marginTop=
"50dp"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/descMesser"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"messer"
...
...
@@ -30,6 +31,14 @@
android:layout_below=
"@id/messerLogoDashboardLogin"
android:layout_centerHorizontal=
"true"
/>
<com.google.android.material.textview.MaterialTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"messer is a digital cashier application"
android:textColor=
"@color/colorWhite"
android:layout_below=
"@id/descMesser"
android:layout_centerHorizontal=
"true"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/signUpButtonDashboardLogin"
android:layout_width=
"match_parent"
...
...
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