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
d4683f4a
Commit
d4683f4a
authored
Dec 05, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue realm#close() is called dupplicately
parent
68e85070
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
11 additions
and
49 deletions
+11
-49
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+0
-7
InputHostnameFragment.java
...android/fragment/server_config/InputHostnameFragment.java
+0
-1
Registerable.java
...c/main/java/chat/rocket/android/service/Registerable.java
+0
-5
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+8
-1
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+0
-13
AbstractDDPDocEventSubscriber.java
...et/android/service/ddp/AbstractDDPDocEventSubscriber.java
+0
-4
AbstractModelObserver.java
...ocket/android/service/observer/AbstractModelObserver.java
+0
-4
AbstractRealmResultsObserver.java
...et/android/realm_helper/AbstractRealmResultsObserver.java
+3
-14
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
d4683f4a
...
...
@@ -123,13 +123,6 @@ public class MainActivity extends AbstractAuthedActivity {
}
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
sessionObserver
!=
null
)
{
sessionObserver
.
keepalive
();
}
}
@Override
protected
void
onDestroy
()
{
if
(
sessionObserver
!=
null
)
{
sessionObserver
.
unsub
();
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/InputHostnameFragment.java
View file @
d4683f4a
...
...
@@ -49,7 +49,6 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
@Override
public
void
onResume
()
{
super
.
onResume
();
serverConfigObserver
.
keepalive
();
}
@Override
public
void
onDestroyView
()
{
...
...
app/src/main/java/chat/rocket/android/service/Registerable.java
View file @
d4683f4a
...
...
@@ -9,11 +9,6 @@ public interface Registerable {
*/
void
register
();
/**
* keepalive.
*/
void
keepalive
();
/**
* unregister.
*/
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
d4683f4a
...
...
@@ -88,7 +88,7 @@ public class RocketChatService extends Service {
}
return
null
;
}).
onSuccessTask
(
task
->
{
connectionRequiredServerConfigObserver
.
keepalive
();
connectionRequiredServerConfigObserver
.
sub
();
return
null
;
});
return
START_STICKY
;
...
...
@@ -133,6 +133,13 @@ public class RocketChatService extends Service {
}
}
@Override
public
void
onDestroy
()
{
if
(
connectionRequiredServerConfigObserver
!=
null
)
{
connectionRequiredServerConfigObserver
.
unsub
();
}
super
.
onDestroy
();
}
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
d4683f4a
...
...
@@ -134,8 +134,6 @@ public class RocketChatWebSocketThread extends HandlerThread {
}
return
null
;
});
}
else
{
new
Handler
(
getLooper
()).
post
(
this
::
keepaliveListeners
);
}
}
...
...
@@ -227,17 +225,6 @@ public class RocketChatWebSocketThread extends HandlerThread {
}
}
//@DebugLog
private
void
keepaliveListeners
()
{
if
(!
listenersRegistered
)
{
return
;
}
for
(
Registerable
registerable
:
listeners
)
{
registerable
.
keepalive
();
}
}
@DebugLog
private
void
unregisterListeners
()
{
if
(!
listenersRegistered
)
{
...
...
app/src/main/java/chat/rocket/android/service/ddp/AbstractDDPDocEventSubscriber.java
View file @
d4683f4a
...
...
@@ -139,10 +139,6 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
}
@Override
public
void
keepalive
()
{
}
@Override
public
void
unregister
()
{
if
(
rxSubscription
!=
null
)
{
rxSubscription
.
unsubscribe
();
...
...
app/src/main/java/chat/rocket/android/service/observer/AbstractModelObserver.java
View file @
d4683f4a
...
...
@@ -27,10 +27,6 @@ abstract class AbstractModelObserver<T extends RealmObject>
observer
.
sub
();
}
@Override
public
void
keepalive
()
{
observer
.
keepalive
();
}
@Override
public
void
unregister
()
{
observer
.
unsub
();
}
...
...
realm-helpers/src/main/java/chat/rocket/android/realm_helper/AbstractRealmResultsObserver.java
View file @
d4683f4a
...
...
@@ -4,7 +4,6 @@ import io.realm.Realm;
import
io.realm.RealmChangeListener
;
import
io.realm.RealmObject
;
import
io.realm.RealmResults
;
import
timber.log.Timber
;
abstract
class
AbstractRealmResultsObserver
<
T
extends
RealmObject
>
{
protected
Realm
realm
;
...
...
@@ -31,26 +30,16 @@ abstract class AbstractRealmResultsObserver<T extends RealmObject> {
results
.
addChangeListener
(
listener
);
}
public
void
keepalive
()
{
if
(
realm
==
null
||
realm
.
isClosed
()
||
!
results
.
isValid
())
{
unsub
();
sub
();
}
}
public
void
unsub
()
{
try
{
if
(
realm
!=
null
)
{
if
(
results
!=
null
)
{
if
(
results
.
isValid
())
{
results
.
removeChangeListener
(
listener
);
}
results
=
null
;
}
if
(
realm
!=
null
&&
!
realm
.
isClosed
())
{
realm
.
close
();
}
}
catch
(
IllegalStateException
exception
)
{
Timber
.
w
(
exception
,
"failed to unsub. ignore."
);
realm
=
null
;
}
}
...
...
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