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
d2542572
Commit
d2542572
authored
Sep 02, 2020
by
Alfansyah Fadlian
Browse files
Options
Browse Files
Download
Plain Diff
login register
parents
0499afd4
041fcb0e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
79 deletions
+109
-79
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-3
FormProductActivity.java
...rc/main/java/com/yono/messeripos/FormProductActivity.java
+16
-21
LoginActivity.java
app/src/main/java/com/yono/messeripos/LoginActivity.java
+9
-5
MainActivity.java
app/src/main/java/com/yono/messeripos/MainActivity.java
+6
-3
UsersService.java
...in/java/com/yono/messeripos/api/service/UsersService.java
+3
-0
MainViewModels.java
.../main/java/com/yono/messeripos/models/MainViewModels.java
+57
-30
UsersModels.java
...src/main/java/com/yono/messeripos/models/UsersModels.java
+14
-1
login_form.xml
app/src/main/res/layout/login_form.xml
+2
-1
register_form.xml
app/src/main/res/layout/register_form.xml
+2
-15
No files found.
app/src/main/AndroidManifest.xml
View file @
d2542572
...
@@ -35,9 +35,6 @@
...
@@ -35,9 +35,6 @@
<activity
<activity
android:name=
".CartActivity"
android:name=
".CartActivity"
android:theme=
"@style/AppTheme.appbar"
/>
android:theme=
"@style/AppTheme.appbar"
/>
<activity
android:name=
".ProductActivity"
android:theme=
"@style/AppTheme.appbar"
/>
<activity
android:name=
".SplashScreen"
>
<activity
android:name=
".SplashScreen"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/com/yono/messeripos/FormProductActivity.java
View file @
d2542572
...
@@ -181,37 +181,32 @@ public class FormProductActivity extends AppCompatActivity {
...
@@ -181,37 +181,32 @@ public class FormProductActivity extends AppCompatActivity {
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
@RequiresApi
(
api
=
Build
.
VERSION_CODES
.
N
)
private
void
setSpinner
(
String
s
)
{
private
void
setSpinner
(
String
s
)
{
progressDialog
.
show
();
HashSet
<
String
>
set
=
new
HashSet
<>();
HashSet
<
String
>
set
=
new
HashSet
<>();
List
<
String
>
str
=
new
ArrayList
<>();
categoryModels
=
new
ArrayList
<>();
categoryModels
=
new
ArrayList
<>();
categoryModels
.
add
(
"SELECT CATEGORY"
);
str
.
add
(
"SELECT CATEGORY"
);
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
mainViewModels
.
getCategory
().
observe
(
this
,
listDataResponse
->
{
progressDialog
.
dismiss
();
List
<
CategoryModels
>
cate
=
listDataResponse
.
getData
();
for
(
CategoryModels
cd:
listDataResponse
.
getData
()){
for
(
CategoryModels
cd:
cate
){
Log
.
i
(
"SPINNER"
,
"setSpinner: "
+
utils
.
convertGson
(
cd
.
getNameCategory
()));
categoryModels
.
add
(
cd
.
getNameCategory
());
categoryModels
.
add
(
cd
.
getNameCategory
());
}
}
List
<
String
>
collect
=
categoryModels
.
stream
().
map
(
v
->
{
if
(
set
.
add
(
v
)
==
true
)
{
str
.
add
(
v
);
}
return
v
;
}).
collect
(
Collectors
.
toList
());
// Log.i("Spinner data", "onCreate: "+utils.convertGson(categoryModels));
Log
.
i
(
"SPINNER"
,
"setSpinner: "
+
utils
.
convertGson
(
str
));
@SuppressLint
(
"ResourceType"
)
ArrayAdapter
<
String
>
dataAdapter
=
new
ArrayAdapter
<
String
>(
FormProductActivity
.
this
,
R
.
id
.
listCategory
,
str
);
binding
.
listCategory
.
setAdapter
(
dataAdapter
);
});
});
List
<
HashSet
<
String
>>
collect
=
categoryModels
.
stream
().
map
(
v
->
{
if
(
set
.
add
(
v
)
==
true
)
{
set
.
add
(
v
);
}
return
set
;
}).
collect
(
Collectors
.
toList
());
Log
.
i
(
"SPINNER"
,
"setSpinner: "
+
utils
.
convertGson
(
collect
));
@SuppressLint
(
"ResourceType"
)
ArrayAdapter
<
String
>
dataAdapter
=
new
ArrayAdapter
<
String
>(
FormProductActivity
.
this
,
R
.
id
.
listCategory
,
categoryModels
);
binding
.
listCategory
.
setAdapter
(
dataAdapter
);
progressDialog
.
dismiss
();
}
}
private
void
saveProduct
(){
private
void
saveProduct
(){
...
...
app/src/main/java/com/yono/messeripos/LoginActivity.java
View file @
d2542572
...
@@ -37,7 +37,7 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -37,7 +37,7 @@ public class LoginActivity extends AppCompatActivity {
SharedPreferences
sharedPreferences
;
SharedPreferences
sharedPreferences
;
Utils
utils
=
new
Utils
();
Utils
utils
=
new
Utils
();
MaterialButton
btnSignup
,
btnSign
I
n
;
MaterialButton
btnSignup
,
btnSign
i
n
;
ConstraintLayout
loginSheetLayout
,
registerSheetLayout
;
ConstraintLayout
loginSheetLayout
,
registerSheetLayout
;
BottomSheetBehavior
sheetBehavior
,
sheetBehavior2
;
BottomSheetBehavior
sheetBehavior
,
sheetBehavior2
;
int
height
,
width
;
int
height
,
width
;
...
@@ -54,7 +54,7 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -54,7 +54,7 @@ public class LoginActivity extends AppCompatActivity {
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
w
.
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
,
WindowManager
.
LayoutParams
.
FLAG_LAYOUT_NO_LIMITS
);
}
}
// bindUI
// bindUI
btnSign
I
n
=
findViewById
(
R
.
id
.
signInButtonDashboardLogin
);
btnSign
i
n
=
findViewById
(
R
.
id
.
signInButtonDashboardLogin
);
loginSheetLayout
=
findViewById
(
R
.
id
.
ConstraintLoginLayout
);
loginSheetLayout
=
findViewById
(
R
.
id
.
ConstraintLoginLayout
);
btnSignup
=
findViewById
(
R
.
id
.
signUpButtonDashboardLogin
);
btnSignup
=
findViewById
(
R
.
id
.
signUpButtonDashboardLogin
);
registerSheetLayout
=
findViewById
(
R
.
id
.
ConstraintRegisterLayout
);
registerSheetLayout
=
findViewById
(
R
.
id
.
ConstraintRegisterLayout
);
...
@@ -65,18 +65,22 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -65,18 +65,22 @@ public class LoginActivity extends AppCompatActivity {
height
=
displayMetrics
.
heightPixels
;
height
=
displayMetrics
.
heightPixels
;
width
=
displayMetrics
.
widthPixels
;
width
=
displayMetrics
.
widthPixels
;
int
maxHeight
=
height
-
((
height
*
10
)
/
100
);
loginSheetLayout
.
setMaxHeight
(
maxHeight
);
// get bottom sheets
// get bottom sheets
sheetBehavior
=
BottomSheetBehavior
.
from
(
loginSheetLayout
);
sheetBehavior
=
BottomSheetBehavior
.
from
(
loginSheetLayout
);
sheetBehavior2
=
BottomSheetBehavior
.
from
(
registerSheetLayout
);
sheetBehavior2
=
BottomSheetBehavior
.
from
(
registerSheetLayout
);
// button on click to form login
btnSignIn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
// button on click
btnSignin
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
if
(
sheetBehavior
.
getState
()
!=
BottomSheetBehavior
.
STATE_EXPANDED
)
{
if
(
sheetBehavior
.
getState
()
!=
BottomSheetBehavior
.
STATE_EXPANDED
)
{
sheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
sheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_EXPANDED
);
loginSheetLayout
.
setMaxHeight
(
height
-
100
);
loginSheetLayout
.
setMaxHeight
(
height
-
100
);
}
else
{
}
else
{
sheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_COLLAPSED
);
sheetBehavior
.
setState
(
BottomSheetBehavior
.
STATE_COLLAPSED
);
}
}
}
}
...
...
app/src/main/java/com/yono/messeripos/MainActivity.java
View file @
d2542572
...
@@ -388,7 +388,6 @@ public class MainActivity extends AppCompatActivity {
...
@@ -388,7 +388,6 @@ public class MainActivity extends AppCompatActivity {
categoryAdapter
.
setListener
(
new
CategoryAdapter
.
CategoryListener
()
{
categoryAdapter
.
setListener
(
new
CategoryAdapter
.
CategoryListener
()
{
@Override
@Override
public
void
onGetProduct
(
CategoryModels
categoryModels
)
{
public
void
onGetProduct
(
CategoryModels
categoryModels
)
{
progressDialog
.
show
();
Log
.
i
(
"diluar if"
,
"onGetProduct: "
+
selectCategory
);
Log
.
i
(
"diluar if"
,
"onGetProduct: "
+
selectCategory
);
if
(!
selectCategory
){
if
(!
selectCategory
){
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
...
@@ -398,14 +397,16 @@ public class MainActivity extends AppCompatActivity {
...
@@ -398,14 +397,16 @@ public class MainActivity extends AppCompatActivity {
Log
.
i
(
"setelah if"
,
"onGetProduct: "
+
selectCategory
);
Log
.
i
(
"setelah if"
,
"onGetProduct: "
+
selectCategory
);
if
(
categoryModels
.
getIdCategory
()
==
0
){
if
(
categoryModels
.
getIdCategory
()
==
0
){
progressDialog
.
show
();
if
(
mainViewModels
.
getProduct
().
getValue
().
getData
().
size
()
!=
0
){
if
(
mainViewModels
.
getProduct
().
getValue
().
getData
().
size
()
!=
0
){
selectCategory
=
false
;
selectCategory
=
false
;
mainViewModels
.
getProduct
().
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
mainViewModels
.
getProduct
().
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
@Override
@Override
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>
listDataResponse
)
{
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>
listDataResponse
)
{
progressDialog
.
dismiss
();
productModelsArrayList
.
clear
();
productModelsArrayList
.
clear
();
productModelsArrayList
.
addAll
(
listDataResponse
.
getData
());
productModelsArrayList
.
addAll
(
listDataResponse
.
getData
());
progressDialog
.
dismiss
();
binding
.
rvProduct
.
setVisibility
(
View
.
VISIBLE
);
binding
.
rvProduct
.
setVisibility
(
View
.
VISIBLE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
GONE
);
binding
.
imgEmpty
.
setVisibility
(
View
.
GONE
);
productAdapter
.
setProduct
(
MainActivity
.
this
,
productModelsArrayList
);
productAdapter
.
setProduct
(
MainActivity
.
this
,
productModelsArrayList
);
...
@@ -420,14 +421,16 @@ public class MainActivity extends AppCompatActivity {
...
@@ -420,14 +421,16 @@ public class MainActivity extends AppCompatActivity {
// binding.imgEmpty.bringToFront();
// binding.imgEmpty.bringToFront();
}
}
}
else
{
}
else
{
progressDialog
.
show
();
selectCategory
=
false
;
selectCategory
=
false
;
mainViewModels
.
getProductByCategory
(
categoryModels
.
getIdCategory
()).
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
>>>()
{
mainViewModels
.
getProductByCategory
(
categoryModels
.
getIdCategory
()).
observe
(
MainActivity
.
this
,
new
Observer
<
DataResponse
<
List
<
ProductModels
>>>()
{
@Override
@Override
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
>>
listDataResponse
)
{
public
void
onChanged
(
DataResponse
<
List
<
ProductModels
>>
listDataResponse
)
{
progressDialog
.
dismiss
();
if
(
listDataResponse
!=
null
)
{
if
(
listDataResponse
!=
null
)
{
productModelsArrayList
.
clear
();
productModelsArrayList
.
clear
();
productModelsArrayList
.
addAll
(
listDataResponse
.
getData
());
productModelsArrayList
.
addAll
(
listDataResponse
.
getData
());
progressDialog
.
dismiss
();
showLoading
(
false
);
showLoading
(
false
);
if
(
productModelsArrayList
.
isEmpty
())
{
if
(
productModelsArrayList
.
isEmpty
())
{
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
binding
.
rvProduct
.
setVisibility
(
View
.
GONE
);
...
...
app/src/main/java/com/yono/messeripos/api/service/UsersService.java
View file @
d2542572
...
@@ -11,4 +11,7 @@ import retrofit2.http.POST;
...
@@ -11,4 +11,7 @@ import retrofit2.http.POST;
public
interface
UsersService
{
public
interface
UsersService
{
@POST
(
ApiHelper
.
VERSI_API_1
+
"login"
)
@POST
(
ApiHelper
.
VERSI_API_1
+
"login"
)
Call
<
DataResponse
<
UsersModels
>>
checkLogin
(
@Body
UsersModels
usersModels
);
Call
<
DataResponse
<
UsersModels
>>
checkLogin
(
@Body
UsersModels
usersModels
);
@POST
(
ApiHelper
.
VERSI_API_1
+
"register"
)
Call
<
DataResponse
<
UsersModels
>>
postRegister
(
@Body
UsersModels
usersModels
);
}
}
app/src/main/java/com/yono/messeripos/models/MainViewModels.java
View file @
d2542572
...
@@ -29,6 +29,8 @@ public class MainViewModels extends ViewModel {
...
@@ -29,6 +29,8 @@ public class MainViewModels extends ViewModel {
MutableLiveData
<
DataResponse
<
List
<
ProductModels
>>>
productByCategory
;
MutableLiveData
<
DataResponse
<
List
<
ProductModels
>>>
productByCategory
;
MutableLiveData
<
DataResponse
<
List
<
CategoryModels
>>>
categoryList
;
MutableLiveData
<
DataResponse
<
List
<
CategoryModels
>>>
categoryList
;
MutableLiveData
<
DataResponse
<
UsersModels
>>
usersLogin
;
MutableLiveData
<
DataResponse
<
UsersModels
>>
usersLogin
;
MutableLiveData
<
DataResponse
<
UsersModels
>>
usersRegister
;
MutableLiveData
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
transactions
;
MutableLiveData
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
transactions
;
private
MainViewModels
mainViewModels
;
private
MainViewModels
mainViewModels
;
...
@@ -36,7 +38,7 @@ public class MainViewModels extends ViewModel {
...
@@ -36,7 +38,7 @@ public class MainViewModels extends ViewModel {
Client
client
=
new
Client
();
Client
client
=
new
Client
();
Utils
utils
=
new
Utils
();
Utils
utils
=
new
Utils
();
public
MainViewModels
(){
public
MainViewModels
()
{
productList
=
new
MutableLiveData
<>();
productList
=
new
MutableLiveData
<>();
categoryList
=
new
MutableLiveData
<>();
categoryList
=
new
MutableLiveData
<>();
productByCategory
=
new
MutableLiveData
<>();
productByCategory
=
new
MutableLiveData
<>();
...
@@ -44,26 +46,26 @@ public class MainViewModels extends ViewModel {
...
@@ -44,26 +46,26 @@ public class MainViewModels extends ViewModel {
}
}
public
LiveData
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
getProduct
(){
public
LiveData
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
getProduct
()
{
getProductList
();
getProductList
();
return
productList
;
return
productList
;
}
}
public
LiveData
<
DataResponse
<
List
<
CategoryModels
>>>
getCategory
(){
public
LiveData
<
DataResponse
<
List
<
CategoryModels
>>>
getCategory
()
{
getCategoryList
();
getCategoryList
();
return
categoryList
;
return
categoryList
;
}
}
public
void
postCategory
(
CategoryModels
categoryModels
){
public
void
postCategory
(
CategoryModels
categoryModels
)
{
saveCategory
(
categoryModels
);
saveCategory
(
categoryModels
);
}
}
public
LiveData
<
DataResponse
<
List
<
ProductModels
>>>
getProductByCategory
(
int
id
){
public
LiveData
<
DataResponse
<
List
<
ProductModels
>>>
getProductByCategory
(
int
id
)
{
getDataProductByCategory
(
id
);
getDataProductByCategory
(
id
);
return
productByCategory
;
return
productByCategory
;
}
}
public
LiveData
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
getAllTransactions
(){
public
LiveData
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
getAllTransactions
()
{
getDataTransaction
();
getDataTransaction
();
return
transactions
;
return
transactions
;
}
}
...
@@ -74,27 +76,27 @@ public class MainViewModels extends ViewModel {
...
@@ -74,27 +76,27 @@ public class MainViewModels extends ViewModel {
categoryServise
.
addCategory
(
categoryModels
).
enqueue
(
new
Callback
<
DataResponse
<
CategoryModels
>>()
{
categoryServise
.
addCategory
(
categoryModels
).
enqueue
(
new
Callback
<
DataResponse
<
CategoryModels
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Response
<
DataResponse
<
CategoryModels
>>
response
)
{
Log
.
i
(
"Add Categiry"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"Add Categiry"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
CategoryModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"error add"
,
"onFailure: "
,
t
);
Log
.
e
(
"error add"
,
"onFailure: "
,
t
);
}
}
});
});
}
}
public
void
deleteProducts
(
int
id
){
public
void
deleteProducts
(
int
id
)
{
ProductService
productService
=
client
.
Client
(
ProductService
.
class
);
ProductService
productService
=
client
.
Client
(
ProductService
.
class
);
productService
.
deleteProducts
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
ProductModels
>>()
{
productService
.
deleteProducts
(
id
).
enqueue
(
new
Callback
<
DataResponse
<
ProductModels
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Response
<
DataResponse
<
ProductModels
>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Response
<
DataResponse
<
ProductModels
>>
response
)
{
Log
.
i
(
"Delete"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"Delete"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
ProductModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"error delete"
,
"onFailure: "
,
t
);
Log
.
e
(
"error delete"
,
"onFailure: "
,
t
);
}
}
});
});
}
}
...
@@ -106,17 +108,17 @@ public class MainViewModels extends ViewModel {
...
@@ -106,17 +108,17 @@ public class MainViewModels extends ViewModel {
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
call
,
public
void
onResponse
(
Call
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
call
,
Response
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
response
)
{
Response
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
response
)
{
Log
.
i
(
"Get all transaction"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"Get all transaction"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
){
if
(
response
.
body
()
!=
null
)
{
transactions
.
setValue
(
response
.
body
());
transactions
.
setValue
(
response
.
body
());
}
else
{
}
else
{
transactions
=
null
;
transactions
=
null
;
}
}
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
List
<
PaymentsModels
<
String
>>>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error get transaction"
,
"onFailure: "
,
t
);
Log
.
e
(
"Error get transaction"
,
"onFailure: "
,
t
);
transactions
=
null
;
transactions
=
null
;
}
}
});
});
...
@@ -130,8 +132,8 @@ public class MainViewModels extends ViewModel {
...
@@ -130,8 +132,8 @@ public class MainViewModels extends ViewModel {
public
void
onResponse
(
Call
<
DataResponse
<
List
<
ProductModels
>>>
call
,
public
void
onResponse
(
Call
<
DataResponse
<
List
<
ProductModels
>>>
call
,
Response
<
DataResponse
<
List
<
ProductModels
>>>
response
)
{
Response
<
DataResponse
<
List
<
ProductModels
>>>
response
)
{
String
js
=
new
Gson
().
toJson
(
response
.
body
());
String
js
=
new
Gson
().
toJson
(
response
.
body
());
Log
.
i
(
"Get data by category"
,
"onResponse: "
+
js
);
Log
.
i
(
"Get data by category"
,
"onResponse: "
+
js
);
if
(
response
!=
null
){
if
(
response
!=
null
)
{
productByCategory
.
setValue
(
response
.
body
());
productByCategory
.
setValue
(
response
.
body
());
}
}
}
}
...
@@ -143,28 +145,53 @@ public class MainViewModels extends ViewModel {
...
@@ -143,28 +145,53 @@ public class MainViewModels extends ViewModel {
});
});
}
}
public
MutableLiveData
<
DataResponse
<
UsersModels
>>
checkLogin
(
UsersModels
usersModels
){
public
MutableLiveData
<
DataResponse
<
UsersModels
>>
checkLogin
(
UsersModels
usersModels
)
{
usersLogin
=
new
MutableLiveData
<>();
usersLogin
=
new
MutableLiveData
<>();
PeriksaLogin
(
usersModels
);
PeriksaLogin
(
usersModels
);
return
usersLogin
;
return
usersLogin
;
}
}
public
MutableLiveData
<
DataResponse
<
UsersModels
>>
checkRegis
(
UsersModels
usersModels
){
usersRegister
=
new
MutableLiveData
<>();
CreateRegister
(
usersModels
);
return
usersRegister
;
}
private
void
PeriksaLogin
(
UsersModels
usersModels
)
{
private
void
PeriksaLogin
(
UsersModels
usersModels
)
{
UsersService
usersService
=
client
.
Client
(
UsersService
.
class
);
UsersService
usersService
=
client
.
Client
(
UsersService
.
class
);
//cek login
usersService
.
checkLogin
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
usersService
.
checkLogin
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
if
(
response
.
body
()
!=
null
){
if
(
response
.
body
()
!=
null
)
{
usersLogin
.
setValue
(
response
.
body
());
usersLogin
.
setValue
(
response
.
body
());
}
}
String
js
=
new
Gson
().
toJson
(
response
.
body
());
String
js
=
new
Gson
().
toJson
(
response
.
body
());
Log
.
d
(
"Periksa login"
,
"Response "
+
js
);
Log
.
d
(
"Periksa login"
,
"Response "
+
js
);
}
@Override
public
void
onFailure
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error Login"
,
"Response "
+
t
.
getMessage
());
}
});
}
private
void
CreateRegister
(
UsersModels
usersModels
){
UsersService
usersService
=
client
.
Client
(
UsersService
.
class
);
//post register
usersService
.
postRegister
(
usersModels
).
enqueue
(
new
Callback
<
DataResponse
<
UsersModels
>>()
{
@Override
public
void
onResponse
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Response
<
DataResponse
<
UsersModels
>>
response
)
{
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
UsersModels
>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error
Login"
,
"Response
"
+
t
.
getMessage
());
Log
.
e
(
"Error
Register"
,
"Response
"
+
t
.
getMessage
());
}
}
});
});
}
}
...
@@ -176,40 +203,40 @@ public class MainViewModels extends ViewModel {
...
@@ -176,40 +203,40 @@ public class MainViewModels extends ViewModel {
productService
.
getProducts
().
enqueue
(
new
Callback
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
productService
.
getProducts
().
enqueue
(
new
Callback
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
call
,
Response
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
call
,
Response
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
response
)
{
Log
.
i
(
"Get products"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
Log
.
i
(
"Get products"
,
"onResponse: "
+
utils
.
convertGson
(
response
.
body
()));
if
(
response
.
body
()
!=
null
){
if
(
response
.
body
()
!=
null
)
{
productList
.
setValue
(
response
.
body
());
productList
.
setValue
(
response
.
body
());
}
else
{
}
else
{
productList
.
setValue
(
null
);
productList
.
setValue
(
null
);
}
}
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
List
<
ProductModels
<
CategoryModels
>>>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error get product"
,
"Response "
+
t
.
getMessage
());
Log
.
e
(
"Error get product"
,
"Response "
+
t
.
getMessage
());
}
}
});
});
}
}
private
void
getCategoryList
(){
private
void
getCategoryList
()
{
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
CategoryServise
categoryServise
=
client
.
Client
(
CategoryServise
.
class
);
categoryServise
.
getCategory
().
enqueue
(
new
Callback
<
DataResponse
<
List
<
CategoryModels
>>>()
{
categoryServise
.
getCategory
().
enqueue
(
new
Callback
<
DataResponse
<
List
<
CategoryModels
>>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
DataResponse
<
List
<
CategoryModels
>>>
call
,
Response
<
DataResponse
<
List
<
CategoryModels
>>>
response
)
{
public
void
onResponse
(
Call
<
DataResponse
<
List
<
CategoryModels
>>>
call
,
Response
<
DataResponse
<
List
<
CategoryModels
>>>
response
)
{
String
js
=
new
Gson
().
toJson
(
response
.
body
());
String
js
=
new
Gson
().
toJson
(
response
.
body
());
Log
.
d
(
"Get Data Category"
,
"Response "
+
js
);
Log
.
d
(
"Get Data Category"
,
"Response "
+
js
);
if
(
response
.
body
()
!=
null
){
if
(
response
.
body
()
!=
null
)
{
categoryList
.
setValue
(
response
.
body
());
categoryList
.
setValue
(
response
.
body
());
}
else
{
}
else
{
categoryList
.
setValue
(
null
);
categoryList
.
setValue
(
null
);
}
}
}
}
@Override
@Override
public
void
onFailure
(
Call
<
DataResponse
<
List
<
CategoryModels
>>>
call
,
Throwable
t
)
{
public
void
onFailure
(
Call
<
DataResponse
<
List
<
CategoryModels
>>>
call
,
Throwable
t
)
{
Log
.
e
(
"Error get product"
,
"Response "
+
t
.
getMessage
());
Log
.
e
(
"Error get product"
,
"Response "
+
t
.
getMessage
());
}
}
});
});
}
}
...
...
app/src/main/java/com/yono/messeripos/models/UsersModels.java
View file @
d2542572
...
@@ -6,14 +6,27 @@ public class UsersModels {
...
@@ -6,14 +6,27 @@ public class UsersModels {
@SerializedName
(
"username"
)
@SerializedName
(
"username"
)
private
String
usernameUsers
;
private
String
usernameUsers
;
@SerializedName
(
"email"
)
private
String
emailUsers
;
@SerializedName
(
"password"
)
@SerializedName
(
"password"
)
private
String
passwordUsers
;
private
String
passwordUsers
;
public
UsersModels
(
String
usernameUsers
,
String
passwordUsers
)
{
public
UsersModels
(
String
usernameUsers
,
String
emailUsers
,
String
passwordUsers
)
{
this
.
usernameUsers
=
usernameUsers
;
this
.
usernameUsers
=
usernameUsers
;
this
.
emailUsers
=
emailUsers
;
this
.
passwordUsers
=
passwordUsers
;
this
.
passwordUsers
=
passwordUsers
;
}
}
public
String
getEmailUsers
()
{
return
emailUsers
;
}
public
void
setEmailUsers
(
String
emailUsers
)
{
this
.
emailUsers
=
emailUsers
;
}
public
String
getUsernameUsers
()
{
public
String
getUsernameUsers
()
{
return
usernameUsers
;
return
usernameUsers
;
}
}
...
...
app/src/main/res/layout/login_form.xml
View file @
d2542572
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"vertical"
android:orientation=
"vertical"
app:behavior_hideable=
"true"
android:layout_gravity=
"bottom"
app:behavior_hideable=
"false"
android:padding=
"20dp"
android:padding=
"20dp"
style=
"@style/Widget.Rounded.BottomSheet"
style=
"@style/Widget.Rounded.BottomSheet"
app:behavior_peekHeight=
"0dp"
app:behavior_peekHeight=
"0dp"
...
...
app/src/main/res/layout/register_form.xml
View file @
d2542572
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
android:fitsSystemWindows=
"true"
android:fitsSystemWindows=
"true"
android:paddingTop=
"10dp"
android:paddingTop=
"10dp"
android:orientation=
"vertical"
android:orientation=
"vertical"
app:behavior_hideable=
"true"
app:behavior_peekHeight=
"0dp"
app:behavior_peekHeight=
"0dp"
app:layout_behavior=
"com.google.android.material.bottomsheet.BottomSheetBehavior"
app:layout_behavior=
"com.google.android.material.bottomsheet.BottomSheetBehavior"
style=
"@style/Widget.Rounded.BottomSheet"
>
style=
"@style/Widget.Rounded.BottomSheet"
>
...
@@ -172,7 +173,7 @@
...
@@ -172,7 +173,7 @@
app:useMaterialThemeColors=
"true"
/>
app:useMaterialThemeColors=
"true"
/>
<com.google.android.material.button.MaterialButton
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btn
Login
"
android:id=
"@+id/btn
Register
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:layout_marginTop=
"10dp"
...
@@ -190,20 +191,6 @@
...
@@ -190,20 +191,6 @@
app:layout_constraintVertical_bias=
"0.01999998"
/>
app:layout_constraintVertical_bias=
"0.01999998"
/>
<ProgressBar
android:id=
"@+id/progressBar"
style=
"?android:attr/progressBarStyle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:elevation=
"2dp"
app:layout_constraintBottom_toBottomOf=
"@id/btnLogin"
app:layout_constraintEnd_toEndOf=
"@id/btnLogin"
app:layout_constraintStart_toStartOf=
"@id/btnLogin"
app:layout_constraintTop_toTopOf=
"@id/btnLogin"
tools:layout_editor_absoluteX=
"64dp"
tools:layout_editor_absoluteY=
"337dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
...
...
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