Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
Your Cashier
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
Ahmad Abi Mulya
Your Cashier
Commits
5e3f552d
Commit
5e3f552d
authored
Aug 27, 2020
by
Wahyu Wibowo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fitur register with service
parent
8eb8cf67
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
325 additions
and
229 deletions
+325
-229
build.gradle
app/build.gradle
+5
-0
RegisterActivity.java
.../example/yourcashiertest/activities/RegisterActivity.java
+26
-1
CartAdapter.java
...ava/com/example/yourcashiertest/adapters/CartAdapter.java
+0
-3
ApiClient.java
...n/java/com/example/yourcashiertest/clients/ApiClient.java
+21
-0
CartModel.java
...in/java/com/example/yourcashiertest/models/CartModel.java
+0
-46
User.java
...rc/main/java/com/example/yourcashiertest/models/User.java
+50
-0
UserService.java
...ava/com/example/yourcashiertest/services/UserService.java
+16
-0
CartVM.java
...n/java/com/example/yourcashiertest/viewmodels/CartVM.java
+0
-19
UserViewModel.java
...com/example/yourcashiertest/viewmodels/UserViewModel.java
+35
-0
activity_register.xml
app/src/main/res/layout/activity_register.xml
+172
-160
No files found.
app/build.gradle
View file @
5e3f552d
...
...
@@ -52,6 +52,11 @@ dependencies {
implementation
"com.github.bumptech.glide:glide:$glide_version"
annotationProcessor
"com.github.bumptech.glide:compiler:$glide_version"
// service
implementation
'com.squareup.retrofit2:retrofit:2.9.0'
implementation
'com.squareup.retrofit2:converter-gson:2.9.0'
implementation
'com.google.code.gson:gson:2.8.6'
testImplementation
'junit:junit:4.13'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
...
...
app/src/main/java/com/example/yourcashiertest/activities/RegisterActivity.java
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
activities
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.lifecycle.ViewModelProvider
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.webkit.WebView
;
import
android.widget.ProgressBar
;
import
android.widget.Toast
;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.databinding.ActivityRegisterBinding
;
import
com.example.yourcashiertest.models.User
;
import
com.example.yourcashiertest.viewmodels.UserViewModel
;
public
class
RegisterActivity
extends
AppCompatActivity
{
WebView
wbCompany
;
ProgressBar
pbLoading
;
private
static
final
String
urLCompany
=
"http://multidaya.id/"
;
ActivityRegisterBinding
binding
;
User
user
;
UserViewModel
viewModel
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_register
);
binding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_register
);
user
=
new
User
();
viewModel
=
new
ViewModelProvider
(
this
,
new
ViewModelProvider
.
NewInstanceFactory
()).
get
(
UserViewModel
.
class
);
binding
.
btnRegister
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
user
.
setEmail
(
binding
.
etEmail
.
getText
().
toString
());
user
.
setFullName
(
binding
.
etUsername
.
getText
().
toString
());
user
.
setPassword
(
binding
.
etPassword
.
getText
().
toString
());
user
.
setPhoneNumber
(
binding
.
etPhoneNumber
.
getText
().
toString
());
viewModel
.
registrasi
(
user
);
Toast
.
makeText
(
getApplicationContext
(),
"Register berhasil"
,
Toast
.
LENGTH_LONG
).
show
();
startActivity
(
new
Intent
(
getApplicationContext
(),
LoginActivity
.
class
));
}
});
}
public
void
tvSignInHere
(
View
view
)
{
...
...
app/src/main/java/com/example/yourcashiertest/adapters/CartAdapter.java
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
adapters
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
...
...
@@ -11,8 +10,6 @@ import androidx.recyclerview.widget.RecyclerView;
import
com.example.yourcashiertest.R
;
import
com.example.yourcashiertest.databinding.CartItemBinding
;
import
com.example.yourcashiertest.entities.Cart
;
import
com.example.yourcashiertest.entities.Product
;
import
com.example.yourcashiertest.models.CartModel
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
...
...
app/src/main/java/com/example/yourcashiertest/clients/ApiClient.java
0 → 100644
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
clients
;
import
com.google.gson.GsonBuilder
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
public
class
ApiClient
{
public
static
<
T
>
T
client
(
Class
<
T
>
service
,
String
url
)
{
Retrofit
retrofit
=
new
Retrofit
.
Builder
()
.
baseUrl
(
url
)
.
addConverterFactory
(
GsonConverterFactory
.
create
(
new
GsonBuilder
().
setLenient
().
create
()
)
)
.
build
();
return
retrofit
.
create
(
service
);
}
}
app/src/main/java/com/example/yourcashiertest/models/CartModel.java
deleted
100644 → 0
View file @
8eb8cf67
package
com
.
example
.
yourcashiertest
.
models
;
public
class
CartModel
{
long
price
,
qty
,
idProduct
;
String
nameProduct
,
image
;
public
long
getPrice
()
{
return
price
;
}
public
void
setPrice
(
long
price
)
{
this
.
price
=
price
;
}
public
long
getQty
()
{
return
qty
;
}
public
void
setQty
(
long
qty
)
{
this
.
qty
=
qty
;
}
public
long
getIdProduct
()
{
return
idProduct
;
}
public
void
setIdProduct
(
long
idProduct
)
{
this
.
idProduct
=
idProduct
;
}
public
String
getNameProduct
()
{
return
nameProduct
;
}
public
void
setNameProduct
(
String
nameProduct
)
{
this
.
nameProduct
=
nameProduct
;
}
public
String
getImage
()
{
return
image
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
}
app/src/main/java/com/example/yourcashiertest/models/User.java
0 → 100644
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
models
;
import
com.google.gson.annotations.SerializedName
;
public
class
User
{
@SerializedName
(
"password"
)
private
String
password
;
@SerializedName
(
"full_name"
)
private
String
fullName
;
@SerializedName
(
"phone_number"
)
private
String
phoneNumber
;
@SerializedName
(
"email"
)
private
String
email
;
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
void
setFullName
(
String
fullName
)
{
this
.
fullName
=
fullName
;
}
public
void
setPhoneNumber
(
String
phoneNumber
)
{
this
.
phoneNumber
=
phoneNumber
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getPassword
(){
return
password
;
}
public
String
getFullName
(){
return
fullName
;
}
public
String
getPhoneNumber
(){
return
phoneNumber
;
}
public
String
getEmail
(){
return
email
;
}
}
\ No newline at end of file
app/src/main/java/com/example/yourcashiertest/services/UserService.java
0 → 100644
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
services
;
import
com.example.yourcashiertest.models.User
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.Headers
;
import
retrofit2.http.POST
;
public
interface
UserService
{
@Headers
(
"Content-Type: application/json"
)
@POST
(
"v1/customer"
)
Call
<
User
>
registerUser
(
@Body
User
user
);
}
app/src/main/java/com/example/yourcashiertest/viewmodels/CartVM.java
deleted
100644 → 0
View file @
8eb8cf67
package
com
.
example
.
yourcashiertest
.
viewmodels
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.ViewModel
;
import
com.example.yourcashiertest.models.CartModel
;
import
java.util.List
;
public
class
CartVM
extends
ViewModel
{
public
MutableLiveData
<
List
<
CartModel
>>
allCart
;
public
MutableLiveData
<
List
<
CartModel
>>
getAllCart
()
{
return
allCart
;
}
public
void
setAllCart
(
List
<
CartModel
>
cart
)
{
this
.
allCart
.
postValue
(
cart
);
}
}
app/src/main/java/com/example/yourcashiertest/viewmodels/UserViewModel.java
0 → 100644
View file @
5e3f552d
package
com
.
example
.
yourcashiertest
.
viewmodels
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.ViewModel
;
import
com.example.yourcashiertest.clients.ApiClient
;
import
com.example.yourcashiertest.models.User
;
import
com.example.yourcashiertest.services.UserService
;
import
java.util.List
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
UserViewModel
extends
ViewModel
{
MutableLiveData
<
List
<
User
>>
listUser
=
new
MutableLiveData
<>();
public
final
String
BASE_URL
=
"https://your-cashier.herokuapp.com/api/"
;
public
void
registrasi
(
User
user
){
ApiClient
.
client
(
UserService
.
class
,
BASE_URL
).
registerUser
(
user
)
.
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
}
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{
}
});
}
}
app/src/main/res/layout/activity_register.xml
View file @
5e3f552d
<?xml version="1.0" encoding="utf-8"?>
<
androidx.constraintlayout.widget.ConstraintL
ayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
l
ayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
>
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".activities.RegisterActivity"
>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvRegister"
android:layout_width=
"wrap_content"
...
...
@@ -15,7 +22,7 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:textStyle=
"bold"
android:text=
"REGISTER ACCOUNT"
/>
android:text=
"REGISTER ACCOUNT"
/>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilUsername"
...
...
@@ -37,6 +44,7 @@
android:imeOptions=
"actionNext"
android:textSize=
"@dimen/text_default"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilEmail"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
...
...
@@ -57,6 +65,7 @@
android:imeOptions=
"actionNext"
android:textSize=
"@dimen/text_default"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilPhoneNumber"
style=
"@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
...
...
@@ -77,6 +86,7 @@
android:imeOptions=
"actionNext"
android:textSize=
"@dimen/text_default"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id=
"@+id/tilPassword"
app:passwordToggleEnabled=
"true"
...
...
@@ -121,6 +131,7 @@
android:textColor=
"@color/blue"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tvDescSk"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/tvYourCashier"
android:onClick=
"tvSignInHere"
...
...
@@ -130,7 +141,7 @@
android:layout_marginTop=
"10dp"
android:text=
"Your Cashier"
app:layout_constraintStart_toEndOf=
"@id/tvSK"
app:layout_constraintTop_toBottomOf=
"@id/tvDescSk"
/>
app:layout_constraintTop_toBottomOf=
"@id/tvDescSk"
/>
<com.google.android.material.button.MaterialButton
android:id=
"@+id/btnRegister"
...
...
@@ -168,4 +179,5 @@
android:textColor=
"@color/blue"
app:layout_constraintStart_toEndOf=
"@id/tvDontHaveAnAccount"
app:layout_constraintTop_toBottomOf=
"@id/btnRegister"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment