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
56cd1959
authored
Sep 09, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Button clear works as it should
parent
b68615ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
25 deletions
app/src/main/java/com/paktalin/vocabularynotebook/Random.java
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/Random.java
0 → 100644
View file @
56cd1959
package
com
.
paktalin
.
vocabularynotebook
;
public
class
Random
{
}
app/src/main/java/com/paktalin/vocabularynotebook/ui/NewWordFragment.kt
View file @
56cd1959
...
@@ -13,8 +13,11 @@ import kotlinx.android.synthetic.main.fragment_new_word.*
...
@@ -13,8 +13,11 @@ import kotlinx.android.synthetic.main.fragment_new_word.*
class
NewWordFragment
:
Fragment
()
{
class
NewWordFragment
:
Fragment
()
{
private
var
etWordEmpty
=
true
private
var
wordEmpty
:
Boolean
=
true
private
var
etTranslationEmpty
=
true
set
(
value
)
{
field
=
value
;
updateButtons
()
}
private
var
translationEmpty
:
Boolean
=
true
set
(
value
)
{
field
=
value
;
updateButtons
()
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
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_new_word
,
container
,
false
)
...
@@ -22,39 +25,53 @@ class NewWordFragment : Fragment() {
...
@@ -22,39 +25,53 @@ class NewWordFragment : Fragment() {
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
super
.
onActivityCreated
(
savedInstanceState
)
etWord
.
addTextChangedListener
(
object
:
TextWatcher
{
etWord
.
addTextChangedListener
(
textWatcher
{
override
fun
beforeTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
wordEmpty
=
etWord
.
text
.
isEmpty
()
})
override
fun
onTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
afterTextChanged
(
editable
:
Editable
)
{
etTranslation
.
addTextChangedListener
(
textWatcher
{
if
(!
etWord
.
text
.
isEmpty
())
{
translationEmpty
=
etTranslation
.
text
.
isEmpty
()
})
showCancelButton
()
etWordEmpty
=
false
btnClear
.
setOnClickListener
{
}
else
etWordEmpty
=
true
etWord
.
text
.
clear
()
if
(!
etWordEmpty
&&
!
etTranslationEmpty
)
etTranslation
.
text
.
clear
()
showAddWordButton
()
}
}
})
}
etTranslation
.
addTextChangedListener
(
object
:
TextWatcher
{
private
fun
textWatcher
(
setEmpty
:
()
->
Unit
):
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
)
{
}
override
fun
onTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
onTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
afterTextChanged
(
editable
:
Editable
)
{
override
fun
afterTextChanged
(
editable
:
Editable
)
{
setEmpty
()
}
if
(!
etTranslation
.
text
.
isEmpty
())
{
}
showCancelButton
()
etTranslationEmpty
=
false
}
else
etTranslationEmpty
=
true
if
(!
etWordEmpty
&&
!
etTranslationEmpty
)
showAddWordButton
()
}
}
})
private
fun
updateButtons
()
{
if
(!
wordEmpty
||
!
translationEmpty
)
showClearButton
()
if
(!
wordEmpty
&&
!
translationEmpty
)
showAddWordButton
()
if
(
wordEmpty
||
translationEmpty
)
hideAddWordButton
()
if
(
wordEmpty
&&
translationEmpty
)
hideClearButton
()
}
}
private
fun
showAddWordButton
()
{
private
fun
showAddWordButton
()
{
Log
.
d
(
TAG
,
"showAddWordButton"
)
//todo show add word button
//todo show add word button
}
}
private
fun
showCancelButton
()
{
private
fun
hideAddWordButton
()
{
Log
.
d
(
TAG
,
"empty word is focused"
)
Log
.
d
(
TAG
,
"hideAddWordButton"
)
btnClear
.
setImageResource
(
R
.
drawable
.
ic_cancel_icon
)
}
private
fun
hideClearButton
()
{
Log
.
d
(
TAG
,
"hideClearButton"
)
btnClear
.
visibility
=
View
.
GONE
}
private
fun
showClearButton
()
{
Log
.
d
(
TAG
,
"showClearButton"
)
btnClear
.
visibility
=
View
.
VISIBLE
btnClear
.
visibility
=
View
.
VISIBLE
//todo add button click listener
//todo add button click listener
}
}
...
...
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