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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kishore Kumar
SEProject
Commits
e23282c2
Commit
e23282c2
authored
8 years ago
by
melvinabraham
Browse files
Options
Downloads
Patches
Plain Diff
Merged Changes and Added Database Functionality
parent
819cdd54
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/com/mapps/seproject/MainActivity.java
+79
-1
79 additions, 1 deletion
app/src/main/java/com/mapps/seproject/MainActivity.java
app/src/main/java/com/mapps/seproject/User.java
+26
-0
26 additions, 0 deletions
app/src/main/java/com/mapps/seproject/User.java
with
105 additions
and
1 deletion
app/src/main/java/com/mapps/seproject/MainActivity.java
+
79
−
1
View file @
e23282c2
...
...
@@ -8,7 +8,15 @@ import android.support.annotation.IdRes;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.google.firebase.auth.FirebaseAuth
;
import
com.google.firebase.database.DataSnapshot
;
import
com.google.firebase.database.DatabaseError
;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
com.google.firebase.database.ValueEventListener
;
import
com.roughike.bottombar.BottomBar
;
import
com.roughike.bottombar.OnTabSelectListener
;
...
...
@@ -19,11 +27,76 @@ public class MainActivity extends AppCompatActivity {
Fragment
compose_activity
;
FragmentManager
fragmentManager
;
FragmentTransaction
fragmentTransaction
;
FirebaseAuth
firebaseAuth
;
int
flag
=
0
;
FirebaseDatabase
database
=
FirebaseDatabase
.
getInstance
();
DatabaseReference
myRef
=
database
.
getReference
(
"message"
);
String
userId
;
String
UserEmail
=
null
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
firebaseAuth
=
FirebaseAuth
.
getInstance
();
final
String
data
=
firebaseAuth
.
getCurrentUser
().
getEmail
();
final
DatabaseReference
mDatabase
=
FirebaseDatabase
.
getInstance
().
getReference
(
"users"
);
/*
userId = mDatabase.push().getKey();
User user = new User(data);
mDatabase.child(userId).setValue(user);
*/
mDatabase
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
DataSnapshot
dataSnapshot
)
{
Log
.
e
(
"Count"
,
""
+
dataSnapshot
.
getChildrenCount
());
for
(
DataSnapshot
idSnapshot
:
dataSnapshot
.
getChildren
())
{
//Log.e("Email:",""+idSnapshot.child("email").toString().split("value =")[1].split(" ")[1]);
UserEmail
=
idSnapshot
.
child
(
"email"
).
toString
().
split
(
"value ="
)[
1
].
split
(
" "
)[
1
].
replaceAll
(
"\\s+"
,
""
);
Log
.
e
(
"Email"
,
UserEmail
);
Log
.
e
(
"Data"
,
data
);
if
(
data
.
equals
(
UserEmail
))
{
Log
.
e
(
"E"
,
"Already Exists"
);
flag
=
1
;
}
}
if
(
flag
==
0
)
{
userId
=
mDatabase
.
push
().
getKey
();
User
user
=
new
User
(
data
);
mDatabase
.
child
(
userId
).
setValue
(
user
);
Log
.
e
(
"E"
,
"new"
);
}
}
@Override
public
void
onCancelled
(
DatabaseError
databaseError
)
{
System
.
out
.
println
(
"The read failed"
+
databaseError
.
getMessage
());
}
});
BottomBar
bottomBar
=
(
BottomBar
)
findViewById
(
R
.
id
.
bottomBar
);
bottomBar
.
setOnTabSelectListener
(
new
OnTabSelectListener
()
{
@Override
...
...
@@ -62,4 +135,9 @@ public class MainActivity extends AppCompatActivity {
}
}
This diff is collapsed.
Click to expand it.
app/src/main/java/com/mapps/seproject/User.java
0 → 100644
+
26
−
0
View file @
e23282c2
package
com.mapps.seproject
;
/**
* Created by melvin on 21/4/17.
*/
public
class
User
{
public
String
email
;
public
User
()
{
}
public
User
(
String
email
)
{
this
.
email
=
email
;
}
}
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