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
c582b8cb
Commit
c582b8cb
authored
Feb 08, 2017
by
Tiago Cunha
Committed by
GitHub
Feb 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #196 from RocketChat/fix/firebase-crash-reports-20170207
Fix/firebase crash reports 20170207
parents
abcedb84
e9f583aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
36 deletions
+48
-36
RxWebSocket.java
...src/main/java/chat/rocket/android_ddp/rx/RxWebSocket.java
+32
-28
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+6
-1
DefaultCookieProvider.java
...a/chat/rocket/android/api/rest/DefaultCookieProvider.java
+9
-5
AbstractFragment.java
...n/java/chat/rocket/android/fragment/AbstractFragment.java
+1
-2
No files found.
android-ddp/src/main/java/chat/rocket/android_ddp/rx/RxWebSocket.java
View file @
c582b8cb
...
...
@@ -7,9 +7,10 @@ import okhttp3.Request;
import
okhttp3.Response
;
import
okhttp3.WebSocket
;
import
okhttp3.WebSocketListener
;
import
rx.Emitter
;
import
rx.Observable
;
import
rx.Subscriber
;
import
rx.exceptions.OnErrorNotImplementedException
;
import
rx.functions.Action1
;
import
rx.observables.ConnectableObservable
;
public
class
RxWebSocket
{
...
...
@@ -23,38 +24,41 @@ public class RxWebSocket {
public
ConnectableObservable
<
RxWebSocketCallback
.
Base
>
connect
(
String
url
)
{
final
Request
request
=
new
Request
.
Builder
().
url
(
url
).
build
();
return
Observable
.
create
(
new
Observable
.
OnSubscribe
<
RxWebSocketCallback
.
Base
>()
{
@Override
public
void
call
(
Subscriber
<?
super
RxWebSocketCallback
.
Base
>
subscriber
)
{
httpClient
.
newWebSocket
(
request
,
new
WebSocketListener
()
{
return
Observable
.
fromEmitter
(
new
Action1
<
Emitter
<
RxWebSocketCallback
.
Base
>>()
{
@Override
public
void
onOpen
(
WebSocket
webSocket
,
Response
response
)
{
RxWebSocket
.
this
.
webSocket
=
webSocket
;
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Open
(
RxWebSocket
.
this
.
webSocket
,
response
));
}
public
void
call
(
Emitter
<
RxWebSocketCallback
.
Base
>
emitter
)
{
httpClient
.
newWebSocket
(
request
,
new
WebSocketListener
()
{
@Override
public
void
onOpen
(
WebSocket
webSocket
,
Response
response
)
{
RxWebSocket
.
this
.
webSocket
=
webSocket
;
emitter
.
onNext
(
new
RxWebSocketCallback
.
Open
(
RxWebSocket
.
this
.
webSocket
,
response
));
}
@Override
public
void
onFailure
(
WebSocket
webSocket
,
Throwable
err
,
Response
response
)
{
try
{
subscrib
er
.
onError
(
new
RxWebSocketCallback
.
Failure
(
webSocket
,
err
,
response
));
}
catch
(
OnErrorNotImplementedException
ex
)
{
RCLog
.
w
(
ex
,
"OnErrorNotImplementedException ignored"
);
}
}
@Override
public
void
onFailure
(
WebSocket
webSocket
,
Throwable
err
,
Response
response
)
{
try
{
emitt
er
.
onError
(
new
RxWebSocketCallback
.
Failure
(
webSocket
,
err
,
response
));
}
catch
(
OnErrorNotImplementedException
ex
)
{
RCLog
.
w
(
ex
,
"OnErrorNotImplementedException ignored"
);
}
}
@Override
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
subscrib
er
.
onNext
(
new
RxWebSocketCallback
.
Message
(
webSocket
,
text
));
}
@Override
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
emitt
er
.
onNext
(
new
RxWebSocketCallback
.
Message
(
webSocket
,
text
));
}
@Override
public
void
onClosed
(
WebSocket
webSocket
,
int
code
,
String
reason
)
{
subscriber
.
onNext
(
new
RxWebSocketCallback
.
Close
(
webSocket
,
code
,
reason
));
subscriber
.
onCompleted
();
@Override
public
void
onClosed
(
WebSocket
webSocket
,
int
code
,
String
reason
)
{
emitter
.
onNext
(
new
RxWebSocketCallback
.
Close
(
webSocket
,
code
,
reason
));
emitter
.
onCompleted
();
}
});
}
}
);
}
}
).
publish
();
}
,
Emitter
.
BackpressureMode
.
BUFFER
).
publish
();
}
public
boolean
sendText
(
String
message
)
throws
IOException
{
...
...
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
c582b8cb
...
...
@@ -74,7 +74,12 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
recoverFromHostnameError
(
prefs
);
}
}
else
{
if
(!
hostname
.
equals
(
newHostname
)
&&
assertServerRealmStoreExists
(
newHostname
))
{
if
(
hostname
.
equals
(
newHostname
))
{
// we are good
return
;
}
if
(
assertServerRealmStoreExists
(
newHostname
))
{
updateHostname
(
newHostname
);
}
else
{
recoverFromHostnameError
(
prefs
);
...
...
app/src/main/java/chat/rocket/android/api/rest/DefaultCookieProvider.java
View file @
c582b8cb
...
...
@@ -33,12 +33,16 @@ public class DefaultCookieProvider implements CookieProvider {
return
""
;
}
final
String
userId
=
realmHelper
.
executeTransactionForRead
(
realm
->
User
.
queryCurrentUser
(
realm
).
findFirst
())
.
getId
()
;
final
S
tring
toke
n
=
realmHelper
.
executeTransactionForRead
(
realm
->
Session
.
queryDefaultSession
(
realm
).
findFirst
())
.
getToken
()
;
final
User
user
=
realmHelper
.
executeTransactionForRead
(
realm
->
User
.
queryCurrentUser
(
realm
).
findFirst
());
final
S
ession
sessio
n
=
realmHelper
.
executeTransactionForRead
(
realm
->
Session
.
queryDefaultSession
(
realm
).
findFirst
());
return
"rc_uid="
+
userId
+
";rc_token="
+
token
;
if
(
user
==
null
||
session
==
null
)
{
return
""
;
}
return
"rc_uid="
+
user
.
getId
()
+
";rc_token="
+
session
.
getToken
();
}
private
String
getHostnameFromCache
()
{
...
...
app/src/main/java/chat/rocket/android/fragment/AbstractFragment.java
View file @
c582b8cb
...
...
@@ -14,9 +14,8 @@ import com.trello.rxlifecycle.components.support.RxFragment;
public
abstract
class
AbstractFragment
extends
RxFragment
{
protected
View
rootView
;
protected
abstract
@LayoutRes
int
getLayout
();
protected
abstract
int
getLayout
();
protected
abstract
void
onSetupView
();
...
...
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