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
60bd38c2
authored
Apr 28, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tag marking in progress
parent
16f12c22
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
5 deletions
.idea/misc.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/ViewHolder.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
app/src/main/res/layout/word_item.xml
app/src/main/res/values/strings.xml
.idea/misc.xml
View file @
60bd38c2
...
...
@@ -35,7 +35,7 @@
</value>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/ViewHolder.kt
View file @
60bd38c2
...
...
@@ -16,12 +16,14 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun
bind
(
wordPojo
:
WordPojo
,
position
:
Int
,
isActivated
:
Boolean
,
color
:
Int
,
showPopupMenu
:
(
View
,
Int
)
->
Unit
)
{
tvWord
.
setText
(
wordPojo
.
word
)
tvTranslation
.
setText
(
wordPojo
.
translation
)
visible
(
itemView
.
clickable_view
)
itemView
.
clickable_view
.
setOnClickListener
{
showPopupMenu
(
itemView
,
position
)
}
itemView
.
isActivated
=
isActivated
itemView
.
tag_marker
.
setTextColor
(
color
)
}
fun
getItemDetails
():
ItemDetailsLookup
.
ItemDetails
<
Long
>
=
...
...
@@ -30,6 +32,10 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
override
fun
getSelectionKey
():
Long
?
=
itemId
}
private
fun
generateColor
()
{
}
companion
object
{
private
val
TAG
=
"VN/"
+
ViewHolder
::
class
.
simpleName
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
60bd38c2
...
...
@@ -66,8 +66,9 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
viewHolder
.
bind
(
vocabulary
.
displayedAt
(
position
),
position
,
(
selectionTracker
.
selected
(
position
.
toLong
()))
&&
state
.
notAddOrEdit
())
{
view
,
p
->
showPopupMenu
(
view
,
p
)
}
(
selectionTracker
.
selected
(
position
.
toLong
()))
&&
state
.
notAddOrEdit
(),
vocabulary
.
getColorForTag
(
vocabulary
.
displayedAt
(
position
).
tag
)
)
{
view
,
p
->
showPopupMenu
(
view
,
p
)
}
// TODO not allow to edit when tag is being selected
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
View file @
60bd38c2
package
com.paktalin.vocabularynotebook.vocabulary
import
android.graphics.Color
import
com.google.firebase.Timestamp
import
com.google.firebase.firestore.QueryDocumentSnapshot
import
com.google.firebase.firestore.QuerySnapshot
import
com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import
java.util.*
class
VocabSet
(
var
wordList
:
MutableList
<
WordPojo
>)
:
Vocabulary
{
var
fullVocabulary
=
BasicVocabulary
(
wordList
)
private
var
displayedVocabulary
=
DisplayedVocabulary
(
wordList
)
var
modifiedVocabulary
=
ModifiedVocabulary
()
var
colorMap
=
mutableMapOf
<
String
?,
Int
>()
companion
object
{
fun
createFromSnapshot
(
querySnapshot
:
QuerySnapshot
):
VocabSet
{
...
...
@@ -30,6 +33,14 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
private
val
TAG
=
"VN/"
+
VocabSet
::
class
.
java
.
simpleName
}
init
{
// TODO link specific colors to specific TAGs
val
rnd
=
Random
()
wordList
.
forEach
{
w
->
colorMap
[
w
.
tag
]
=
Color
.
argb
(
255
,
rnd
.
nextInt
(
256
),
rnd
.
nextInt
(
256
),
rnd
.
nextInt
(
256
))
}
}
override
fun
addAll
(
words
:
MutableList
<
WordPojo
>)
{
listOf
(
fullVocabulary
,
displayedVocabulary
,
modifiedVocabulary
)
.
forEach
{
v
->
v
.
addAll
(
words
)
}
...
...
@@ -84,4 +95,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
modifiedVocabulary
.
addWord
(
displayedAt
(
position
.
toInt
()))
}
}
fun
getColorForTag
(
tag
:
String
?):
Int
{
return
colorMap
[
tag
]
?:
Color
.
TRANSPARENT
}
}
\ No newline at end of file
app/src/main/res/layout/word_item.xml
View file @
60bd38c2
...
...
@@ -33,11 +33,19 @@
android:paddingRight=
"16dp"
android:paddingBottom=
"8dp"
>
<TextView
android:id=
"@+id/tag_marker"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"@string/tag_point"
android:textSize=
"@dimen/text_size"
/>
<EditText
android:id=
"@+id/word"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1
4
"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_word"
android:inputType=
"textMultiLine"
...
...
@@ -54,7 +62,7 @@
android:id=
"@+id/translation"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1
4
"
android:background=
"@android:color/transparent"
android:hint=
"@string/hint_translation"
android:inputType=
"textMultiLine"
...
...
app/src/main/res/values/strings.xml
View file @
60bd38c2
...
...
@@ -14,6 +14,7 @@
<string
name=
"sign_up"
>
Sign Up
</string>
<string
name=
"log_in"
>
Log In
</string>
<string
name=
"enter_tag"
>
Add tag
</string>
<string
name=
"tag_point"
translatable=
"false"
>
\u2022
</string>
<!--Toast messages-->
<string
name=
"toast_empty_vocabulary"
>
Your vocabulary is empty. Add your fist word!
</string>
...
...
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