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
cab16d05
authored
Apr 29, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring: removed sort() function from VocabularyAdapter
parent
38404f70
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
cab16d05
...
@@ -10,7 +10,6 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
...
@@ -10,7 +10,6 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.fragments.SubmitEditedFragment
import
com.paktalin.vocabularynotebook.ui.fragments.SubmitEditedFragment
import
com.paktalin.vocabularynotebook.ui.recycler_view.selection_tracker.MySelectionTracker
import
com.paktalin.vocabularynotebook.ui.recycler_view.selection_tracker.MySelectionTracker
import
com.paktalin.vocabularynotebook.utils.Log
import
com.paktalin.vocabularynotebook.utils.addSubmitFragment
import
com.paktalin.vocabularynotebook.utils.addSubmitFragment
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.gone
import
com.paktalin.vocabularynotebook.utils.visible
import
com.paktalin.vocabularynotebook.utils.visible
...
@@ -37,7 +36,8 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -37,7 +36,8 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
var
sort
:
Sort
=
Sort
.
BY_TIME
var
sort
:
Sort
=
Sort
.
BY_TIME
set
(
value
)
{
set
(
value
)
{
field
=
value
field
=
value
sort
()
vocabulary
.
sort
(
sort
)
notifyDataSetChanged
()
}
}
init
{
init
{
...
@@ -73,14 +73,13 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -73,14 +73,13 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
fun
refresh
()
{}
fun
refresh
()
{}
fun
addWord
(
newWord
:
WordPojo
)
{
fun
addWord
(
newWord
:
WordPojo
)
{
Log
.
d
(
TAG
,
"vocabularyAdapter addWord"
)
vocabulary
.
addWord
(
newWord
)
vocabulary
.
addWord
(
newWord
)
this
.
sort
()
notifyDataSetChanged
()
}
}
fun
updateWord
(
wordPojo
:
WordPojo
)
{
fun
updateWord
(
wordPojo
:
WordPojo
)
{
vocabulary
.
updateWord
(
wordPojo
)
vocabulary
.
updateWord
(
wordPojo
)
this
.
sort
()
notifyDataSetChanged
()
}
}
fun
filter
(
query
:
String
)
{
fun
filter
(
query
:
String
)
{
...
@@ -120,11 +119,6 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -120,11 +119,6 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
this
.
notifyItemRangeChanged
(
position
,
vocabulary
.
displayedSize
())
this
.
notifyItemRangeChanged
(
position
,
vocabulary
.
displayedSize
())
}
}
private
fun
sort
()
{
vocabulary
.
sort
(
sort
)
this
.
notifyDataSetChanged
()
}
private
fun
editWord
(
container
:
View
,
wordPosition
:
Int
)
{
private
fun
editWord
(
container
:
View
,
wordPosition
:
Int
)
{
addSubmitFragment
(
mainActivity
.
supportFragmentManager
,
addSubmitFragment
(
mainActivity
.
supportFragmentManager
,
SubmitEditedFragment
().
apply
{
SubmitEditedFragment
().
apply
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
View file @
cab16d05
...
@@ -49,6 +49,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
...
@@ -49,6 +49,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
override
fun
updateWord
(
updatedWord
:
WordPojo
)
{
override
fun
updateWord
(
updatedWord
:
WordPojo
)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
// TODO change this
sort
(
displayedVocabulary
.
sort
)
}
}
override
fun
deleteWord
(
wordPojo
:
WordPojo
)
{
override
fun
deleteWord
(
wordPojo
:
WordPojo
)
{
...
@@ -59,6 +61,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
...
@@ -59,6 +61,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
override
fun
addWord
(
newWord
:
WordPojo
)
{
override
fun
addWord
(
newWord
:
WordPojo
)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
// TODO change this
sort
(
displayedVocabulary
.
sort
)
}
}
fun
sort
(
sort
:
Sort
)
{
fun
sort
(
sort
:
Sort
)
{
...
...
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