Commit 0608c4c0 by Paktalin

Fixed bug with overwriting time

parent c4329ccd
...@@ -7,8 +7,8 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordItem ...@@ -7,8 +7,8 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordItem
class AddWordFragment : WordFragment() { class AddWordFragment : WordFragment() {
override fun saveToFirestore(wordPojo: WordItem.Pojo, vocabularyId: String) { override fun saveToFirestore(word:String, translation:String, vocabularyId: String) {
mainActivity.showProgressBar() val wordPojo = WordItem.Pojo(word, translation, null)
ConfiguredFirestore.instance ConfiguredFirestore.instance
.collection(VOCABULARIES).document(vocabularyId) .collection(VOCABULARIES).document(vocabularyId)
.collection(WORDS).add(wordPojo) .collection(WORDS).add(wordPojo)
......
...@@ -49,8 +49,8 @@ class EditWordFragment : WordFragment() { ...@@ -49,8 +49,8 @@ class EditWordFragment : WordFragment() {
} }
} }
override fun saveToFirestore(wordPojo: WordItem.Pojo, vocabularyId: String) { override fun saveToFirestore(word:String, translation:String, vocabularyId: String) {
mainActivity.showProgressBar() val wordPojo = WordItem.Pojo(word, translation, wordItem.pojo.time)
ConfiguredFirestore.instance ConfiguredFirestore.instance
.collection(VOCABULARIES).document(vocabularyId) .collection(VOCABULARIES).document(vocabularyId)
.collection(WORDS).document(wordItem.id).set(wordPojo) .collection(WORDS).document(wordItem.id).set(wordPojo)
......
...@@ -76,11 +76,11 @@ class VocabularyFragment : Fragment() { ...@@ -76,11 +76,11 @@ class VocabularyFragment : Fragment() {
recyclerView.adapter = adapter recyclerView.adapter = adapter
} }
fun addWordItem(newWordItem: WordItem) { fun addWordItem(newWord: WordItem) {
(recyclerView.adapter as VocabularyAdapter).addWord(newWordItem) (recyclerView.adapter as VocabularyAdapter).addWord(newWord)
} }
fun updateWordItem(updatedWordItem: WordItem) { fun updateWordItem(updatedWord: WordItem) {
(recyclerView.adapter as VocabularyAdapter).updateWord(updatedWordItem) (recyclerView.adapter as VocabularyAdapter).updateWord(updatedWord)
} }
} }
\ No newline at end of file
...@@ -78,9 +78,8 @@ abstract class WordFragment : Fragment() { ...@@ -78,9 +78,8 @@ abstract class WordFragment : Fragment() {
val word = word.text.toString() val word = word.text.toString()
val translation = translation.text.toString() val translation = translation.text.toString()
val vocabularyId = mainActivity.vocabularyId val vocabularyId = mainActivity.vocabularyId
val wordPojo = WordItem.Pojo(word, translation, null) mainActivity.showProgressBar()
saveToFirestore(word, translation, vocabularyId)
saveToFirestore(wordPojo, vocabularyId)
return return
} }
...@@ -89,6 +88,6 @@ abstract class WordFragment : Fragment() { ...@@ -89,6 +88,6 @@ abstract class WordFragment : Fragment() {
translation.text.clear() translation.text.clear()
} }
protected abstract fun saveToFirestore(wordPojo: WordItem.Pojo, vocabularyId:String) protected abstract fun saveToFirestore(word:String, translation:String, vocabularyId:String)
protected abstract fun updateRecycleView(wordItem: WordItem) protected abstract fun updateRecycleView(wordItem: WordItem)
} }
\ 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