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
0c67e41d
authored
Apr 20, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring. Generalized Vocabularies with Vocabulary interface
parent
977460e3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
31 deletions
.idea/misc.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.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
.idea/misc.xml
View file @
0c67e41d
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
</value>
</value>
</option>
</option>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
0c67e41d
...
@@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
private
fun
setUpVocabularyAdapter
()
{
private
fun
setUpVocabularyAdapter
()
{
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
FirestoreManager
().
extractVocabularyId
({
// recyclerView.adapter = VocabularyAdapter(Vocabulary(), this@MainActivity)
// recyclerView.adapter = VocabularyAdapter(
Basic
Vocabulary(), this@MainActivity)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
run
{
run
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/BasicVocabulary.kt
0 → 100644
View file @
0c67e41d
package
com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
open
class
BasicVocabulary
(
var
wordList
:
MutableList
<
WordItem
>):
Vocabulary
{
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
wordList
.
addAll
(
words
)
}
override
fun
deleteWord
(
wordItem
:
WordItem
)
{
wordList
.
remove
(
wordItem
)
}
override
fun
addWord
(
newWord
:
WordItem
)
{
wordList
.
add
(
0
,
newWord
)
}
override
fun
updateWord
(
updatedWord
:
WordItem
)
{
wordList
[
wordList
.
indexOf
(
updatedWord
)]
=
updatedWord
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/DisplayedVocabulary.kt
View file @
0c67e41d
...
@@ -2,7 +2,7 @@ package com.paktalin.vocabularynotebook.vocabulary
...
@@ -2,7 +2,7 @@ package com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
class
DisplayedVocabulary
(
override
var
wordList
:
MutableList
<
WordItem
>):
Vocabulary
(
wordList
)
{
class
DisplayedVocabulary
(
wordList
:
MutableList
<
WordItem
>):
Basic
Vocabulary
(
wordList
)
{
var
sort
:
Sort
=
Sort
.
BY_TIME
var
sort
:
Sort
=
Sort
.
BY_TIME
fun
clear
()
{
fun
clear
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/ModifiedVocabulary.kt
View file @
0c67e41d
...
@@ -4,8 +4,8 @@ import com.paktalin.vocabularynotebook.firestoreitems.ModifiedLabel
...
@@ -4,8 +4,8 @@ import com.paktalin.vocabularynotebook.firestoreitems.ModifiedLabel
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
class
ModifiedVocabulary
:
Vocabulary
()
{
class
ModifiedVocabulary
:
Vocabulary
{
override
var
wordList
=
mutableListOf
<
WordItem
>()
var
wordList
=
mutableListOf
<
WordItem
>()
private
val
maxPermitted
=
9
private
val
maxPermitted
=
9
override
fun
addWord
(
newWord
:
WordItem
)
{
override
fun
addWord
(
newWord
:
WordItem
)
{
...
@@ -22,7 +22,6 @@ class ModifiedVocabulary : Vocabulary() {
...
@@ -22,7 +22,6 @@ class ModifiedVocabulary : Vocabulary() {
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
}
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
}
fun
add
(
wordItem
:
WordItem
,
modifiedLabel
:
ModifiedLabel
)
{
fun
add
(
wordItem
:
WordItem
,
modifiedLabel
:
ModifiedLabel
)
{
wordItem
.
modifiedLabel
=
modifiedLabel
wordItem
.
modifiedLabel
=
modifiedLabel
wordList
.
add
(
wordItem
)
wordList
.
add
(
wordItem
)
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
View file @
0c67e41d
...
@@ -5,12 +5,11 @@ import com.google.firebase.firestore.QueryDocumentSnapshot
...
@@ -5,12 +5,11 @@ 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.WordItem
class
VocabSet
(
override
var
wordList
:
MutableList
<
WordItem
>)
:
Vocabulary
()
{
class
VocabSet
(
var
wordList
:
MutableList
<
WordItem
>)
:
Vocabulary
{
var
fullVocabulary
=
Vocabulary
(
wordList
)
var
fullVocabulary
=
Basic
Vocabulary
(
wordList
)
private
var
displayedVocabulary
=
DisplayedVocabulary
(
wordList
)
private
var
displayedVocabulary
=
DisplayedVocabulary
(
wordList
)
var
modifiedVocabulary
=
ModifiedVocabulary
()
var
modifiedVocabulary
=
ModifiedVocabulary
()
private
val
vocabs
=
setOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
companion
object
{
companion
object
{
fun
createFromSnapshot
(
querySnapshot
:
QuerySnapshot
):
VocabSet
{
fun
createFromSnapshot
(
querySnapshot
:
QuerySnapshot
):
VocabSet
{
...
@@ -29,19 +28,23 @@ class VocabSet(override var wordList: MutableList<WordItem>) : Vocabulary() {
...
@@ -29,19 +28,23 @@ class VocabSet(override var wordList: MutableList<WordItem>) : Vocabulary() {
}
}
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
vocabs
.
forEach
{
v
->
v
.
addAll
(
words
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addAll
(
words
)
}
}
}
override
fun
updateWord
(
updatedWord
:
WordItem
)
{
override
fun
updateWord
(
updatedWord
:
WordItem
)
{
vocabs
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
}
}
override
fun
deleteWord
(
wordItem
:
WordItem
)
{
override
fun
deleteWord
(
wordItem
:
WordItem
)
{
vocabs
.
forEach
{
v
->
v
.
deleteWord
(
wordItem
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
deleteWord
(
wordItem
)
}
}
}
override
fun
addWord
(
newWord
:
WordItem
)
{
override
fun
addWord
(
newWord
:
WordItem
)
{
vocabs
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
}
}
fun
sort
(
sort
:
Sort
)
{
fun
sort
(
sort
:
Sort
)
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/Vocabulary.kt
View file @
0c67e41d
...
@@ -2,26 +2,13 @@ package com.paktalin.vocabularynotebook.vocabulary
...
@@ -2,26 +2,13 @@ package com.paktalin.vocabularynotebook.vocabulary
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
open
class
Vocabulary
()
{
interface
Vocabulary
{
open
lateinit
var
wordList
:
MutableList
<
WordItem
>
constructor
(
wordList
:
MutableList
<
WordItem
>):
this
()
{
fun
addAll
(
words
:
MutableList
<
WordItem
>)
this
.
wordList
=
wordList
}
open
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
fun
deleteWord
(
wordItem
:
WordItem
)
wordList
.
addAll
(
words
)
}
open
fun
deleteWord
(
wordItem
:
WordItem
)
{
fun
addWord
(
newWord
:
WordItem
)
wordList
.
remove
(
wordItem
)
}
open
fun
addWord
(
newWord
:
WordItem
)
{
fun
updateWord
(
updatedWord
:
WordItem
)
wordList
.
add
(
0
,
newWord
)
}
open
fun
updateWord
(
updatedWord
:
WordItem
)
{
wordList
[
wordList
.
indexOf
(
updatedWord
)]
=
updatedWord
}
}
}
\ 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