Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
vocabulary_notebook
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
10b25a86
authored
Sep 07, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Data is retrieved from a linked vocabulary
parent
e92751b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
app/src/main/java/com/paktalin/vocabularynotebook/activities/UserActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/activities/UserActivity.kt
View file @
10b25a86
...
...
@@ -6,15 +6,22 @@ import android.support.v7.app.AppCompatActivity
import
android.util.Log
import
com.google.firebase.auth.FirebaseAuth
import
com.google.firebase.firestore.DocumentReference
import
com.google.firebase.firestore.DocumentSnapshot
import
com.google.firebase.firestore.FirebaseFirestore
import
com.paktalin.vocabularynotebook.R
import
kotlinx.android.synthetic.main.activity_user.*
class
UserActivity
:
AppCompatActivity
()
{
private
lateinit
var
userDocument
:
DocumentReference
private
val
db
=
FirebaseFirestore
.
getInstance
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_user
)
extractUserDocument
()
printUserData
()
}
...
...
@@ -23,15 +30,29 @@ class UserActivity : AppCompatActivity() {
FirebaseAuth
.
getInstance
().
signOut
()
}
@SuppressLint
(
"SetTextI18n"
)
private
fun
printUserData
()
{
private
fun
extractUserDocument
()
{
val
userId
=
FirebaseAuth
.
getInstance
().
currentUser
!!
.
uid
Log
.
d
(
TAG
,
"retrieved userId: $userId"
)
val
db
=
FirebaseFirestore
.
getInstance
()
userDocument
=
db
.
collection
(
"users"
).
document
(
userId
)
}
db
.
collection
(
"users"
).
document
(
userId
).
get
().
addOnSuccessListener
{
task
->
@SuppressLint
(
"SetTextI18n"
)
private
fun
printUserData
()
{
userDocument
.
get
().
addOnSuccessListener
{
task
->
val
email
=
task
.
get
(
"email"
).
toString
()
tvUserData
.
text
=
"email: $email"
tvUserData
.
text
=
email
retrieveVocabulary
(
task
)
}
}
private
fun
retrieveVocabulary
(
task
:
DocumentSnapshot
)
{
val
vocabularies
:
List
<
DocumentReference
>
=
task
.
get
(
"vocabularies"
)
as
List
<
DocumentReference
>
val
firstVocab
=
vocabularies
[
0
].
id
db
.
collection
(
"vocabularies"
).
document
(
firstVocab
).
get
().
addOnSuccessListener
{
task
->
val
vocabTitle
=
task
.
get
(
"title"
).
toString
()
tvUserData
.
append
(
"\n\nvocabularies:\n$vocabTitle"
)
}
}
...
...
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