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
8683cc3b
authored
Apr 21, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring
parent
9ebbb31a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
31 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/MyItemDetailsLookup.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/res/drawable/selector.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/MyItemDetailsLookup.kt
deleted
100644 → 0
View file @
9ebbb31a
package
com.paktalin.vocabularynotebook.ui
import
android.view.MotionEvent
import
androidx.recyclerview.selection.ItemDetailsLookup
import
androidx.recyclerview.widget.RecyclerView
class
MyItemDetailsLookup
(
private
val
recyclerView
:
RecyclerView
)
:
ItemDetailsLookup
<
Long
>()
{
override
fun
getItemDetails
(
event
:
MotionEvent
):
ItemDetails
<
Long
>?
{
val
view
=
recyclerView
.
findChildViewUnder
(
event
.
x
,
event
.
y
)
if
(
view
!=
null
)
{
return
(
recyclerView
.
getChildViewHolder
(
view
)
as
ViewHolder
)
.
getItemDetails
()
}
return
null
}
}
\ No newline at end of file
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
8683cc3b
...
...
@@ -93,15 +93,7 @@ class MainActivity : AppCompatActivity() {
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
vocabularyAdapter
=
VocabularyAdapter
(
VocabSet
.
createFromSnapshot
(
querySnapshot
),
this
@MainActivity
)
recyclerView
.
adapter
=
vocabularyAdapter
tracker
=
SelectionTracker
.
Builder
<
Long
>(
"mySelection"
,
recyclerView
,
StableIdKeyProvider
(
recyclerView
),
MyItemDetailsLookup
(
recyclerView
),
StorageStrategy
.
createLongStorage
()
).
withSelectionPredicate
(
SelectionPredicates
.
createSelectAnything
()
).
build
()
setSelectionTracker
()
(
recyclerView
.
adapter
as
VocabularyAdapter
).
tracker
=
tracker
}
else
showToastNoWords
()
...
...
@@ -129,6 +121,18 @@ class MainActivity : AppCompatActivity() {
shortToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
))
}
private
fun
setSelectionTracker
()
{
tracker
=
SelectionTracker
.
Builder
<
Long
>(
"mySelection"
,
recyclerView
,
StableIdKeyProvider
(
recyclerView
),
MyItemDetailsLookup
(
recyclerView
),
StorageStrategy
.
createLongStorage
()
).
withSelectionPredicate
(
SelectionPredicates
.
createSelectAnything
()
).
build
()
}
override
fun
onPause
()
{
super
.
onPause
()
hideKeyboard
()
...
...
@@ -141,6 +145,4 @@ class MainActivity : AppCompatActivity() {
companion
object
{
private
val
TAG
=
"VN/"
+
MainActivity
::
class
.
simpleName
}
}
\ No newline at end of file
app/src/main/res/drawable/selector.xml
View file @
8683cc3b
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@android:color/holo_blue_light"
android:state_activated=
"true"
/>
<item
android:drawable=
"@android:color/
white
"
/>
<item
android:drawable=
"@android:color/
transparent
"
/>
</selector>
\ 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