Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
likorn
/
vocabulary_notebook
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4968f1b6
authored
Apr 20, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transformed WordItem to WordPojo, fixed duplicated modified words bug
parent
a91bfbe1
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
91 additions
and
98 deletions
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordItem.kt
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordPojo.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/ViewHolder.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/utils/FirestoreManager.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/BasicVocabulary.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/DisplayedVocabulary.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/ModifiedVocabulary.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/Vocabulary.kt
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordItem.kt
deleted
100644 → 0
View file @
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
}
}
app/src/main/java/com/paktalin/vocabularynotebook/firestoreitems/WordPojo.kt
0 → 100644
View file @
4968f1b6
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
())
}
}
app/src/main/java/com/paktalin/vocabularynotebook/ui/ViewHolder.kt
View file @
4968f1b6
...
...
@@ -4,7 +4,7 @@ import android.support.v7.widget.RecyclerView
import
android.view.View
import
android.widget.LinearLayout
import
android.widget.TextView
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
kotlinx.android.synthetic.main.word_item.view.*
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
...
...
@@ -12,9 +12,9 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private
val
tvTranslation
:
TextView
=
itemView
.
translation
val
layout
:
LinearLayout
=
itemView
.
layout
fun
init
(
word
Item
:
WordItem
,
position
:
Int
,
showPopupMenu
:
(
View
,
Int
)
->
Unit
)
{
tvWord
.
text
=
word
Item
.
p
ojo
.
word
tvTranslation
.
text
=
word
Item
.
p
ojo
.
translation
fun
init
(
word
Pojo
:
WordPojo
,
position
:
Int
,
showPopupMenu
:
(
View
,
Int
)
->
Unit
)
{
tvWord
.
text
=
word
P
ojo
.
word
tvTranslation
.
text
=
word
P
ojo
.
translation
itemView
.
setOnClickListener
{
showPopupMenu
(
itemView
,
position
)
}
}
}
app/src/main/java/com/paktalin/vocabularynotebook/ui/VocabularyAdapter.kt
View file @
4968f1b6
...
...
@@ -8,7 +8,7 @@ import android.support.v7.widget.RecyclerView
import
android.view.*
import
com.paktalin.vocabularynotebook.OnQueryTextListener
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
com.paktalin.vocabularynotebook.ui.fragments.EditWordFragment
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.Log
...
...
@@ -69,20 +69,20 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}*/
}
private
fun
deleteWord
(
word
Item
:
WordItem
,
position
:
Int
)
{
vocabulary
.
deleteWord
(
word
Item
)
private
fun
deleteWord
(
word
Pojo
:
WordPojo
,
position
:
Int
)
{
vocabulary
.
deleteWord
(
word
Pojo
)
recyclerView
.
removeViewAt
(
position
)
this
.
notifyItemRemoved
(
position
)
this
.
notifyItemRangeChanged
(
position
,
vocabulary
.
displayedSize
())
}
fun
addWord
(
newWord
:
Word
Item
)
{
fun
addWord
(
newWord
:
Word
Pojo
)
{
Log
.
d
(
TAG
,
"vocabularyAdapter addWord"
)
vocabulary
.
addWord
(
newWord
)
this
.
sort
()
}
fun
updateWord
(
updatedWord
:
Word
Item
)
{
fun
updateWord
(
updatedWord
:
Word
Pojo
)
{
vocabulary
.
updateWord
(
updatedWord
)
this
.
sort
()
}
...
...
@@ -93,7 +93,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}
@SuppressLint
(
"ResourceType"
)
private
fun
startEditFragment
(
container
:
View
,
word
Item
:
WordItem
)
{
private
fun
startEditFragment
(
container
:
View
,
word
Pojo
:
WordPojo
)
{
//set container id
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
container
.
id
=
View
.
generateViewId
()
...
...
@@ -101,7 +101,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
// start EditWordFragment
val
arguments
=
Bundle
()
arguments
.
putSerializable
(
"word
Item"
,
wordItem
)
arguments
.
putSerializable
(
"word
Pojo"
,
wordPojo
)
addFragment
(
mainActivity
.
supportFragmentManager
,
EditWordFragment
(),
container
.
id
,
arguments
,
"edit_fragment"
)
}
...
...
@@ -114,7 +114,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
notifyDataSetChanged
()
}
fun
getModifiedWords
():
MutableMap
<
Word
Item
,
ModifiedVocabulary
.
Label
>
{
fun
getModifiedWords
():
MutableMap
<
Word
Pojo
,
ModifiedVocabulary
.
Label
>
{
return
vocabulary
.
getModified
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
View file @
4968f1b6
...
...
@@ -3,7 +3,7 @@ package com.paktalin.vocabularynotebook.ui.fragments
import
android.os.Bundle
import
android.text.Editable
import
android.text.TextWatcher
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
com.paktalin.vocabularynotebook.utils.*
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.fragment_editable_word.*
...
...
@@ -39,7 +39,7 @@ class AddWordFragment : WordFragment() {
override
fun
save
(
word
:
String
,
translation
:
String
)
{
// TODO addAll entry point
clearFields
()
mainActivity
.
vocabularyAdapter
.
addWord
(
Word
Item
(
WordItem
.
Pojo
(
word
,
translation
,
null
)
))
mainActivity
.
vocabularyAdapter
.
addWord
(
Word
Pojo
(
word
,
translation
))
this
.
word
.
requestFocus
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
4968f1b6
...
...
@@ -6,9 +6,8 @@ import android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.view.inputmethod.InputMethodManager
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.removeFragment
import
com.paktalin.vocabularynotebook.utils.visible
...
...
@@ -17,7 +16,7 @@ import kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.word_item.view.*
class
EditWordFragment
:
WordFragment
()
{
private
lateinit
var
word
Item
:
WordItem
private
lateinit
var
word
Pojo
:
WordPojo
private
var
container
:
ViewGroup
?
=
null
override
fun
cancelEditing
()
{
...
...
@@ -29,7 +28,7 @@ class EditWordFragment : WordFragment() {
mainActivity
=
activity
as
MainActivity
this
.
container
=
container
hidePreviousViews
()
word
Item
=
arguments
!!
[
"wordItem"
]
as
WordItem
word
Pojo
=
arguments
!!
[
"wordPojo"
]
as
WordPojo
//(mainActivity.recyclerView.layoutManager as LockableLayoutManager).isScrollEnabled = false
return
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
)
}
...
...
@@ -42,8 +41,8 @@ class EditWordFragment : WordFragment() {
}
private
fun
setWordItemData
()
{
word
.
setText
(
word
Item
.
p
ojo
.
word
)
translation
.
setText
(
word
Item
.
p
ojo
.
translation
)
word
.
setText
(
word
P
ojo
.
word
)
translation
.
setText
(
word
P
ojo
.
translation
)
}
private
fun
setFocusOnWord
()
{
...
...
@@ -65,9 +64,9 @@ class EditWordFragment : WordFragment() {
}
override
fun
save
(
word
:
String
,
translation
:
String
)
{
// TODO edit entry point
word
Item
.
pojo
=
WordItem
.
Pojo
(
word
,
translation
,
wordItem
.
pojo
.
time
)
mainActivity
.
vocabularyAdapter
.
updateWord
(
word
Item
)
wordPojo
.
word
=
word
word
Pojo
.
translation
=
translation
mainActivity
.
vocabularyAdapter
.
updateWord
(
word
Pojo
)
stop
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/utils/FirestoreManager.kt
View file @
4968f1b6
...
...
@@ -7,7 +7,7 @@ import com.google.firebase.firestore.*
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.UserPojo
import
com.paktalin.vocabularynotebook.firestoreitems.VocabularyPojo
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
com.paktalin.vocabularynotebook.ui.activities.LogInActivity
import
com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary
import
com.paktalin.vocabularynotebook.vocabulary.ModifiedVocabulary.Label
...
...
@@ -48,7 +48,7 @@ class FirestoreManager {
}
}
fun
saveWords
(
wordMap
:
MutableMap
<
Word
Item
,
ModifiedVocabulary
.
Label
>)
{
fun
saveWords
(
wordMap
:
MutableMap
<
Word
Pojo
,
ModifiedVocabulary
.
Label
>)
{
if
(
wordMap
.
isEmpty
())
return
val
batch
=
db
.
batch
()
...
...
@@ -58,10 +58,11 @@ class FirestoreManager {
if
(
entry
.
value
==
Label
.
DELETED
)
batch
.
delete
(
wordsCollection
.
document
(
entry
.
key
.
id
!!
))
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
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"
)
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/BasicVocabulary.kt
View file @
4968f1b6
package
com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
open
class
BasicVocabulary
(
var
wordList
:
MutableList
<
Word
Item
>):
Vocabulary
{
open
class
BasicVocabulary
(
var
wordList
:
MutableList
<
Word
Pojo
>):
Vocabulary
{
init
{
wordList
=
wordList
.
toMutableList
()
}
override
fun
addAll
(
words
:
MutableList
<
Word
Item
>)
{
override
fun
addAll
(
words
:
MutableList
<
Word
Pojo
>)
{
wordList
.
addAll
(
words
)
}
override
fun
deleteWord
(
word
Item
:
WordItem
)
{
wordList
.
remove
(
word
Item
)
override
fun
deleteWord
(
word
Pojo
:
WordPojo
)
{
wordList
.
remove
(
word
Pojo
)
}
override
fun
addWord
(
newWord
:
Word
Item
)
{
override
fun
addWord
(
newWord
:
Word
Pojo
)
{
wordList
.
add
(
0
,
newWord
)
}
override
fun
updateWord
(
updatedWord
:
Word
Item
)
{
override
fun
updateWord
(
updatedWord
:
Word
Pojo
)
{
wordList
[
wordList
.
indexOf
(
updatedWord
)]
=
updatedWord
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/DisplayedVocabulary.kt
View file @
4968f1b6
package
com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
class
DisplayedVocabulary
(
wordList
:
MutableList
<
Word
Item
>):
BasicVocabulary
(
wordList
)
{
class
DisplayedVocabulary
(
wordList
:
MutableList
<
Word
Pojo
>):
BasicVocabulary
(
wordList
)
{
var
sort
:
Sort
=
Sort
.
BY_TIME
fun
clear
()
{
...
...
@@ -13,12 +13,12 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word
return
wordList
.
size
}
fun
at
(
index
:
Int
):
Word
Item
{
fun
at
(
index
:
Int
):
Word
Pojo
{
return
wordList
[
index
]
}
fun
byQuery
(
query
:
String
,
allWords
:
MutableList
<
Word
Item
>)
{
allWords
.
filter
{
wordItem
->
wordItem
.
contains
(
query
)
}.
toCollection
(
wordList
)
fun
byQuery
(
query
:
String
,
allWords
:
MutableList
<
Word
Pojo
>)
{
allWords
.
filter
{
wordItem
->
contains
(
wordItem
,
query
)
}.
toCollection
(
wordList
)
}
fun
sort
(
sort
:
Sort
)
{
...
...
@@ -26,19 +26,25 @@ class DisplayedVocabulary(wordList: MutableList<WordItem>): BasicVocabulary(word
when
(
sort
)
{
Sort
.
BY_TIME
->
{
wordList
.
sortWith
(
Comparator
{
item1
,
item2
->
-
item1
.
pojo
.
time
!!
.
compareTo
(
item2
.
pojo
.
time
)
-
item1
.
time
!!
.
compareTo
(
item2
.
time
)
})
}
Sort
.
BY_WORD
->
{
wordList
.
sortWith
(
Comparator
{
item1
,
item2
->
item1
.
pojo
.
word
.
toLowerCase
().
compareTo
(
item2
.
pojo
.
word
.
toLowerCase
())
item1
.
word
.
toLowerCase
().
compareTo
(
item2
.
word
.
toLowerCase
())
})
}
Sort
.
BY_TRANSLATION
->
{
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
)
}
}
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/ModifiedVocabulary.kt
View file @
4968f1b6
package
com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
class
ModifiedVocabulary
:
Vocabulary
{
var
wordMap
=
mutableMapOf
<
Word
Item
,
Label
>()
var
wordMap
=
mutableMapOf
<
Word
Pojo
,
Label
>()
private
val
maxPermitted
=
9
override
fun
addWord
(
newWord
:
Word
Item
)
{
override
fun
addWord
(
newWord
:
Word
Pojo
)
{
add
(
newWord
,
Label
.
ADDED
)
}
override
fun
updateWord
(
updatedWord
:
Word
Item
)
{
override
fun
updateWord
(
updatedWord
:
Word
Pojo
)
{
add
(
updatedWord
,
Label
.
UPDATED
)
}
override
fun
deleteWord
(
word
Item
:
WordItem
)
{
add
(
word
Item
,
Label
.
DELETED
)
override
fun
deleteWord
(
word
Pojo
:
WordPojo
)
{
add
(
word
Pojo
,
Label
.
DELETED
)
}
override
fun
addAll
(
words
:
MutableList
<
Word
Item
>)
{
}
override
fun
addAll
(
words
:
MutableList
<
Word
Pojo
>)
{
}
fun
add
(
word
Item
:
WordItem
,
label
:
Label
)
{
wordMap
[
word
Item
]
=
label
if
(
wordMap
.
size
==
maxPermitted
)
{
fun
add
(
word
Pojo
:
WordPojo
,
label
:
Label
)
{
wordMap
[
word
Pojo
]
=
label
if
(
wordMap
.
size
==
maxPermitted
)
FirestoreManager
().
saveWords
(
wordMap
)
wordMap
.
clear
()
}
}
fun
get
():
MutableMap
<
Word
Item
,
Label
>
{
fun
get
():
MutableMap
<
Word
Pojo
,
Label
>
{
return
wordMap
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
View file @
4968f1b6
...
...
@@ -3,9 +3,9 @@ package com.paktalin.vocabularynotebook.vocabulary
import
com.google.firebase.Timestamp
import
com.google.firebase.firestore.QueryDocumentSnapshot
import
com.google.firebase.firestore.QuerySnapshot
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
class
VocabSet
(
var
wordList
:
MutableList
<
Word
Item
>)
:
Vocabulary
{
class
VocabSet
(
var
wordList
:
MutableList
<
Word
Pojo
>)
:
Vocabulary
{
var
fullVocabulary
=
BasicVocabulary
(
wordList
)
private
var
displayedVocabulary
=
DisplayedVocabulary
(
wordList
)
...
...
@@ -13,13 +13,13 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
companion
object
{
fun
createFromSnapshot
(
querySnapshot
:
QuerySnapshot
):
VocabSet
{
val
wordList
=
mutableListOf
<
Word
Item
>()
val
wordList
=
mutableListOf
<
Word
Pojo
>()
querySnapshot
.
forEach
{
s
->
wordList
.
add
(
toWordItem
(
s
))
}
return
VocabSet
(
wordList
)
}
private
fun
toWordItem
(
snapshot
:
QueryDocumentSnapshot
):
Word
Item
{
return
Word
Item
(
private
fun
toWordItem
(
snapshot
:
QueryDocumentSnapshot
):
Word
Pojo
{
return
Word
Pojo
(
snapshot
[
"word"
].
toString
(),
snapshot
[
"translation"
].
toString
(),
(
snapshot
[
"time"
]
as
Timestamp
).
toDate
(),
...
...
@@ -27,22 +27,22 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
}
}
override
fun
addAll
(
words
:
MutableList
<
Word
Item
>)
{
override
fun
addAll
(
words
:
MutableList
<
Word
Pojo
>)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addAll
(
words
)
}
}
override
fun
updateWord
(
updatedWord
:
Word
Item
)
{
override
fun
updateWord
(
updatedWord
:
Word
Pojo
)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
}
override
fun
deleteWord
(
word
Item
:
WordItem
)
{
override
fun
deleteWord
(
word
Pojo
:
WordPojo
)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
deleteWord
(
word
Item
)
}
.
forEach
{
v
->
v
.
deleteWord
(
word
Pojo
)
}
}
override
fun
addWord
(
newWord
:
Word
Item
)
{
override
fun
addWord
(
newWord
:
Word
Pojo
)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
}
...
...
@@ -59,7 +59,7 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
displayedVocabulary
.
byQuery
(
query
,
wordList
)
}
fun
displayedAt
(
position
:
Int
):
Word
Item
{
fun
displayedAt
(
position
:
Int
):
Word
Pojo
{
return
displayedVocabulary
.
at
(
position
)
}
...
...
@@ -67,5 +67,5 @@ class VocabSet(var wordList: MutableList<WordItem>) : Vocabulary {
fun
clearDisplayed
()
{
displayedVocabulary
.
clear
()
}
fun
getModified
():
MutableMap
<
Word
Item
,
ModifiedVocabulary
.
Label
>
{
return
modifiedVocabulary
.
get
()
}
fun
getModified
():
MutableMap
<
Word
Pojo
,
ModifiedVocabulary
.
Label
>
{
return
modifiedVocabulary
.
get
()
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/Vocabulary.kt
View file @
4968f1b6
package
com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Item
import
com.paktalin.vocabularynotebook.firestoreitems.Word
Pojo
interface
Vocabulary
{
fun
addAll
(
words
:
MutableList
<
Word
Item
>)
fun
addAll
(
words
:
MutableList
<
Word
Pojo
>)
fun
deleteWord
(
word
Item
:
WordItem
)
fun
deleteWord
(
word
Pojo
:
WordPojo
)
fun
addWord
(
newWord
:
Word
Item
)
fun
addWord
(
newWord
:
Word
Pojo
)
fun
updateWord
(
updatedWord
:
Word
Item
)
fun
updateWord
(
updatedWord
:
Word
Pojo
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment