Commit 9b814d03 by Paktalin

Fixed bug with WordItem's time

parent 548c2ee9
...@@ -84,9 +84,7 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va ...@@ -84,9 +84,7 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
private fun sortByTime() { private fun sortByTime() {
wordItems.sortWith(Comparator { item1, item2 -> wordItems.sortWith(Comparator { item1, item2 ->
-item1.pojo.time!!.compareTo(item2.pojo.time) -item1.pojo.time!!.compareTo(item2.pojo.time) })
})
wordItems.forEach{ item -> Log.d(TAG, item.pojo.print())}
} }
fun sort() { fun sort() {
......
...@@ -32,8 +32,8 @@ class EditWordFragment : WordFragment() { ...@@ -32,8 +32,8 @@ class EditWordFragment : WordFragment() {
} }
private fun setWordItemData() { private fun setWordItemData() {
word.setText(wordItem.pojo!!.word) word.setText(wordItem.pojo.word)
translation.setText(wordItem.pojo!!.translation) translation.setText(wordItem.pojo.translation)
} }
private fun setFocusOnWord() { private fun setFocusOnWord() {
......
...@@ -7,6 +7,7 @@ import android.util.Log ...@@ -7,6 +7,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.google.firebase.Timestamp
import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.DocumentSnapshot import com.google.firebase.firestore.DocumentSnapshot
import com.google.firebase.firestore.Query import com.google.firebase.firestore.Query
...@@ -14,6 +15,7 @@ import com.paktalin.vocabularynotebook.* ...@@ -14,6 +15,7 @@ import com.paktalin.vocabularynotebook.*
import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordItem
import kotlinx.android.synthetic.main.fragment_vocabulary.* import kotlinx.android.synthetic.main.fragment_vocabulary.*
import java.util.*
class VocabularyFragment : Fragment() { class VocabularyFragment : Fragment() {
companion object { companion object {
...@@ -64,9 +66,10 @@ class VocabularyFragment : Fragment() { ...@@ -64,9 +66,10 @@ class VocabularyFragment : Fragment() {
val wordItems: MutableList<WordItem> = mutableListOf() val wordItems: MutableList<WordItem> = mutableListOf()
for (ref in documents) { for (ref in documents) {
val word = ref.get("word").toString() val word = ref["word"].toString()
val translation = ref.get("translation").toString() val translation = ref["translation"].toString()
wordItems.add(WordItem(word, translation, ref.id, vocabularyId)) val time = ref["time"] as Timestamp
wordItems.add(WordItem(word, translation, time.toDate(), ref.id, vocabularyId))
} }
val adapter = VocabularyAdapter(wordItems, activity!!) val adapter = VocabularyAdapter(wordItems, activity!!)
......
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