use of net.iGap.story.ViewUserDialogFragment in project iGap-Android by KianIranian-STDG.
the class StoryDisplayFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
counter = 0;
emojiSharedPreferences = getActivity().getSharedPreferences(SHP_SETTING.EMOJI, MODE_PRIVATE);
stories = storyUser.getStories();
isMyStory = storyUser.getUserId() == AccountManager.getInstance().getCurrentUser().getId();
if (isMyStory) {
storyReplyContainer.setVisibility(View.INVISIBLE);
storySeenContainer.setVisibility(View.VISIBLE);
} else {
if (stories.get(counter).isRoom()) {
storyReplyContainer.setVisibility(View.INVISIBLE);
} else {
storyReplyContainer.setVisibility(View.VISIBLE);
}
storySeenContainer.setVisibility(View.INVISIBLE);
}
if (isFormChat) {
storyReplyContainer.setVisibility(View.INVISIBLE);
storySeenContainer.setVisibility(View.INVISIBLE);
}
setUpUi();
storyReplyContainer.setOnClickListener(view1 -> {
setupReply();
});
sendIcon.setOnClickListener(view1 -> {
String replyText = Objects.requireNonNull(replyEditText.getText()).toString().trim();
if (replyText.length() == 0) {
replyEditText.setText("");
Toast.makeText(context, R.string.please_write_your_message, Toast.LENGTH_LONG).show();
} else if (!checkEmptyMessageWithSemiSpace(new String[] { replyText })) {
return;
}
replyEditText.setText("");
hideKeyboard();
RealmRoom realmRoom = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("chatRoom.peer_id", stories.get(counter).getUserId()).findFirst();
});
if (realmRoom == null) {
IG_RPC.Chat_get_room chat_get_room = new IG_RPC.Chat_get_room();
chat_get_room.peerId = stories.get(counter).getUserId();
getRequestManager().sendRequest(chat_get_room, (response, error) -> {
if (response != null) {
IG_RPC.Res_chat_get_room res = (IG_RPC.Res_chat_get_room) response;
ChatSendMessageUtil.getInstance(AccountManager.selectedAccount).buildStoryReply(res.room.getTypeValue(), res.room.getId(), stories.get(counter), null, replyText);
hideReplyViews();
}
});
} else {
ChatSendMessageUtil.getInstance(AccountManager.selectedAccount).buildStoryReply(realmRoom.getType().getNumber(), realmRoom.getId(), stories.get(counter), null, replyText);
hideReplyViews();
Toast.makeText(context, getString(R.string.sending_reply), Toast.LENGTH_SHORT).show();
}
});
storySeenContainer.setOnClickListener(v -> {
if (isMyStory && stories.get(counter).getViewCount() > 0) {
ViewUserDialogFragment blankFragment = new ViewUserDialogFragment(stories.get(counter).getViewCount(), stories.get(counter).getUserIdList());
blankFragment.setViewUserDialogState(StoryDisplayFragment.this::onCancel);
blankFragment.show(getParentFragmentManager(), blankFragment.getTag());
pauseCurrentStory();
}
});
emojiIcon.setOnClickListener(view1 -> {
if (keyboardView == null)
createKeyboardView();
if (isPopupShowing() && keyboardView.getCurrentMode() != KeyboardView.MODE_KEYBOARD && keyboardView.getCurrentMode() != -1) {
showPopup(KeyboardView.MODE_KEYBOARD);
openKeyBoard();
} else {
showPopup(KeyboardView.MODE_EMOJI);
AndroidUtils.hideKeyboard(replyEditText);
}
});
}
Aggregations