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
ede577cb
authored
Apr 21, 2019
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with searchView initialization, tag layout is shown when hasSelection()
parent
50a4eced
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
app/src/main/res/layout/content_main.xml
app/src/main/res/layout/tag.xml
app/src/main/java/com/paktalin/vocabularynotebook/ui/activities/MainActivity.kt
View file @
ede577cb
...
...
@@ -22,10 +22,11 @@ import com.paktalin.vocabularynotebook.vocabulary.Sort
import
com.paktalin.vocabularynotebook.vocabulary.VocabSet
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.tag.*
class
MainActivity
:
AppCompatActivity
()
{
lateinit
var
searchView
:
SearchView
var
searchView
:
SearchView
?
=
null
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
private
var
tracker
:
SelectionTracker
<
Long
>?
=
null
...
...
@@ -34,6 +35,7 @@ class MainActivity : AppCompatActivity() {
setContentView
(
R
.
layout
.
activity_main
)
FirestoreManager
.
vocabularyId
=
getSavedVocabularyIdFromPreferences
(
this
@MainActivity
)
recyclerView
.
adapter
=
VocabularyAdapter
(
VocabSet
(
mutableListOf
()),
this
@MainActivity
)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
setUpSwipeRefresh
()
setUpNavigationView
()
hideKeyboard
()
...
...
@@ -43,7 +45,7 @@ class MainActivity : AppCompatActivity() {
menuInflater
.
inflate
(
R
.
menu
.
options_menu
,
menu
)
searchView
=
menu
!!
.
findItem
(
R
.
id
.
search
).
actionView
as
SearchView
// extract vocabulary data only after searchView is initialized,
// since it needs to be called in the Vocabulary
Fragment
initialization
// since it needs to be called in the Vocabulary
Adapter
initialization
setUpVocabularyAdapter
()
return
true
}
...
...
@@ -89,7 +91,6 @@ class MainActivity : AppCompatActivity() {
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
run
{
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
...
...
@@ -138,8 +139,10 @@ class MainActivity : AppCompatActivity() {
super
.
onSelectionChanged
()
if
(
tracker
?.
hasSelection
()
!!
)
{
Log
.
d
(
TAG
,
"selection ${tracker?.selection?.toList().toString()}"
)
visible
(
tagLayout
)
}
else
{
gone
(
tagLayout
)
}
//TODO my implementation
}
})
(
recyclerView
.
adapter
as
VocabularyAdapter
).
tracker
=
tracker
...
...
app/src/main/java/com/paktalin/vocabularynotebook/ui/recycler_view/VocabularyAdapter.kt
View file @
ede577cb
...
...
@@ -40,7 +40,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
override
fun
onAttachedToRecyclerView
(
recyclerView
:
RecyclerView
)
{
super
.
onAttachedToRecyclerView
(
recyclerView
)
this
.
recyclerView
=
recyclerView
mainActivity
.
searchView
.
setOnQueryTextListener
(
OnQueryTextListener
(
this
@VocabularyAdapter
))
mainActivity
.
searchView
?
.
setOnQueryTextListener
(
OnQueryTextListener
(
this
@VocabularyAdapter
))
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
...
...
app/src/main/res/layout/content_main.xml
View file @
ede577cb
...
...
@@ -43,4 +43,6 @@
<include
layout=
"@layout/submit"
/>
<include
layout=
"@layout/tag"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/tag.xml
View file @
ede577cb
<?xml version="1.0" encoding="utf-8"?>
<
androidx.constraintlayout.widget.Constraint
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto
"
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/tagLayout
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:orientation=
"vertical"
>
android:layout_alignParentBottom=
"true"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<AutoCompleteTextView
android:id=
"@+id/
brand
"
android:layout_width=
"
0dp
"
android:id=
"@+id/
tag
"
android:layout_width=
"
match_parent
"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_marginLeft=
"8dp"
android:layout_marginTop=
"8dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
android:hint=
"@string/enter_tag"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
android:layout_margin=
"8dp"
android:hint=
"@string/enter_tag"
/>
</LinearLayout>
\ 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