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
9f8de0f3
authored
Apr 19, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring
parent
14e394cc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
24 deletions
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/ui/fragments/AddWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
9f8de0f3
...
...
@@ -56,6 +56,7 @@ class VocabularyAdapter(private val fullVocabulary: Vocabulary, private val main
}
private
fun
deleteWord
(
position
:
Int
)
{
//TODO delete entry point
displayedVocabulary
.
deleteWord
(
position
)
// update recyclerView
recyclerView
.
removeViewAt
(
position
)
...
...
@@ -73,11 +74,13 @@ class VocabularyAdapter(private val fullVocabulary: Vocabulary, private val main
fun
addWord
(
newWord
:
WordItem
)
{
displayedVocabulary
.
addWord
(
newWord
)
// TODO add word to fullVocabulary
this
.
sort
()
}
fun
updateWord
(
updatedWord
:
WordItem
)
{
displayedVocabulary
.
updateWord
(
updatedWord
)
// TODO update word in fullVocabulary
this
.
sort
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
9f8de0f3
...
...
@@ -125,14 +125,6 @@ class MainActivity : AppCompatActivity() {
shortToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
))
}
fun
addWord
(
newWord
:
WordItem
)
{
vocabularyAdapter
.
addWord
(
newWord
)
}
fun
updateWord
(
updatedWord
:
WordItem
)
{
vocabularyAdapter
.
updateWord
(
updatedWord
)
}
override
fun
onPause
()
{
super
.
onPause
()
// TODO save changes
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
View file @
9f8de0f3
...
...
@@ -38,6 +38,8 @@ class AddWordFragment : WordFragment() {
}
override
fun
saveToFirestore
(
word
:
String
,
translation
:
String
,
vocabularyId
:
String
)
{
// TODO add entry point
val
wordPojo
=
WordItem
.
Pojo
(
word
,
translation
,
null
)
FirestoreManager
().
saveNewWord
(
{
documentId
->
onSuccessfulSave
(
wordPojo
,
vocabularyId
,
documentId
)
},
...
...
@@ -45,10 +47,6 @@ class AddWordFragment : WordFragment() {
wordPojo
)
}
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
mainActivity
.
addWord
(
wordItem
)
}
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
TextWatcher
{
return
object
:
TextWatcher
{
override
fun
beforeTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
...
...
@@ -66,7 +64,7 @@ class AddWordFragment : WordFragment() {
clearFields
()
mainActivity
.
removeProgressBar
()
val
wordItem
=
WordItem
(
wordPojo
,
documentId
,
vocabularyId
)
updateRecycleView
(
wordItem
)
mainActivity
.
vocabularyAdapter
.
addWord
(
wordItem
)
word
.
requestFocus
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
9f8de0f3
...
...
@@ -41,10 +41,6 @@ class EditWordFragment : WordFragment() {
visible
(
mainActivity
.
btnSubmitLayout
)
}
override
fun
updateRecycleView
(
wordItem
:
WordItem
)
{
mainActivity
.
updateWord
(
wordItem
)
}
private
fun
setWordItemData
()
{
word
.
setText
(
wordItem
.
pojo
.
word
)
translation
.
setText
(
wordItem
.
pojo
.
translation
)
...
...
@@ -69,6 +65,7 @@ class EditWordFragment : WordFragment() {
}
override
fun
saveToFirestore
(
word
:
String
,
translation
:
String
,
vocabularyId
:
String
)
{
// TODO edit entry point
val
wordPojo
=
WordItem
.
Pojo
(
word
,
translation
,
wordItem
.
pojo
.
time
)
FirestoreManager
().
updateWord
(
{
onSuccessfulSave
(
wordPojo
)
},
...
...
@@ -80,7 +77,7 @@ class EditWordFragment : WordFragment() {
gone
(
mainActivity
.
btnSubmitLayout
)
mainActivity
.
removeProgressBar
()
wordItem
.
pojo
=
wordPojo
updateRecycleView
(
wordItem
)
mainActivity
.
vocabularyAdapter
.
updateWord
(
wordItem
)
stop
()
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
9f8de0f3
...
...
@@ -34,11 +34,8 @@ abstract class WordFragment : Fragment() {
fun
submitWord
()
{
gone
(
mainActivity
.
btnSubmitLayout
)
val
word
=
word
.
text
.
toString
()
val
translation
=
translation
.
text
.
toString
()
mainActivity
.
addProgressBar
()
saveToFirestore
(
word
,
translation
,
FirestoreManager
.
vocabularyId
!!
)
saveToFirestore
(
word
.
text
.
toString
(),
translation
.
text
.
toString
()
,
FirestoreManager
.
vocabularyId
!!
)
return
}
...
...
@@ -49,5 +46,4 @@ abstract class WordFragment : Fragment() {
protected
abstract
fun
cancelEditing
()
protected
abstract
fun
saveToFirestore
(
word
:
String
,
translation
:
String
,
vocabularyId
:
String
)
protected
abstract
fun
updateRecycleView
(
wordItem
:
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