Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mobile_Pecunia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Filip Stanicak
Mobile_Pecunia
Commits
600b7e36
Commit
600b7e36
authored
5 years ago
by
Bruno Teixeira
Browse files
Options
Downloads
Patches
Plain Diff
Retrofit example
parent
7cd196e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Frontend/app/src/main/java/com/example/mobileapp/Start_Screen.java
+24
-3
24 additions, 3 deletions
...app/src/main/java/com/example/mobileapp/Start_Screen.java
with
24 additions
and
3 deletions
Frontend/app/src/main/java/com/example/mobileapp/Start_Screen.java
+
24
−
3
View file @
600b7e36
...
@@ -3,23 +3,31 @@ package com.example.mobileapp;
...
@@ -3,23 +3,31 @@ package com.example.mobileapp;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.example.mobileapp.model.User
;
import
com.example.mobileapp.networking.RetrofitClient
;
import
com.example.mobileapp.networking.UserService
;
import
com.google.android.material.textfield.TextInputLayout
;
import
com.google.android.material.textfield.TextInputLayout
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
Start_Screen
extends
AppCompatActivity
{
public
class
Start_Screen
extends
AppCompatActivity
{
private
TextInputLayout
textInputEmail
;
private
TextInputLayout
textInputEmail
;
private
TextInputLayout
textInputPW
;
private
TextInputLayout
textInputPW
;
private
UserService
userService
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
userService
=
RetrofitClient
.
getRetrofitInstance
().
create
(
UserService
.
class
);
textInputEmail
=
findViewById
(
R
.
id
.
text_input_email
);
textInputEmail
=
findViewById
(
R
.
id
.
text_input_email
);
textInputPW
=
findViewById
(
R
.
id
.
text_input_pw
);
textInputPW
=
findViewById
(
R
.
id
.
text_input_pw
);
...
@@ -27,7 +35,6 @@ public class Start_Screen extends AppCompatActivity {
...
@@ -27,7 +35,6 @@ public class Start_Screen extends AppCompatActivity {
private
boolean
validateEmail
()
{
private
boolean
validateEmail
()
{
String
emailInput
=
textInputEmail
.
getEditText
().
getText
().
toString
().
trim
();
String
emailInput
=
textInputEmail
.
getEditText
().
getText
().
toString
().
trim
();
if
(
emailInput
.
isEmpty
())
{
if
(
emailInput
.
isEmpty
())
{
textInputEmail
.
setError
(
"Field cannot be empty"
);
textInputEmail
.
setError
(
"Field cannot be empty"
);
return
false
;
return
false
;
...
@@ -66,6 +73,20 @@ public class Start_Screen extends AppCompatActivity {
...
@@ -66,6 +73,20 @@ public class Start_Screen extends AppCompatActivity {
}
}
startActivity
(
new
Intent
(
Start_Screen
.
this
,
Trip_Overview_Screen
.
class
));
startActivity
(
new
Intent
(
Start_Screen
.
this
,
Trip_Overview_Screen
.
class
));
Toast
.
makeText
(
this
,
"Logging in ..."
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
this
,
"Logging in ..."
,
Toast
.
LENGTH_SHORT
).
show
();
final
User
[]
testUser
=
new
User
[
0
];
Call
<
User
>
call
=
userService
.
getUserByEmail
(
"bruno@mail.com"
);
call
.
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
// https://medium.com/@prakash_pun/retrofit-a-simple-android-tutorial-48437e4e5a23
testUser
[
0
]
=
response
.
body
();
}
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{
//onFailure
}
});
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment