use of net.iGap.network.AbstractObject in project iGap-Android by KianIranian-STDG.
the class MessageController method addMyStory.
public void addMyStory(List<ProtoStoryUserAddNew.StoryAddRequest> storyObjects) {
isSendingStory = true;
HttpUploader.isMultiUpload = false;
HttpUploader.isRoomMultiUpload = false;
AbstractObject request = null;
IG_RPC.Story_User_Add_New story_user_addNew = new IG_RPC.Story_User_Add_New();
story_user_addNew.storyAddRequests = storyObjects;
request = story_user_addNew;
getRequestManager().sendRequest(request, (response, error) -> {
if (error == null) {
IG_RPC.Res_Story_User_Add_New res = (IG_RPC.Res_Story_User_Add_New) response;
getMessageDataStorage().updateUserAddedStory(res.stories);
MessageController.isSendingStory = false;
} else {
IG_RPC.Error err = (IG_RPC.Error) error;
MessageController.isSendingStory = false;
G.runOnUiThread(() -> EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_UPLOADED_FAILED));
}
});
}
use of net.iGap.network.AbstractObject in project iGap-Android by KianIranian-STDG.
the class MessageController method editMessage.
public void editMessage(long messageId, long documentId, long roomId, String newMessage, int chatType) {
AbstractObject req = null;
if (chatType == CHAT_VALUE) {
IG_RPC.Chat_edit_message req_chat_edit = new IG_RPC.Chat_edit_message();
req_chat_edit.message = newMessage;
req_chat_edit.messageId = messageId;
req_chat_edit.documentId = documentId;
req_chat_edit.roomId = roomId;
req = req_chat_edit;
} else if (chatType == GROUP_VALUE) {
IG_RPC.Group_edit_message req_group_edit = new IG_RPC.Group_edit_message();
req_group_edit.message = newMessage;
req_group_edit.messageId = messageId;
req_group_edit.documentId = documentId;
req_group_edit.roomId = roomId;
req = req_group_edit;
} else if (chatType == ProtoGlobal.Room.Type.CHANNEL_VALUE) {
IG_RPC.Channel_edit_message req_channel_edit = new IG_RPC.Channel_edit_message();
req_channel_edit.message = newMessage;
req_channel_edit.messageId = messageId;
req_channel_edit.documentId = documentId;
req_channel_edit.roomId = roomId;
req = req_channel_edit;
}
getRequestManager().sendRequest(req, (response, error) -> {
if (response != null) {
onMessageEditResponse(response, false);
} else {
IG_RPC.Error err = (IG_RPC.Error) error;
FileLog.e("Edit message -> Major: " + err.minor + " Minor: " + err.minor);
}
});
}
use of net.iGap.network.AbstractObject in project iGap-Android by KianIranian-STDG.
the class MessageController method clearHistoryMessage.
public void clearHistoryMessage(final long roomId) {
if (roomId > 0) {
RealmRoom realmRoom = getMessageDataStorage().getRoom(roomId);
long clearMessageId;
if (realmRoom == null || !realmRoom.isLoaded() || !realmRoom.isValid()) {
return;
}
if (realmRoom.getLastMessage() != null) {
clearMessageId = realmRoom.getLastMessage().getMessageId();
} else {
clearMessageId = getMessageDataStorage().getRoomClearId(roomId);
}
if (clearMessageId == 0) {
return;
}
getMessageDataStorage().setRoomClearId(roomId, clearMessageId, true);
AbstractObject req = null;
if (realmRoom.getType() == ProtoGlobal.Room.Type.CHAT) {
IG_RPC.Chat_Clear_History historyReq = new IG_RPC.Chat_Clear_History();
historyReq.roomId = roomId;
historyReq.lastMessageId = clearMessageId;
req = historyReq;
} else if (realmRoom.getType() == ProtoGlobal.Room.Type.GROUP) {
IG_RPC.Group_Clear_History historyReq = new IG_RPC.Group_Clear_History();
historyReq.roomId = roomId;
historyReq.lastMessageId = clearMessageId;
req = historyReq;
}
getRequestManager().sendRequest(req, (response, error) -> {
if (error == null) {
long clearId = 0;
if (response instanceof IG_RPC.Res_Chat_Clear_History) {
IG_RPC.Res_Chat_Clear_History resClearMessage = (IG_RPC.Res_Chat_Clear_History) response;
clearId = resClearMessage.clearId;
} else if (response instanceof IG_RPC.Res_Group_Clear_History) {
IG_RPC.Res_Group_Clear_History resClearMessage = (IG_RPC.Res_Group_Clear_History) response;
clearId = resClearMessage.clearId;
}
getMessageDataStorage().clearRoomHistory(roomId, clearId);
}
});
}
}
use of net.iGap.network.AbstractObject in project iGap-Android by KianIranian-STDG.
the class MessageController method sendUpdateStatus.
public void sendUpdateStatus(int roomType, long roomId, long messageId, long documentId, int roomMessageStatus) {
AbstractObject req = null;
if (roomType == CHAT_VALUE) {
IG_RPC.Chat_Update_Status chatUpdateStatusReq = new IG_RPC.Chat_Update_Status();
chatUpdateStatusReq.roomId = roomId;
chatUpdateStatusReq.messageId = messageId;
chatUpdateStatusReq.documentId = documentId;
chatUpdateStatusReq.roomMessageStatus = ProtoGlobal.RoomMessageStatus.forNumber(roomMessageStatus);
req = chatUpdateStatusReq;
} else if (roomType == GROUP_VALUE) {
IG_RPC.Group_Update_Status groupUpdateStatusReq = new IG_RPC.Group_Update_Status();
groupUpdateStatusReq.roomId = roomId;
groupUpdateStatusReq.messageId = messageId;
groupUpdateStatusReq.documentId = documentId;
groupUpdateStatusReq.roomMessageStatus = ProtoGlobal.RoomMessageStatus.forNumber(roomMessageStatus);
req = groupUpdateStatusReq;
}
getRequestManager().sendRequest(req, (response, error) -> {
if (error == null) {
onMessageStatusResponse(response, false);
}
});
}
use of net.iGap.network.AbstractObject in project iGap-Android by KianIranian-STDG.
the class MyStatusStoryListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getEventManager().addObserver(EventManager.STORY_LIST_FETCHED, this);
getEventManager().addObserver(EventManager.STORY_USER_ADD_NEW, this);
getEventManager().addObserver(EventManager.STORY_USER_ADD_VIEW, this);
getEventManager().addObserver(EventManager.STORY_DELETED, this);
getEventManager().addObserver(EventManager.STORY_UPLOADED_FAILED, this);
getEventManager().addObserver(EventManager.STORY_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_SENDING, this);
getEventManager().addObserver(EventManager.STORY_USER_INFO, this);
getEventManager().addObserver(EventManager.STORY_STATUS_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_ROOM_IMAGE_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_ROOM_UPLOAD, this);
progressBar.setVisibility(View.VISIBLE);
sendRoomStory();
loadStories();
AbstractObject req = null;
IG_RPC.Story_Get_Own_Story_Views story_get_own_story_views = new IG_RPC.Story_Get_Own_Story_Views();
story_get_own_story_views.offset = 0;
story_get_own_story_views.limit = 50;
req = story_get_own_story_views;
getRequestManager().sendRequest(req, (response, error) -> {
if (error == null) {
IG_RPC.Res_Story_Get_Own_Story_Views res = (IG_RPC.Res_Story_Get_Own_Story_Views) response;
getMessageDataStorage().updateOwnViews(res.groupedViews);
// G.runOnUiThread(() -> loadStories());
} else {
progressBar.setVisibility(View.GONE);
}
});
floatActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
} else {
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(false)).setReplace(false).load();
}
}
});
customStatusActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
} else {
new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(false)).setReplace(false).load();
}
}
});
mOffset = 0;
recyclerListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
private boolean scrollUpdated;
private boolean scrollingManually;
private int prevTop;
private int prevPosition;
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
scrollingManually = newState == RecyclerView.SCROLL_STATE_DRAGGING;
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
View view = layoutManager.getChildAt(0);
if (firstVisibleItemPosition > 0 && view != null) {
firstVisibleItemPositionOffset = view.getTop();
}
if (!storyListFetched) {
if (mOffset > 0) {
int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
if (lastVisiblePosition + 10 >= mOffset) {
// GetStoryList(mOffset, 50);
}
}
}
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
if (firstVisibleItem != RecyclerView.NO_POSITION) {
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
if (holder != null && holder.getAdapterPosition() != 0) {
int firstViewTop = holder.itemView.getTop();
boolean goingDown;
boolean changed = true;
if (prevPosition == firstVisibleItem) {
final int topDelta = prevTop - firstViewTop;
goingDown = firstViewTop < prevTop;
changed = Math.abs(topDelta) > 1;
} else {
goingDown = firstVisibleItem > prevPosition;
}
if (changed && scrollUpdated && (goingDown || scrollingManually)) {
hideFloatingButton(goingDown);
}
prevPosition = firstVisibleItem;
prevTop = firstViewTop;
scrollUpdated = true;
}
}
}
});
}
Aggregations