Search in sources :

Example 11 with ParamWithAvatarType

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();
        }
    });
}
Also used : AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 12 with ParamWithAvatarType

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();
    });
}
Also used : CircleImageView(net.iGap.module.CircleImageView) TextView(android.widget.TextView) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 13 with ParamWithAvatarType

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()));
}
Also used : ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 14 with ParamWithAvatarType

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());
    }
}
Also used : ParamWithInitBitmap(net.iGap.helper.avatar.ParamWithInitBitmap) Bitmap(android.graphics.Bitmap) ParamWithInitBitmap(net.iGap.helper.avatar.ParamWithInitBitmap) RealmRoom(net.iGap.realm.RealmRoom) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType)

Example 15 with ParamWithAvatarType

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();
}
Also used : ClipboardManager(android.content.ClipboardManager) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) NonNull(androidx.annotation.NonNull) ViewModel(androidx.lifecycle.ViewModel) Theme(net.iGap.module.Theme) G(net.iGap.G) ClipboardManager(android.content.ClipboardManager) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) DataBindingUtil(androidx.databinding.DataBindingUtil) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) MEditText(net.iGap.module.MEditText) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) RequestChannelKickAdmin(net.iGap.request.RequestChannelKickAdmin) ViewGroup(android.view.ViewGroup) FragmentChannelProfileViewModel(net.iGap.viewmodel.FragmentChannelProfileViewModel) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) AlphaAnimation(android.view.animation.AlphaAnimation) CLIPBOARD_SERVICE(android.content.Context.CLIPBOARD_SERVICE) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) EventManager(net.iGap.observers.eventbus.EventManager) NotNull(org.jetbrains.annotations.NotNull) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) ResourcesCompat(androidx.core.content.res.ResourcesCompat) ActivityMain(net.iGap.activities.ActivityMain) HelperUrl(net.iGap.helper.HelperUrl) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AccountManager(net.iGap.module.accountManager.AccountManager) Linkify(android.text.util.Linkify) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) Toast(android.widget.Toast) ActivityProfileChannelBinding(net.iGap.databinding.ActivityProfileChannelBinding) Build(android.os.Build) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) RealmRoomAccess(net.iGap.realm.RealmRoomAccess) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) RequestChannelKickModerator(net.iGap.request.RequestChannelKickModerator) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) CircleImageView(net.iGap.module.CircleImageView) OnChannelAvatarDelete(net.iGap.observers.interfaces.OnChannelAvatarDelete) TypedValue(android.util.TypedValue) R(net.iGap.R) BetterLinkMovementMethod(me.saket.bettermovementmethod.BetterLinkMovementMethod) DbManager(net.iGap.module.accountManager.DbManager) RequestChannelKickMember(net.iGap.request.RequestChannelKickMember) MEditText(net.iGap.module.MEditText) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) View(android.view.View) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) CircleImageView(net.iGap.module.CircleImageView) ActivityMain(net.iGap.activities.ActivityMain) Theme(net.iGap.module.Theme) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) HelperFragment(net.iGap.helper.HelperFragment) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ClipData(android.content.ClipData) LinearLayout(android.widget.LinearLayout)

Aggregations

ParamWithAvatarType (net.iGap.helper.avatar.ParamWithAvatarType)23 AvatarHandler (net.iGap.helper.avatar.AvatarHandler)10 View (android.view.View)9 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)8 HelperFragment (net.iGap.helper.HelperFragment)8 Theme (net.iGap.module.Theme)8 TextView (android.widget.TextView)7 NonNull (androidx.annotation.NonNull)7 Bundle (android.os.Bundle)6 Nullable (androidx.annotation.Nullable)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 G (net.iGap.G)6 R (net.iGap.R)6 CircleImageView (net.iGap.module.CircleImageView)6 DbManager (net.iGap.module.accountManager.DbManager)6 Gravity (android.view.Gravity)5 ViewGroup (android.view.ViewGroup)5 FrameLayout (android.widget.FrameLayout)5 Toast (android.widget.Toast)5