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
9e92d9a2
Commit
9e92d9a2
authored
Nov 11, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code style.
parent
8035b4a7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
57 deletions
+47
-57
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+10
-9
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+9
-8
MethodCallHelper.java
...ain/java/chat/rocket/android/helper/MethodCallHelper.java
+23
-38
RoomListManager.java
...rocket/android/layouthelper/chatroom/RoomListManager.java
+4
-2
Email.java
app/src/main/java/chat/rocket/android/model/Email.java
+1
-0
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
9e92d9a2
...
...
@@ -75,15 +75,16 @@ public class MainActivity extends AbstractAuthedActivity {
.
subscribe
(
RxView
.
visibility
(
findViewById
(
R
.
id
.
user_action_container
)));
}
private
RealmListObserver
<
RoomSubscription
>
roomsObserver
=
new
RealmListObserver
<
RoomSubscription
>()
{
@Override
protected
RealmResults
<
RoomSubscription
>
queryItems
(
Realm
realm
)
{
return
realm
.
where
(
RoomSubscription
.
class
).
findAll
();
}
@Override
protected
void
onCollectionChanged
(
List
<
RoomSubscription
>
list
)
{
roomListManager
.
setRooms
(
list
);
}
};
private
RealmListObserver
<
RoomSubscription
>
roomsObserver
=
new
RealmListObserver
<
RoomSubscription
>()
{
@Override
protected
RealmResults
<
RoomSubscription
>
queryItems
(
Realm
realm
)
{
return
realm
.
where
(
RoomSubscription
.
class
).
findAll
();
}
@Override
protected
void
onCollectionChanged
(
List
<
RoomSubscription
>
list
)
{
roomListManager
.
setRooms
(
list
);
}
};
private
void
showRoomFragment
(
String
roomId
)
{
showFragment
(
RoomFragment
.
create
(
roomId
));
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
9e92d9a2
...
...
@@ -44,15 +44,16 @@ public class RoomFragment extends AbstractChatRoomFragment {
}
private
RealmObjectObserver
<
RoomSubscription
>
roomObserver
=
new
RealmObjectObserver
<
RoomSubscription
>()
{
@Override
protected
RealmQuery
<
RoomSubscription
>
query
(
Realm
realm
)
{
return
realm
.
where
(
RoomSubscription
.
class
).
equalTo
(
"rid"
,
roomId
);
}
private
RealmObjectObserver
<
RoomSubscription
>
roomObserver
=
new
RealmObjectObserver
<
RoomSubscription
>()
{
@Override
protected
RealmQuery
<
RoomSubscription
>
query
(
Realm
realm
)
{
return
realm
.
where
(
RoomSubscription
.
class
).
equalTo
(
"rid"
,
roomId
);
}
@Override
protected
void
onChange
(
RoomSubscription
roomSubscription
)
{
onRenderRoom
(
roomSubscription
);
}
};
@Override
protected
void
onChange
(
RoomSubscription
roomSubscription
)
{
onRenderRoom
(
roomSubscription
);
}
};
private
void
onRenderRoom
(
RoomSubscription
roomSubscription
)
{
activityToolbar
.
setTitle
(
roomSubscription
.
getName
());
...
...
app/src/main/java/chat/rocket/android/helper/MethodCallHelper.java
View file @
9e92d9a2
...
...
@@ -154,41 +154,31 @@ public class MethodCallHelper {
}
private
Task
<
Long
>
getRoomSubscriptionRecursive
(
long
timestamp
)
{
return
call
(
"subscriptions/get"
,
param
->
param
.
put
(
"$date"
,
timestamp
),
task
->
{
JSONObject
result
=
task
.
getResult
();
long
nextTimestamp
=
0
;
try
{
nextTimestamp
=
result
.
getJSONArray
(
"remove"
)
.
getJSONObject
(
0
).
getJSONObject
(
"_deletedAt"
).
getLong
(
"$date"
);
}
catch
(
JSONException
exception
)
{
return
getObjectRecursive
(
"subscriptions"
,
updatedRooms
->
{
for
(
int
i
=
0
;
i
<
updatedRooms
.
length
();
i
++)
{
updatedRooms
.
getJSONObject
(
i
).
put
(
"serverConfigId"
,
serverConfigId
);
}
},
timestamp
);
}
try
{
JSONArray
updatedRooms
=
result
.
getJSONArray
(
"update"
);
for
(
int
i
=
0
;
i
<
updatedRooms
.
length
();
i
++)
{
updatedRooms
.
getJSONObject
(
i
).
put
(
"serverConfigId"
,
serverConfigId
);
}
Task
<
Void
>
saveToDB
=
RealmHelperBolts
.
executeTransaction
(
realm
->
{
realm
.
createOrUpdateAllFromJson
(
RoomSubscription
.
class
,
result
.
getJSONArray
(
"update"
));
return
null
;
});
if
(
nextTimestamp
>
0
&&
(
timestamp
==
0
||
nextTimestamp
<
timestamp
))
{
final
long
_next
=
nextTimestamp
;
return
saveToDB
.
onSuccessTask
(
_task
->
getRoomSubscriptionRecursive
(
_next
));
}
else
{
return
saveToDB
.
onSuccessTask
(
_task
->
Task
.
forResult
(
0L
));
}
}
catch
(
JSONException
exception
)
{
return
Task
.
forError
(
exception
);
private
Task
<
Long
>
getRoomRecursive
(
long
timestamp
)
{
return
getObjectRecursive
(
"rooms"
,
updatedRooms
->
{
for
(
int
i
=
0
;
i
<
updatedRooms
.
length
();
i
++)
{
JSONObject
roomJson
=
updatedRooms
.
getJSONObject
(
i
);
String
rid
=
roomJson
.
getString
(
"_id"
);
roomJson
.
put
(
"rid"
,
rid
)
.
put
(
"serverConfigId"
,
serverConfigId
)
.
remove
(
"_id"
);
}
});
}
,
timestamp
);
}
private
Task
<
Long
>
getRoomRecursive
(
long
timestamp
)
{
return
call
(
"rooms/get"
,
param
->
param
.
put
(
"$date"
,
timestamp
),
task
->
{
private
interface
Customizer
{
void
customizeResult
(
JSONArray
updatedRooms
)
throws
JSONException
;
}
private
Task
<
Long
>
getObjectRecursive
(
String
objName
,
Customizer
customizer
,
long
timestamp
)
{
return
call
(
objName
+
"/get"
,
param
->
param
.
put
(
"$date"
,
timestamp
),
task
->
{
JSONObject
result
=
task
.
getResult
();
long
nextTimestamp
=
0
;
...
...
@@ -196,17 +186,12 @@ public class MethodCallHelper {
nextTimestamp
=
result
.
getJSONArray
(
"remove"
)
.
getJSONObject
(
0
).
getJSONObject
(
"_deletedAt"
).
getLong
(
"$date"
);
}
catch
(
JSONException
exception
)
{
// keep nextTimestamp = 0
}
try
{
JSONArray
updatedRooms
=
result
.
getJSONArray
(
"update"
);
for
(
int
i
=
0
;
i
<
updatedRooms
.
length
();
i
++)
{
JSONObject
roomJson
=
updatedRooms
.
getJSONObject
(
i
);
String
rid
=
roomJson
.
getString
(
"_id"
);
roomJson
.
put
(
"rid"
,
rid
)
.
put
(
"serverConfigId"
,
serverConfigId
)
.
remove
(
"_id"
);
}
customizer
.
customizeResult
(
updatedRooms
);
Task
<
Void
>
saveToDB
=
RealmHelperBolts
.
executeTransaction
(
realm
->
{
realm
.
createOrUpdateAllFromJson
(
RoomSubscription
.
class
,
result
.
getJSONArray
(
"update"
));
...
...
@@ -215,7 +200,7 @@ public class MethodCallHelper {
if
(
nextTimestamp
>
0
&&
(
timestamp
==
0
||
nextTimestamp
<
timestamp
))
{
final
long
_next
=
nextTimestamp
;
return
saveToDB
.
onSuccessTask
(
_task
->
get
RoomRecursive
(
_next
));
return
saveToDB
.
onSuccessTask
(
_task
->
get
ObjectRecursive
(
objName
,
customizer
,
_next
));
}
else
{
return
saveToDB
.
onSuccessTask
(
_task
->
Task
.
forResult
(
0L
));
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/RoomListManager.java
View file @
9e92d9a2
...
...
@@ -43,7 +43,8 @@ public class RoomListManager {
String
type
=
roomSubscription
.
getT
();
if
(
RoomSubscription
.
TYPE_CHANNEL
.
equals
(
type
)
||
RoomSubscription
.
TYPE_PRIVATE
.
equals
(
type
))
{
if
(
RoomSubscription
.
TYPE_CHANNEL
.
equals
(
type
)
||
RoomSubscription
.
TYPE_PRIVATE
.
equals
(
type
))
{
insertOrUpdateItem
(
channelsContainer
,
roomSubscription
);
removeItemIfExists
(
dmContainer
,
name
);
}
else
if
(
RoomSubscription
.
TYPE_DIRECT_MESSAGE
.
equals
(
type
))
{
...
...
@@ -85,7 +86,8 @@ public class RoomListManager {
}
}
private
void
updateRoomItemView
(
RoomListItemView
roomListItemView
,
RoomSubscription
roomSubscription
)
{
private
void
updateRoomItemView
(
RoomListItemView
roomListItemView
,
RoomSubscription
roomSubscription
)
{
roomListItemView
.
setRoomId
(
roomSubscription
.
getRid
())
.
setRoomName
(
roomSubscription
.
getName
())
...
...
app/src/main/java/chat/rocket/android/model/Email.java
View file @
9e92d9a2
...
...
@@ -4,6 +4,7 @@ import io.realm.RealmObject;
import
io.realm.annotations.PrimaryKey
;
/**
* Login-User's email
*/
public
class
Email
extends
RealmObject
{
@PrimaryKey
private
String
address
;
...
...
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