Commit fe166ecf authored by Yusuke Iwaki's avatar Yusuke Iwaki

rename Getter/Setter of RealmObject subclasses.

parent f1292997
......@@ -93,7 +93,7 @@ public class RoomFragment extends AbstractChatRoomFragment
.isNotNull("hostname")
.findFirst()).getHostname();
userId = realmHelper.executeTransactionForRead(realm ->
User.queryCurrentUser(realm).findFirst()).get_id();
User.queryCurrentUser(realm).findFirst()).getId();
token = realmHelper.executeTransactionForRead(realm ->
Session.queryDefaultSession(realm).findFirst()).getToken();
roomObserver = realmHelper
......@@ -146,9 +146,9 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void onItemClick(PairedMessage pairedMessage) {
if (pairedMessage.target != null) {
final int syncstate = pairedMessage.target.getSyncstate();
final int syncstate = pairedMessage.target.getSyncState();
if (syncstate == SyncState.FAILED) {
final String messageId = pairedMessage.target.get_id();
final String messageId = pairedMessage.target.getId();
new AlertDialog.Builder(getContext())
.setPositiveButton(R.string.resend, (dialog, which) -> {
realmHelper.executeTransaction(realm ->
......@@ -264,7 +264,7 @@ public class RoomFragment extends AbstractChatRoomFragment
return;
}
String type = roomSubscription.getT();
String type = roomSubscription.getType();
if (RoomSubscription.TYPE_CHANNEL.equals(type)) {
activityToolbar.setNavigationIcon(R.drawable.ic_hashtag_white_24dp);
} else if (RoomSubscription.TYPE_PRIVATE.equals(type)) {
......@@ -284,8 +284,8 @@ public class RoomFragment extends AbstractChatRoomFragment
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
if (listView != null && listView.getAdapter() instanceof MessageListAdapter) {
MessageListAdapter adapter = (MessageListAdapter) listView.getAdapter();
final int syncstate = procedure.getSyncstate();
final boolean hasNext = procedure.isHasNext();
final int syncstate = procedure.getSyncState();
final boolean hasNext = procedure.hasNext();
RCLog.d("hasNext: %s syncstate: %d", hasNext, syncstate);
if (syncstate == SyncState.SYNCED || syncstate == SyncState.FAILED) {
scrollListener.setLoadingDone();
......@@ -322,7 +322,7 @@ public class RoomFragment extends AbstractChatRoomFragment
.equalTo("hasNext", true)
.findFirst();
if (procedure != null) {
procedure.setSyncstate(SyncState.NOT_SYNCED);
procedure.setSyncState(SyncState.NOT_SYNCED);
}
return null;
}).onSuccessTask(task -> {
......
......@@ -68,7 +68,7 @@ public class FileUploadProgressDialogFragment extends AbstractChatroomDialogFrag
return;
}
int syncstate = state.getSyncstate();
int syncstate = state.getSyncState();
if (syncstate == SyncState.SYNCED) {
dismiss();
} else if (syncstate == SyncState.FAILED) {
......
......@@ -113,7 +113,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatroomDialogFragment {
return;
}
int syncstate = procedure.getSyncstate();
int syncstate = procedure.getSyncState();
if (previousSyncState != syncstate) {
onSyncStateUpdated(syncstate);
previousSyncState = syncstate;
......
......@@ -65,7 +65,7 @@ public class MessageViewHolder extends RealmModelViewHolder<PairedMessage> {
.attachmentsInto(attachments, hostname, userId, token);
if (pairedMessage.target != null) {
int syncstate = pairedMessage.target.getSyncstate();
int syncstate = pairedMessage.target.getSyncState();
if (syncstate == SyncState.NOT_SYNCED || syncstate == SyncState.SYNCING) {
itemView.setAlpha(0.6f);
} else {
......@@ -79,7 +79,7 @@ public class MessageViewHolder extends RealmModelViewHolder<PairedMessage> {
private void renderNewDayAndSequential(PairedMessage pairedMessage) {
//see Rocket.Chat:packages/rocketchat-livechat/app/client/views/message.coffee
if (!pairedMessage.hasSameDate()) {
setNewDay(DateTime.fromEpocMs(pairedMessage.target.getTs(), DateTime.Format.DATE));
setNewDay(DateTime.fromEpocMs(pairedMessage.target.getTimestamp(), DateTime.Format.DATE));
setSequential(false);
} else if (!pairedMessage.target.isGroupable() || !pairedMessage.nextSibling.isGroupable()
|| !pairedMessage.hasSameUser()) {
......
......@@ -20,8 +20,8 @@ public class PairedMessage {
*/
public boolean hasSameDate() {
return nextSibling != null
&& DateTime.fromEpocMs(nextSibling.getTs(), DateTime.Format.DATE)
.equals(DateTime.fromEpocMs(target.getTs(), DateTime.Format.DATE));
&& DateTime.fromEpocMs(nextSibling.getTimestamp(), DateTime.Format.DATE)
.equals(DateTime.fromEpocMs(target.getTimestamp(), DateTime.Format.DATE));
}
/**
......@@ -29,7 +29,7 @@ public class PairedMessage {
*/
public boolean hasSameUser() {
return nextSibling != null
&& nextSibling.getU() != null && target.getU() != null
&& nextSibling.getU().get_id().equals(target.getU().get_id());
&& nextSibling.getUser() != null && target.getUser() != null
&& nextSibling.getUser().getId().equals(target.getUser().getId());
}
}
......@@ -47,7 +47,7 @@ public class RoomListManager {
continue;
}
String type = roomSubscription.getT();
String type = roomSubscription.getType();
if (RoomSubscription.TYPE_CHANNEL.equals(type)
|| RoomSubscription.TYPE_PRIVATE.equals(type)) {
......@@ -114,9 +114,9 @@ public class RoomListManager {
private void updateRoomItemView(RoomListItemView roomListItemView,
RoomSubscription roomSubscription) {
roomListItemView
.setRoomId(roomSubscription.getRid())
.setRoomId(roomSubscription.getRoomId())
.setRoomName(roomSubscription.getName())
.setRoomType(roomSubscription.getT())
.setRoomType(roomSubscription.getType())
.setAlert(roomSubscription.isAlert())
.setUnreadCount(roomSubscription.getUnread());
......
......@@ -38,59 +38,59 @@ public class Message extends RealmObject {
return messageJson;
}
public String get_id() {
public String getId() {
return _id;
}
public void set_id(String _id) {
public void setId(String _id) {
this._id = _id;
}
public String getT() {
public String getType() {
return t;
}
public void setT(String t) {
public void setType(String t) {
this.t = t;
}
public String getRid() {
public String getRoomId() {
return rid;
}
public void setRid(String rid) {
public void setRoomId(String rid) {
this.rid = rid;
}
public int getSyncstate() {
public int getSyncState() {
return syncstate;
}
public void setSyncstate(int syncstate) {
public void setSyncState(int syncstate) {
this.syncstate = syncstate;
}
public long getTs() {
public long getTimestamp() {
return ts;
}
public void setTs(long ts) {
public void setTimestamp(long ts) {
this.ts = ts;
}
public String getMsg() {
public String getMessage() {
return msg;
}
public void setMsg(String msg) {
public void setMessage(String msg) {
this.msg = msg;
}
public User getU() {
public User getUser() {
return u;
}
public void setU(User u) {
public void setUser(User u) {
this.u = u;
}
......
......@@ -16,11 +16,11 @@ public class MeteorLoginServiceConfiguration
private String appId; //for Facebook
private String clientId; //for other auth providers
public String get_id() {
public String getId() {
return _id;
}
public void set_id(String _id) {
public void setId(String _id) {
this._id = _id;
}
......
......@@ -60,11 +60,11 @@ public class PublicSetting extends RealmObject {
return defaultValue;
}
public String get_id() {
public String getId() {
return _id;
}
public void set_id(String _id) {
public void setId(String _id) {
this._id = _id;
}
......@@ -92,11 +92,11 @@ public class PublicSetting extends RealmObject {
this.value = value;
}
public long get_updatedAt() {
public long getUpdatedAt() {
return _updatedAt;
}
public void set_updatedAt(long _updatedAt) {
public void setUpdatedAt(long _updatedAt) {
this._updatedAt = _updatedAt;
}
......
......@@ -42,19 +42,19 @@ public class RoomSubscription extends RealmObject {
return roomSubscriptionJson;
}
public String get_id() {
public String getId() {
return _id;
}
public void set_id(String _id) {
public void setId(String _id) {
this._id = _id;
}
public String getRid() {
public String getRoomId() {
return rid;
}
public void setRid(String rid) {
public void setRoomId(String rid) {
this.rid = rid;
}
......@@ -66,11 +66,11 @@ public class RoomSubscription extends RealmObject {
this.name = name;
}
public String getT() {
public String getType() {
return t;
}
public void setT(String t) {
public void setType(String t) {
this.t = t;
}
......@@ -98,19 +98,19 @@ public class RoomSubscription extends RealmObject {
this.unread = unread;
}
public long get_updatedAt() {
public long getUpdatedAt() {
return _updatedAt;
}
public void set_updatedAt(long _updatedAt) {
public void setUpdatedAt(long _updatedAt) {
this._updatedAt = _updatedAt;
}
public long getLs() {
public long getLastSeen() {
return ls;
}
public void setLs(long ls) {
public void setLastSeen(long ls) {
this.ls = ls;
}
}
......@@ -27,11 +27,11 @@ public class User extends RealmObject {
return realm.where(User.class).isNotEmpty("emails");
}
public String get_id() {
public String getId() {
return _id;
}
public void set_id(String _id) {
public void setId(String _id) {
this._id = _id;
}
......
......@@ -31,11 +31,11 @@ public class FileUploading extends RealmObject {
this.uplId = uplId;
}
public int getSyncstate() {
public int getSyncState() {
return syncstate;
}
public void setSyncstate(int syncstate) {
public void setSyncState(int syncstate) {
this.syncstate = syncstate;
}
......
......@@ -22,11 +22,11 @@ public class GetUsersOfRoomsProcedure extends RealmObject {
this.roomId = roomId;
}
public int getSyncstate() {
public int getSyncState() {
return syncstate;
}
public void setSyncstate(int syncstate) {
public void setSyncState(int syncstate) {
this.syncstate = syncstate;
}
......
......@@ -24,11 +24,11 @@ public class LoadMessageProcedure extends RealmObject {
this.roomId = roomId;
}
public int getSyncstate() {
public int getSyncState() {
return syncstate;
}
public void setSyncstate(int syncstate) {
public void setSyncState(int syncstate) {
this.syncstate = syncstate;
}
......@@ -56,7 +56,7 @@ public class LoadMessageProcedure extends RealmObject {
this.count = count;
}
public boolean isHasNext() {
public boolean hasNext() {
return hasNext;
}
......
......@@ -52,7 +52,7 @@ public class MethodCall extends RealmObject {
realmHelper.createObjectObserver(realm ->
realm.where(MethodCall.class).equalTo("methodCallId", newId));
observer.setOnUpdateListener(methodCall -> {
int syncstate = methodCall.getSyncstate();
int syncstate = methodCall.getSyncState();
RCLog.d("MethodCall[%s] syncstate=%d", methodCall.getMethodCallId(), syncstate);
if (syncstate == SyncState.SYNCED) {
String resultJson = methodCall.getResultJson();
......@@ -102,11 +102,11 @@ public class MethodCall extends RealmObject {
this.methodCallId = methodCallId;
}
public int getSyncstate() {
public int getSyncState() {
return syncstate;
}
public void setSyncstate(int syncstate) {
public void setSyncState(int syncstate) {
this.syncstate = syncstate;
}
......
......@@ -23,14 +23,14 @@ public class MessageRenderer extends AbstractRenderer<Message> {
public MessageRenderer(Context context, Message message) {
super(context, message);
userRenderer = new UserRenderer(context, message.getU());
userRenderer = new UserRenderer(context, message.getUser());
}
/**
* show Avatar image.
*/
public MessageRenderer avatarInto(ImageView imageView, String hostname) {
switch (object.getSyncstate()) {
switch (object.getSyncState()) {
case SyncState.FAILED:
imageView.setImageResource(R.drawable.ic_error_outline_black_24dp);
break;
......@@ -57,13 +57,13 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return this;
}
switch (object.getSyncstate()) {
switch (object.getSyncState()) {
case SyncState.NOT_SYNCED:
case SyncState.SYNCING:
textView.setText(R.string.sending);
break;
default:
textView.setText(DateTime.fromEpocMs(object.getTs(), DateTime.Format.TIME));
textView.setText(DateTime.fromEpocMs(object.getTimestamp(), DateTime.Format.TIME));
break;
}
......@@ -78,7 +78,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return this;
}
rocketChatMessageLayout.setText(object.getMsg());
rocketChatMessageLayout.setText(object.getMessage());
return this;
}
......
......@@ -56,7 +56,7 @@ public class CurrentUserObserver extends AbstractModelObserver<User> {
}
listeners = new ArrayList<>();
final String userId = user.get_id();
final String userId = user.getId();
// get and observe Room subscriptions.
methodCall.getRoomSubscriptions().onSuccess(task -> {
......
......@@ -46,7 +46,7 @@ public class FileUploadingToS3Observer extends AbstractModelObserver<FileUploadi
.equalTo("storageType", FileUploading.STORAGE_TYPE_S3)
.findAll();
for (FileUploading req : pendingUploadRequests) {
req.setSyncstate(SyncState.NOT_SYNCED);
req.setSyncState(SyncState.NOT_SYNCED);
}
// clean up records.
......
......@@ -46,7 +46,7 @@ public class FileUploadingWithUfsObserver extends AbstractModelObserver<FileUplo
.endGroup()
.findAll();
for (FileUploading req : pendingUploadRequests) {
req.setSyncstate(SyncState.NOT_SYNCED);
req.setSyncState(SyncState.NOT_SYNCED);
}
// clean up records.
......@@ -99,7 +99,7 @@ public class FileUploadingWithUfsObserver extends AbstractModelObserver<FileUplo
return;
}
final String cookie = String.format("rc_uid=%s; rc_token=%s",
currentUser.get_id(), session.getToken());
currentUser.getId(), session.getToken());
FileUploading fileUploading = results.get(0);
final String roomId = fileUploading.getRoomId();
......
......@@ -61,7 +61,7 @@ public class LoadMessageProcedureObserver extends AbstractModelObserver<LoadMess
.equalTo("rid", roomId)
.equalTo("syncstate", SyncState.SYNCED)
.findAllSorted("ts", Sort.ASCENDING).first(null));
long lastTs = lastMessage != null ? lastMessage.getTs() : 0;
long lastTs = lastMessage != null ? lastMessage.getTimestamp() : 0;
int messageCount = _task.getResult().length();
return realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(LoadMessageProcedure.class, new JSONObject()
......
......@@ -33,7 +33,7 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
.equalTo("syncstate", SyncState.SYNCING)
.findAll();
for (MethodCall call : pendingMethodCalls) {
call.setSyncstate(SyncState.NOT_SYNCED);
call.setSyncState(SyncState.NOT_SYNCED);
}
// clean up records.
......
......@@ -32,7 +32,7 @@ public class NewMessageObserver extends AbstractModelObserver<Message> {
.equalTo("syncstate", SyncState.SYNCING)
.findAll();
for (Message message : pendingMethodCalls) {
message.setSyncstate(SyncState.NOT_SYNCED);
message.setSyncState(SyncState.NOT_SYNCED);
}
return null;
......@@ -54,9 +54,9 @@ public class NewMessageObserver extends AbstractModelObserver<Message> {
}
Message message = results.get(0);
final String messageId = message.get_id();
final String roomId = message.getRid();
final String msg = message.getMsg();
final String messageId = message.getId();
final String roomId = message.getRoomId();
final String msg = message.getMessage();
realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(Message.class, new JSONObject()
......
......@@ -35,21 +35,21 @@ public class ReactiveNotificationManager extends AbstractModelObserver<RoomSubsc
public void onUpdateResults(List<RoomSubscription> roomSubscriptions) {
JSONArray notifications = new JSONArray();
for (RoomSubscription roomSubscription : roomSubscriptions) {
final String roomId = roomSubscription.getRid();
final String roomId = roomSubscription.getRoomId();
NotificationItem item = realmHelper.executeTransactionForRead(realm ->
realm.where(NotificationItem.class).equalTo("roomId", roomId).findFirst());
long lastSeenAt = Math.max(item != null ? item.getLastSeenAt() : 0, roomSubscription.getLs());
long lastSeenAt = Math.max(item != null ? item.getLastSeenAt() : 0, roomSubscription.getLastSeen());
try {
JSONObject notification = new JSONObject()
.put("roomId", roomSubscription.getRid())
.put("roomId", roomSubscription.getRoomId())
.put("title", roomSubscription.getName())
.put("description", "new message")
.put("unreadCount", roomSubscription.getUnread())
.put("contentUpdatedAt", roomSubscription.get_updatedAt())
.put("contentUpdatedAt", roomSubscription.getUpdatedAt())
.put("lastSeenAt", lastSeenAt);
if (RoomSubscription.TYPE_DIRECT_MESSAGE.equals(roomSubscription.getT())) {
if (RoomSubscription.TYPE_DIRECT_MESSAGE.equals(roomSubscription.getType())) {
notification.put("senderName", roomSubscription.getName());
} else {
notification.put("senderName", JSONObject.NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment