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
9f71b0c0
authored
Apr 22, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Selection is only shown and tagFragment is added if not in edit mode
parent
6917a770
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
10 deletions
.idea/misc.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitFragment.kt
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
.idea/misc.xml
View file @
9f71b0c0
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</value>
</value>
</option>
</option>
</component>
</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"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
9f71b0c0
...
@@ -12,6 +12,8 @@ import androidx.appcompat.widget.SearchView
...
@@ -12,6 +12,8 @@ import androidx.appcompat.widget.SearchView
import
androidx.recyclerview.selection.Selection
import
androidx.recyclerview.selection.Selection
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.ui.fragments.SubmitAddedFragment
import
com.paktalin.vocabularynotebook.ui.fragments.SubmitAddedFragment
import
com.paktalin.vocabularynotebook.ui.fragments.SubmitFragment
import
com.paktalin.vocabularynotebook.ui.fragments.TagFragment
import
com.paktalin.vocabularynotebook.ui.recycler_view.VocabularyAdapter
import
com.paktalin.vocabularynotebook.ui.recycler_view.VocabularyAdapter
import
com.paktalin.vocabularynotebook.ui.recycler_view.selection_tracker.MySelectionTracker
import
com.paktalin.vocabularynotebook.ui.recycler_view.selection_tracker.MySelectionTracker
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
...
@@ -26,6 +28,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -26,6 +28,7 @@ class MainActivity : AppCompatActivity() {
var
searchView
:
SearchView
?
=
null
var
searchView
:
SearchView
?
=
null
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
private
var
tagFragment
=
TagFragment
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -132,13 +135,14 @@ class MainActivity : AppCompatActivity() {
...
@@ -132,13 +135,14 @@ class MainActivity : AppCompatActivity() {
}
}
private
fun
whenSelectionChanges
(
selection
:
Selection
<
Long
>)
{
private
fun
whenSelectionChanges
(
selection
:
Selection
<
Long
>)
{
if
(!
selection
.
isEmpty
)
{
if
(!
selection
.
isEmpty
&&
SubmitFragment
.
zeroInstances
())
{
vocabularyAdapter
.
showPopupMenu
=
false
vocabularyAdapter
.
showPopupMenu
=
false
Log
.
d
(
TAG
,
"selection ${selection.toList()}"
)
tagFragment
.
setSelection
(
selection
.
toList
()
)
add
TagFragment
(
supportFragmentManager
,
R
.
id
.
main_activity_container
)
add
Fragment
(
supportFragmentManager
,
tagFragment
,
R
.
id
.
main_activity_container
)
}
else
{
}
else
if
(
selection
.
isEmpty
)
{
vocabularyAdapter
.
showPopupMenu
=
true
vocabularyAdapter
.
showPopupMenu
=
true
remove
TagFragment
(
supportFragmentManager
)
remove
Fragment
(
supportFragmentManager
,
tagFragment
)
}
}
}
}
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/SubmitFragment.kt
View file @
9f71b0c0
...
@@ -46,6 +46,10 @@ abstract class SubmitFragment : Fragment() {
...
@@ -46,6 +46,10 @@ abstract class SubmitFragment : Fragment() {
companion
object
{
companion
object
{
private
val
TAG
=
"VN/"
+
SubmitFragment
::
class
.
java
.
simpleName
private
val
TAG
=
"VN/"
+
SubmitFragment
::
class
.
java
.
simpleName
var
instances
:
Int
=
0
private
var
instances
:
Int
=
0
fun
zeroInstances
():
Boolean
{
return
instances
==
0
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/fragments/TagFragment.kt
View file @
9f71b0c0
...
@@ -7,6 +7,7 @@ import android.view.ViewGroup
...
@@ -7,6 +7,7 @@ import android.view.ViewGroup
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.R
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.ui.activities.MainActivity
import
com.paktalin.vocabularynotebook.utils.Log
import
com.paktalin.vocabularynotebook.utils.removeTagFragment
import
com.paktalin.vocabularynotebook.utils.removeTagFragment
import
com.paktalin.vocabularynotebook.utils.shortToast
import
com.paktalin.vocabularynotebook.utils.shortToast
import
kotlinx.android.synthetic.main.fragment_tag.*
import
kotlinx.android.synthetic.main.fragment_tag.*
...
@@ -25,6 +26,11 @@ class TagFragment : Fragment() {
...
@@ -25,6 +26,11 @@ class TagFragment : Fragment() {
btnCancelTag
.
setOnClickListener
{
cancel
()
}
btnCancelTag
.
setOnClickListener
{
cancel
()
}
}
}
fun
setSelection
(
selectionList
:
List
<
Long
>)
{
Log
.
d
(
TAG
,
"selection $selectionList"
)
}
private
fun
submit
()
{
private
fun
submit
()
{
tag_et
.
text
.
toString
().
let
{
tag_et
.
text
.
toString
().
let
{
if
(
it
.
isBlank
())
if
(
it
.
isBlank
())
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
9f71b0c0
...
@@ -54,7 +54,8 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -54,7 +54,8 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
override
fun
onBindViewHolder
(
viewHolder
:
ViewHolder
,
position
:
Int
)
{
override
fun
onBindViewHolder
(
viewHolder
:
ViewHolder
,
position
:
Int
)
{
val
wordItem
=
vocabulary
.
displayedAt
(
position
)
val
wordItem
=
vocabulary
.
displayedAt
(
position
)
selectionTracker
.
let
{
selectionTracker
.
let
{
viewHolder
.
bind
(
wordItem
,
position
,
it
.
selected
(
position
.
toLong
()))
{
view
,
p
->
showPopupMenu
(
view
,
p
)
}
viewHolder
.
bind
(
wordItem
,
position
,
it
.
selected
(
position
.
toLong
())
&&
showPopupMenu
)
{
view
,
p
->
showPopupMenu
(
view
,
p
)
}
}
}
this
.
viewHolder
=
viewHolder
this
.
viewHolder
=
viewHolder
//todo set click listener to menu
//todo set click listener to menu
...
@@ -129,7 +130,6 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
...
@@ -129,7 +130,6 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}
}
fun
addTagToSelected
(
tag
:
String
)
{
fun
addTagToSelected
(
tag
:
String
)
{
}
}
companion
object
{
companion
object
{
...
...
app/src/main/java/com/paktalin/vocabularynotebook/utils/ActivityUtil.kt
View file @
9f71b0c0
...
@@ -38,7 +38,7 @@ fun addTagFragment(fragmentManager: FragmentManager, containerId: Int) {
...
@@ -38,7 +38,7 @@ fun addTagFragment(fragmentManager: FragmentManager, containerId: Int) {
}
}
fun
addSubmitFragment
(
fragmentManager
:
FragmentManager
,
fragment
:
SubmitFragment
,
containerId
:
Int
)
{
fun
addSubmitFragment
(
fragmentManager
:
FragmentManager
,
fragment
:
SubmitFragment
,
containerId
:
Int
)
{
if
(
SubmitFragment
.
instances
==
0
)
addFragment
(
fragmentManager
,
fragment
,
containerId
)
if
(
SubmitFragment
.
zeroInstances
()
)
addFragment
(
fragmentManager
,
fragment
,
containerId
)
}
}
fun
removeTagFragment
(
fragmentManager
:
FragmentManager
)
{
fun
removeTagFragment
(
fragmentManager
:
FragmentManager
)
{
...
...
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