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
daa4eff2
authored
Apr 21, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added selectionTracker observer
parent
8683cc3b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/res/layout/tag.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
daa4eff2
...
@@ -93,9 +93,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -93,9 +93,7 @@ class MainActivity : AppCompatActivity() {
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
vocabularyAdapter
=
VocabularyAdapter
(
VocabSet
.
createFromSnapshot
(
querySnapshot
),
this
@MainActivity
)
vocabularyAdapter
=
VocabularyAdapter
(
VocabSet
.
createFromSnapshot
(
querySnapshot
),
this
@MainActivity
)
recyclerView
.
adapter
=
vocabularyAdapter
recyclerView
.
adapter
=
vocabularyAdapter
setSelectionTracker
()
setUpSelectionTracker
()
(
recyclerView
.
adapter
as
VocabularyAdapter
).
tracker
=
tracker
}
else
showToastNoWords
()
}
else
showToastNoWords
()
}
}
}
}
...
@@ -121,7 +119,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -121,7 +119,7 @@ class MainActivity : AppCompatActivity() {
shortToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
))
shortToast
(
this
,
getString
(
R
.
string
.
toast_empty_vocabulary
))
}
}
private
fun
setSelectionTracker
()
{
private
fun
set
Up
SelectionTracker
()
{
tracker
=
SelectionTracker
.
Builder
<
Long
>(
tracker
=
SelectionTracker
.
Builder
<
Long
>(
"mySelection"
,
"mySelection"
,
recyclerView
,
recyclerView
,
...
@@ -131,6 +129,18 @@ class MainActivity : AppCompatActivity() {
...
@@ -131,6 +129,18 @@ class MainActivity : AppCompatActivity() {
).
withSelectionPredicate
(
).
withSelectionPredicate
(
SelectionPredicates
.
createSelectAnything
()
SelectionPredicates
.
createSelectAnything
()
).
build
()
).
build
()
tracker
?.
addObserver
(
object
:
SelectionTracker
.
SelectionObserver
<
Long
>()
{
override
fun
onSelectionChanged
()
{
super
.
onSelectionChanged
()
if
(
tracker
?.
hasSelection
()
!!
)
{
Log
.
d
(
TAG
,
"selection ${tracker?.selection?.toList().toString()}"
)
}
//TODO my implementation
}
})
(
recyclerView
.
adapter
as
VocabularyAdapter
).
tracker
=
tracker
}
}
override
fun
onPause
()
{
override
fun
onPause
()
{
...
...
app/src/main/res/layout/tag.xml
0 → 100644
View file @
daa4eff2
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:orientation=
"vertical"
>
<Spinner
android:id=
"@+id/spinner2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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