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