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