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
Show 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
...
@@ -22,10 +22,11 @@ import com.paktalin.vocabularynotebook.vocabulary.Sort
import
com.paktalin.vocabularynotebook.vocabulary.VocabSet
import
com.paktalin.vocabularynotebook.vocabulary.VocabSet
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.content_main.*
import
kotlinx.android.synthetic.main.tag.*
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
lateinit
var
searchView
:
SearchView
var
searchView
:
SearchView
?
=
null
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
lateinit
var
vocabularyAdapter
:
VocabularyAdapter
private
var
tracker
:
SelectionTracker
<
Long
>?
=
null
private
var
tracker
:
SelectionTracker
<
Long
>?
=
null
...
@@ -34,6 +35,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -34,6 +35,7 @@ class MainActivity : AppCompatActivity() {
setContentView
(
R
.
layout
.
activity_main
)
setContentView
(
R
.
layout
.
activity_main
)
FirestoreManager
.
vocabularyId
=
getSavedVocabularyIdFromPreferences
(
this
@MainActivity
)
FirestoreManager
.
vocabularyId
=
getSavedVocabularyIdFromPreferences
(
this
@MainActivity
)
recyclerView
.
adapter
=
VocabularyAdapter
(
VocabSet
(
mutableListOf
()),
this
@MainActivity
)
recyclerView
.
adapter
=
VocabularyAdapter
(
VocabSet
(
mutableListOf
()),
this
@MainActivity
)
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
setUpSwipeRefresh
()
setUpSwipeRefresh
()
setUpNavigationView
()
setUpNavigationView
()
hideKeyboard
()
hideKeyboard
()
...
@@ -43,7 +45,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -43,7 +45,7 @@ class MainActivity : AppCompatActivity() {
menuInflater
.
inflate
(
R
.
menu
.
options_menu
,
menu
)
menuInflater
.
inflate
(
R
.
menu
.
options_menu
,
menu
)
searchView
=
menu
!!
.
findItem
(
R
.
id
.
search
).
actionView
as
SearchView
searchView
=
menu
!!
.
findItem
(
R
.
id
.
search
).
actionView
as
SearchView
// extract vocabulary data only after searchView is initialized,
// 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
()
setUpVocabularyAdapter
()
return
true
return
true
}
}
...
@@ -89,7 +91,6 @@ class MainActivity : AppCompatActivity() {
...
@@ -89,7 +91,6 @@ class MainActivity : AppCompatActivity() {
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
addProgressBar
(
supportFragmentManager
,
R
.
id
.
container_main
)
FirestoreManager
().
extractVocabularyId
({
FirestoreManager
().
extractVocabularyId
({
recyclerView
.
layoutManager
=
LockableLayoutManager
(
this
@MainActivity
)
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
FirestoreManager
().
extractVocabulary
{
querySnapshot
->
run
{
run
{
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
if
(
querySnapshot
!=
null
&&
!
querySnapshot
.
isEmpty
)
{
...
@@ -138,8 +139,10 @@ class MainActivity : AppCompatActivity() {
...
@@ -138,8 +139,10 @@ class MainActivity : AppCompatActivity() {
super
.
onSelectionChanged
()
super
.
onSelectionChanged
()
if
(
tracker
?.
hasSelection
()
!!
)
{
if
(
tracker
?.
hasSelection
()
!!
)
{
Log
.
d
(
TAG
,
"selection ${tracker?.selection?.toList().toString()}"
)
Log
.
d
(
TAG
,
"selection ${tracker?.selection?.toList().toString()}"
)
visible
(
tagLayout
)
}
else
{
gone
(
tagLayout
)
}
}
//TODO my implementation
}
}
})
})
(
recyclerView
.
adapter
as
VocabularyAdapter
).
tracker
=
tracker
(
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
...
@@ -40,7 +40,7 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
override
fun
onAttachedToRecyclerView
(
recyclerView
:
RecyclerView
)
{
override
fun
onAttachedToRecyclerView
(
recyclerView
:
RecyclerView
)
{
super
.
onAttachedToRecyclerView
(
recyclerView
)
super
.
onAttachedToRecyclerView
(
recyclerView
)
this
.
recyclerView
=
recyclerView
this
.
recyclerView
=
recyclerView
mainActivity
.
searchView
.
setOnQueryTextListener
(
OnQueryTextListener
(
this
@VocabularyAdapter
))
mainActivity
.
searchView
?
.
setOnQueryTextListener
(
OnQueryTextListener
(
this
@VocabularyAdapter
))
}
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
...
...
app/src/main/res/layout/content_main.xml
View file @
ede577cb
...
@@ -43,4 +43,6 @@
...
@@ -43,4 +43,6 @@
<include
layout=
"@layout/submit"
/>
<include
layout=
"@layout/submit"
/>
<include
layout=
"@layout/tag"
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/tag.xml
View file @
ede577cb
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<
androidx.constraintlayout.widget.Constraint
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto
"
android:id=
"@+id/tagLayout
"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@color/colorPrimary"
android:background=
"@color/colorPrimary"
android:orientation=
"vertical"
>
android:layout_alignParentBottom=
"true"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<AutoCompleteTextView
<AutoCompleteTextView
android:id=
"@+id/
brand
"
android:id=
"@+id/
tag
"
android:layout_width=
"
0dp
"
android:layout_width=
"
match_parent
"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"8dp"
android:layout_margin=
"8dp"
android:layout_marginLeft=
"8dp"
android:hint=
"@string/enter_tag"
/>
android:layout_marginTop=
"8dp"
</LinearLayout>
android:layout_marginBottom=
"8dp"
\ No newline at end of file
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
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