Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
f495ce5f
Commit
f495ce5f
authored
Jan 15, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spotlight functionality inside de Toolbar
parent
4aa50996
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
28 deletions
+71
-28
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+38
-14
fragment_chat_rooms.xml
app/src/main/res/layout/fragment_chat_rooms.xml
+21
-14
chatrooms_menu.xml
app/src/main/res/menu/chatrooms_menu.xml
+10
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
f495ce5f
...
...
@@ -2,12 +2,12 @@ package chat.rocket.android.chatrooms.ui
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.util.DiffUtil
import
android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.support.v7.widget.SearchView
import
android.view.*
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
...
...
@@ -15,6 +15,7 @@ import chat.rocket.android.chatrooms.presentation.ChatRoomsView
import
chat.rocket.android.widget.DividerItemDecoration
import
chat.rocket.core.model.ChatRoom
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.fragment_chat_rooms.*
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.android.UI
...
...
@@ -23,7 +24,9 @@ import kotlinx.coroutines.experimental.launch
import
javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
private
var
searchView
:
SearchView
?
=
null
companion
object
{
fun
newInstance
()
=
ChatRoomsFragment
()
...
...
@@ -32,6 +35,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
fragment_chat_rooms
,
container
,
false
)
...
...
@@ -39,24 +43,40 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
floating_search_view
.
setOnQueryChangeListener
{
oldQuery
,
newQuery
->
floating_search_view
.
showProgress
()
presenter
.
chatRoomsByName
(
newQuery
)
if
(
oldQuery
.
isNotEmpty
()
&&
newQuery
.
isEmpty
())
{
floating_search_view
.
clearSuggestions
()
floating_search_view
.
hideProgress
()
}
}
activity
?.
apply
{
(
activity
as
AppCompatActivity
).
apply
{
recycler_view
.
layoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
recycler_view
.
addItemDecoration
(
DividerItemDecoration
(
this
,
144
,
32
))
recycler_view
.
adapter
=
ChatRoomsAdapter
(
this
)
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
if
(
supportActionBar
==
null
)
{
setSupportActionBar
(
toolbar
)
supportActionBar
?.
setDisplayHomeAsUpEnabled
(
false
)
supportActionBar
?.
setDisplayShowHomeEnabled
(
false
)
supportActionBar
?.
setDisplayShowTitleEnabled
(
false
)
}
}
presenter
.
loadChatRooms
()
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
?,
inflater
:
MenuInflater
?)
{
inflater
?.
inflate
(
R
.
menu
.
chatrooms_menu
,
menu
)
val
searchItem
=
menu
?.
findItem
(
R
.
id
.
action_search
)
searchView
=
searchItem
?.
actionView
as
SearchView
val
sv
=
searchView
sv
?.
setOnQueryTextListener
(
object
:
SearchView
.
OnQueryTextListener
{
override
fun
onQueryTextSubmit
(
query
:
String
?):
Boolean
{
return
queryChatRoomsByName
(
query
)
}
override
fun
onQueryTextChange
(
newText
:
String
?):
Boolean
{
return
queryChatRoomsByName
(
newText
)
}
})
}
/*override fun showChatRooms(dataSet: MutableList<ChatRoom>) {
floating_search_view.hideProgress()
}*/
...
...
@@ -69,7 +89,6 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
DiffUtil
.
calculateDiff
(
RoomsDiffCallback
(
adapter
.
dataSet
,
newDataSet
))
}.
await
()
floating_search_view
.
hideProgress
()
adapter
.
updateRooms
(
newDataSet
)
diff
.
dispatchUpdatesTo
(
adapter
)
}
...
...
@@ -84,6 +103,11 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
private
fun
queryChatRoomsByName
(
name
:
String
?):
Boolean
{
presenter
.
chatRoomsByName
(
name
?:
""
)
return
true
}
class
RoomsDiffCallback
(
private
val
oldRooms
:
List
<
ChatRoom
>,
private
val
newRooms
:
List
<
ChatRoom
>)
:
DiffUtil
.
Callback
()
{
override
fun
areItemsTheSame
(
oldItemPosition
:
Int
,
newItemPosition
:
Int
):
Boolean
{
...
...
app/src/main/res/layout/fragment_chat_rooms.xml
View file @
f495ce5f
<?xml version="1.0" encoding="utf-8"?>
<
Relative
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
android.support.design.widget.Coordinator
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
tools:context=
".chatrooms.ui.ChatRoomsFragment"
>
<include
android:id=
"@+id/layout_app_bar"
layout=
"@layout/app_bar"
android:background=
"@color/black"
/>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clipToPadding=
"false"
android:gravity=
"center_horizontal"
android:paddingTop=
"84dp"
/>
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
/>
<!--<com.arlib.floatingsearchview.FloatingSearchView-->
<!--android:id="@+id/floating_search_view"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--app:floatingSearch_close_search_on_keyboard_dismiss="true"-->
<!--app:floatingSearch_dimBackground="false"-->
<!--app:floatingSearch_dismissOnOutsideTouch="true"-->
<!--app:floatingSearch_leftActionMode="showSearch"-->
<!--app:floatingSearch_searchBarMarginLeft="4dp"-->
<!--app:floatingSearch_searchBarMarginRight="4dp"-->
<!--app:floatingSearch_searchBarMarginTop="28dp" />-->
<com.arlib.floatingsearchview.FloatingSearchView
android:id=
"@+id/floating_search_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:floatingSearch_close_search_on_keyboard_dismiss=
"true"
app:floatingSearch_dimBackground=
"false"
app:floatingSearch_dismissOnOutsideTouch=
"true"
app:floatingSearch_leftActionMode=
"showSearch"
app:floatingSearch_searchBarMarginLeft=
"4dp"
app:floatingSearch_searchBarMarginRight=
"4dp"
app:floatingSearch_searchBarMarginTop=
"28dp"
/>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
...
...
@@ -36,4 +43,4 @@
app:indicatorName=
"BallPulseIndicator"
tools:visibility=
"visible"
/>
</RelativeLayout>
\ No newline at end of file
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
app/src/main/res/menu/chatrooms_menu.xml
0 → 100644
View file @
f495ce5f
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/action_search"
android:icon=
"@android:drawable/ic_menu_search"
android:title=
"@string/search"
app:actionViewClass=
"android.support.v7.widget.SearchView"
app:showAsAction=
"always|collapseActionView"
/>
</menu>
\ No newline at end of file
app/src/main/res/values-pt-rBR/strings.xml
View file @
f495ce5f
...
...
@@ -35,5 +35,6 @@
<string
name=
"msg_content_description_log_in_using_twitter"
>
Fazer login através do Twitter
</string>
<string
name=
"msg_content_description_log_in_using_gitlab"
>
Fazer login através do Gitlab
</string>
<string
name=
"msg_you"
>
Você
</string>
<string
name=
"search"
>
Pesquisar
</string>
</resources>
app/src/main/res/values/strings.xml
View file @
f495ce5f
...
...
@@ -37,5 +37,6 @@
<string
name=
"msg_content_description_log_in_using_twitter"
>
Login using Twitter
</string>
<string
name=
"msg_content_description_log_in_using_gitlab"
>
Login using Gitlab
</string>
<string
name=
"msg_you"
>
You
</string>
<string
name=
"search"
>
Search
</string>
</resources>
\ 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