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
2537be11
authored
Sep 09, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New word is extracted to fragment
parent
6124010d
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
133 additions
and
62 deletions
.idea/assetWizardSettings.xml
app/src/main/java/com/paktalin/vocabularynotebook/NewWordFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/Utils.kt
app/src/main/java/com/paktalin/vocabularynotebook/ViewHolder.kt
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/activities/VocabularyFragment.kt
app/src/main/res/drawable/ic_done_icon.xml
app/src/main/res/layout/fragment_new_word.xml
app/src/main/res/layout/fragment_vocabulary.xml
app/src/main/res/layout/word_item.xml
app/src/main/res/values/strings.xml
.idea/assetWizardSettings.xml
View file @
2537be11
...
...
@@ -14,8 +14,8 @@
<option
name=
"values"
>
<map>
<entry
key=
"assetSourceType"
value=
"FILE"
/>
<entry
key=
"outputName"
value=
"ic_
cancel
_icon"
/>
<entry
key=
"sourceFile"
value=
"C:\Users\litak\Desktop\
cancel
_icon.svg"
/>
<entry
key=
"outputName"
value=
"ic_
done
_icon"
/>
<entry
key=
"sourceFile"
value=
"C:\Users\litak\Desktop\
done
_icon.svg"
/>
</map>
</option>
</PersistentState>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/NewWordFragment.kt
0 → 100644
View file @
2537be11
package
com.paktalin.vocabularynotebook
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
class
NewWordFragment
:
Fragment
()
{
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_new_word
,
container
,
false
)
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/Utils.kt
View file @
2537be11
...
...
@@ -15,14 +15,5 @@ class Utils {
}
return
true
}
fun
setEmptyEditText
(
et
:
EditText
,
hint
:
String
)
{
et
.
isClickable
=
true
et
.
isFocusable
=
true
et
.
isFocusableInTouchMode
=
true
et
.
isCursorVisible
=
true
et
.
hint
=
hint
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN
)
et
.
background
=
null
}
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ViewHolder.kt
View file @
2537be11
...
...
@@ -5,34 +5,43 @@ import android.text.Editable
import
android.text.TextWatcher
import
android.util.Log
import
android.view.View
import
android.widget.EditText
import
android.widget.ImageButton
import
android.widget.LinearLayout
import
android.widget.TextView
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
val
etWord
:
EditText
=
itemView
.
findViewById
(
R
.
id
.
etWord
)
val
etTranslation
:
EditText
=
itemView
.
findViewById
(
R
.
id
.
etTranslation
)
val
tvWord
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
etWord
)
val
tvTranslation
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
etTranslation
)
val
btnPopupMenu
:
ImageButton
=
itemView
.
findViewById
(
R
.
id
.
btnContextMenu
)
val
layout
:
LinearLayout
=
itemView
.
findViewById
(
R
.
id
.
tableLayout
)
private
var
etWordEmpty
=
true
private
var
etTranslationEmpty
=
true
fun
showEmptyItem
()
{
btnPopupMenu
.
isClickable
=
false
btnPopupMenu
.
visibility
=
View
.
INVISIBLE
Utils
.
setEmptyEditText
(
etWord
,
"new word"
)
Utils
.
setEmptyEditText
(
etTranslation
,
"translation"
)
etWord
.
addTextChangedListener
(
object
:
TextWatcher
{
tvWord
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
beforeTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
onTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
afterTextChanged
(
editable
:
Editable
)
{
if
(!
etWord
.
text
.
isEmpty
())
showCancelButton
()
}
if
(!
tvWord
.
text
.
isEmpty
())
{
showCancelButton
()
etWordEmpty
=
false
}
else
etWordEmpty
=
true
if
(!
etWordEmpty
&&
!
etTranslationEmpty
)
showAddWordButton
()
}
})
this
.
et
Translation
.
addTextChangedListener
(
object
:
TextWatcher
{
this
.
tv
Translation
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
beforeTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
onTextChanged
(
charSequence
:
CharSequence
,
i
:
Int
,
i1
:
Int
,
i2
:
Int
)
{
}
override
fun
afterTextChanged
(
editable
:
Editable
)
{
if
(!
etTranslation
.
text
.
isEmpty
())
showCancelButton
()
}
if
(!
tvTranslation
.
text
.
isEmpty
())
{
showCancelButton
()
etTranslationEmpty
=
false
}
else
etTranslationEmpty
=
true
if
(!
etWordEmpty
&&
!
etTranslationEmpty
)
showAddWordButton
()
}
})
}
...
...
@@ -43,5 +52,9 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
//todo add button click listener
}
private
fun
showAddWordButton
()
{
//todo show add word button
}
companion
object
{
private
val
TAG
=
"VN/"
+
ViewHolder
::
class
.
java
.
simpleName
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/VocabularyAdapter.kt
View file @
2537be11
...
...
@@ -23,19 +23,16 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
if
(
position
==
0
)
holder
.
showEmptyItem
()
else
{
val
wordItem
=
wordItems
[
position
]
holder
.
etWord
.
setText
(
wordItem
.
pojo
!!
.
word
)
holder
.
etTranslation
.
setText
(
wordItem
.
pojo
!!
.
translation
)
holder
.
tvWord
.
text
=
wordItem
.
pojo
!!
.
word
holder
.
tvTranslation
.
text
=
wordItem
.
pojo
!!
.
translation
holder
.
layout
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
etWord
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
etTranslation
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
layout
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
tvWord
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
tvTranslation
.
setOnClickListener
{
openWordItemInfo
(
wordItem
)
}
holder
.
btnPopupMenu
.
setOnClickListener
{
showPopupMenu
(
holder
.
btnPopupMenu
,
position
)
}
//todo set click listener to menu
}
}
override
fun
getItemCount
():
Int
{
return
wordItems
.
size
...
...
@@ -52,8 +49,11 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
val
inflater
=
popup
.
menuInflater
inflater
.
inflate
(
R
.
menu
.
word_item_menu
,
popup
.
menu
)
popup
.
setOnMenuItemClickListener
{
if
(
it
.
itemId
==
R
.
id
.
item_delete
)
{
deleteWordItem
(
position
)
}
true
}
if
(
it
.
itemId
==
R
.
id
.
item_delete
)
{
deleteWordItem
(
position
)
}
true
}
popup
.
show
()
}
...
...
@@ -65,7 +65,7 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
this
.
notifyItemRangeChanged
(
position
,
wordItems
.
size
)
}
companion
object
{
private
val
TAG
=
"VN/"
+
VocabularyAdapter
::
class
.
java
.
simpleName
}
init
{
wordItems
.
add
(
0
,
WordItem
.
createEmpty
())
}
companion
object
{
private
val
TAG
=
"VN/"
+
VocabularyAdapter
::
class
.
java
.
simpleName
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/activities/VocabularyFragment.kt
View file @
2537be11
...
...
@@ -37,7 +37,6 @@ class VocabularyFragment : Fragment() {
override
fun
onActivityCreated
(
savedInstanceState
:
Bundle
?)
{
super
.
onActivityCreated
(
savedInstanceState
)
setEmptyAdapter
()
fabAddWord
.
setOnClickListener
(
{
addWord
()
}
)
retrieveData
()
}
...
...
app/src/main/res/drawable/ic_done_icon.xml
0 → 100644
View file @
2537be11
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
>
<path
android:fillColor=
"#FF000000"
android:pathData=
"M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"
/>
</vector>
app/src/main/res/layout/fragment_new_word.xml
0 → 100644
View file @
2537be11
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<EditText
android:id=
"@+id/etWord"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:inputType=
"text"
android:textSize=
"22sp"
android:hint=
"@string/hint_new_word"
tools:ignore=
"LabelFor"
/>
<EditText
android:id=
"@+id/etTranslation"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:inputType=
"text"
android:textSize=
"22sp"
android:hint=
"@string/hint_translation"
tools:ignore=
"LabelFor"
/>
<ImageButton
android:id=
"@+id/btnContextMenu"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:background=
"@android:color/transparent"
app:srcCompat=
"@drawable/ic_cancel_icon"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
app/src/main/res/layout/fragment_vocabulary.xml
View file @
2537be11
...
...
@@ -7,10 +7,11 @@
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
tools:context=
"com.paktalin.vocabularynotebook.activities.VocabularyFragment"
>
<include
layout=
"@layout/img_background"
/>
<include
layout=
"@layout/img_background"
/>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/recyclerView"
<fragment
android:id=
"@+id/fragment"
android:name=
"com.paktalin.vocabularynotebook.NewWordFragment"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
...
...
@@ -22,15 +23,17 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<android.support.
design.widget.FloatingActionButton
android:id=
"@+id/
fabAddWord
"
android:layout_width=
"
wrap_cont
ent"
<android.support.
v7.widget.RecyclerView
android:id=
"@+id/
recyclerView
"
android:layout_width=
"
match_par
ent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"16dp"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:src=
"@android:drawable/ic_input_add"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
/>
android:layout_marginEnd=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/fragment"
/>
</android.support.constraint.ConstraintLayout>
app/src/main/res/layout/word_item.xml
View file @
2537be11
...
...
@@ -13,30 +13,20 @@
android:focusableInTouchMode=
"true"
android:padding=
"8dp"
>
<
EditText
<
TextView
android:id=
"@+id/etWord"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:cursorVisible=
"false"
android:clickable=
"false"
android:focusable=
"false"
android:focusableInTouchMode=
"false"
android:textSize=
"22sp"
tools:ignore=
"LabelFor"
android:inputType=
"text"
/>
<
EditText
<
TextView
android:id=
"@+id/etTranslation"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"8"
android:background=
"@android:color/transparent"
android:cursorVisible=
"false"
android:clickable=
"false"
android:focusable=
"false"
android:focusableInTouchMode=
"false"
android:textSize=
"22sp"
tools:ignore=
"LabelFor"
android:inputType=
"text"
/>
...
...
app/src/main/res/values/strings.xml
View file @
2537be11
...
...
@@ -9,4 +9,6 @@
<string
name=
"tv_translation"
>
Translation
</string>
<string
name=
"btn_save"
>
Save
</string>
<string
name=
"btn_cancel"
>
Cancel
</string>
<string
name=
"hint_new_word"
>
new word
</string>
<string
name=
"hint_translation"
>
translation
</string>
</resources>
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