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
9b78a83f
authored
Apr 25, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tag is added to the selected words
parent
7fb927f7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
8 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/TagFragment.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
app/src/main/java/com/paktalin/vocabularynotebook/utils/ActivityUtil.kt
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/TagFragment.kt
View file @
9b78a83f
...
...
@@ -7,13 +7,13 @@ import android.view.ViewGroup
import
androidx.fragment.app.Fragment
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.Log
import
com.paktalin.vocabularynotebook.utils.removeFragment
import
com.paktalin.vocabularynotebook.utils.shortToast
import
kotlinx.android.synthetic.main.fragment_tag.*
class
TagFragment
:
Fragment
()
{
private
lateinit
var
mainActivity
:
MainActivity
private
var
selectionList
=
mutableListOf
<
Long
>()
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
fragment_tag
,
container
,
false
)
...
...
@@ -27,8 +27,7 @@ class TagFragment : Fragment() {
}
fun
setSelection
(
selectionList
:
List
<
Long
>)
{
Log
.
d
(
TAG
,
"selection $selectionList"
)
this
.
selectionList
=
selectionList
.
toMutableList
()
}
private
fun
submit
()
{
...
...
@@ -36,7 +35,7 @@ class TagFragment : Fragment() {
if
(
it
.
isBlank
())
shortToast
(
mainActivity
,
mainActivity
.
getString
(
R
.
string
.
toast_tag_cannot_be_empty
))
else
mainActivity
.
vocabularyAdapter
?.
addTagToSelected
(
it
)
mainActivity
.
vocabularyAdapter
?.
addTagToSelected
(
it
,
selectionList
)
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
9b78a83f
...
...
@@ -139,7 +139,8 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
return
vocabulary
.
getModified
()
}
fun
addTagToSelected
(
tag
:
String
)
{
fun
addTagToSelected
(
tag
:
String
,
selectionList
:
MutableList
<
Long
>)
{
vocabulary
.
addTag
(
selectionList
,
tag
)
}
companion
object
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/utils/ActivityUtil.kt
View file @
9b78a83f
...
...
@@ -17,7 +17,7 @@ import org.apache.commons.lang3.StringUtils
val
progressFragment
=
ProgressFragment
()
fun
addFragment
(
fragmentManager
:
FragmentManager
,
fragment
:
Fragment
,
containerId
:
Int
,
arg
:
Bundle
?
=
null
,
tag
:
String
?
=
null
)
{
if
(!
fragment
.
isAdded
)
if
(
fragmentManager
.
findFragmentById
(
fragment
.
id
)
==
null
&&
!
fragment
.
isAdded
)
fragmentManager
.
beginTransaction
()
.
add
(
containerId
,
fragment
.
apply
{
arguments
=
arg
},
tag
)
.
commitAllowingStateLoss
()
...
...
app/src/main/java/com/paktalin/vocabularynotebook/vocabulary/VocabSet.kt
View file @
9b78a83f
...
...
@@ -25,6 +25,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
(
snapshot
[
"time"
]
as
Timestamp
).
toDate
(),
snapshot
.
id
)
}
private
val
TAG
=
"VN/"
+
VocabSet
::
class
.
java
.
simpleName
}
override
fun
addAll
(
words
:
MutableList
<
WordPojo
>)
{
...
...
@@ -63,11 +65,22 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
return
displayedVocabulary
.
at
(
position
)
}
fun
displayedSize
():
Int
{
return
displayedVocabulary
.
size
()
}
fun
displayedSize
():
Int
{
return
displayedVocabulary
.
size
()
}
fun
clearDisplayed
()
{
displayedVocabulary
.
clear
()
}
fun
clearDisplayed
()
{
displayedVocabulary
.
clear
()
}
fun
getModified
():
MutableMap
<
WordPojo
,
Boolean
>
{
return
modifiedVocabulary
.
get
()
}
fun
addTag
(
selectionList
:
MutableList
<
Long
>,
tag
:
String
)
{
selectionList
.
forEach
{
position
->
displayedAt
(
position
.
toInt
()).
tag
=
tag
modifiedVocabulary
.
addWord
(
displayedAt
(
position
.
toInt
()))
}
}
}
\ 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