use of net.iGap.observers.interfaces.OnUpdateUserOrRoomInfo in project iGap-Android by KianIranian-STDG.
the class FragmentChat method onResume.
@Override
public void onResume() {
isPaused = false;
super.onResume();
if (showKeyboardOnResume || (keyboardViewVisible && keyboardView != null && keyboardView.getCurrentMode() == KeyboardView.MODE_KEYBOARD)) {
showPopup(KeyboardView.MODE_KEYBOARD);
openKeyboardInternal(edtChat);
}
if (FragmentShearedMedia.list != null && FragmentShearedMedia.list.size() > 0) {
deleteSelectedMessageFromAdapter(FragmentShearedMedia.list);
FragmentShearedMedia.list.clear();
}
canUpdateAfterDownload = true;
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
if (getActivity() == null || getActivity().isFinishing() || !isAdded()) {
return;
}
initLayoutHashNavigationCallback();
showSpamBar();
updateShowItemInScreen();
if (isGoingFromUserLink) {
new RequestClientSubscribeToRoom().clientSubscribeToRoom(mRoomId);
}
DbManager.getInstance().doRealmTask(realm -> {
final RealmRoom room = realm.where(RealmRoom.class).equalTo("id", mRoomId).findFirst();
if (room != null) {
if (G.connectionState == ConnectionState.CONNECTING || G.connectionState == ConnectionState.WAITING_FOR_NETWORK) {
setConnectionText(G.connectionState);
} else {
if (room.getType() != CHAT) {
/**
* set member count
* set this code in onResume for update this value when user
* come back from profile activities
*/
String members = null;
if (room.getType() == GROUP && room.getGroupRoom() != null) {
members = room.getGroupRoom().getParticipantsCountLabel();
} else if (room.getType() == CHANNEL && room.getChannelRoom() != null) {
members = room.getChannelRoom().getParticipantsCountLabel();
}
final String finalMembers = members;
if (finalMembers != null) {
if (finalMembers != null && HelperString.isNumeric(finalMembers) && Integer.parseInt(finalMembers) == 1) {
mToolbar.setSubTitle(finalMembers + " " + G.fragmentActivity.getResources().getString(R.string.one_member_chat));
} else {
mToolbar.setSubTitle(finalMembers + " " + G.fragmentActivity.getResources().getString(R.string.member_chat));
}
if (HelperCalander.isPersianUnicode)
mToolbar.setSubTitle(convertToUnicodeFarsiNumber(mToolbar.getSubTitleText()));
}
} else {
RealmRegisteredInfo realmRegisteredInfo = RealmRegisteredInfo.getRegistrationInfo(realm, room.getChatRoom().getPeerId());
if (realmRegisteredInfo != null) {
setUserStatus(realmRegisteredInfo.getStatus(), realmRegisteredInfo.getLastSeen());
}
}
}
}
/**
* hint: should use from this method here because we need checkAction
* changeState after set members count for avoid from hide action if exist
*/
checkAction();
if (room != null) {
mToolbar.setTitle(EmojiManager.getInstance().replaceEmoji(room.getTitle(), null));
}
});
try {
mediaContainer.didLayoutChanged();
} catch (Exception e) {
e.printStackTrace();
}
}
}, Config.LOW_START_PAGE_TIME);
mRoomIdStatic = mRoomId;
lastChatRoomId = mRoomId;
titleStatic = title;
G.onUserInfoResponse = this;
G.onSetAction = this;
G.onUserUpdateStatus = this;
G.onLastSeenUpdateTiming = this;
G.onChatDelete = this;
G.onConnectionChangeStateChat = this;
HelperNotification.getInstance().cancelNotification();
G.onBotClick = this;
/*finishActivity = new FinishActivity() {
@Override
public void finishActivity() {
// ActivityChat.this.finish();
finishChat();
}
};*/
initCallbacks();
HelperNotification.getInstance().isChatRoomNow = true;
onUpdateUserOrRoomInfo = messageId -> {
if (messageId != null && messageId.length() > 0) {
G.handler.post(() -> {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
if (linearLayoutManager != null) {
int start = linearLayoutManager.findFirstVisibleItemPosition();
if (start < 0) {
start = 0;
}
for (int i = start; i < mAdapter.getItemCount() && i < start + 15; i++) {
try {
MessageObject messageObject = mAdapter.getItem(i).messageObject;
if (messageObject != null && (String.valueOf(messageObject.id)).equals(messageId)) {
mAdapter.notifyItemChanged(i);
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
};
if (isCloudRoom) {
avatarItem.setVisibility(View.VISIBLE);
avatarItem.setImageResource(R.drawable.ic_cloud_space_blue);
} else {
setAvatar();
}
if (mForwardMessages == null) {
rootView.findViewById(R.id.ac_ll_forward).setVisibility(View.GONE);
}
RealmRoom realmRoom = getRoom();
if (realmRoom != null) {
isMuteNotification = realmRoom.getMute();
if (!isBot) {
txtChannelMute.setText(isMuteNotification ? R.string.unmute : R.string.mute);
iconChannelMute.setText(isMuteNotification ? R.string.icon_speaker : R.string.icon_mute);
}
if (!mToolbar.isSearchFieldVisible()) {
iconMute.setVisibility(isMuteNotification ? View.VISIBLE : View.GONE);
}
}
registerListener();
// enable attachment popup camera if was visible
if (mAttachmentPopup != null && mAttachmentPopup.isShowing) {
if (ContextCompat.checkSelfPermission(G.fragmentActivity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.ON_CAMERA_PERMISSION_GRANTED);
}
}
onLinkClick = v -> {
if (keyboardViewVisible) {
hideKeyboard();
}
};
}
Aggregations