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
857abccc
Unverified
Commit
857abccc
authored
Dec 01, 2017
by
Leonardo Aramaki
Committed by
GitHub
Dec 01, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #596 from RocketChat/fix/logout-and-login-same-user
[FIX] Logout and login with the same user
parents
9bcef2c4
b1a1e4a3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
423 additions
and
418 deletions
+423
-418
build.gradle
app/build.gradle
+3
-2
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+2
-5
MainContract.java
.../main/java/chat/rocket/android/activity/MainContract.java
+1
-1
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+3
-1
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+2
-3
LoginPresenter.java
...rocket/android/fragment/server_config/LoginPresenter.java
+73
-73
SidebarMainContract.java
.../rocket/android/fragment/sidebar/SidebarMainContract.java
+2
-2
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+298
-307
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+24
-18
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+5
-2
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+9
-3
MessageInteractor.kt
...in/java/chat/rocket/core/interactors/MessageInteractor.kt
+1
-1
No files found.
app/build.gradle
View file @
857abccc
...
@@ -3,7 +3,8 @@ apply plugin: 'io.fabric'
...
@@ -3,7 +3,8 @@ apply plugin: 'io.fabric'
repositories
{
repositories
{
maven
{
url
'https://maven.fabric.io/public'
}
maven
{
url
'https://maven.fabric.io/public'
}
maven
{
url
'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
// maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' }
maven
{
url
'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo'
}
}
}
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
...
@@ -100,7 +101,7 @@ ext {
...
@@ -100,7 +101,7 @@ ext {
playLibVersion
=
'11.6.0'
playLibVersion
=
'11.6.0'
stethoVersion
=
'1.5.0'
stethoVersion
=
'1.5.0'
stethoOkhttp3Version
=
'1.5.0'
stethoOkhttp3Version
=
'1.5.0'
stethoRealmVersion
=
'2.
1.0
'
stethoRealmVersion
=
'2.
2.2
'
rxbindingVersion
=
'2.0.0'
rxbindingVersion
=
'2.0.0'
rxlifecycleVersion
=
'2.1.0'
rxlifecycleVersion
=
'2.1.0'
icepickVersion
=
'3.2.0'
icepickVersion
=
'3.2.0'
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
857abccc
...
@@ -347,15 +347,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -347,15 +347,12 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
@DebugLog
@DebugLog
public
void
onLogout
()
{
public
void
onLogout
()
{
presenter
.
prepareToLogout
();
if
(
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
()
==
null
)
{
if
(
new
RocketChatCache
(
getApplicationContext
()).
getSelectedServerHostname
()
==
null
)
{
finish
();
LaunchUtil
.
showMainActivity
(
this
);
LaunchUtil
.
showMainActivity
(
this
);
}
else
{
}
else
{
onHostnameUpdated
();
onHostnameUpdated
();
}
}
}
}
@DebugLog
public
void
beforeLogoutCleanUp
()
{
presenter
.
beforeLogoutCleanUp
();
}
}
}
app/src/main/java/chat/rocket/android/activity/MainContract.java
View file @
857abccc
...
@@ -40,6 +40,6 @@ public interface MainContract {
...
@@ -40,6 +40,6 @@ public interface MainContract {
void
loadSignedInServers
(
String
hostname
);
void
loadSignedInServers
(
String
hostname
);
void
beforeLogoutCleanUp
();
void
prepareToLogout
();
}
}
}
}
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
857abccc
...
@@ -28,6 +28,7 @@ import chat.rocket.core.models.Session;
...
@@ -28,6 +28,7 @@ import chat.rocket.core.models.Session;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.PublicSettingRepository
;
import
chat.rocket.core.repositories.PublicSettingRepository
;
import
chat.rocket.core.utils.Pair
;
import
chat.rocket.core.utils.Pair
;
import
hugo.weaving.DebugLog
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
...
@@ -133,8 +134,9 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -133,8 +134,9 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
@DebugLog
@Override
@Override
public
void
beforeLogoutCleanUp
()
{
public
void
prepareToLogout
()
{
clearSubscriptions
();
clearSubscriptions
();
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
857abccc
...
@@ -77,7 +77,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -77,7 +77,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
success
->
{
success
->
{
if
(
success
)
{
if
(
!
success
)
{
connectivityManagerApi
.
keepAliveServer
();
connectivityManagerApi
.
keepAliveServer
();
}
}
},
},
...
@@ -89,14 +89,13 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -89,14 +89,13 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
@Override
@Override
public
void
loadMoreMessages
()
{
public
void
loadMoreMessages
()
{
final
Disposable
subscription
=
getSingleRoom
()
final
Disposable
subscription
=
getSingleRoom
()
.
flatMap
(
messageInteractor:
:
loadMoreMessages
)
.
flatMap
(
messageInteractor:
:
loadMoreMessages
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
success
->
{
success
->
{
if
(
success
)
{
if
(
!
success
)
{
connectivityManagerApi
.
keepAliveServer
();
connectivityManagerApi
.
keepAliveServer
();
}
}
},
},
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginPresenter.java
View file @
857abccc
...
@@ -18,81 +18,81 @@ import chat.rocket.core.repositories.PublicSettingRepository;
...
@@ -18,81 +18,81 @@ import chat.rocket.core.repositories.PublicSettingRepository;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
public
class
LoginPresenter
extends
BasePresenter
<
LoginContract
.
View
>
public
class
LoginPresenter
extends
BasePresenter
<
LoginContract
.
View
>
implements
LoginContract
.
Presenter
{
implements
LoginContract
.
Presenter
{
private
final
LoginServiceConfigurationRepository
loginServiceConfigurationRepository
;
private
final
LoginServiceConfigurationRepository
loginServiceConfigurationRepository
;
private
final
PublicSettingRepository
publicSettingRepository
;
private
final
PublicSettingRepository
publicSettingRepository
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
MethodCallHelper
methodCallHelper
;
public
LoginPresenter
(
LoginServiceConfigurationRepository
loginServiceConfigurationRepository
,
public
LoginPresenter
(
LoginServiceConfigurationRepository
loginServiceConfigurationRepository
,
PublicSettingRepository
publicSettingRepository
,
PublicSettingRepository
publicSettingRepository
,
MethodCallHelper
methodCallHelper
)
{
MethodCallHelper
methodCallHelper
)
{
this
.
loginServiceConfigurationRepository
=
loginServiceConfigurationRepository
;
this
.
loginServiceConfigurationRepository
=
loginServiceConfigurationRepository
;
this
.
publicSettingRepository
=
publicSettingRepository
;
this
.
publicSettingRepository
=
publicSettingRepository
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
methodCallHelper
=
methodCallHelper
;
}
@Override
public
void
bindView
(
@NonNull
LoginContract
.
View
view
)
{
super
.
bindView
(
view
);
getLoginServices
();
}
@Override
public
void
login
(
String
username
,
String
password
)
{
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
password
))
{
return
;
}
}
view
.
showLoader
();
@Override
public
void
bindView
(
@NonNull
LoginContract
.
View
view
)
{
addSubscription
(
super
.
bindView
(
view
);
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
LDAP
.
ENABLE
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
getLoginServices
();
.
observeOn
(
AndroidSchedulers
.
mainThread
())
}
.
subscribe
(
publicSettingOptional
->
doLogin
(
username
,
password
,
publicSettingOptional
),
@Override
Logger:
:
report
public
void
login
(
String
username
,
String
password
)
{
)
if
(
TextUtils
.
isEmpty
(
username
)
||
TextUtils
.
isEmpty
(
password
))
{
);
return
;
}
}
private
void
getLoginServices
()
{
view
.
showLoader
();
addSubscription
(
loginServiceConfigurationRepository
.
getAll
()
addSubscription
(
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
publicSettingRepository
.
getById
(
PublicSettingsConstants
.
LDAP
.
ENABLE
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribe
(
.
observeOn
(
AndroidSchedulers
.
mainThread
())
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
),
.
subscribe
(
Logger:
:
report
publicSettingOptional
->
doLogin
(
username
,
password
,
publicSettingOptional
),
)
Logger:
:
report
);
)
}
);
}
private
void
doLogin
(
String
username
,
String
password
,
Optional
<
PublicSetting
>
optional
)
{
call
(
username
,
password
,
optional
)
private
void
getLoginServices
()
{
.
continueWith
(
task
->
{
addSubscription
(
if
(
task
.
isFaulted
())
{
loginServiceConfigurationRepository
.
getAll
()
view
.
hideLoader
();
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
final
Exception
error
=
task
.
getError
();
.
subscribe
(
loginServiceConfigurations
->
view
.
showLoginServices
(
loginServiceConfigurations
),
if
(
error
instanceof
TwoStepAuthException
)
{
Logger:
:
report
view
.
showTwoStepAuth
();
)
}
else
{
);
view
.
showError
(
error
.
getMessage
());
}
}
return
null
;
},
Task
.
UI_THREAD_EXECUTOR
);
}
private
Task
<
Void
>
call
(
String
username
,
String
password
,
Optional
<
PublicSetting
>
optional
)
{
if
(
optional
.
isPresent
()
&&
optional
.
get
().
getValueAsBoolean
())
{
return
methodCallHelper
.
loginWithLdap
(
username
,
password
);
}
}
return
methodCallHelper
.
loginWithEmail
(
username
,
password
);
private
void
doLogin
(
String
username
,
String
password
,
Optional
<
PublicSetting
>
optional
)
{
}
call
(
username
,
password
,
optional
)
.
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
view
.
hideLoader
();
final
Exception
error
=
task
.
getError
();
if
(
error
instanceof
TwoStepAuthException
)
{
view
.
showTwoStepAuth
();
}
else
{
view
.
showError
(
error
.
getMessage
());
}
}
return
null
;
},
Task
.
UI_THREAD_EXECUTOR
);
}
private
Task
<
Void
>
call
(
String
username
,
String
password
,
Optional
<
PublicSetting
>
optional
)
{
if
(
optional
.
isPresent
()
&&
optional
.
get
().
getValueAsBoolean
())
{
return
methodCallHelper
.
loginWithLdap
(
username
,
password
);
}
return
methodCallHelper
.
loginWithEmail
(
username
,
password
);
}
}
}
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainContract.java
View file @
857abccc
...
@@ -25,7 +25,7 @@ public interface SidebarMainContract {
...
@@ -25,7 +25,7 @@ public interface SidebarMainContract {
void
show
(
User
user
);
void
show
(
User
user
);
void
on
LogoutCleanUp
();
void
on
PreparedToLogOut
();
}
}
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
...
@@ -48,6 +48,6 @@ public interface SidebarMainContract {
...
@@ -48,6 +48,6 @@ public interface SidebarMainContract {
void
onLogout
(
Continuation
<
Void
,
Object
>
continuation
);
void
onLogout
(
Continuation
<
Void
,
Object
>
continuation
);
void
beforeLogoutCleanUp
();
void
prepareToLogOut
();
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
857abccc
...
@@ -22,7 +22,6 @@ import java.util.ArrayList;
...
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
bolts.Task
;
import
chat.rocket.android.BuildConfig
;
import
chat.rocket.android.BuildConfig
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
...
@@ -51,323 +50,315 @@ import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
...
@@ -51,323 +50,315 @@ import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSessionRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
hugo.weaving.DebugLog
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
public
class
SidebarMainFragment
extends
AbstractFragment
implements
SidebarMainContract
.
View
{
public
class
SidebarMainFragment
extends
AbstractFragment
implements
SidebarMainContract
.
View
{
private
SidebarMainContract
.
Presenter
presenter
;
private
SidebarMainContract
.
Presenter
presenter
;
private
RoomListAdapter
adapter
;
private
RoomListAdapter
adapter
;
private
SearchView
searchView
;
private
SearchView
searchView
;
private
TextView
loadMoreResultsText
;
private
TextView
loadMoreResultsText
;
private
List
<
RoomSidebar
>
roomSidebarList
=
Collections
.
emptyList
();
private
List
<
RoomSidebar
>
roomSidebarList
=
Collections
.
emptyList
();
private
Disposable
spotlightDisposable
;
private
Disposable
spotlightDisposable
;
private
String
hostname
;
private
String
hostname
;
private
static
final
String
HOSTNAME
=
"hostname"
;
private
static
final
String
HOSTNAME
=
"hostname"
;
public
SidebarMainFragment
()
{}
public
SidebarMainFragment
()
{
}
/**
* build SidebarMainFragment with hostname.
*/
public
static
SidebarMainFragment
create
(
String
hostname
)
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
HOSTNAME
,
hostname
);
SidebarMainFragment
fragment
=
new
SidebarMainFragment
();
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
hostname
=
getArguments
().
getString
(
HOSTNAME
);
RealmUserRepository
userRepository
=
new
RealmUserRepository
(
hostname
);
AbsoluteUrlHelper
absoluteUrlHelper
=
new
AbsoluteUrlHelper
(
hostname
,
new
RealmServerInfoRepository
(),
userRepository
,
new
SessionInteractor
(
new
RealmSessionRepository
(
hostname
))
);
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getContext
().
getApplicationContext
());
presenter
=
new
SidebarMainPresenter
(
hostname
,
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
userRepository
,
rocketChatCache
,
absoluteUrlHelper
,
new
MethodCallHelper
(
getContext
(),
hostname
),
new
RealmSpotlightRepository
(
hostname
)
);
}
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
view
=
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
presenter
.
bindView
(
this
);
return
view
;
}
@Override
public
void
onDestroyView
()
{
presenter
.
release
();
super
.
onDestroyView
();
}
@Override
public
void
onResume
()
{
super
.
onResume
();
}
@Override
public
void
onPause
()
{
super
.
onPause
();
}
@Override
protected
int
getLayout
()
{
return
R
.
layout
.
fragment_sidebar_main
;
}
@SuppressLint
(
"RxLeakedSubscription"
)
@Override
protected
void
onSetupView
()
{
setupUserActionToggle
();
setupUserStatusButtons
();
setupLogoutButton
();
setupVersionInfo
();
searchView
=
rootView
.
findViewById
(
R
.
id
.
search
);
adapter
=
new
RoomListAdapter
();
adapter
.
setOnItemClickListener
(
new
RoomListAdapter
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
RoomSidebar
roomSidebar
)
{
searchView
.
setQuery
(
null
,
false
);
searchView
.
clearFocus
();
presenter
.
onRoomSelected
(
roomSidebar
);
}
@Override
/**
public
void
onItemClick
(
Spotlight
spotlight
)
{
* build SidebarMainFragment with hostname.
searchView
.
setQuery
(
null
,
false
);
*/
searchView
.
clearFocus
();
public
static
SidebarMainFragment
create
(
String
hostname
)
{
presenter
.
onSpotlightSelected
(
spotlight
);
Bundle
args
=
new
Bundle
();
}
args
.
putString
(
HOSTNAME
,
hostname
);
});
SidebarMainFragment
fragment
=
new
SidebarMainFragment
();
RecyclerView
recyclerView
=
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
fragment
.
setArguments
(
args
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
));
recyclerView
.
setAdapter
(
adapter
);
return
fragment
;
}
loadMoreResultsText
=
rootView
.
findViewById
(
R
.
id
.
text_load_more_results
);
@Override
RxSearchView
.
queryTextChanges
(
searchView
)
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
.
observeOn
(
AndroidSchedulers
.
mainThread
())
super
.
onCreate
(
savedInstanceState
);
.
subscribe
(
charSequence
->
{
if
(
spotlightDisposable
!=
null
&&
!
spotlightDisposable
.
isDisposed
())
{
hostname
=
getArguments
().
getString
(
HOSTNAME
);
spotlightDisposable
.
dispose
();
RealmUserRepository
userRepository
=
new
RealmUserRepository
(
hostname
);
}
presenter
.
disposeSubscriptions
();
AbsoluteUrlHelper
absoluteUrlHelper
=
new
AbsoluteUrlHelper
(
if
(
charSequence
.
length
()
==
0
)
{
hostname
,
loadMoreResultsText
.
setVisibility
(
View
.
GONE
);
new
RealmServerInfoRepository
(),
adapter
.
setMode
(
RoomListAdapter
.
MODE_ROOM
);
userRepository
,
presenter
.
bindView
(
this
);
new
SessionInteractor
(
new
RealmSessionRepository
(
hostname
))
}
else
{
filterRoomSidebarList
(
charSequence
);
}
});
loadMoreResultsText
.
setOnClickListener
(
view
->
loadMoreResults
());
}
@Override
public
void
showRoomSidebarList
(
@NonNull
List
<
RoomSidebar
>
roomSidebarList
)
{
this
.
roomSidebarList
=
roomSidebarList
;
adapter
.
setRoomSidebarList
(
roomSidebarList
);
}
@Override
public
void
filterRoomSidebarList
(
CharSequence
term
)
{
List
<
RoomSidebar
>
filteredRoomSidebarList
=
new
ArrayList
<>();
for
(
RoomSidebar
roomSidebar:
roomSidebarList
)
{
if
(
roomSidebar
.
getRoomName
().
contains
(
term
))
{
filteredRoomSidebarList
.
add
(
roomSidebar
);
}
}
if
(
filteredRoomSidebarList
.
isEmpty
())
{
loadMoreResults
();
}
else
{
loadMoreResultsText
.
setVisibility
(
View
.
VISIBLE
);
adapter
.
setMode
(
RoomListAdapter
.
MODE_ROOM
);
adapter
.
setRoomSidebarList
(
filteredRoomSidebarList
);
}
}
private
void
loadMoreResults
()
{
spotlightDisposable
=
presenter
.
searchSpotlight
(
searchView
.
getQuery
().
toString
())
.
toObservable
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
this
::
showSearchSuggestions
);
}
private
void
showSearchSuggestions
(
List
<
Spotlight
>
spotlightList
)
{
loadMoreResultsText
.
setVisibility
(
View
.
GONE
);
adapter
.
setMode
(
RoomListAdapter
.
MODE_SPOTLIGHT
);
adapter
.
setSpotlightList
(
spotlightList
);
}
@SuppressLint
(
"RxLeakedSubscription"
)
private
void
setupUserActionToggle
()
{
final
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
toggleUserAction
.
setFocusableInTouchMode
(
false
);
rootView
.
findViewById
(
R
.
id
.
user_info_container
).
setOnClickListener
(
view
->
toggleUserAction
.
toggle
());
RxCompoundButton
.
checkedChanges
(
toggleUserAction
)
.
compose
(
bindToLifecycle
())
.
subscribe
(
this
::
showUserActionContainer
,
Logger:
:
report
);
);
}
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getContext
().
getApplicationContext
());
public
void
showUserActionContainer
(
boolean
show
)
{
rootView
.
findViewById
(
R
.
id
.
user_action_outer_container
)
presenter
=
new
SidebarMainPresenter
(
.
setVisibility
(
show
?
View
.
VISIBLE
:
View
.
GONE
);
hostname
,
}
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
userRepository
,
public
void
toggleUserActionContainer
(
boolean
checked
)
{
rocketChatCache
,
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
absoluteUrlHelper
,
toggleUserAction
.
setChecked
(
checked
);
new
MethodCallHelper
(
getContext
(),
hostname
),
}
new
RealmSpotlightRepository
(
hostname
)
);
@Override
}
public
void
showScreen
()
{
rootView
.
setVisibility
(
View
.
VISIBLE
);
@Nullable
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
@Override
View
view
=
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
public
void
showEmptyScreen
()
{
presenter
.
bindView
(
this
);
rootView
.
setVisibility
(
View
.
INVISIBLE
);
return
view
;
}
}
@Override
@Override
public
void
show
(
User
user
)
{
public
void
onDestroyView
()
{
onRenderCurrentUser
(
user
);
presenter
.
release
();
updateRoomListMode
();
super
.
onDestroyView
();
}
}
private
void
setupUserStatusButtons
()
{
@Override
rootView
.
findViewById
(
R
.
id
.
btn_status_online
).
setOnClickListener
(
view
->
{
public
void
onResume
()
{
presenter
.
onUserOnline
();
super
.
onResume
();
closeUserActionContainer
();
});
}
rootView
.
findViewById
(
R
.
id
.
btn_status_away
).
setOnClickListener
(
view
->
{
presenter
.
onUserAway
();
@Override
closeUserActionContainer
();
public
void
onPause
()
{
});
rootView
.
findViewById
(
R
.
id
.
btn_status_busy
).
setOnClickListener
(
view
->
{
super
.
onPause
();
presenter
.
onUserBusy
();
}
closeUserActionContainer
();
});
@Override
rootView
.
findViewById
(
R
.
id
.
btn_status_invisible
).
setOnClickListener
(
view
->
{
protected
int
getLayout
()
{
presenter
.
onUserOffline
();
return
R
.
layout
.
fragment_sidebar_main
;
closeUserActionContainer
();
}
});
}
@SuppressLint
(
"RxLeakedSubscription"
)
@Override
private
void
onRenderCurrentUser
(
User
user
)
{
protected
void
onSetupView
()
{
if
(
user
!=
null
)
{
setupUserActionToggle
();
UserRenderer
userRenderer
=
new
UserRenderer
(
user
);
setupUserStatusButtons
();
userRenderer
.
showAvatar
(
rootView
.
findViewById
(
R
.
id
.
current_user_avatar
),
hostname
);
setupLogoutButton
();
userRenderer
.
showUsername
(
rootView
.
findViewById
(
R
.
id
.
current_user_name
));
setupVersionInfo
();
userRenderer
.
showStatusColor
(
rootView
.
findViewById
(
R
.
id
.
current_user_status
));
searchView
=
rootView
.
findViewById
(
R
.
id
.
search
);
adapter
=
new
RoomListAdapter
();
adapter
.
setOnItemClickListener
(
new
RoomListAdapter
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
RoomSidebar
roomSidebar
)
{
searchView
.
setQuery
(
null
,
false
);
searchView
.
clearFocus
();
presenter
.
onRoomSelected
(
roomSidebar
);
}
@Override
public
void
onItemClick
(
Spotlight
spotlight
)
{
searchView
.
setQuery
(
null
,
false
);
searchView
.
clearFocus
();
presenter
.
onSpotlightSelected
(
spotlight
);
}
});
RecyclerView
recyclerView
=
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
VERTICAL
,
false
));
recyclerView
.
setAdapter
(
adapter
);
loadMoreResultsText
=
rootView
.
findViewById
(
R
.
id
.
text_load_more_results
);
RxSearchView
.
queryTextChanges
(
searchView
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
charSequence
->
{
if
(
spotlightDisposable
!=
null
&&
!
spotlightDisposable
.
isDisposed
())
{
spotlightDisposable
.
dispose
();
}
presenter
.
disposeSubscriptions
();
if
(
charSequence
.
length
()
==
0
)
{
loadMoreResultsText
.
setVisibility
(
View
.
GONE
);
adapter
.
setMode
(
RoomListAdapter
.
MODE_ROOM
);
presenter
.
bindView
(
this
);
}
else
{
filterRoomSidebarList
(
charSequence
);
}
});
loadMoreResultsText
.
setOnClickListener
(
view
->
loadMoreResults
());
}
@Override
public
void
showRoomSidebarList
(
@NonNull
List
<
RoomSidebar
>
roomSidebarList
)
{
this
.
roomSidebarList
=
roomSidebarList
;
adapter
.
setRoomSidebarList
(
roomSidebarList
);
}
@Override
public
void
filterRoomSidebarList
(
CharSequence
term
)
{
List
<
RoomSidebar
>
filteredRoomSidebarList
=
new
ArrayList
<>();
for
(
RoomSidebar
roomSidebar
:
roomSidebarList
)
{
if
(
roomSidebar
.
getRoomName
().
contains
(
term
))
{
filteredRoomSidebarList
.
add
(
roomSidebar
);
}
}
if
(
filteredRoomSidebarList
.
isEmpty
())
{
loadMoreResults
();
}
else
{
loadMoreResultsText
.
setVisibility
(
View
.
VISIBLE
);
adapter
.
setMode
(
RoomListAdapter
.
MODE_ROOM
);
adapter
.
setRoomSidebarList
(
filteredRoomSidebarList
);
}
}
private
void
loadMoreResults
()
{
spotlightDisposable
=
presenter
.
searchSpotlight
(
searchView
.
getQuery
().
toString
())
.
toObservable
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
this
::
showSearchSuggestions
);
}
private
void
showSearchSuggestions
(
List
<
Spotlight
>
spotlightList
)
{
loadMoreResultsText
.
setVisibility
(
View
.
GONE
);
adapter
.
setMode
(
RoomListAdapter
.
MODE_SPOTLIGHT
);
adapter
.
setSpotlightList
(
spotlightList
);
}
@SuppressLint
(
"RxLeakedSubscription"
)
private
void
setupUserActionToggle
()
{
final
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
toggleUserAction
.
setFocusableInTouchMode
(
false
);
rootView
.
findViewById
(
R
.
id
.
user_info_container
).
setOnClickListener
(
view
->
toggleUserAction
.
toggle
());
RxCompoundButton
.
checkedChanges
(
toggleUserAction
)
.
compose
(
bindToLifecycle
())
.
subscribe
(
this
::
showUserActionContainer
,
Logger:
:
report
);
}
}
}
public
void
showUserActionContainer
(
boolean
show
)
{
private
void
updateRoomListMode
()
{
rootView
.
findViewById
(
R
.
id
.
user_action_outer_container
)
final
List
<
RoomListHeader
>
roomListHeaders
=
new
ArrayList
<>();
.
setVisibility
(
show
?
View
.
VISIBLE
:
View
.
GONE
);
}
roomListHeaders
.
add
(
new
UnreadRoomListHeader
(
getString
(
R
.
string
.
fragment_sidebar_main_unread_rooms_title
)
public
void
toggleUserActionContainer
(
boolean
checked
)
{
));
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
toggleUserAction
.
setChecked
(
checked
);
roomListHeaders
.
add
(
new
FavoriteRoomListHeader
(
}
getString
(
R
.
string
.
fragment_sidebar_main_favorite_title
)
));
@Override
public
void
showScreen
()
{
roomListHeaders
.
add
(
new
LivechatRoomListHeader
(
rootView
.
setVisibility
(
View
.
VISIBLE
);
getString
(
R
.
string
.
fragment_sidebar_main_livechat_title
)
}
));
@Override
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
public
void
showEmptyScreen
()
{
getString
(
R
.
string
.
fragment_sidebar_main_channels_title
),
rootView
.
setVisibility
(
View
.
INVISIBLE
);
()
->
showAddRoomDialog
(
AddChannelDialogFragment
.
create
(
hostname
))
}
));
roomListHeaders
.
add
(
new
DirectMessageRoomListHeader
(
@Override
getString
(
R
.
string
.
fragment_sidebar_main_direct_messages_title
),
public
void
show
(
User
user
)
{
()
->
showAddRoomDialog
(
AddDirectMessageDialogFragment
.
create
(
hostname
))
onRenderCurrentUser
(
user
);
));
updateRoomListMode
();
}
adapter
.
setRoomListHeaders
(
roomListHeaders
);
}
private
void
setupUserStatusButtons
()
{
rootView
.
findViewById
(
R
.
id
.
btn_status_online
).
setOnClickListener
(
view
->
{
@Override
presenter
.
onUserOnline
();
public
void
onLogoutCleanUp
()
{
closeUserActionContainer
();
Activity
activity
=
getActivity
();
});
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
rootView
.
findViewById
(
R
.
id
.
btn_status_away
).
setOnClickListener
(
view
->
{
((
MainActivity
)
activity
).
onLogout
();
presenter
.
onUserAway
();
presenter
.
onLogout
(
task
->
{
closeUserActionContainer
();
if
(
task
.
isFaulted
())
{
});
return
Task
.
forError
(
task
.
getError
());
rootView
.
findViewById
(
R
.
id
.
btn_status_busy
).
setOnClickListener
(
view
->
{
presenter
.
onUserBusy
();
closeUserActionContainer
();
});
rootView
.
findViewById
(
R
.
id
.
btn_status_invisible
).
setOnClickListener
(
view
->
{
presenter
.
onUserOffline
();
closeUserActionContainer
();
});
}
private
void
onRenderCurrentUser
(
User
user
)
{
if
(
user
!=
null
)
{
UserRenderer
userRenderer
=
new
UserRenderer
(
user
);
userRenderer
.
showAvatar
(
rootView
.
findViewById
(
R
.
id
.
current_user_avatar
),
hostname
);
userRenderer
.
showUsername
(
rootView
.
findViewById
(
R
.
id
.
current_user_name
));
userRenderer
.
showStatusColor
(
rootView
.
findViewById
(
R
.
id
.
current_user_status
));
}
}
return
null
;
});
}
}
}
private
void
updateRoomListMode
()
{
private
void
setupLogoutButton
()
{
final
List
<
RoomListHeader
>
roomListHeaders
=
new
ArrayList
<>();
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
closeUserActionContainer
();
roomListHeaders
.
add
(
new
UnreadRoomListHeader
(
// Clear relative data and set new hostname if any.
getString
(
R
.
string
.
fragment_sidebar_main_unread_rooms_title
)
presenter
.
beforeLogoutCleanUp
();
));
final
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
roomListHeaders
.
add
(
new
FavoriteRoomListHeader
(
// Clear subscriptions on MainPresenter.
getString
(
R
.
string
.
fragment_sidebar_main_favorite_title
)
((
MainActivity
)
activity
).
beforeLogoutCleanUp
();
));
}
});
roomListHeaders
.
add
(
new
LivechatRoomListHeader
(
}
getString
(
R
.
string
.
fragment_sidebar_main_livechat_title
)
));
public
void
clearSearchViewFocus
()
{
searchView
.
clearFocus
();
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
}
getString
(
R
.
string
.
fragment_sidebar_main_channels_title
),
()
->
showAddRoomDialog
(
AddChannelDialogFragment
.
create
(
hostname
))
public
void
closeUserActionContainer
()
{
));
final
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
roomListHeaders
.
add
(
new
DirectMessageRoomListHeader
(
if
(
toggleUserAction
!=
null
&&
toggleUserAction
.
isChecked
())
{
getString
(
R
.
string
.
fragment_sidebar_main_direct_messages_title
),
toggleUserAction
.
setChecked
(
false
);
()
->
showAddRoomDialog
(
AddDirectMessageDialogFragment
.
create
(
hostname
))
));
adapter
.
setRoomListHeaders
(
roomListHeaders
);
}
@DebugLog
@Override
public
void
onPreparedToLogOut
()
{
final
Activity
activity
=
getActivity
();
if
(
activity
!=
null
&&
activity
instanceof
MainActivity
)
{
((
MainActivity
)
activity
).
onLogout
();
}
}
private
void
setupLogoutButton
()
{
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
closeUserActionContainer
();
// Clear relative data and set new hostname if any.
presenter
.
prepareToLogOut
();
});
}
}
}
private
void
setupVersionInfo
()
{
public
void
clearSearchViewFocus
()
{
TextView
versionInfoView
=
rootView
.
findViewById
(
R
.
id
.
version_info
);
searchView
.
clearFocus
();
versionInfoView
.
setText
(
getString
(
R
.
string
.
version_info_text
,
BuildConfig
.
VERSION_NAME
));
}
}
private
void
showAddRoomDialog
(
DialogFragment
dialog
)
{
public
void
closeUserActionContainer
()
{
dialog
.
show
(
getFragmentManager
(),
"AbstractAddRoomDialogFragment"
);
final
CompoundButton
toggleUserAction
=
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
);
}
if
(
toggleUserAction
!=
null
&&
toggleUserAction
.
isChecked
())
{
toggleUserAction
.
setChecked
(
false
);
}
}
private
void
setupVersionInfo
()
{
TextView
versionInfoView
=
rootView
.
findViewById
(
R
.
id
.
version_info
);
versionInfoView
.
setText
(
getString
(
R
.
string
.
version_info_text
,
BuildConfig
.
VERSION_NAME
));
}
private
void
showAddRoomDialog
(
DialogFragment
dialog
)
{
dialog
.
show
(
getFragmentManager
(),
"AbstractAddRoomDialogFragment"
);
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
857abccc
...
@@ -18,7 +18,6 @@ import chat.rocket.android.helper.LogIfError;
...
@@ -18,7 +18,6 @@ import chat.rocket.android.helper.LogIfError;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.Logger
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.android.shared.BasePresenter
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.Room
;
...
@@ -33,6 +32,7 @@ import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository;
...
@@ -33,6 +32,7 @@ import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
import
io.realm.Realm
;
public
class
SidebarMainPresenter
extends
BasePresenter
<
SidebarMainContract
.
View
>
implements
SidebarMainContract
.
Presenter
{
public
class
SidebarMainPresenter
extends
BasePresenter
<
SidebarMainContract
.
View
>
implements
SidebarMainContract
.
Presenter
{
private
final
String
hostname
;
private
final
String
hostname
;
...
@@ -150,20 +150,26 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -150,20 +150,26 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
}
}
@Override
@Override
public
void
beforeLogoutCleanUp
()
{
public
void
prepareToLogOut
()
{
clearSubscriptions
();
onLogout
(
task
->
{
String
currentHostname
=
rocketChatCache
.
getSelectedServerHostname
();
if
(
task
.
isFaulted
())
{
RealmHelper
realmHelper
=
RealmStore
.
getOrCreate
(
currentHostname
);
return
Task
.
forError
(
task
.
getError
());
realmHelper
.
executeTransaction
(
realm
->
{
}
realm
.
executeTransactionAsync
(
realmObj
->
realmObj
.
deleteAll
());
CookieManager
.
getInstance
().
removeAllCookie
();
clearSubscriptions
();
ConnectivityManagerApi
connectivityManagerApi
=
ConnectivityManager
.
getInstance
(
RocketChatApplication
.
getInstance
());
String
currentHostname
=
rocketChatCache
.
getSelectedServerHostname
();
connectivityManagerApi
.
removeServer
(
currentHostname
);
RealmHelper
realmHelper
=
RealmStore
.
getOrCreate
(
currentHostname
);
rocketChatCache
.
removeHostname
(
currentHostname
);
return
realmHelper
.
executeTransaction
(
realm
->
{
rocketChatCache
.
removeSelectedRoomId
(
currentHostname
);
rocketChatCache
.
removeHostname
(
currentHostname
);
rocketChatCache
.
setSelectedServerHostname
(
rocketChatCache
.
getFirstLoggedHostnameIfAny
());
rocketChatCache
.
removeSelectedRoomId
(
currentHostname
);
view
.
onLogoutCleanUp
();
rocketChatCache
.
setSelectedServerHostname
(
rocketChatCache
.
getFirstLoggedHostnameIfAny
());
return
null
;
realm
.
executeTransactionAsync
(
Realm:
:
deleteAll
);
view
.
onPreparedToLogOut
();
ConnectivityManager
.
getInstance
(
RocketChatApplication
.
getInstance
())
.
removeServer
(
hostname
);
CookieManager
.
getInstance
().
removeAllCookie
();
return
null
;
});
});
});
}
}
...
@@ -223,11 +229,11 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -223,11 +229,11 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
this
::
processUsers
,
Logger:
:
report
);
.
subscribe
(
this
::
processUsers
,
Logger:
:
report
);
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
void
processUsers
(
List
<
User
>
userList
)
{
private
void
processUsers
(
List
<
User
>
userList
)
{
for
(
User
user:
userList
)
{
for
(
User
user
:
userList
)
{
for
(
RoomSidebar
roomSidebar
:
roomSidebarList
)
{
for
(
RoomSidebar
roomSidebar
:
roomSidebarList
)
{
if
(
roomSidebar
.
getRoomName
().
equals
(
user
.
getUsername
()))
{
if
(
roomSidebar
.
getRoomName
().
equals
(
user
.
getUsername
()))
{
roomSidebar
.
setUserStatus
(
user
.
getStatus
());
roomSidebar
.
setUserStatus
(
user
.
getStatus
());
}
}
...
...
app/src/main/java/chat/rocket/android/service/RealmBasedConnectivityManager.java
View file @
857abccc
...
@@ -279,8 +279,11 @@ import io.reactivex.subjects.BehaviorSubject;
...
@@ -279,8 +279,11 @@ import io.reactivex.subjects.BehaviorSubject;
if
(
serviceInterface
!=
null
)
{
if
(
serviceInterface
!=
null
)
{
return
serviceInterface
.
disconnectFromServer
(
hostname
)
return
serviceInterface
.
disconnectFromServer
(
hostname
)
// //after disconnection from server, remove HOSTNAME key from HashMap
//after disconnection from server, remove HOSTNAME key from HashMap
.
doAfterTerminate
(()
->
serverConnectivityList
.
remove
(
hostname
));
.
doAfterTerminate
(()
->
{
serverConnectivityList
.
remove
(
hostname
);
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
});
}
else
{
}
else
{
return
Single
.
error
(
new
IllegalStateException
(
"not prepared"
));
return
Single
.
error
(
new
IllegalStateException
(
"not prepared"
));
}
}
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
857abccc
...
@@ -229,6 +229,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -229,6 +229,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
RxWebSocketCallback
.
Close
result
=
_task
.
getResult
();
RxWebSocketCallback
.
Close
result
=
_task
.
getResult
();
if
(
result
.
code
==
DDPClient
.
REASON_NETWORK_ERROR
)
{
if
(
result
.
code
==
DDPClient
.
REASON_NETWORK_ERROR
)
{
reconnect
();
reconnect
();
}
else
{
unregisterListenersAndClose
();
}
}
return
null
;
return
null
;
});
});
...
@@ -333,8 +335,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -333,8 +335,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
.
findAll
());
.
findAll
());
if
(
sessions
!=
null
&&
sessions
.
size
()
>
0
)
{
if
(
sessions
!=
null
&&
sessions
.
size
()
>
0
)
{
//
i
f we have a session try to resume it. At this point we're probably recovering from
//
I
f we have a session try to resume it. At this point we're probably recovering from
// a disconnection state
// a disconnection state
.
final
CompositeDisposable
disposables
=
new
CompositeDisposable
();
final
CompositeDisposable
disposables
=
new
CompositeDisposable
();
MethodCallHelper
methodCall
=
new
MethodCallHelper
(
realmHelper
);
MethodCallHelper
methodCall
=
new
MethodCallHelper
(
realmHelper
);
disposables
.
add
(
disposables
.
add
(
...
@@ -351,7 +353,11 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -351,7 +353,11 @@ public class RocketChatWebSocketThread extends HandlerThread {
createObserversAndRegister
();
createObserversAndRegister
();
disposables
.
clear
();
disposables
.
clear
();
},
},
error
->
logErrorAndUnsubscribe
(
disposables
,
error
)
error
->
{
logErrorAndUnsubscribe
(
disposables
,
error
);
connectivityManager
.
notifyConnectionLost
(
hostname
,
DDPClient
.
REASON_NETWORK_ERROR
);
}
)
)
);
);
}
else
{
}
else
{
...
...
rocket-chat-core/src/main/java/chat/rocket/core/interactors/MessageInteractor.kt
View file @
857abccc
...
@@ -19,7 +19,7 @@ class MessageInteractor(private val messageRepository: MessageRepository,
...
@@ -19,7 +19,7 @@ class MessageInteractor(private val messageRepository: MessageRepository,
val
roomHistoryState
=
RoomHistoryState
.
builder
()
val
roomHistoryState
=
RoomHistoryState
.
builder
()
.
setRoomId
(
room
.
roomId
)
.
setRoomId
(
room
.
roomId
)
.
setSyncState
(
SyncState
.
NOT_SYNCED
)
.
setSyncState
(
SyncState
.
NOT_SYNCED
)
.
setCount
(
10
0
)
.
setCount
(
5
0
)
.
setReset
(
true
)
.
setReset
(
true
)
.
setComplete
(
false
)
.
setComplete
(
false
)
.
setTimestamp
(
0
)
.
setTimestamp
(
0
)
...
...
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