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
Hide 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 @@
</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/activities/MainActivity.kt
View file @
9f71b0c0
...
...
@@ -12,6 +12,8 @@ import androidx.appcompat.widget.SearchView
import
androidx.recyclerview.selection.Selection
import
com.paktalin.vocabularynotebook.R
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.selection_tracker.MySelectionTracker
import
com.paktalin.vocabularynotebook.ui.views.LockableLayoutManager
...
...
@@ -26,6 +28,7 @@ class MainActivity : AppCompatActivity() {
var
searchView
:
SearchView
?
=
null
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
private
var
tagFragment
=
TagFragment
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
...
...
@@ -132,13 +135,14 @@ class MainActivity : AppCompatActivity() {
}
private
fun
whenSelectionChanges
(
selection
:
Selection
<
Long
>)
{
if
(!
selection
.
isEmpty
)
{
if
(!
selection
.
isEmpty
&&
SubmitFragment
.
zeroInstances
())
{
vocabularyAdapter
.
showPopupMenu
=
false
Log
.
d
(
TAG
,
"selection ${selection.toList()}"
)
add
TagFragment
(
supportFragmentManager
,
R
.
id
.
main_activity_container
)
}
else
{
tagFragment
.
setSelection
(
selection
.
toList
()
)
add
Fragment
(
supportFragmentManager
,
tagFragment
,
R
.
id
.
main_activity_container
)
}
else
if
(
selection
.
isEmpty
)
{
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() {
companion
object
{
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
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.removeTagFragment
import
com.paktalin.vocabularynotebook.utils.shortToast
import
kotlinx.android.synthetic.main.fragment_tag.*
...
...
@@ -25,6 +26,11 @@ class TagFragment : Fragment() {
btnCancelTag
.
setOnClickListener
{
cancel
()
}
}
fun
setSelection
(
selectionList
:
List
<
Long
>)
{
Log
.
d
(
TAG
,
"selection $selectionList"
)
}
private
fun
submit
()
{
tag_et
.
text
.
toString
().
let
{
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
override
fun
onBindViewHolder
(
viewHolder
:
ViewHolder
,
position
:
Int
)
{
val
wordItem
=
vocabulary
.
displayedAt
(
position
)
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
//todo set click listener to menu
...
...
@@ -129,7 +130,6 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
}
fun
addTagToSelected
(
tag
:
String
)
{
}
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) {
}
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
)
{
...
...
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