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
Show 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 @@
</value>
</option>
</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"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
0c67e41d
...
...
@@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
private
fun
setUpVocabularyAdapter
()
{
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
// recyclerView.adapter = VocabularyAdapter(Vocabulary(), this@MainActivity)
// recyclerView.adapter = VocabularyAdapter(
Basic
Vocabulary(), this@MainActivity)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
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
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
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
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.utils.FirestoreManager
class
ModifiedVocabulary
:
Vocabulary
()
{
override
var
wordList
=
mutableListOf
<
WordItem
>()
class
ModifiedVocabulary
:
Vocabulary
{
var
wordList
=
mutableListOf
<
WordItem
>()
private
val
maxPermitted
=
9
override
fun
addWord
(
newWord
:
WordItem
)
{
...
...
@@ -22,7 +22,6 @@ class ModifiedVocabulary : Vocabulary() {
override
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
}
fun
add
(
wordItem
:
WordItem
,
modifiedLabel
:
ModifiedLabel
)
{
wordItem
.
modifiedLabel
=
modifiedLabel
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
import
com.google.firebase.firestore.QuerySnapshot
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
)
var
modifiedVocabulary
=
ModifiedVocabulary
()
private
val
vocabs
=
setOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
companion
object
{
fun
createFromSnapshot
(
querySnapshot
:
QuerySnapshot
):
VocabSet
{
...
...
@@ -29,19 +28,23 @@ class VocabSet(override var wordList: MutableList<WordItem>) : Vocabulary() {
}
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
)
{
vocabs
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
updateWord
(
updatedWord
)
}
}
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
)
{
vocabs
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addWord
(
newWord
)
}
}
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
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
open
class
Vocabulary
()
{
open
lateinit
var
wordList
:
MutableList
<
WordItem
>
interface
Vocabulary
{
constructor
(
wordList
:
MutableList
<
WordItem
>):
this
()
{
this
.
wordList
=
wordList
}
fun
addAll
(
words
:
MutableList
<
WordItem
>)
open
fun
addAll
(
words
:
MutableList
<
WordItem
>)
{
wordList
.
addAll
(
words
)
}
fun
deleteWord
(
wordItem
:
WordItem
)
open
fun
deleteWord
(
wordItem
:
WordItem
)
{
wordList
.
remove
(
wordItem
)
}
fun
addWord
(
newWord
:
WordItem
)
open
fun
addWord
(
newWord
:
WordItem
)
{
wordList
.
add
(
0
,
newWord
)
}
open
fun
updateWord
(
updatedWord
:
WordItem
)
{
wordList
[
wordList
.
indexOf
(
updatedWord
)]
=
updatedWord
}
fun
updateWord
(
updatedWord
:
WordItem
)
}
\ 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