Commit 0608c4c0 by Paktalin

Fixed bug with overwriting time

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