Commit 97b5eba8 by Paktalin

Retrieves real vocabulary data

parent 254957f2
...@@ -75,22 +75,7 @@ class VocabularyFragment : Fragment() { ...@@ -75,22 +75,7 @@ class VocabularyFragment : Fragment() {
val vocabularyTitle = task.get("title").toString() val vocabularyTitle = task.get("title").toString()
tvUserData.append("\n\nvocabularies:\n$vocabularyTitle") tvUserData.append("\n\nvocabularies:\n$vocabularyTitle")
} }
val mLayoutManager = LinearLayoutManager(activity) retrieveWordsFromVocabulary()
recyclerView.layoutManager = mLayoutManager
recyclerView.setHasFixedSize(true)
val items: List<WordItemPojo> = Arrays.asList(
WordItemPojo("uno", "one"),
WordItemPojo("due", "two"),
WordItemPojo("tre", "three"))
val adapter = VocabularyAdapter(items)
recyclerView.adapter = adapter
/*vocabulary.collection(WORDS).get().addOnSuccessListener {
val items: List<String> = Arrays.asList("one", "two", "three")
val adapter = VocabularyAdapter(items)
recyclerView.adapter = adapter
}*/
} }
private fun addWord() { private fun addWord() {
...@@ -100,6 +85,21 @@ class VocabularyFragment : Fragment() { ...@@ -100,6 +85,21 @@ class VocabularyFragment : Fragment() {
} }
private fun retrieveWordsFromVocabulary() { private fun retrieveWordsFromVocabulary() {
val mLayoutManager = LinearLayoutManager(activity)
recyclerView.layoutManager = mLayoutManager
recyclerView.setHasFixedSize(true)
vocabulary.collection(WORDS).get().addOnSuccessListener {
val wordItems: MutableList<WordItemPojo> = mutableListOf()
for (ref in it.documents) {
val word = ref.get("word").toString()
val translation = ref.get("translation").toString()
wordItems.add(WordItemPojo(word, translation))
}
val adapter = VocabularyAdapter(wordItems)
recyclerView.adapter = adapter
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment