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
b40028f8
Commit
b40028f8
authored
Feb 24, 2017
by
Tiago Cunha
Committed by
GitHub
Feb 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #220 from RocketChat/fix/crashes
Fix crashes
parents
9120eea0
e06c4156
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
83 additions
and
29 deletions
+83
-29
AbstractFragmentActivity.java
...hat/rocket/android/activity/AbstractFragmentActivity.java
+1
-2
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+3
-1
MainPresenter.java
...main/java/chat/rocket/android/activity/MainPresenter.java
+19
-3
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+2
-0
SidebarMainContract.java
.../rocket/android/fragment/sidebar/SidebarMainContract.java
+2
-0
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+7
-10
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+11
-1
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
RealmSettings.java
...at/rocket/persistence/realm/models/ddp/RealmSettings.java
+1
-1
RealmRoomRepository.java
...t/persistence/realm/repositories/RealmRoomRepository.java
+26
-9
MessageInteractor.java
.../java/chat/rocket/core/interactors/MessageInteractor.java
+3
-0
Preferences.java
...re/src/main/java/chat/rocket/core/models/Preferences.java
+1
-0
Settings.java
...-core/src/main/java/chat/rocket/core/models/Settings.java
+3
-0
User.java
...chat-core/src/main/java/chat/rocket/core/models/User.java
+1
-0
RoomRepository.java
...in/java/chat/rocket/core/repositories/RoomRepository.java
+2
-1
No files found.
app/src/main/java/chat/rocket/android/activity/AbstractFragmentActivity.java
View file @
b40028f8
...
@@ -25,9 +25,8 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
...
@@ -25,9 +25,8 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
Icepick
.
saveInstanceState
(
this
,
outState
);
Icepick
.
saveInstanceState
(
this
,
outState
);
}
}
protected
abstract
@IdRes
@IdRes
int
getLayoutContainerForFragment
();
protected
abstract
int
getLayoutContainerForFragment
();
@Override
@Override
public
final
void
onBackPressed
()
{
public
final
void
onBackPressed
()
{
...
...
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
b40028f8
...
@@ -10,6 +10,7 @@ import android.view.View;
...
@@ -10,6 +10,7 @@ import android.view.View;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
...
@@ -136,7 +137,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -136,7 +137,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
createRoomInteractor
,
createRoomInteractor
,
sessionInteractor
,
sessionInteractor
,
new
MethodCallHelper
(
this
,
hostname
),
new
MethodCallHelper
(
this
,
hostname
),
ConnectivityManager
.
getInstance
(
getApplicationContext
())
ConnectivityManager
.
getInstance
(
getApplicationContext
()),
new
RocketChatCache
(
this
)
);
);
updateSidebarMainFragment
();
updateSidebarMainFragment
();
...
...
app/src/main/java/chat/rocket/android/activity/MainPresenter.java
View file @
b40028f8
...
@@ -8,6 +8,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
...
@@ -8,6 +8,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
import
chat.rocket.android.service.ConnectivityManagerApi
;
...
@@ -26,30 +27,33 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -26,30 +27,33 @@ public class MainPresenter extends BasePresenter<MainContract.View>
private
final
SessionInteractor
sessionInteractor
;
private
final
SessionInteractor
sessionInteractor
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
private
final
ConnectivityManagerApi
connectivityManagerApi
;
private
final
RocketChatCache
rocketChatCache
;
public
MainPresenter
(
RoomInteractor
roomInteractor
,
public
MainPresenter
(
RoomInteractor
roomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
CanCreateRoomInteractor
canCreateRoomInteractor
,
SessionInteractor
sessionInteractor
,
SessionInteractor
sessionInteractor
,
MethodCallHelper
methodCallHelper
,
MethodCallHelper
methodCallHelper
,
ConnectivityManagerApi
connectivityManagerApi
)
{
ConnectivityManagerApi
connectivityManagerApi
,
RocketChatCache
rocketChatCache
)
{
this
.
roomInteractor
=
roomInteractor
;
this
.
roomInteractor
=
roomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
canCreateRoomInteractor
=
canCreateRoomInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
sessionInteractor
=
sessionInteractor
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
this
.
connectivityManagerApi
=
connectivityManagerApi
;
this
.
rocketChatCache
=
rocketChatCache
;
}
}
@Override
@Override
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
public
void
bindView
(
@NonNull
MainContract
.
View
view
)
{
super
.
bindView
(
view
);
super
.
bindView
(
view
);
view
.
showHome
();
if
(
shouldLaunchAddServerActivity
())
{
if
(
shouldLaunchAddServerActivity
())
{
view
.
showAddServerScreen
();
view
.
showAddServerScreen
();
return
;
return
;
}
}
openRoom
();
subscribeToUnreadCount
();
subscribeToUnreadCount
();
subscribeToSession
();
subscribeToSession
();
setUserOnline
();
setUserOnline
();
...
@@ -86,6 +90,18 @@ public class MainPresenter extends BasePresenter<MainContract.View>
...
@@ -86,6 +90,18 @@ public class MainPresenter extends BasePresenter<MainContract.View>
addSubscription
(
subscription
);
addSubscription
(
subscription
);
}
}
private
void
openRoom
()
{
String
hostname
=
rocketChatCache
.
getSelectedServerHostname
();
String
roomId
=
rocketChatCache
.
getSelectedRoomId
();
if
(
roomId
==
null
||
roomId
.
length
()
==
0
)
{
view
.
showHome
();
return
;
}
onOpenRoom
(
hostname
,
roomId
);
}
private
void
subscribeToUnreadCount
()
{
private
void
subscribeToUnreadCount
()
{
final
Disposable
subscription
=
Flowable
.
combineLatest
(
final
Disposable
subscription
=
Flowable
.
combineLatest
(
roomInteractor
.
getTotalUnreadRoomsCount
(),
roomInteractor
.
getTotalUnreadRoomsCount
(),
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
b40028f8
...
@@ -179,6 +179,8 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -179,6 +179,8 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
private
void
getRoomHistoryStateInfo
()
{
private
void
getRoomHistoryStateInfo
()
{
final
Disposable
subscription
=
roomRepository
.
getHistoryStateByRoomId
(
roomId
)
final
Disposable
subscription
=
roomRepository
.
getHistoryStateByRoomId
(
roomId
)
.
distinctUntilChanged
()
.
distinctUntilChanged
()
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainContract.java
View file @
b40028f8
...
@@ -22,6 +22,8 @@ public interface SidebarMainContract {
...
@@ -22,6 +22,8 @@ public interface SidebarMainContract {
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
interface
Presenter
extends
BaseContract
.
Presenter
<
View
>
{
void
onRoomSelected
(
Room
room
);
void
onUserOnline
();
void
onUserOnline
();
void
onUserAway
();
void
onUserAway
();
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
b40028f8
...
@@ -19,7 +19,6 @@ import chat.rocket.android.R;
...
@@ -19,7 +19,6 @@ import chat.rocket.android.R;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.AbstractFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AbstractAddRoomDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment
;
import
chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
...
@@ -47,8 +46,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -47,8 +46,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private
String
hostname
;
private
String
hostname
;
private
RocketChatCache
rocketChatCache
;
public
SidebarMainFragment
()
{
public
SidebarMainFragment
()
{
}
}
...
@@ -72,12 +69,11 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -72,12 +69,11 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
Bundle
args
=
getArguments
();
Bundle
args
=
getArguments
();
hostname
=
args
==
null
?
null
:
args
.
getString
(
HOSTNAME
);
hostname
=
args
==
null
?
null
:
args
.
getString
(
HOSTNAME
);
rocketChatCache
=
new
RocketChatCache
(
getContext
());
presenter
=
new
SidebarMainPresenter
(
presenter
=
new
SidebarMainPresenter
(
hostname
,
hostname
,
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
new
RoomInteractor
(
new
RealmRoomRepository
(
hostname
)),
new
RealmUserRepository
(
hostname
),
new
RealmUserRepository
(
hostname
),
new
RocketChatCache
(
getContext
()),
TextUtils
.
isEmpty
(
hostname
)
?
null
:
new
MethodCallHelper
(
getContext
(),
hostname
)
TextUtils
.
isEmpty
(
hostname
)
?
null
:
new
MethodCallHelper
(
getContext
(),
hostname
)
);
);
}
}
...
@@ -107,7 +103,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -107,7 +103,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
setupVersionInfo
();
setupVersionInfo
();
adapter
=
new
RoomListAdapter
();
adapter
=
new
RoomListAdapter
();
adapter
.
setOnItemClickListener
(
room
->
rocketChatCache
.
setSelectedRoomId
(
room
.
getRoomId
()
));
adapter
.
setOnItemClickListener
(
room
->
presenter
.
onRoomSelected
(
room
));
RecyclerView
recyclerView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
RecyclerView
recyclerView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
room_list_container
);
recyclerView
.
setLayoutManager
(
recyclerView
.
setLayoutManager
(
...
@@ -119,9 +115,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -119,9 +115,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
final
CompoundButton
toggleUserAction
=
final
CompoundButton
toggleUserAction
=
((
CompoundButton
)
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
));
((
CompoundButton
)
rootView
.
findViewById
(
R
.
id
.
toggle_user_action
));
toggleUserAction
.
setFocusableInTouchMode
(
false
);
toggleUserAction
.
setFocusableInTouchMode
(
false
);
rootView
.
findViewById
(
R
.
id
.
user_info_container
).
setOnClickListener
(
view
->
{
toggleUserAction
.
toggle
();
rootView
.
findViewById
(
R
.
id
.
user_info_container
)
});
.
setOnClickListener
(
view
->
toggleUserAction
.
toggle
());
RxJavaInterop
.
toV2Flowable
(
RxCompoundButton
.
checkedChanges
(
toggleUserAction
))
RxJavaInterop
.
toV2Flowable
(
RxCompoundButton
.
checkedChanges
(
toggleUserAction
))
.
compose
(
bindToLifecycle
())
.
compose
(
bindToLifecycle
())
.
subscribe
(
aBoolean
->
{
.
subscribe
(
aBoolean
->
{
...
@@ -201,7 +198,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -201,7 +198,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
}
}
private
void
showAddRoomDialog
(
DialogFragment
dialog
)
{
private
void
showAddRoomDialog
(
DialogFragment
dialog
)
{
dialog
.
show
(
getFragmentManager
(),
AbstractAddRoomDialogFragment
.
class
.
getSimpleName
()
);
dialog
.
show
(
getFragmentManager
(),
"AbstractAddRoomDialogFragment"
);
}
}
@Override
@Override
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
b40028f8
...
@@ -6,11 +6,13 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
...
@@ -6,11 +6,13 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.LogIfError
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
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.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.core.repositories.UserRepository
;
...
@@ -20,13 +22,16 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -20,13 +22,16 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private
final
String
hostname
;
private
final
String
hostname
;
private
final
RoomInteractor
roomInteractor
;
private
final
RoomInteractor
roomInteractor
;
private
final
UserRepository
userRepository
;
private
final
UserRepository
userRepository
;
private
final
RocketChatCache
rocketChatCache
;
private
final
MethodCallHelper
methodCallHelper
;
private
final
MethodCallHelper
methodCallHelper
;
public
SidebarMainPresenter
(
String
hostname
,
RoomInteractor
roomInteractor
,
public
SidebarMainPresenter
(
String
hostname
,
RoomInteractor
roomInteractor
,
UserRepository
userRepository
,
MethodCallHelper
methodCallHelper
)
{
UserRepository
userRepository
,
RocketChatCache
rocketChatCache
,
MethodCallHelper
methodCallHelper
)
{
this
.
hostname
=
hostname
;
this
.
hostname
=
hostname
;
this
.
roomInteractor
=
roomInteractor
;
this
.
roomInteractor
=
roomInteractor
;
this
.
userRepository
=
userRepository
;
this
.
userRepository
=
userRepository
;
this
.
rocketChatCache
=
rocketChatCache
;
this
.
methodCallHelper
=
methodCallHelper
;
this
.
methodCallHelper
=
methodCallHelper
;
}
}
...
@@ -45,6 +50,11 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -45,6 +50,11 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
subscribeToUser
();
subscribeToUser
();
}
}
@Override
public
void
onRoomSelected
(
Room
room
)
{
rocketChatCache
.
setSelectedRoomId
(
room
.
getRoomId
());
}
@Override
@Override
public
void
onUserOnline
()
{
public
void
onUserOnline
()
{
updateCurrentUserStatus
(
User
.
STATUS_ONLINE
);
updateCurrentUserStatus
(
User
.
STATUS_ONLINE
);
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
b40028f8
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
...
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
2.14.1
-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-
3.4
-all.zip
persistence-realm/src/main/java/chat/rocket/persistence/realm/models/ddp/RealmSettings.java
View file @
b40028f8
...
@@ -19,7 +19,7 @@ public class RealmSettings extends RealmObject {
...
@@ -19,7 +19,7 @@ public class RealmSettings extends RealmObject {
public
Settings
asSettings
()
{
public
Settings
asSettings
()
{
return
Settings
.
builder
()
return
Settings
.
builder
()
.
setId
(
id
)
.
setId
(
id
)
.
setPreferences
(
preferences
.
asPreferences
()
)
.
setPreferences
(
preferences
!=
null
?
preferences
.
asPreferences
()
:
null
)
.
build
();
.
build
();
}
}
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/repositories/RealmRoomRepository.java
View file @
b40028f8
...
@@ -2,6 +2,7 @@ package chat.rocket.persistence.realm.repositories;
...
@@ -2,6 +2,7 @@ package chat.rocket.persistence.realm.repositories;
import
android.os.Looper
;
import
android.os.Looper
;
import
android.support.v4.util.Pair
;
import
android.support.v4.util.Pair
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
import
io.reactivex.Single
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
@@ -60,20 +61,36 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
...
@@ -60,20 +61,36 @@ public class RealmRoomRepository extends RealmRepository implements RoomReposito
}
}
@Override
@Override
public
Flowable
<
RoomHistoryState
>
getHistoryStateByRoomId
(
String
roomId
)
{
public
Flowable
<
Optional
<
RoomHistoryState
>
>
getHistoryStateByRoomId
(
String
roomId
)
{
return
Flowable
.
defer
(()
->
Flowable
.
using
(
return
Flowable
.
defer
(()
->
Flowable
.
using
(
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
()
->
new
Pair
<>(
RealmStore
.
getRealm
(
hostname
),
Looper
.
myLooper
()),
pair
->
RxJavaInterop
.
toV2Flowable
(
pair
->
{
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
LoadMessageProcedure
messageProcedure
=
pair
.
first
.
where
(
LoadMessageProcedure
.
class
)
.
findFirst
()
.
equalTo
(
LoadMessageProcedure
.
ID
,
roomId
)
.<
LoadMessageProcedure
>
asObservable
()
.
findFirst
();
.
filter
(
loadMessageProcedure
->
loadMessageProcedure
!=
null
&&
loadMessageProcedure
.
isLoaded
()
&&
loadMessageProcedure
.
isValid
())),
if
(
messageProcedure
==
null
)
{
return
Flowable
.
just
(
Optional
.<
LoadMessageProcedure
>
absent
());
}
return
RxJavaInterop
.
toV2Flowable
(
messageProcedure
.<
LoadMessageProcedure
>
asObservable
()
.
filter
(
loadMessageProcedure
->
loadMessageProcedure
.
isLoaded
()
&&
loadMessageProcedure
.
isValid
())
.
map
(
Optional:
:
of
));
},
pair
->
close
(
pair
.
first
,
pair
.
second
)
pair
->
close
(
pair
.
first
,
pair
.
second
)
)
)
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
unsubscribeOn
(
AndroidSchedulers
.
from
(
Looper
.
myLooper
()))
.
map
(
LoadMessageProcedure:
:
asRoomHistoryState
));
.
map
(
optional
->
{
if
(
optional
.
isPresent
())
{
return
Optional
.
of
(
optional
.
get
().
asRoomHistoryState
());
}
return
Optional
.
absent
();
}));
}
}
@Override
@Override
...
...
rocket-chat-core/src/main/java/chat/rocket/core/interactors/MessageInteractor.java
View file @
b40028f8
package
chat
.
rocket
.
core
.
interactors
;
package
chat
.
rocket
.
core
.
interactors
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
import
io.reactivex.Single
;
...
@@ -38,6 +39,8 @@ public class MessageInteractor {
...
@@ -38,6 +39,8 @@ public class MessageInteractor {
public
Single
<
Boolean
>
loadMoreMessages
(
Room
room
)
{
public
Single
<
Boolean
>
loadMoreMessages
(
Room
room
)
{
return
roomRepository
.
getHistoryStateByRoomId
(
room
.
getRoomId
())
return
roomRepository
.
getHistoryStateByRoomId
(
room
.
getRoomId
())
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
filter
(
roomHistoryState
->
{
.
filter
(
roomHistoryState
->
{
int
syncState
=
roomHistoryState
.
getSyncState
();
int
syncState
=
roomHistoryState
.
getSyncState
();
return
!
roomHistoryState
.
isComplete
()
return
!
roomHistoryState
.
isComplete
()
...
...
rocket-chat-core/src/main/java/chat/rocket/core/models/Preferences.java
View file @
b40028f8
...
@@ -27,6 +27,7 @@ public abstract class Preferences {
...
@@ -27,6 +27,7 @@ public abstract class Preferences {
public
abstract
boolean
isAutoImageLoad
();
public
abstract
boolean
isAutoImageLoad
();
@Nullable
public
abstract
String
getEmailNotificationMode
();
public
abstract
String
getEmailNotificationMode
();
public
abstract
boolean
isUnreadAlert
();
public
abstract
boolean
isUnreadAlert
();
...
...
rocket-chat-core/src/main/java/chat/rocket/core/models/Settings.java
View file @
b40028f8
...
@@ -2,11 +2,14 @@ package chat.rocket.core.models;
...
@@ -2,11 +2,14 @@ package chat.rocket.core.models;
import
com.google.auto.value.AutoValue
;
import
com.google.auto.value.AutoValue
;
import
javax.annotation.Nullable
;
@AutoValue
@AutoValue
public
abstract
class
Settings
{
public
abstract
class
Settings
{
public
abstract
String
getId
();
public
abstract
String
getId
();
@Nullable
public
abstract
Preferences
getPreferences
();
public
abstract
Preferences
getPreferences
();
public
static
Builder
builder
()
{
public
static
Builder
builder
()
{
...
...
rocket-chat-core/src/main/java/chat/rocket/core/models/User.java
View file @
b40028f8
...
@@ -15,6 +15,7 @@ public abstract class User {
...
@@ -15,6 +15,7 @@ public abstract class User {
public
abstract
String
getId
();
public
abstract
String
getId
();
@Nullable
public
abstract
String
getUsername
();
public
abstract
String
getUsername
();
@Nullable
@Nullable
...
...
rocket-chat-core/src/main/java/chat/rocket/core/repositories/RoomRepository.java
View file @
b40028f8
package
chat
.
rocket
.
core
.
repositories
;
package
chat
.
rocket
.
core
.
repositories
;
import
com.fernandocejas.arrow.optional.Optional
;
import
io.reactivex.Flowable
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
import
io.reactivex.Single
;
...
@@ -13,7 +14,7 @@ public interface RoomRepository {
...
@@ -13,7 +14,7 @@ public interface RoomRepository {
Flowable
<
Room
>
getById
(
String
roomId
);
Flowable
<
Room
>
getById
(
String
roomId
);
Flowable
<
RoomHistoryState
>
getHistoryStateByRoomId
(
String
roomId
);
Flowable
<
Optional
<
RoomHistoryState
>
>
getHistoryStateByRoomId
(
String
roomId
);
Single
<
Boolean
>
setHistoryState
(
RoomHistoryState
roomHistoryState
);
Single
<
Boolean
>
setHistoryState
(
RoomHistoryState
roomHistoryState
);
}
}
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