Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SEProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kishore Kumar
SEProject
Commits
cb209649
Commit
cb209649
authored
8 years ago
by
melvinabraham
Browse files
Options
Downloads
Patches
Plain Diff
Register Activity Working
parent
7dbc5aeb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/com/mapps/seproject/RegisterActivity.java
+129
-1
129 additions, 1 deletion
app/src/main/java/com/mapps/seproject/RegisterActivity.java
with
129 additions
and
1 deletion
app/src/main/java/com/mapps/seproject/RegisterActivity.java
+
129
−
1
View file @
cb209649
package
com.mapps.seproject
;
package
com.mapps.seproject
;
import
android.app.ProgressDialog
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
public
class
RegisterActivity
extends
AppCompatActivity
{
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.firebase.auth.AuthResult
;
import
com.google.firebase.auth.FirebaseAuth
;
public
class
RegisterActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
EditText
email
;
EditText
password
;
Button
b
;
TextView
loginText
;
ProgressDialog
progress
;
FirebaseAuth
firebaseAuth
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -11,8 +33,114 @@ public class RegisterActivity extends AppCompatActivity {
...
@@ -11,8 +33,114 @@ public class RegisterActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_register
);
setContentView
(
R
.
layout
.
activity_register
);
firebaseAuth
=
FirebaseAuth
.
getInstance
();
if
(
firebaseAuth
.
getCurrentUser
()
!=
null
)
{
finish
();
startActivity
(
new
Intent
(
getApplicationContext
(),
UserActivity
.
class
));
// If user is already logged in
}
progress
=
new
ProgressDialog
(
this
);
email
=
(
EditText
)
findViewById
(
R
.
id
.
etRegEmail
);
password
=
(
EditText
)
findViewById
(
R
.
id
.
etRegPassword
);
b
=
(
Button
)
findViewById
(
R
.
id
.
bRegister
);
loginText
=
(
TextView
)
findViewById
(
R
.
id
.
textLogin
);
b
.
setOnClickListener
(
this
);
loginText
.
setOnClickListener
(
this
);
}
public
void
registerUser
()
{
String
mail
=
email
.
getText
().
toString
().
trim
();
String
pass
=
password
.
getText
().
toString
().
trim
();
if
(
TextUtils
.
isEmpty
(
mail
))
{
Toast
.
makeText
(
this
,
"Enter E-Mail"
,
Toast
.
LENGTH_SHORT
).
show
();
// Incase Any of the fields are empty
return
;
}
if
(
TextUtils
.
isEmpty
(
pass
))
{
Toast
.
makeText
(
this
,
"Enter Password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
progress
.
setMessage
(
"Registering"
);
// Progress Bar
progress
.
show
();
firebaseAuth
.
createUserWithEmailAndPassword
(
mail
,
pass
)
// Create New Entry
.
addOnCompleteListener
(
this
,
new
OnCompleteListener
<
AuthResult
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
AuthResult
>
task
)
{
if
(
task
.
isSuccessful
())
{
// On Successful Registration
Toast
.
makeText
(
RegisterActivity
.
this
,
"Registered Successfuly"
,
Toast
.
LENGTH_SHORT
).
show
();
progress
.
hide
();
}
else
{
Toast
.
makeText
(
RegisterActivity
.
this
,
"Failed to Register"
,
Toast
.
LENGTH_SHORT
).
show
();
//task.getException().getMessage();
}
}
});
}
@Override
public
void
onClick
(
View
v
)
{
if
(
v
==
b
)
// Register the current user
{
registerUser
();
}
if
(
v
==
loginText
){
// Go to login activity
finish
();
startActivity
(
new
Intent
(
getApplicationContext
(),
LoginActivity
.
class
));
}
...
...
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