Commit 4968f1b6 by Paktalin

Transformed WordItem to WordPojo, fixed duplicated modified words bug

parent a91bfbe1
package com.paktalin.vocabularynotebook.firestoreitems
import java.io.Serializable
import java.util.Date
class WordItem(word: String, translation: String, time: Date?, var id: String?) : Serializable {
var pojo: Pojo = Pojo(word, translation, time)
class Pojo(var word: String, var translation: String, var time:Date? = null) : Serializable {
init {
if (time == null) time = Date(System.currentTimeMillis())
}
}
constructor(pojo: Pojo, id: String?)
: this(pojo.word, pojo.translation, pojo.time, id)
constructor(pojo: Pojo) : this(pojo, null)
fun contains(string:String):Boolean {
return pojo.word.toLowerCase().contains(string) ||
pojo.translation.toLowerCase().contains(string)
}
companion object { private val TAG = "VN/" + WordItem::class.java.simpleName }
}
package com.paktalin.vocabularynotebook.firestoreitems
import java.io.Serializable
import java.util.Date
class WordPojo(var word: String, var translation: String, var time:Date? = null, var id: String? = null) : Serializable {
init {
if (time == null)
time = Date(System.currentTimeMillis())
}
}
...@@ -4,7 +4,7 @@ import android.support.v7.widget.RecyclerView ...@@ -4,7 +4,7 @@ import android.support.v7.widget.RecyclerView
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import kotlinx.android.synthetic.main.word_item.view.* import kotlinx.android.synthetic.main.word_item.view.*
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
...@@ -12,9 +12,9 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { ...@@ -12,9 +12,9 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val tvTranslation: TextView = itemView.translation private val tvTranslation: TextView = itemView.translation
val layout: LinearLayout = itemView.layout val layout: LinearLayout = itemView.layout
fun init(wordItem: WordItem, position: Int, showPopupMenu: (View, Int) -> Unit) { fun init(wordPojo: WordPojo, position: Int, showPopupMenu: (View, Int) -> Unit) {
tvWord.text = wordItem.pojo.word tvWord.text = wordPojo.word
tvTranslation.text = wordItem.pojo.translation tvTranslation.text = wordPojo.translation
itemView.setOnClickListener { showPopupMenu(itemView, position) } itemView.setOnClickListener { showPopupMenu(itemView, position) }
} }
} }
...@@ -8,7 +8,7 @@ import android.support.v7.widget.RecyclerView ...@@ -8,7 +8,7 @@ import android.support.v7.widget.RecyclerView
import android.view.* import android.view.*
import com.paktalin.vocabularynotebook.OnQueryTextListener import com.paktalin.vocabularynotebook.OnQueryTextListener
import com.paktalin.vocabularynotebook.R import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.ui.fragments.EditWordFragment import com.paktalin.vocabularynotebook.ui.fragments.EditWordFragment
import com.paktalin.vocabularynotebook.ui.activities.MainActivity import com.paktalin.vocabularynotebook.ui.activities.MainActivity
import com.paktalin.vocabularynotebook.utils.Log import com.paktalin.vocabularynotebook.utils.Log
...@@ -69,20 +69,20 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi ...@@ -69,20 +69,20 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}*/ }*/
} }
private fun deleteWord(wordItem: WordItem, position: Int) { private fun deleteWord(wordPojo: WordPojo, position: Int) {
vocabulary.deleteWord(wordItem) vocabulary.deleteWord(wordPojo)
recyclerView.removeViewAt(position) recyclerView.removeViewAt(position)
this.notifyItemRemoved(position) this.notifyItemRemoved(position)
this.notifyItemRangeChanged(position, vocabulary.displayedSize()) this.notifyItemRangeChanged(position, vocabulary.displayedSize())
} }
fun addWord(newWord: WordItem) { fun addWord(newWord: WordPojo) {
Log.d(TAG, "vocabularyAdapter addWord") Log.d(TAG, "vocabularyAdapter addWord")
vocabulary.addWord(newWord) vocabulary.addWord(newWord)
this.sort() this.sort()
} }
fun updateWord(updatedWord: WordItem) { fun updateWord(updatedWord: WordPojo) {
vocabulary.updateWord(updatedWord) vocabulary.updateWord(updatedWord)
this.sort() this.sort()
} }
...@@ -93,7 +93,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi ...@@ -93,7 +93,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
} }
@SuppressLint("ResourceType") @SuppressLint("ResourceType")
private fun startEditFragment(container: View, wordItem: WordItem) { private fun startEditFragment(container: View, wordPojo: WordPojo) {
//set container id //set container id
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
container.id = View.generateViewId() container.id = View.generateViewId()
...@@ -101,7 +101,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi ...@@ -101,7 +101,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
// start EditWordFragment // start EditWordFragment
val arguments = Bundle() val arguments = Bundle()
arguments.putSerializable("wordItem", wordItem) arguments.putSerializable("wordPojo", wordPojo)
addFragment(mainActivity.supportFragmentManager, EditWordFragment(), container.id, arguments, "edit_fragment") addFragment(mainActivity.supportFragmentManager, EditWordFragment(), container.id, arguments, "edit_fragment")
} }
...@@ -114,7 +114,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi ...@@ -114,7 +114,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
notifyDataSetChanged() notifyDataSetChanged()
} }
fun getModifiedWords(): MutableMap<WordItem, ModifiedVocabulary.Label> { fun getModifiedWords(): MutableMap<WordPojo, ModifiedVocabulary.Label> {
return vocabulary.getModified() return vocabulary.getModified()
} }
......
...@@ -3,7 +3,7 @@ package com.paktalin.vocabularynotebook.ui.fragments ...@@ -3,7 +3,7 @@ package com.paktalin.vocabularynotebook.ui.fragments
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.utils.* import com.paktalin.vocabularynotebook.utils.*
import kotlinx.android.synthetic.main.content_main.* import kotlinx.android.synthetic.main.content_main.*
import kotlinx.android.synthetic.main.fragment_editable_word.* import kotlinx.android.synthetic.main.fragment_editable_word.*
...@@ -39,7 +39,7 @@ class AddWordFragment : WordFragment() { ...@@ -39,7 +39,7 @@ class AddWordFragment : WordFragment() {
override fun save(word:String, translation:String) { override fun save(word:String, translation:String) {
// TODO addAll entry point // TODO addAll entry point
clearFields() clearFields()
mainActivity.vocabularyAdapter.addWord(WordItem(WordItem.Pojo(word, translation, null))) mainActivity.vocabularyAdapter.addWord(WordPojo(word, translation))
this.word.requestFocus() this.word.requestFocus()
} }
......
...@@ -6,9 +6,8 @@ import android.view.LayoutInflater ...@@ -6,9 +6,8 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.ui.activities.MainActivity import com.paktalin.vocabularynotebook.ui.activities.MainActivity
import com.paktalin.vocabularynotebook.utils.FirestoreManager
import com.paktalin.vocabularynotebook.utils.gone import com.paktalin.vocabularynotebook.utils.gone
import com.paktalin.vocabularynotebook.utils.removeFragment import com.paktalin.vocabularynotebook.utils.removeFragment
import com.paktalin.vocabularynotebook.utils.visible import com.paktalin.vocabularynotebook.utils.visible
...@@ -17,7 +16,7 @@ import kotlinx.android.synthetic.main.fragment_editable_word.* ...@@ -17,7 +16,7 @@ import kotlinx.android.synthetic.main.fragment_editable_word.*
import kotlinx.android.synthetic.main.word_item.view.* import kotlinx.android.synthetic.main.word_item.view.*
class EditWordFragment : WordFragment() { class EditWordFragment : WordFragment() {
private lateinit var wordItem: WordItem private lateinit var wordPojo: WordPojo
private var container: ViewGroup? = null private var container: ViewGroup? = null
override fun cancelEditing() { override fun cancelEditing() {
...@@ -29,7 +28,7 @@ class EditWordFragment : WordFragment() { ...@@ -29,7 +28,7 @@ class EditWordFragment : WordFragment() {
mainActivity = activity as MainActivity mainActivity = activity as MainActivity
this.container = container this.container = container
hidePreviousViews() hidePreviousViews()
wordItem = arguments!!["wordItem"] as WordItem wordPojo = arguments!!["wordPojo"] as WordPojo
//(mainActivity.recyclerView.layoutManager as LockableLayoutManager).isScrollEnabled = false //(mainActivity.recyclerView.layoutManager as LockableLayoutManager).isScrollEnabled = false
return super.onCreateView(inflater, container, savedInstanceState) return super.onCreateView(inflater, container, savedInstanceState)
} }
...@@ -42,8 +41,8 @@ class EditWordFragment : WordFragment() { ...@@ -42,8 +41,8 @@ class EditWordFragment : WordFragment() {
} }
private fun setWordItemData() { private fun setWordItemData() {
word.setText(wordItem.pojo.word) word.setText(wordPojo.word)
translation.setText(wordItem.pojo.translation) translation.setText(wordPojo.translation)
} }
private fun setFocusOnWord() { private fun setFocusOnWord() {
...@@ -65,9 +64,9 @@ class EditWordFragment : WordFragment() { ...@@ -65,9 +64,9 @@ class EditWordFragment : WordFragment() {
} }
override fun save(word: String, translation: String) { override fun save(word: String, translation: String) {
// TODO edit entry point wordPojo.word = word
wordItem.pojo = WordItem.Pojo(word, translation, wordItem.pojo.time) wordPojo.translation = translation
mainActivity.vocabularyAdapter.updateWord(wordItem) mainActivity.vocabularyAdapter.updateWord(wordPojo)
stop() stop()
} }
......
...@@ -7,7 +7,7 @@ import com.google.firebase.firestore.* ...@@ -7,7 +7,7 @@ import com.google.firebase.firestore.*
import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore import com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import com.paktalin.vocabularynotebook.firestoreitems.UserPojo import com.paktalin.vocabularynotebook.firestoreitems.UserPojo
import com.paktalin.vocabularynotebook.firestoreitems.VocabularyPojo import com.paktalin.vocabularynotebook.firestoreitems.VocabularyPojo
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.ui.activities.LogInActivity import com.paktalin.vocabularynotebook.ui.activities.LogInActivity
import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary
import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary.Label import com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary.Label
...@@ -48,7 +48,7 @@ class FirestoreManager { ...@@ -48,7 +48,7 @@ class FirestoreManager {
} }
} }
fun saveWords(wordMap: MutableMap<WordItem, ModifiedVocabulary.Label>) { fun saveWords(wordMap: MutableMap<WordPojo, ModifiedVocabulary.Label>) {
if (wordMap.isEmpty()) if (wordMap.isEmpty())
return return
val batch = db.batch() val batch = db.batch()
...@@ -58,10 +58,11 @@ class FirestoreManager { ...@@ -58,10 +58,11 @@ class FirestoreManager {
if (entry.value == Label.DELETED) if (entry.value == Label.DELETED)
batch.delete(wordsCollection.document(entry.key.id!!)) batch.delete(wordsCollection.document(entry.key.id!!))
else if (entry.value == Label.UPDATED && entry.key.id != null) else if (entry.value == Label.UPDATED && entry.key.id != null)
batch.set(wordsCollection.document(entry.key.id!!), entry.key.pojo) batch.set(wordsCollection.document(entry.key.id!!), entry.key)
else else
batch.set(wordsCollection.document(), entry.key.pojo) batch.set(wordsCollection.document(), entry.key)
}} }}
wordMap.clear()
batch.commit().addOnCompleteListener { Log.d(TAG, "words are successfully pushed to Firestore") } batch.commit().addOnCompleteListener { Log.d(TAG, "words are successfully pushed to Firestore") }
} }
......
package com.paktalin.vocabularynotebook.vocabulary package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
open class BasicVocabulary(var wordList: MutableList<WordItem>): Vocabulary { open class BasicVocabulary(var wordList: MutableList<WordPojo>): Vocabulary {
init { init {
wordList = wordList.toMutableList() wordList = wordList.toMutableList()
} }
override fun addAll(words: MutableList<WordItem>) { override fun addAll(words: MutableList<WordPojo>) {
wordList.addAll(words) wordList.addAll(words)
} }
override fun deleteWord(wordItem: WordItem) { override fun deleteWord(wordPojo: WordPojo) {
wordList.remove(wordItem) wordList.remove(wordPojo)
} }
override fun addWord(newWord: WordItem) { override fun addWord(newWord: WordPojo) {
wordList.add(0, newWord) wordList.add(0, newWord)
} }
override fun updateWord(updatedWord: WordItem) { override fun updateWord(updatedWord: WordPojo) {
wordList[wordList.indexOf(updatedWord)] = updatedWord wordList[wordList.indexOf(updatedWord)] = updatedWord
} }
} }
\ No newline at end of file
package com.paktalin.vocabularynotebook.vocabulary package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(wordList) { class DisplayedVocabulary(wordList: MutableList<WordPojo>): BasicVocabulary(wordList) {
var sort: Sort = Sort.BY_TIME var sort: Sort = Sort.BY_TIME
fun clear() { fun clear() {
...@@ -13,12 +13,12 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word ...@@ -13,12 +13,12 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word
return wordList.size return wordList.size
} }
fun at(index: Int): WordItem { fun at(index: Int): WordPojo {
return wordList[index] return wordList[index]
} }
fun byQuery(query: String, allWords: MutableList<WordItem>) { fun byQuery(query: String, allWords: MutableList<WordPojo>) {
allWords.filter { wordItem -> wordItem.contains(query) }.toCollection(wordList) allWords.filter { wordItem -> contains(wordItem, query) }.toCollection(wordList)
} }
fun sort(sort: Sort) { fun sort(sort: Sort) {
...@@ -26,19 +26,25 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word ...@@ -26,19 +26,25 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word
when (sort) { when (sort) {
Sort.BY_TIME -> { Sort.BY_TIME -> {
wordList.sortWith(Comparator { item1, item2 -> wordList.sortWith(Comparator { item1, item2 ->
-item1.pojo.time!!.compareTo(item2.pojo.time) -item1.time!!.compareTo(item2.time)
}) })
} }
Sort.BY_WORD -> { Sort.BY_WORD -> {
wordList.sortWith(Comparator { item1, item2 -> wordList.sortWith(Comparator { item1, item2 ->
item1.pojo.word.toLowerCase().compareTo(item2.pojo.word.toLowerCase()) item1.word.toLowerCase().compareTo(item2.word.toLowerCase())
}) })
} }
Sort.BY_TRANSLATION -> { Sort.BY_TRANSLATION -> {
wordList.sortWith(Comparator { item1, item2 -> wordList.sortWith(Comparator { item1, item2 ->
item1.pojo.translation.toLowerCase().compareTo(item2.pojo.translation.toLowerCase()) item1.translation.toLowerCase().compareTo(item2.translation.toLowerCase())
}) })
} }
} }
} }
// TODO convert to a lambda expression
fun contains(wordPojo: WordPojo, string:String):Boolean {
return wordPojo.word.toLowerCase().contains(string) ||
wordPojo.translation.toLowerCase().contains(string)
}
} }
package com.paktalin.vocabularynotebook.vocabulary package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import com.paktalin.vocabularynotebook.utils.FirestoreManager import com.paktalin.vocabularynotebook.utils.FirestoreManager
class ModifiedVocabulary : Vocabulary { class ModifiedVocabulary : Vocabulary {
var wordMap = mutableMapOf<WordItem, Label>() var wordMap = mutableMapOf<WordPojo, Label>()
private val maxPermitted = 9 private val maxPermitted = 9
override fun addWord(newWord: WordItem) { override fun addWord(newWord: WordPojo) {
add(newWord, Label.ADDED) add(newWord, Label.ADDED)
} }
override fun updateWord(updatedWord: WordItem) { override fun updateWord(updatedWord: WordPojo) {
add(updatedWord, Label.UPDATED) add(updatedWord, Label.UPDATED)
} }
override fun deleteWord(wordItem: WordItem) { override fun deleteWord(wordPojo: WordPojo) {
add(wordItem, Label.DELETED) add(wordPojo, Label.DELETED)
} }
override fun addAll(words: MutableList<WordItem>) { } override fun addAll(words: MutableList<WordPojo>) { }
fun add(wordItem: WordItem, label: Label) { fun add(wordPojo: WordPojo, label: Label) {
wordMap[wordItem] = label wordMap[wordPojo] = label
if (wordMap.size == maxPermitted) { if (wordMap.size == maxPermitted)
FirestoreManager().saveWords(wordMap) FirestoreManager().saveWords(wordMap)
wordMap.clear()
}
} }
fun get(): MutableMap<WordItem, Label> { fun get(): MutableMap<WordPojo, Label> {
return wordMap return wordMap
} }
......
...@@ -3,9 +3,9 @@ package com.paktalin.vocabularynotebook.vocabulary ...@@ -3,9 +3,9 @@ package com.paktalin.vocabularynotebook.vocabulary
import com.google.firebase.Timestamp import com.google.firebase.Timestamp
import com.google.firebase.firestore.QueryDocumentSnapshot import com.google.firebase.firestore.QueryDocumentSnapshot
import com.google.firebase.firestore.QuerySnapshot import com.google.firebase.firestore.QuerySnapshot
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary { class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
var fullVocabulary = BasicVocabulary(wordList) var fullVocabulary = BasicVocabulary(wordList)
private var displayedVocabulary = DisplayedVocabulary(wordList) private var displayedVocabulary = DisplayedVocabulary(wordList)
...@@ -13,13 +13,13 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary { ...@@ -13,13 +13,13 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
companion object { companion object {
fun createFromSnapshot(querySnapshot: QuerySnapshot): VocabSet { fun createFromSnapshot(querySnapshot: QuerySnapshot): VocabSet {
val wordList = mutableListOf<WordItem>() val wordList = mutableListOf<WordPojo>()
querySnapshot.forEach { s -> wordList.add(toWordItem(s)) } querySnapshot.forEach { s -> wordList.add(toWordItem(s)) }
return VocabSet(wordList) return VocabSet(wordList)
} }
private fun toWordItem(snapshot: QueryDocumentSnapshot): WordItem { private fun toWordItem(snapshot: QueryDocumentSnapshot): WordPojo {
return WordItem( return WordPojo(
snapshot["word"].toString(), snapshot["word"].toString(),
snapshot["translation"].toString(), snapshot["translation"].toString(),
(snapshot["time"] as Timestamp).toDate(), (snapshot["time"] as Timestamp).toDate(),
...@@ -27,22 +27,22 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary { ...@@ -27,22 +27,22 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
} }
} }
override fun addAll(words: MutableList<WordItem>) { override fun addAll(words: MutableList<WordPojo>) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary) listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.addAll(words) } .forEach { v -> v.addAll(words) }
} }
override fun updateWord(updatedWord: WordItem) { override fun updateWord(updatedWord: WordPojo) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary) listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.updateWord(updatedWord) } .forEach { v -> v.updateWord(updatedWord) }
} }
override fun deleteWord(wordItem: WordItem) { override fun deleteWord(wordPojo: WordPojo) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary) listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.deleteWord(wordItem) } .forEach { v -> v.deleteWord(wordPojo) }
} }
override fun addWord(newWord: WordItem) { override fun addWord(newWord: WordPojo) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary) listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.addWord(newWord) } .forEach { v -> v.addWord(newWord) }
} }
...@@ -59,7 +59,7 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary { ...@@ -59,7 +59,7 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
displayedVocabulary.byQuery(query, wordList) displayedVocabulary.byQuery(query, wordList)
} }
fun displayedAt(position: Int): WordItem { fun displayedAt(position: Int): WordPojo {
return displayedVocabulary.at(position) return displayedVocabulary.at(position)
} }
...@@ -67,5 +67,5 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary { ...@@ -67,5 +67,5 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
fun clearDisplayed() { displayedVocabulary.clear() } fun clearDisplayed() { displayedVocabulary.clear() }
fun getModified(): MutableMap<WordItem, ModifiedVocabulary.Label> { return modifiedVocabulary.get() } fun getModified(): MutableMap<WordPojo, ModifiedVocabulary.Label> { return modifiedVocabulary.get() }
} }
\ No newline at end of file
package com.paktalin.vocabularynotebook.vocabulary package com.paktalin.vocabularynotebook.vocabulary
import com.paktalin.vocabularynotebook.firestoreitems.WordItem import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
interface Vocabulary { interface Vocabulary {
fun addAll(words: MutableList<WordItem>) fun addAll(words: MutableList<WordPojo>)
fun deleteWord(wordItem: WordItem) fun deleteWord(wordPojo: WordPojo)
fun addWord(newWord: WordItem) fun addWord(newWord: WordPojo)
fun updateWord(updatedWord: WordItem) fun updateWord(updatedWord: WordPojo)
} }
\ 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