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
3f133546
Commit
3f133546
authored
Aug 09, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SidebarMainFragment.java
parent
0bb9d23c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
36 deletions
+28
-36
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+28
-36
No files found.
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
3f133546
...
...
@@ -33,12 +33,12 @@ import chat.rocket.core.SortDirection;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.Spotlight
Room
;
import
chat.rocket.core.models.Spotlight
;
import
chat.rocket.core.models.User
;
import
chat.rocket.persistence.realm.repositories.RealmRoomRepository
;
import
chat.rocket.persistence.realm.repositories.RealmServerInfoRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightR
oomR
epository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
com.jakewharton.rxbinding2.support.v7.widget.RxSearchView
;
import
com.jakewharton.rxbinding2.widget.RxCompoundButton
;
...
...
@@ -50,21 +50,17 @@ import java.util.List;
import
java.util.concurrent.TimeUnit
;
public
class
SidebarMainFragment
extends
AbstractFragment
implements
SidebarMainContract
.
View
{
private
static
final
String
HOSTNAME
=
"hostname"
;
private
SidebarMainContract
.
Presenter
presenter
;
private
RoomListAdapter
adapter
;
private
String
hostname
;
private
MethodCallHelper
methodCallHelper
;
private
RealmSpotlightR
oomRepository
realmSpotlightRoom
Repository
;
private
RealmSpotlightR
epository
realmSpotlight
Repository
;
private
SearchView
searchView
;
public
SidebarMainFragment
()
{
}
private
static
final
String
HOSTNAME
=
"hostname"
;
public
SidebarMainFragment
()
{}
/**
* create SidebarMainFragment with hostname.
...
...
@@ -87,7 +83,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
hostname
=
args
==
null
?
null
:
args
.
getString
(
HOSTNAME
);
methodCallHelper
=
new
MethodCallHelper
(
getContext
(),
hostname
);
realmSpotlightR
oomRepository
=
new
RealmSpotlightRoom
Repository
(
hostname
);
realmSpotlightR
epository
=
new
RealmSpotlight
Repository
(
hostname
);
RealmUserRepository
userRepository
=
new
RealmUserRepository
(
hostname
);
...
...
@@ -133,6 +129,8 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
setupLogoutButton
();
setupVersionInfo
();
searchView
=
rootView
.
findViewById
(
R
.
id
.
search
);
adapter
=
new
RoomListAdapter
();
adapter
.
setOnItemClickListener
(
new
RoomListAdapter
.
OnItemClickListener
()
{
@Override
...
...
@@ -142,42 +140,35 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
}
@Override
public
void
onItemClick
(
Spotlight
Room
spotlightRoom
)
{
public
void
onItemClick
(
Spotlight
spotlight
)
{
searchView
.
setQuery
(
null
,
false
);
searchView
.
clearFocus
();
methodCallHelper
.
joinRoom
(
spotlight
Room
.
getId
())
methodCallHelper
.
joinRoom
(
spotlight
.
getId
())
.
onSuccessTask
(
task
->
{
presenter
.
onSpotlight
RoomSelected
(
spotlightRoom
);
presenter
.
onSpotlight
Selected
(
spotlight
);
return
null
;
});
}
});
RecyclerView
recyclerView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
));
RecyclerView
recyclerView
=
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
));
recyclerView
.
setAdapter
(
adapter
);
searchView
=
(
SearchView
)
rootView
.
findViewById
(
R
.
id
.
search
);
RxSearchView
.
queryTextChanges
(
searchView
)
.
compose
(
bindToLifecycle
())
.
debounce
(
3
00
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
1
00
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
switchMap
(
it
->
{
if
(
it
.
length
()
==
0
)
{
.
switchMap
(
charSequence
->
{
if
(
charSequence
.
length
()
==
0
)
{
adapter
.
setMode
(
RoomListAdapter
.
MODE_ROOM
);
return
Observable
.
just
(
Collections
.<
SpotlightRoom
>
emptyList
());
return
Observable
.
just
(
Collections
.<
Spotlight
>
emptyList
());
}
else
{
adapter
.
setMode
(
RoomListAdapter
.
MODE_SPOTLIGHT
);
final
String
queryString
=
charSequence
.
toString
();
methodCallHelper
.
searchSpotlight
(
queryString
);
return
realmSpotlightRepository
.
getSuggestionsFor
(
queryString
,
SortDirection
.
ASC
,
10
).
toObservable
();
}
adapter
.
setMode
(
RoomListAdapter
.
MODE_SPOTLIGHT_ROOM
);
final
String
queryString
=
it
.
toString
();
methodCallHelper
.
searchSpotlightRooms
(
queryString
);
return
realmSpotlightRoomRepository
.
getSuggestionsFor
(
queryString
,
SortDirection
.
DESC
,
10
)
.
toObservable
();
})
.
subscribe
(
this
::
showSearchSuggestions
,
...
...
@@ -185,6 +176,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
);
}
private
void
showSearchSuggestions
(
List
<
Spotlight
>
spotlightList
)
{
adapter
.
setSpotlightList
(
spotlightList
);
}
@SuppressLint
(
"RxLeakedSubscription"
)
private
void
setupUserActionToggle
()
{
final
CompoundButton
toggleUserAction
=
...
...
@@ -305,7 +300,4 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
updateRoomListMode
(
user
);
}
private
void
showSearchSuggestions
(
List
<
SpotlightRoom
>
spotlightRooms
)
{
adapter
.
setSpotlightRoomList
(
spotlightRooms
);
}
}
}
\ 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