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
080d3fb8
authored
Apr 19, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring
parent
632ea2a0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
28 deletions
app/src/main/java/com/paktalin/vocabularynotebook/Vocabulary.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/Vocabulary.kt
View file @
080d3fb8
...
...
@@ -7,6 +7,7 @@ import com.paktalin.vocabularynotebook.utils.FirestoreManager.Companion.vocabula
class
Vocabulary
()
{
private
var
words
:
MutableList
<
WordItem
>
=
mutableListOf
()
private
var
displayed
:
MutableList
<
WordItem
>
=
mutableListOf
()
constructor
(
vocabulary
:
Vocabulary
)
:
this
()
{
copyWordsFrom
(
vocabulary
)
...
...
@@ -22,14 +23,6 @@ class Vocabulary() {
}
}
companion
object
{
private
val
TAG
=
"VN/"
+
Vocabulary
::
class
.
java
.
simpleName
const
val
SORT_BY_TIME
=
0
const
val
SORT_BY_WORD
=
1
const
val
SORT_BY_TRANSLATION
=
2
}
fun
sort
(
sortOrder
:
Int
)
{
when
(
sortOrder
)
{
SORT_BY_TIME
->
sortByTime
()
...
...
@@ -82,4 +75,12 @@ class Vocabulary() {
words
.
sortWith
(
Comparator
{
item1
,
item2
->
item1
.
pojo
.
translation
.
toLowerCase
().
compareTo
(
item2
.
pojo
.
translation
.
toLowerCase
())
})
}
companion
object
{
private
val
TAG
=
"VN/"
+
Vocabulary
::
class
.
java
.
simpleName
const
val
SORT_BY_TIME
=
0
const
val
SORT_BY_WORD
=
1
const
val
SORT_BY_TRANSLATION
=
2
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
080d3fb8
...
...
@@ -55,15 +55,6 @@ class VocabularyAdapter(private val fullVocabulary: Vocabulary, private val main
popup
.
show
()
}
private
fun
deleteWord
(
position
:
Int
)
{
//TODO delete from fullVocabulary
displayedVocabulary
.
deleteWord
(
position
)
// update recyclerView
recyclerView
.
removeViewAt
(
position
)
this
.
notifyItemRemoved
(
position
)
this
.
notifyItemRangeChanged
(
position
,
displayedVocabulary
.
size
())
}
fun
refresh
()
{
/*displayedVocabulary.clear()
FirestoreManager().extractVocabulary { documents ->
...
...
@@ -72,6 +63,14 @@ class VocabularyAdapter(private val fullVocabulary: Vocabulary, private val main
}*/
}
private
fun
deleteWord
(
position
:
Int
)
{
//TODO delete from fullVocabulary
displayedVocabulary
.
deleteWord
(
position
)
recyclerView
.
removeViewAt
(
position
)
this
.
notifyItemRemoved
(
position
)
this
.
notifyItemRangeChanged
(
position
,
displayedVocabulary
.
size
())
}
fun
addWord
(
newWord
:
WordItem
)
{
displayedVocabulary
.
addWord
(
newWord
)
// TODO add word to fullVocabulary
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
080d3fb8
...
...
@@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
}
private
fun
setUpVocabularyAdapter
()
{
addProgressBar
()
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
// recyclerView.adapter = VocabularyAdapter(Vocabulary(), this@MainActivity)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
...
...
@@ -96,8 +96,8 @@ class MainActivity : AppCompatActivity() {
}
}
},
{
sho
wToastNoWords
(
)
},
{
removeProgressBar
()
},
this
)
{
sho
rtToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
)
)
},
{
removeProgressBar
(
supportFragmentManager
)
},
this
)
}
private
fun
hideKeyboard
()
{
...
...
@@ -113,14 +113,6 @@ class MainActivity : AppCompatActivity() {
imm
.
hideSoftInputFromWindow
(
view
.
windowToken
,
0
)
}
fun
addProgressBar
()
{
com
.
paktalin
.
vocabularynotebook
.
utils
.
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
}
fun
removeProgressBar
()
{
com
.
paktalin
.
vocabularynotebook
.
utils
.
removeProgressBar
(
supportFragmentManager
)
}
private
fun
showToastNoWords
()
{
shortToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
))
}
...
...
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