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
4467b7c0
authored
Nov 10, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Name refactoring
parent
e1a5bbb4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
15 deletions
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/res/layout/activity_main.xml
app/src/main/res/layout/notebook_sheet.xml → app/src/main/res/layout/content_main.xml
app/src/main/res/layout/fragment_new_word.xml → app/src/main/res/layout/fragment_editable_word.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/AddWordFragment.kt
View file @
4467b7c0
...
...
@@ -8,7 +8,7 @@ import com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCAB
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.shortToast
import
kotlinx.android.synthetic.main.fragment_
new
_word.*
import
kotlinx.android.synthetic.main.fragment_
editable
_word.*
class
AddWordFragment
:
WordFragment
()
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/EditWordFragment.kt
View file @
4467b7c0
...
...
@@ -12,11 +12,11 @@ import com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.appsetup.ConfiguredFirestore
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.VOCABULARIES
import
com.paktalin.vocabularynotebook.firestoreitems.Vocabulary.Companion.WORDS
import
com.paktalin.vocabularynotebook.hide
import
com.paktalin.vocabularynotebook.removeFragment
import
com.paktalin.vocabularynotebook.shortToast
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.word_item.view.*
class
EditWordFragment
:
WordFragment
()
{
...
...
@@ -61,7 +61,7 @@ class EditWordFragment : WordFragment() {
.
collection
(
WORDS
).
document
(
wordItem
.
id
).
set
(
wordPojo
)
.
addOnSuccessListener
{
Log
.
i
(
TAG
,
"Successfully updated the word"
)
hide
(
btnSubmit
)
hide
SubmitButton
(
)
mainActivity
.
removeProgressBar
()
wordItem
.
pojo
=
wordPojo
updateRecycleView
(
wordItem
)
...
...
@@ -76,7 +76,7 @@ class EditWordFragment : WordFragment() {
private
fun
stop
()
{
// set onClickListener from AddWordFragment
//mainActivity.btnSubmit.setOnClickListener { (mainActivity.fragmentNew
Word as AddWordFragment).submitWord() }
mainActivity
.
btnSubmit
.
setOnClickListener
{
(
mainActivity
.
fragmentAdd
Word
as
AddWordFragment
).
submitWord
()
}
removeFragment
(
mainActivity
.
supportFragmentManager
,
this
)
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/WordFragment.kt
View file @
4467b7c0
...
...
@@ -9,10 +9,9 @@ import android.view.View
import
android.view.ViewGroup
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.firestoreitems.WordItem
import
com.paktalin.vocabularynotebook.hide
import
com.paktalin.vocabularynotebook.show
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
kotlinx.android.synthetic.main.fragment_new_word.*
import
kotlinx.android.synthetic.main.fragment_editable_word.*
import
kotlinx.android.synthetic.main.content_main.*
abstract
class
WordFragment
:
Fragment
()
{
protected
lateinit
var
mainActivity
:
MainActivity
...
...
@@ -24,14 +23,13 @@ abstract class WordFragment : Fragment() {
set
(
value
)
{
field
=
value
;
updateButtons
()
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_
new
_word
,
container
,
false
)
return
inflater
.
inflate
(
R
.
layout
.
fragment_
editable
_word
,
container
,
false
)
}
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
mainActivity
=
activity
as
MainActivity
btnSubmit
.
setOnClickListener
{
submitWord
()
}
mainActivity
.
btnSubmit
.
setOnClickListener
{
submitWord
()
}
word
.
addTextChangedListener
(
textWatcher
{
wordEmpty
=
word
.
text
.
isEmpty
()
})
...
...
@@ -42,8 +40,8 @@ abstract class WordFragment : Fragment() {
}
open
fun
updateButtons
()
{
if
(!
wordEmpty
&&
!
translationEmpty
)
show
(
btnSubmit
)
if
(
wordEmpty
||
translationEmpty
)
hide
(
btnSubmit
)
if
(!
wordEmpty
&&
!
translationEmpty
)
show
SubmitButton
(
)
if
(
wordEmpty
||
translationEmpty
)
hide
SubmitButton
(
)
}
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
TextWatcher
{
...
...
@@ -54,7 +52,13 @@ abstract class WordFragment : Fragment() {
}
}
private
fun
submitWord
()
{
private
fun
showSubmitButton
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
VISIBLE
}
protected
fun
hideSubmitButton
()
{
mainActivity
.
btnSubmitLayout
.
visibility
=
View
.
GONE
}
fun
submitWord
()
{
mainActivity
.
hideKeyboardNotFromActivity
(
mainActivity
)
val
word
=
word
.
text
.
toString
()
...
...
app/src/main/res/layout/activity_main.xml
View file @
4467b7c0
...
...
@@ -13,7 +13,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/
notebook_sheet
"
/>
<include
layout=
"@layout/
content_main
"
/>
</FrameLayout>
<android.support.design.widget.NavigationView
...
...
app/src/main/res/layout/
notebook_sheet
.xml
→
app/src/main/res/layout/
content_main
.xml
View file @
4467b7c0
File moved
app/src/main/res/layout/fragment_
new
_word.xml
→
app/src/main/res/layout/fragment_
editable
_word.xml
View file @
4467b7c0
File moved
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