use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class CardToCardFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
avatarHandler.getAvatar(new ParamWithAvatarType(view.findViewById(R.id.userAvatar), peerId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
AppCompatTextView userNameTextView = view.findViewById(R.id.tv_cardToCard_transferTo);
AppCompatTextView bankNameTv = view.findViewById(R.id.tv_chat_card_bankName);
userNameTextView.setText(String.format(getString(R.string.money_request), userName));
AppCompatEditText cardNumberEtCard = view.findViewById(R.id.et_chat_card_cardNumber);
AppCompatEditText amountEtCard = view.findViewById(R.id.et_chat_card_cardamount);
AppCompatEditText descEtCard = view.findViewById(R.id.et_chat_card_desc);
amountEtCard.addTextChangedListener(new TextWatcher() {
boolean isSettingText;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mPrice[0] = s.toString().replaceAll(",", "");
}
@Override
public void afterTextChanged(Editable s) {
if (isSettingText)
return;
isSettingText = true;
String s1 = null;
try {
s1 = String.format(Locale.US, "%,d", Long.parseLong(mPrice[0]));
} catch (NumberFormatException e) {
e.printStackTrace();
}
amountEtCard.setText(s1);
amountEtCard.setSelection(amountEtCard.length());
isSettingText = false;
}
});
cardNumberEtCard.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() >= 7) {
bankNameTv.setText(bankName(cardNumberEtCard.getEditableText().toString().replace("-", "")));
} else {
bankNameTv.setText("");
}
}
});
view.findViewById(R.id.btn_cardToCard_confirm).setOnClickListener(v -> {
if (cardNumberEtCard.getEditableText().toString().trim().length() == 19) {
if (amountEtCard.getEditableText().toString().trim().length() >= 6) {
if (descEtCard.getEditableText().toString().trim().length() > 0) {
if (getParentFragment() instanceof ParentChatMoneyTransferFragment) {
((ParentChatMoneyTransferFragment) getParentFragment()).finishedCardToCard(cardNumberEtCard.getEditableText().toString(), amountEtCard.getEditableText().toString(), descEtCard.getEditableText().toString());
}
} else {
Toast.makeText(getContext(), R.string.cardtocard_descriotion_error, Toast.LENGTH_SHORT).show();
}
} else {
if (amountEtCard.getEditableText().toString().trim().length() == 0) {
Toast.makeText(getContext(), R.string.cardtocard_amount_empty_error, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), R.string.cardtocard_morethan_error, Toast.LENGTH_SHORT).show();
}
}
} else {
if (cardNumberEtCard.getEditableText().toString().trim().length() <= 19) {
Toast.makeText(getContext(), R.string.cardtocard_cardnumber_error, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), R.string.cardtocard_cartnumber_error, Toast.LENGTH_SHORT).show();
}
}
});
view.findViewById(R.id.btn_cardToCard_cancel).setOnClickListener(v -> {
if (getParentFragment() instanceof ParentChatMoneyTransferFragment) {
((ParentChatMoneyTransferFragment) getParentFragment()).dismissDialog();
}
});
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class JoinDialogFragment method setupView.
private void setupView(View view) {
CircleImageView ivAvatar = view.findViewById(R.id.ivAvatar);
TextView tvName = view.findViewById(R.id.tvName);
TextView tvTitle = view.findViewById(R.id.tvTitle);
TextView tvMemberCount = view.findViewById(R.id.tvMemberCount);
TextView btnCancel = view.findViewById(R.id.btnCancel);
TextView btnJoin = view.findViewById(R.id.btnJoin);
String title = getString(R.string.do_you_want_to_join_to_this);
String memberNumber = "";
switch(mRoom.getType()) {
case CHANNEL:
if (HelperCalander.isPersianUnicode) {
title += getString(R.string.channel) + " " + "عضو شوید؟";
} else {
title += getString(R.string.channel) + "?";
}
memberNumber = mRoom.getChannelRoomExtra().getParticipantsCount() + " " + G.context.getString(R.string.member_chat);
break;
case GROUP:
if (HelperCalander.isPersianUnicode) {
title += getString(R.string.group) + " " + "عضو شوید؟";
} else {
title += getString(R.string.group) + "?";
}
memberNumber = mRoom.getGroupRoomExtra().getParticipantsCount() + " " + getString(R.string.member_chat);
break;
}
tvTitle.setText(title);
tvName.setText(mRoom.getTitle());
tvMemberCount.setText(memberNumber);
if (getActivity() != null) {
((ActivityEnhanced) getActivity()).avatarHandler.getAvatar(new ParamWithAvatarType(ivAvatar, mRoom.getId()).avatarType(AvatarHandler.AvatarType.ROOM));
}
btnCancel.setOnClickListener(v -> {
mListener.onCancelClicked();
dismiss();
});
btnJoin.setOnClickListener(v -> {
mListener.onJoinClicked();
dismiss();
});
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class AccountsDialogAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull AccountViewHolder holder, int position) {
holder.username.setGravity(G.isAppRtl ? Gravity.RIGHT : Gravity.LEFT);
if (currentUserPosition == position) {
holder.currentUserView.setVisibility(View.VISIBLE);
} else {
holder.currentUserView.setVisibility(View.INVISIBLE);
}
if (mAccountsList.get(position).isAssigned()) {
holder.getOtherAccountUserId(mAccountsList.get(position).getId());
mAvatarHandler.getAvatar(new ParamWithAvatarType(holder.userAvatar, mAccountsList.get(position).getId()).avatarType(AvatarHandler.AvatarType.USER).showMain(), true);
holder.username.setText(mAccountsList.get(position).getName());
holder.messageUnreadCount.setVisibility(View.VISIBLE);
String t;
if (mAccountsList.get(position).getUnReadMessageCount() > 99) {
t = "+99";
holder.messageUnreadCount.setVisibility(View.VISIBLE);
} else if (mAccountsList.get(position).getUnReadMessageCount() == 0) {
t = "";
holder.messageUnreadCount.setVisibility(View.INVISIBLE);
} else {
t = String.valueOf(mAccountsList.get(position).getUnReadMessageCount());
holder.messageUnreadCount.setVisibility(View.VISIBLE);
}
holder.messageUnreadCount.setText(t);
} else {
holder.userAvatar.setImageResource(R.drawable.add_chat_background);
holder.username.setText(R.string.add_new_account);
holder.messageUnreadCount.setVisibility(View.INVISIBLE);
}
holder.itemView.setOnClickListener(v -> mListener.onAccountClick(mAccountsList.get(holder.getAdapterPosition()).isAssigned(), mAccountsList.get(holder.getAdapterPosition()).getId()));
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class FragmentChat method setAvatar.
/**
* call this method for set avatar for this room and this method
* will be automatically detect id and chat type for show avatar
*/
private void setAvatar() {
long idForGetAvatar;
AvatarHandler.AvatarType type;
if (chatType == CHAT) {
idForGetAvatar = chatPeerId;
type = AvatarHandler.AvatarType.USER;
} else {
idForGetAvatar = mRoomId;
type = AvatarHandler.AvatarType.ROOM;
}
final RealmRoom realmRoom = getRoom();
if (realmRoom == null || !realmRoom.isValid()) {
avatarHandler.getAvatar(new ParamWithAvatarType(avatarItem, chatPeerId).avatarSize(R.dimen.dp60).avatarType(AvatarHandler.AvatarType.USER).showMain());
} else {
Bitmap init = HelperImageBackColor.drawAlphabetOnPicture((int) context.getResources().getDimension(R.dimen.dp60), realmRoom.getInitials(), realmRoom.getColor());
avatarHandler.getAvatar(new ParamWithInitBitmap(avatarItem, idForGetAvatar).initBitmap(init).showMain());
}
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class FragmentChannelProfile method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (currentRoomAccess != null) {
checkRoomAccess(currentRoomAccess);
roomAccessChangeListener = (realmRoomAccess, changeSet) -> checkRoomAccess(realmRoomAccess);
currentRoomAccess.addChangeListener(roomAccessChangeListener);
}
imvChannelAvatar = binding.toolbarAvatar;
imvChannelAvatar.setOnClickListener(v -> viewModel.onClickCircleImage());
binding.toolbarBack.setOnClickListener(v -> popBackStackFragment());
binding.toolbarMore.setOnClickListener(v -> showPopUp());
binding.toolbarEdit.setOnClickListener(v -> {
if (getActivity() != null && viewModel.checkIsEditableAndReturnState()) {
new HelperFragment(getActivity().getSupportFragmentManager(), EditChannelFragment.newInstance(viewModel.roomId)).setReplace(false).load();
}
});
viewModel.channelName.observe(getViewLifecycleOwner(), s -> {
binding.toolbarTxtNameCollapsed.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameCollapsed.getPaint().getFontMetricsInt()));
binding.toolbarTxtNameExpanded.setText(EmojiManager.getInstance().replaceEmoji(s, binding.toolbarTxtNameExpanded.getPaint().getFontMetricsInt()));
});
viewModel.channelSecondsTitle.observe(getViewLifecycleOwner(), s -> binding.toolbarTxtStatusExpanded.setText(s));
viewModel.menuPopupVisibility.observe(getViewLifecycleOwner(), integer -> {
if (integer != null) {
binding.toolbarMore.setVisibility(integer);
}
});
viewModel.channelDescription.observe(getViewLifecycleOwner(), description -> {
if (getActivity() != null && description != null) {
binding.description.setText(HelperUrl.setUrlLink(getActivity(), description, true, false, null, true));
}
});
viewModel.goBack.observe(getViewLifecycleOwner(), goBack -> {
if (goBack != null && goBack) {
popBackStackFragment();
}
});
viewModel.muteNotifListener.observe(getViewLifecycleOwner(), isMute -> {
getRoomController().clientMuteRoom(viewModel.roomId, isMute);
binding.enableNotification.setChecked(isMute);
});
viewModel.goToRoomListPage.observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() instanceof ActivityMain && isGo != null && isGo) {
((ActivityMain) getActivity()).removeAllFragmentFromMain();
/*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(2);*/
}
});
viewModel.goToShowMemberList.observe(getViewLifecycleOwner(), data -> {
if (getActivity() != null && data != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowMember.newInstance2(this, data.getRoomId(), data.getRole(), data.getUserId(), data.getSelectedRole(), data.isNeedGetMemberList(), false)).setReplace(false).load();
}
});
viewModel.showDialogCopyLink.observe(getViewLifecycleOwner(), link -> {
if (getActivity() != null && link != null) {
LinearLayout layoutChannelLink = new LinearLayout(getActivity());
layoutChannelLink.setOrientation(LinearLayout.VERTICAL);
View viewRevoke = new View(getActivity());
LinearLayout.LayoutParams viewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
TextInputLayout inputChannelLink = new TextInputLayout(getActivity());
MEditText edtLink = new MEditText(getActivity());
edtLink.setHint(R.string.channel_public_hint_revoke);
edtLink.setTypeface(ResourcesCompat.getFont(edtLink.getContext(), R.font.main_font));
edtLink.setText(link);
edtLink.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dp14));
edtLink.setTextColor(new Theme().getTitleTextColor(getActivity()));
edtLink.setHintTextColor(getResources().getColor(R.color.hint_edit_text));
edtLink.setPadding(0, 8, 0, 8);
edtLink.setEnabled(false);
edtLink.setSingleLine(true);
inputChannelLink.addView(edtLink);
inputChannelLink.addView(viewRevoke, viewParams);
TextView txtLink = new AppCompatTextView(getActivity());
txtLink.setText(link);
txtLink.setTextColor(new Theme().getTitleTextColor(getActivity()));
viewRevoke.setBackgroundColor(getResources().getColor(R.color.line_edit_text));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
edtLink.setBackground(getResources().getDrawable(android.R.color.transparent));
}
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutChannelLink.addView(inputChannelLink, layoutParams);
layoutChannelLink.addView(txtLink, layoutParams);
if (getActivity() != null) {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("LINK_GROUP", link);
clipboard.setPrimaryClip(clip);
Toast.makeText(getActivity(), R.string.copied, Toast.LENGTH_SHORT).show();
}
}
});
viewModel.goToSharedMediaPage.observe(getViewLifecycleOwner(), typeModel -> {
if (getActivity() != null && typeModel != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShearedMedia.newInstance(typeModel)).setReplace(false).load();
}
});
viewModel.goToShowAvatarPage.observe(getViewLifecycleOwner(), roomId -> {
if (getActivity() != null && roomId != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentShowAvatars.newInstance(roomId, FragmentShowAvatars.From.channel)).setReplace(false).load();
}
});
viewModel.showDialogLeaveChannel.observe(getViewLifecycleOwner(), isShow -> showDialogLeaveChannel());
viewModel.goToChatRoom.observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null && isGo) {
((ActivityMain) getActivity()).removeAllFragmentFromMain();
}
});
viewModel.showErrorMessage.observe(getViewLifecycleOwner(), errorMessageResId -> {
if (errorMessageResId != null) {
HelperError.showSnackMessage(getString(errorMessageResId), false);
}
});
BetterLinkMovementMethod.linkify(Linkify.ALL, binding.description).setOnLinkClickListener((tv, url) -> {
return false;
}).setOnLinkLongClickListener((tv, url) -> {
if (HelperUrl.isTextLink(url)) {
G.isLinkClicked = true;
HelperUrl.openLinkDialog(getActivity(), url);
}
return true;
});
// binding.description.setMovementMethod(LinkMovementMethod.getInstance());
AppUtils.setProgresColler(binding.loading);
FragmentShowAvatars.onComplete = (result, messageOne, MessageTow) -> {
long mAvatarId = 0;
if (messageOne != null && !messageOne.equals("")) {
mAvatarId = Long.parseLong(messageOne);
}
avatarHandler.avatarDelete(new ParamWithAvatarType(imvChannelAvatar, viewModel.roomId).avatarType(AvatarHandler.AvatarType.ROOM), mAvatarId);
};
setAvatar();
initialToolbar();
}
Aggregations