Search in sources :

Example 26 with MessageObject

use of net.iGap.structs.MessageObject in project iGap-Android by KianIranian-STDG.

the class ShowMediaListener method popUpMenuTopSheet.

public void popUpMenuTopSheet(RealmRoomMessage roomMessage) {
    List<Integer> items = new ArrayList<>();
    items.add(R.string.save_to_gallery);
    MessageObject messageObject = MessageObject.create(roomMessage);
    ProtoGlobal.RoomMessageType messageType = ProtoGlobal.RoomMessageType.forNumber(messageObject.messageType);
    if (messageType == ProtoGlobal.RoomMessageType.VIDEO || messageType == ProtoGlobal.RoomMessageType.VIDEO_TEXT) {
        items.add(R.string.share_video_file);
    } else {
        items.add(R.string.share_image);
    }
    if (RoomObject.isRoomPublic(room)) {
        if (MessageObject.canSharePublic(messageObject)) {
            items.add(R.string.share_file_link);
        }
    }
    new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
        if (items.get(position) == R.string.save_to_gallery) {
            saveToGallery(messageObject);
        } else if (items.get(position) == R.string.share_file_link) {
            shareMediaLink(messageObject);
        } else {
            shareContent(messageObject);
        }
    }).show();
}
Also used : TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) Arrays(java.util.Arrays) Bundle(android.os.Bundle) AppUtils(net.iGap.module.AppUtils) NonNull(androidx.annotation.NonNull) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) WindowManager(android.view.WindowManager) Player(com.google.android.exoplayer2.Player) SimpleExoPlayer(com.google.android.exoplayer2.SimpleExoPlayer) MessageProgress(net.iGap.messageprogress.MessageProgress) G(net.iGap.G) RealmUserInfo(net.iGap.realm.RealmUserInfo) LayoutTransition(android.animation.LayoutTransition) Fragment(androidx.fragment.app.Fragment) View(android.view.View) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) RealmConstants(net.iGap.realm.RealmConstants) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) HelperCalander(net.iGap.helper.HelperCalander) Status(net.iGap.module.downloader.Status) ScrollingMovementMethod(android.text.method.ScrollingMovementMethod) RealmRoom(net.iGap.realm.RealmRoom) Downloader(net.iGap.module.downloader.Downloader) ViewGroup(android.view.ViewGroup) HelperLog(net.iGap.helper.HelperLog) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) MusicPlayer(net.iGap.module.MusicPlayer) HttpRequest(net.iGap.module.downloader.HttpRequest) IDownloader(net.iGap.module.downloader.IDownloader) Sort(io.realm.Sort) EventManager(net.iGap.observers.eventbus.EventManager) DownloadObject(net.iGap.module.downloader.DownloadObject) Typeface(android.graphics.Typeface) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) AttachmentObject(net.iGap.structs.AttachmentObject) RippleView(net.iGap.libs.rippleeffect.RippleView) AndroidUtils(net.iGap.module.AndroidUtils) ResourcesCompat(androidx.core.content.res.ResourcesCompat) ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) AccountManager(net.iGap.module.accountManager.AccountManager) Intent(android.content.Intent) ViewPager2(androidx.viewpager2.widget.ViewPager2) PlayerView(com.google.android.exoplayer2.ui.PlayerView) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) ImageLoadingServiceInjector(net.iGap.module.imageLoaderService.ImageLoadingServiceInjector) SparseArrayCompat(androidx.collection.SparseArrayCompat) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) WeakReference(java.lang.ref.WeakReference) VerticalSwipeBackLayout(net.iGap.libs.swipeback.VerticalSwipeBackLayout) AbstractMessage(com.google.protobuf.AbstractMessage) HelperDownloadFile(net.iGap.helper.HelperDownloadFile) LayoutInflater(android.view.LayoutInflater) MessageObject(net.iGap.structs.MessageObject) PhotoView(com.github.chrisbanes.photoview.PhotoView) TextUtils(android.text.TextUtils) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) File(java.io.File) RealmAvatar(net.iGap.realm.RealmAvatar) HelperSaveFile(net.iGap.helper.HelperSaveFile) Configuration(android.content.res.Configuration) ProtoGlobal(net.iGap.proto.ProtoGlobal) ViewTreeObserver(android.view.ViewTreeObserver) R(net.iGap.R) RoomObject(net.iGap.helper.RoomObject) DbManager(net.iGap.module.accountManager.DbManager) ArrayList(java.util.ArrayList) ProtoGlobal(net.iGap.proto.ProtoGlobal) MessageObject(net.iGap.structs.MessageObject)

Example 27 with MessageObject

use of net.iGap.structs.MessageObject in project iGap-Android by KianIranian-STDG.

the class FragmentShearedMedia method initComponent.

private void initComponent(View view) {
    FrameLayout toolbarLayout = view.findViewById(R.id.frg_shared_media_ll_toolbar_layout);
    FragmentMediaContainer mediaContainer = new FragmentMediaContainer(getContext(), this);
    mediaContainer.setListener(i -> {
        switch(i) {
            case FragmentMediaContainer.CALL_TAG:
                getActivity().startActivity(new Intent(getContext(), CallActivity.class));
                break;
            case FragmentMediaContainer.MEDIA_TAG:
                if (!MusicPlayer.isVoice) {
                    Intent intent = new Intent(context, ActivityMain.class);
                    intent.putExtra(ActivityMain.openMediaPlayer, true);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    getActivity().startActivity(intent);
                }
                break;
            case FragmentMediaContainer.PLAY_TAG:
                break;
        }
    });
    sharedMediaToolbar = new Toolbar(getContext());
    sharedMediaToolbar.setBackIcon(new BackDrawable(false));
    sharedMediaToolbar.createToolbarItems();
    sharedMediaToolbar.setTitle(getString(R.string.shared_media));
    sharedMediaToolbar.setListener(i -> {
        switch(i) {
            case -1:
                if (isSelectedMode) {
                    adapter.resetSelected();
                    sharedMediaToolbar.hideActionToolbar();
                    return;
                }
                popBackStackFragment();
                break;
            case deleteTag:
                DbManager.getInstance().doRealmTask(realm -> {
                    String count = SelectedList.size() + "";
                    final RealmRoom realmRoom = RealmRoom.getRealmRoom(realm, roomId);
                    if (roomType == ProtoGlobal.Room.Type.CHAT && bothDeleteMessageId != null && bothDeleteMessageId.size() > 0) {
                        // TODO: 1/10/21 OPTIMAZE CODE
                        // show both Delete check box
                        String delete;
                        if (HelperCalander.isPersianUnicode) {
                            delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + count);
                        } else {
                            delete = HelperCalander.convertToUnicodeFarsiNumber(requireContext().getResources().getString(R.string.st_desc_delete) + "the");
                        }
                        new MaterialDialog.Builder(getContext()).limitIconToDefaultSize().content(delete).title(R.string.message).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive((dialog, which) -> {
                            if (!dialog.isPromptCheckBoxChecked()) {
                                bothDeleteMessageId = null;
                            }
                            if (realmRoom != null) {
                                ArrayList<Long> selectedListForDel = new ArrayList<>();
                                ArrayList<Long> selectedDocumentListForDel = new ArrayList<>();
                                for (StructShearedMedia item : SelectedList) {
                                    selectedListForDel.add(item.messageId);
                                    selectedDocumentListForDel.add(item.documentId);
                                }
                                getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, selectedListForDel, selectedDocumentListForDel, bothDeleteMessageId);
                            }
                            resetItems();
                        }).checkBoxPromptRes(R.string.delete_item_dialog, false, null).show();
                    } else {
                        new MaterialDialog.Builder(requireContext()).title(R.string.message).content(getContext().getResources().getString(R.string.st_desc_delete) + count).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                bothDeleteMessageId = null;
                                if (realmRoom != null) {
                                    ArrayList<Long> messageIds = new ArrayList<>();
                                    ArrayList<Long> documentIds = new ArrayList<>();
                                    for (StructShearedMedia item : SelectedList) {
                                        messageIds.add(item.messageId);
                                        documentIds.add(item.documentId);
                                    }
                                    getMessageController().deleteSelectedMessage(roomType.getNumber(), roomId, messageIds, documentIds, bothDeleteMessageId);
                                }
                                resetItems();
                            }
                        }).show();
                    }
                });
                break;
            case forwardTag:
                ArrayList<MessageObject> messageInfos = new ArrayList<>(SelectedList.size());
                for (StructShearedMedia media : SelectedList) {
                    messageInfos.add(MessageObject.create(media.item));
                }
                FragmentChat.mForwardMessages = messageInfos;
                adapter.resetSelected();
                if (getActivity() instanceof ActivityMain) {
                    ((ActivityMain) getActivity()).setForwardMessage(true);
                    ((ActivityMain) getActivity()).removeAllFragmentFromMain();
                /*new HelperFragment(getActivity().getSupportFragmentManager()).popBackStack(3);*/
                }
                break;
            case seeInChatTag:
                if (SelectedList.size() == 1) {
                    long messageId = SelectedList.get(0).messageId;
                    long documentId = SelectedList.get(0).documentId;
                    RealmRoomMessage.setGap(messageId, documentId);
                    goToPositionFromShardMedia.goToPosition(messageId, documentId);
                    goToPosition = true;
                    popBackStackFragment();
                    adapter.resetSelected();
                    popBackStackFragment();
                }
                break;
        }
    });
    createActionMode();
    toolbarLayout.addView(mediaContainer, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 39, Gravity.BOTTOM, 0, 60, 0, 0));
    toolbarLayout.addView(sharedMediaToolbar);
    progressBar = view.findViewById(R.id.asm_progress_bar_waiting);
    AppUtils.setProgresColler(progressBar);
    mediaTypesLayout = view.findViewById(R.id.asm_ll_media_types_buttons);
    complete = new OnComplete() {

        @Override
        public void complete(boolean result, String messageOne, String MessageTwo) {
            int whatAction = 0;
            String number = "0";
            if (messageOne != null) {
                if (messageOne.length() > 0)
                    whatAction = Integer.parseInt(messageOne);
            }
            if (MessageTwo != null)
                if (MessageTwo.length() > 0)
                    number = MessageTwo;
            callBack(result, whatAction, number);
        }
    };
    recyclerView = view.findViewById(R.id.asm_recycler_view_sheared_media);
    recyclerView.setItemViewCacheSize(400);
    recyclerView.setItemAnimator(null);
    onScrollListener = new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (isThereAnyMoreItemToLoad) {
                if (!isSendRequestForLoading) {
                    int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
                    if (lastVisiblePosition + 30 >= offset) {
                        new RequestClientSearchRoomHistory().clientSearchRoomHistory(roomId, nextMessageId, nextDocumentId, mFilter);
                        isSendRequestForLoading = true;
                        progressBar.setVisibility(View.VISIBLE);
                    }
                }
            }
        }
    };
    recyclerView.addOnScrollListener(onScrollListener);
    checkSelectedDefaultTab();
    makeSharedTypesViews();
    checkSharedButtonsBackgrounds();
}
Also used : ArrayList(java.util.ArrayList) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) CallActivity(net.iGap.activities.CallActivity) ActivityMain(net.iGap.activities.ActivityMain) NonNull(androidx.annotation.NonNull) RealmRoom(net.iGap.realm.RealmRoom) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) FragmentMediaContainer(net.iGap.messenger.ui.components.FragmentMediaContainer) RequestClientSearchRoomHistory(net.iGap.request.RequestClientSearchRoomHistory) OnComplete(net.iGap.observers.interfaces.OnComplete) Intent(android.content.Intent) DialogAction(com.afollestad.materialdialogs.DialogAction) FrameLayout(android.widget.FrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) MessageObject(net.iGap.structs.MessageObject)

Example 28 with MessageObject

use of net.iGap.structs.MessageObject in project iGap-Android by KianIranian-STDG.

the class AbstractMessage method bindView.

@Override
@CallSuper
public void bindView(final VH holder, List<Object> payloads) {
    super.bindView(holder, payloads);
    if (messageObject == null) {
        return;
    }
    NewChatItemHolder mHolder;
    if (holder instanceof NewChatItemHolder) {
        mHolder = (NewChatItemHolder) holder;
    } else if (holder instanceof LogItem.ViewHolder || holder instanceof LogWalletCardToCard.ViewHolder || holder instanceof LogWalletBill.ViewHolder || holder instanceof LogWalletTopup.ViewHolder || holder instanceof LogWallet.ViewHolder) {
        messageClickListener.onItemShowingMessageId(messageObject);
        return;
    } else {
        return;
    }
    this.holder = holder;
    if (messageObject.forwardedMessage == null && messageObject.isSenderMe() && attachment != null && messageObject.status == MessageObject.STATUS_SENDING) {
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_PROGRESS, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPRESS, this);
        if (!Uploader.getInstance().isCompressingOrUploading(messageObject.id + "")) {
            // TODO: 12/29/20 MESSAGE_REFACTOR
            UploadObject fileObject = UploadObject.createForMessage(messageObject, type);
            if (fileObject != null) {
                Uploader.getInstance().upload(fileObject);
            }
        } else {
            MessageProgress messageProgress = ((IProgress) holder).getProgress();
            int progress = Uploader.getInstance().getUploadProgress(messageObject.id + "");
            messageProgress.withProgress(progress);
            receivedEvent(EventManager.ON_UPLOAD_PROGRESS, AccountManager.selectedAccount, String.valueOf(messageObject.id), progress);
        }
    } else {
        EventManager.getInstance(currentAccount).removeObserver(EventManager.ON_UPLOAD_PROGRESS, this);
        EventManager.getInstance(currentAccount).removeObserver(EventManager.ON_UPLOAD_COMPRESS, this);
    }
    if (attachment != null) {
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPRESS, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_UPLOAD_COMPLETED, this);
        EventManager.getInstance(currentAccount).addObserver(EventManager.ON_FILE_DOWNLOAD_COMPLETED, this);
    }
    // TODO: 12/29/20 MESSAGE_REFACTOR
    mHolder.getItemContainer().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            OnClickRow(mHolder, view);
        }
    });
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            OnClickRow(mHolder, view);
        }
    });
    if (holder instanceof CardToCardItem.ViewHolder) {
        CardToCardItem.ViewHolder cardToCardHolder = (CardToCardItem.ViewHolder) holder;
        cardToCardHolder.getRootView().setMinWidth(G.maxChatBox - i_Dp(R.dimen.dp100));
        cardToCardHolder.getInnerLayout().setMinimumWidth(G.maxChatBox - i_Dp(R.dimen.dp100));
        if (messageObject.forwardedMessage == null && messageObject.additionalData != null && messageObject.additionalType == AdditionalType.CARD_TO_CARD_MESSAGE) {
            CardToCardValue value = new CardToCardValue();
            try {
                JSONArray rootJsonArray = new JSONArray(messageObject.additionalData);
                for (int i = 0; i < rootJsonArray.length(); i++) {
                    JSONArray valuJsonArray = rootJsonArray.getJSONArray(i);
                    for (int j = 0; j < valuJsonArray.length(); j++) {
                        JSONObject rootJsonObject = new JSONObject(valuJsonArray.getJSONObject(i).toString());
                        JSONObject valueObject = rootJsonObject.getJSONObject("value");
                        String cardNumber = valueObject.getString("cardNumber");
                        int amount = valueObject.getInt("amount");
                        long userId = valueObject.getLong("userId");
                        value.setAmount(amount);
                        value.setCardNumber(cardNumber);
                        value.setUserId(userId);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            cardToCardHolder.setValue(value);
        }
        cardToCardHolder.setOnCardToCard(cardToCard -> {
            CardToCardHelper.NewCallCardToCard(G.currentActivity, cardToCard.getUserId(), cardToCard.getAmount(), cardToCard.getCardNumber());
        });
    }
    if (holder instanceof ChatItemWithTextHolder) {
        ChatItemWithTextHolder withTextHolder = (ChatItemWithTextHolder) holder;
        // withTextHolder.messageView.setHasEmoji(structMessage.hasEmojiInText());
        int maxsize = 0;
        withTextHolder.removeButtonLayout();
        if ((type == ProtoGlobal.Room.Type.CHANNEL) || (type == ProtoGlobal.Room.Type.CHAT) && messageObject.forwardedMessage != null) {
            maxsize = G.maxChatBox - 16;
        }
        if (maxsize > 0)
            withTextHolder.messageView.setMaxWidth(maxsize);
        if (messageObject.hasLink) {
            try {
                BetterLinkMovementMethod.linkify(Linkify.ALL, withTextHolder.messageView).setOnLinkClickListener((tv, url) -> {
                    return FragmentChat.isInSelectionMode;
                }).setOnLinkLongClickListener((tv, url) -> {
                    if (!FragmentChat.isInSelectionMode) {
                        if (HelperUrl.isTextLink(url)) {
                            G.isLinkClicked = true;
                            messageClickListener.onOpenLinkDialog(url);
                        }
                    }
                    return true;
                });
            } catch (AndroidRuntimeException runtimeException) {
                /**
                 *this try-catch added to fixing bug following bug:
                 * this bug happens because the "Android System WebView" started being
                 * installed as its own application from Android 5.0 and greater and this
                 * code happens to be running while "Android System WebView" is being updated.
                 * While its being updated the package doesn't exist so it causes this exception
                 */
                Toast.makeText(context, R.string.please_try_again, Toast.LENGTH_LONG).show();
            }
        } else {
        // remove BetterLinkMovementMethod
        }
        try {
            if (messageObject.forwardedMessage == null && messageObject.additionalData != null && messageObject.additionalType == AdditionalType.UNDER_MESSAGE_BUTTON) {
                HashMap<Integer, JSONArray> buttonList = MakeButtons.parseData(messageObject.additionalData);
                int rowSize = buttonList.size();
                for (int i = 0; i < rowSize; i++) {
                    int columSize = buttonList.get(i).length();
                    LinearLayout childLayout = MakeButtons.createLayout(((ChatItemWithTextHolder) holder).getContext());
                    for (int j = 0; j < columSize; j++) {
                        ButtonEntity buttonEntity = new Gson().fromJson(buttonList.get(i).get(j).toString(), ButtonEntity.class);
                        buttonEntity.setJsonObject(buttonList.get(i).get(j).toString());
                        childLayout = MakeButtons.addButtons(theme, buttonEntity, buttonList.get(i).length(), 1f, childLayout, (view, btnEntity) -> {
                            if (FragmentChat.isInSelectionMode) {
                                holder.itemView.performLongClick();
                                return;
                            }
                            mAdapter.onBotButtonClicked(() -> onBotBtnClick(view, btnEntity));
                        });
                    }
                    withTextHolder.addButtonLayout(childLayout);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        ((LinearLayout.LayoutParams) ((LinearLayout) withTextHolder.messageView.getParent()).getLayoutParams()).gravity = AndroidUtils.isTextRtl(messageObject.forwardedMessage != null ? messageObject.forwardedMessage.message : messageObject.message) ? Gravity.RIGHT : Gravity.LEFT;
    }
    /**
     * for return message that start showing to view
     */
    messageClickListener.onItemShowingMessageId(messageObject);
    if (isSelected() || messageObject.isSelected) {
        ((FrameLayout) holder.itemView).setForeground(new ColorDrawable(G.context.getResources().getColor(R.color.colorChatMessageSelectableItemBg)));
    } else {
        ((FrameLayout) holder.itemView).setForeground(new ColorDrawable(Color.TRANSPARENT));
    }
    /**
     * only will be called when message layout is directional-base (e.g. single chat)
     */
    if (directionalBased) {
        if (!messageObject.isSenderMe() || type == ProtoGlobal.Room.Type.CHANNEL) {
            updateLayoutForReceive(holder);
        } else if (messageObject.isSenderMe()) {
            updateLayoutForSend(holder);
        }
    }
    if (!messageObject.isTimeOrLogMessage()) {
        /**
         * check failed state ,because if is failed we want show to user even is in channel
         */
        if (mAdapter.getRealmRoom() != null && mAdapter.getRealmRoom().isValid() && mAdapter.getRealmRoom().getType() == ProtoGlobal.Room.Type.CHANNEL && ProtoGlobal.RoomMessageStatus.FAILED != ProtoGlobal.RoomMessageStatus.valueOf(messageObject.status)) {
            mHolder.getMessageStatusTv().setVisibility(View.GONE);
        } else {
            mHolder.getMessageStatusTv().setVisibility(View.VISIBLE);
            AppUtils.rightMessageStatus(mHolder.getMessageStatusTv(), ProtoGlobal.RoomMessageStatus.forNumber(messageObject.status), ProtoGlobal.RoomMessageType.forNumber(messageObject.forwardedMessage != null ? messageObject.forwardedMessage.messageType : messageObject.messageType), messageObject.isSenderMe());
        }
    }
    if (// TODO: 12/29/20 MESSAGE_REFACTOR
    messageObject.edited)
        if (messageObject.channelExtra != null && messageObject.channelExtra.getSignature() != null && messageObject.forwardedMessage.channelExtra.getSignature().length() > 0)
            mHolder.getSignatureTv().setText(mHolder.getResources().getString(R.string.edited) + " " + messageObject.forwardedMessage.channelExtra.getSignature());
        else {
            mHolder.getSignatureTv().setText(mHolder.getResources().getString(R.string.edited));
        }
    else
        mHolder.getSignatureTv().setText("");
    /**
     * display user avatar only if chat type is GROUP
     */
    View messageSenderAvatar = mHolder.getItemContainer().findViewById(R.id.messageSenderAvatar);
    if (messageSenderAvatar != null) {
        messageSenderAvatar.setVisibility(View.GONE);
    }
    replyMessageIfNeeded(holder);
    forwardMessageIfNeeded(holder);
    View messageSenderName = mHolder.getContentBloke().findViewById(R.id.messageSenderName);
    if (messageSenderName != null) {
        messageSenderName.setVisibility(View.GONE);
    }
    if (type == ProtoGlobal.Room.Type.GROUP) {
        if (!messageObject.isSenderMe()) {
            addSenderNameToGroupIfNeed(mHolder);
            if (messageSenderAvatar == null) {
                messageSenderAvatar = ViewMaker.makeCircleImageView();
                mHolder.getItemContainer().addView(messageSenderAvatar, 0);
            }
            messageSenderAvatar.setVisibility(View.VISIBLE);
            messageSenderAvatar.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (FragmentChat.isInSelectionMode) {
                        holder.itemView.performLongClick();
                        return;
                    }
                    messageClickListener.onSenderAvatarClick(v, messageObject, holder.getAdapterPosition());
                }
            });
            messageSenderAvatar.setOnLongClickListener(getLongClickPerform(holder));
            final ImageView copyMessageSenderAvatar = (ImageView) messageSenderAvatar;
            mAdapter.avatarHandler.getAvatar(new ParamWithAvatarType(copyMessageSenderAvatar, messageObject.userId).avatarType(AvatarHandler.AvatarType.USER));
        }
    } else {
        FrameLayout forwardContainer = mHolder.getItemContainer().findViewById(R.id.messageForwardContainer);
        ContextThemeWrapper wrapper = new ContextThemeWrapper(holder.itemView.getContext(), Theme.getInstance().getTheme(holder.itemView.getContext()));
        if (forwardContainer == null) {
            forwardContainer = new FrameLayout(holder.itemView.getContext());
            forwardContainer.setId(R.id.messageForwardContainer);
            if (mAdapter.getRealmRoom() != null && mAdapter.getRealmRoom().getChatRoom() != null && mAdapter.getRealmRoom().getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId()) {
                mHolder.getItemContainer().addView(forwardContainer, 0, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.MATCH_PARENT, Gravity.BOTTOM));
            } else {
                mHolder.getItemContainer().addView(forwardContainer, 1, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.MATCH_PARENT, Gravity.BOTTOM));
            }
            forwardContainer.addView(mHolder.getChannelForwardIv(), LayoutCreator.createFrame(26, 26, Gravity.BOTTOM, 4, 4, 8, 4));
            forwardContainer.setVisibility(View.GONE);
        }
        if (type == ProtoGlobal.Room.Type.CHANNEL) {
            mHolder.getChannelForwardIv().setImageDrawable(VectorDrawableCompat.create(holder.itemView.getContext().getResources(), R.drawable.ic_channel_forward_light, wrapper.getTheme()));
            forwardContainer.setVisibility(View.VISIBLE);
            mHolder.getChannelForwardIv().setOnClickListener(v -> {
                if (isAllowToForward(messageObject))
                    messageClickListener.onForwardClick(messageObject);
            });
        }
        if (type == ProtoGlobal.Room.Type.CHAT && mAdapter.getRealmRoom().getChatRoom() != null && mAdapter.getRealmRoom().getChatRoom().getPeerId() == AccountManager.getInstance().getCurrentUser().getId() && !messageObject.isGiftSticker()) {
            mHolder.getChannelForwardIv().setImageDrawable(VectorDrawableCompat.create(holder.itemView.getContext().getResources(), R.drawable.ic_cloud_forward, wrapper.getTheme()));
            forwardContainer.setVisibility(View.VISIBLE);
            mHolder.getChannelForwardIv().setOnClickListener(v -> {
                if (isAllowToForward(messageObject))
                    messageClickListener.onForwardFromCloudClick(messageObject);
            });
        }
    }
    /**
     * set message time
     */
    String time = HelperCalander.getClocktime(messageObject.createTime, false);
    if (HelperCalander.isPersianUnicode) {
        mHolder.getMessageTimeTv().setText(HelperCalander.convertToUnicodeFarsiNumber(time));
    } else {
        mHolder.getMessageTimeTv().setText(time);
    }
    prepareAttachmentIfNeeded(holder, messageObject.forwardedMessage != null ? messageObject.forwardedMessage.messageType : messageObject.messageType);
    /**
     * show vote layout for channel otherwise hide layout also get message state for channel
     */
    mHolder.getVoteContainer().setVisibility(View.GONE);
    mHolder.getViewContainer().setVisibility(View.GONE);
    if (!(holder instanceof StickerItem.ViewHolder)) {
        if ((type == ProtoGlobal.Room.Type.CHANNEL)) {
            showSeenContainer(holder);
        }
    }
    // TODO: 12/29/20 MESSAGE_REFACTOR
    if (messageObject.channelExtra != null && messageObject.channelExtra.getSignature() != null && messageObject.channelExtra.getSignature().length() > 0) {
        mHolder.getContentBloke().setMinimumWidth(LayoutCreator.dp(200));
    } else if (messageObject.edited) {
        mHolder.getContentBloke().setMinimumWidth(LayoutCreator.dp(100));
    }
}
Also used : NonNull(androidx.annotation.NonNull) FileLog(net.iGap.helper.FileLog) UploadObject(net.iGap.module.upload.UploadObject) ProtoFileDownload(net.iGap.proto.ProtoFileDownload) IMAGE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_VALUE) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) JSONException(org.json.JSONException) AdditionalType(net.iGap.module.additionalData.AdditionalType) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) Log(android.util.Log) ArrayMap(androidx.collection.ArrayMap) Realm(io.realm.Realm) HelperCalander(net.iGap.helper.HelperCalander) ChatSendMessageUtil(net.iGap.module.ChatSendMessageUtil) RealmRoom(net.iGap.realm.RealmRoom) Downloader(net.iGap.module.downloader.Downloader) Uploader(net.iGap.module.upload.Uploader) ViewMaker.i_Dp(net.iGap.adapter.items.chat.ViewMaker.i_Dp) Tuple(net.iGap.libs.Tuple) SHP_SETTING(net.iGap.module.SHP_SETTING) G.context(net.iGap.G.context) OnProgressUpdate(net.iGap.observers.interfaces.OnProgressUpdate) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) EventManager(net.iGap.observers.eventbus.EventManager) DownloadObject(net.iGap.module.downloader.DownloadObject) EmojiManager(net.iGap.libs.emojiKeyboard.emoji.EmojiManager) AttachmentObject(net.iGap.structs.AttachmentObject) HelperUrl(net.iGap.helper.HelperUrl) AbstractItem(com.mikepenz.fastadapter.items.AbstractItem) AccountManager(net.iGap.module.accountManager.AccountManager) ArrayList(java.util.ArrayList) OnMessageProgressClick(net.iGap.messageprogress.OnMessageProgressClick) ButtonActionType(net.iGap.module.additionalData.ButtonActionType) Toast(android.widget.Toast) LayoutCreator(net.iGap.helper.LayoutCreator) IMAGE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.IMAGE_TEXT_VALUE) HelperCheckInternetConnection(net.iGap.helper.HelperCheckInternetConnection) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) AUDIO(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO) SpannableString(android.text.SpannableString) MessageObject(net.iGap.structs.MessageObject) StyleSpan(android.text.style.StyleSpan) TextUtils(android.text.TextUtils) CallSuper(androidx.annotation.CallSuper) File(java.io.File) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) CardToCardHelper(net.iGap.helper.CardToCardHelper) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) AUDIO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_VALUE) BetterLinkMovementMethod(me.saket.bettermovementmethod.BetterLinkMovementMethod) DbManager(net.iGap.module.accountManager.DbManager) FILE_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_TEXT_VALUE) LinearLayout(android.widget.LinearLayout) AppUtils(net.iGap.module.AppUtils) Spannable(android.text.Spannable) Theme(net.iGap.module.Theme) MessageProgress(net.iGap.messageprogress.MessageProgress) GIF_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_VALUE) G(net.iGap.G) LocalFileType(net.iGap.module.enums.LocalFileType) AndroidRuntimeException(android.util.AndroidRuntimeException) RealmUserInfo(net.iGap.realm.RealmUserInfo) JSONObject(org.json.JSONObject) AUDIO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT_VALUE) IMessageItem(net.iGap.observers.interfaces.IMessageItem) Gson(com.google.gson.Gson) Locale(java.util.Locale) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) VIDEO_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_VALUE) MessagesAdapter(net.iGap.adapter.MessagesAdapter) FILE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.FILE_VALUE) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) OnProgress(net.iGap.messageprogress.OnProgress) ViewGroup(android.view.ViewGroup) GIF_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.GIF_TEXT_VALUE) List(java.util.List) TextView(android.widget.TextView) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) MusicPlayer(net.iGap.module.MusicPlayer) G.isLocationFromBot(net.iGap.G.isLocationFromBot) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Typeface(android.graphics.Typeface) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) Context(android.content.Context) AndroidUtils(net.iGap.module.AndroidUtils) ResourcesCompat(androidx.core.content.res.ResourcesCompat) HelperGetMessageState(net.iGap.helper.HelperGetMessageState) MakeButtons(net.iGap.module.MakeButtons) HashMap(java.util.HashMap) Linkify(android.text.util.Linkify) TimeUtils(net.iGap.module.TimeUtils) AdditionalObject(net.iGap.structs.AdditionalObject) FragmentChat(net.iGap.fragments.FragmentChat) MODE_PRIVATE(android.content.Context.MODE_PRIVATE) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) RealmAdditional(net.iGap.realm.RealmAdditional) HelperDownloadFile(net.iGap.helper.HelperDownloadFile) CardToCardValue(net.iGap.model.CardToCardValue) VOICE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE) AUDIO_TEXT(net.iGap.proto.ProtoGlobal.RoomMessageType.AUDIO_TEXT) DialogAction(com.afollestad.materialdialogs.DialogAction) FragmentPaymentBill(net.iGap.fragments.FragmentPaymentBill) RequestManager(net.iGap.network.RequestManager) Color(android.graphics.Color) CountDownTimer(android.os.CountDownTimer) ButtonEntity(net.iGap.module.additionalData.ButtonEntity) ProtoGlobal(net.iGap.proto.ProtoGlobal) VIDEO_TEXT_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VIDEO_TEXT_VALUE) VOICE_VALUE(net.iGap.proto.ProtoGlobal.RoomMessageType.VOICE_VALUE) R(net.iGap.R) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson) SpannableString(android.text.SpannableString) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) CardToCardValue(net.iGap.model.CardToCardValue) AndroidRuntimeException(android.util.AndroidRuntimeException) UploadObject(net.iGap.module.upload.UploadObject) ImageView(android.widget.ImageView) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ImageView(android.widget.ImageView) ReserveSpaceRoundedImageView(net.iGap.module.ReserveSpaceRoundedImageView) ReserveSpaceGifImageView(net.iGap.module.ReserveSpaceGifImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) JSONException(org.json.JSONException) AndroidRuntimeException(android.util.AndroidRuntimeException) JSONObject(org.json.JSONObject) ColorDrawable(android.graphics.drawable.ColorDrawable) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) ButtonEntity(net.iGap.module.additionalData.ButtonEntity) LinearLayout(android.widget.LinearLayout) MessageProgress(net.iGap.messageprogress.MessageProgress) CallSuper(androidx.annotation.CallSuper)

Example 29 with MessageObject

use of net.iGap.structs.MessageObject in project iGap-Android by KianIranian-STDG.

the class AbstractMessage method receivedEvent.

@Override
public void receivedEvent(int id, int account, Object... args) {
    if (id == EventManager.ON_UPLOAD_PROGRESS) {
        G.runOnUiThread(() -> {
            String messageKey = (String) args[0];
            String messageId = String.valueOf(messageObject.id);
            long fileSize = 0;
            if (args.length == 3) {
                fileSize = (long) args[2];
            } else {
                fileSize = attachment.size;
            }
            if (messageKey.equals(messageId)) {
                int progress = (int) args[1];
                String progressString = String.valueOf(progress);
                String attachmentSizeString = AndroidUtils.humanReadableByteCount(fileSize, true);
                if (G.selectedLanguage.equals("fa")) {
                    progressString = HelperCalander.convertToUnicodeFarsiNumber(progressString);
                    attachmentSizeString = HelperCalander.convertToUnicodeFarsiNumber(attachmentSizeString);
                }
                if (holder instanceof FileItem.ViewHolder || holder instanceof VideoWithTextItem.ViewHolder) {
                    TextView progressTextView = ((IProgress) holder).getProgressTextView();
                    progressTextView.setText(String.format(Locale.US, "%s%% — %s", progressString, attachmentSizeString));
                } else if (holder instanceof AudioItem.ViewHolder) {
                    AudioItem.ViewHolder audioHolder = (AudioItem.ViewHolder) holder;
                    audioHolder.getSongTimeTv().setText(String.format(Locale.US, "%s%% — %s", progressString, attachmentSizeString));
                }
                MessageProgress progressView = ((IProgress) holder).getProgress();
                if (progressView.getTag() != null && progressView.getTag().equals(messageObject.id) && messageObject.status != MessageObject.STATUS_FAILED) {
                    if (progress >= 1 && progress != 100) {
                        progressView.withProgress(progress);
                    }
                }
            }
        });
    } else if (id == EventManager.ON_UPLOAD_COMPRESS) {
        G.runOnUiThread(() -> {
            String messageKey = (String) args[0];
            String messageId = String.valueOf(messageObject.id);
            if (messageKey.equals(messageId) && holder instanceof VideoWithTextItem.ViewHolder) {
                VideoWithTextItem.ViewHolder videoHolder = (VideoWithTextItem.ViewHolder) holder;
                int progress = (int) args[1];
                if (progress <= 99) {
                    String progressString = String.valueOf(progress);
                    if (G.selectedLanguage.equals("fa")) {
                        progressString = HelperCalander.convertToUnicodeFarsiNumber(progressString);
                    }
                    videoHolder.duration.setText(String.format(G.context.getResources().getString(R.string.video_duration), progressString + "%" + G.context.getResources().getString(R.string.compressing) + "—" + AndroidUtils.humanReadableByteCount(attachment.size, true), AndroidUtils.formatDuration((int) (attachment.duration * 1000L))));
                } else {
                    long fileSize;
                    if (args.length == 3) {
                        fileSize = (long) args[2];
                    } else {
                        fileSize = attachment.size;
                    }
                    videoHolder.duration.setText(String.format(G.context.getResources().getString(R.string.video_duration), AndroidUtils.humanReadableByteCount(fileSize, true) + " ", AndroidUtils.formatDuration((int) (attachment.duration * 1000L)) + G.context.getResources().getString(R.string.Uploading)));
                }
            }
        });
    } else if (id == EventManager.ON_UPLOAD_COMPLETED) {
        G.runOnUiThread(() -> {
            long messageId = (long) args[1];
            if (messageId == messageObject.id) {
                ProtoGlobal.RoomMessageType messageType = (ProtoGlobal.RoomMessageType) args[0];
                if (attachment == null || args[2] == null || args[3] == null) {
                    return;
                }
                attachment.token = (String) args[3];
                onProgressFinish(holder, attachment, messageType.getNumber());
                loadImageOrThumbnail(messageType);
            }
        });
    } else if (id == EventManager.ON_FILE_DOWNLOAD_COMPLETED) {
        G.runOnUiThread(() -> {
            MessageObject downloadedMessage = (MessageObject) args[0];
            if (downloadedMessage.id == messageObject.id) {
                attachment.filePath = downloadedMessage.attachment.filePath;
                attachment.token = downloadedMessage.attachment.token;
                ProtoGlobal.RoomMessageType messageType = ProtoGlobal.RoomMessageType.forNumber(downloadedMessage.messageType);
                onProgressFinish(holder, downloadedMessage.attachment, messageType.getNumber());
                loadImageOrThumbnail(messageType);
            }
        });
    }
}
Also used : ProtoGlobal(net.iGap.proto.ProtoGlobal) SpannableString(android.text.SpannableString) TextView(android.widget.TextView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) MessageObject(net.iGap.structs.MessageObject) MessageProgress(net.iGap.messageprogress.MessageProgress)

Example 30 with MessageObject

use of net.iGap.structs.MessageObject in project iGap-Android by KianIranian-STDG.

the class AbstractMessage method onBotBtnClick.

public void onBotBtnClick(View v, ButtonEntity buttonEntity) {
    DbManager.getInstance().doRealmTask(realm -> {
        try {
            if (v.getId() == ButtonActionType.USERNAME_LINK) {
                // TODO: fixed this and do not use G.currentActivity
                HelperUrl.checkUsernameAndGoToRoomWithMessageId(G.currentActivity, ((ArrayList<String>) v.getTag()).get(0).substring(1), HelperUrl.ChatEntry.chat, 0, 0);
            } else if (v.getId() == ButtonActionType.BOT_ACTION) {
                long messageId = System.currentTimeMillis();
                RealmRoomMessage roomMessage = new RealmRoomMessage();
                roomMessage.setMessageId(messageId);
                roomMessage.setMessageType(ProtoGlobal.RoomMessageType.TEXT);
                roomMessage.setRoomId(messageObject.roomId);
                roomMessage.setMessage(((ArrayList<String>) v.getTag()).get(1));
                roomMessage.setStatus(ProtoGlobal.RoomMessageStatus.SENDING.toString());
                roomMessage.setUserId(AccountManager.getInstance().getCurrentUser().getId());
                roomMessage.setCreateTime(TimeUtils.currentLocalTime());
                if (((ArrayList<String>) v.getTag()).get(2) != null) {
                    RealmAdditional additional = new RealmAdditional();
                    additional.setId(AppUtils.makeRandomId());
                    additional.setAdditionalData(((ArrayList<String>) v.getTag()).get(2));
                    additional.setAdditionalType(3);
                    roomMessage.setRealmAdditional(additional);
                }
                new Thread(() -> {
                    DbManager.getInstance().doRealmTransaction(realm12 -> {
                        realm12.copyToRealmOrUpdate(roomMessage);
                    });
                }).start();
                MessageObject botMessage = MessageObject.create(roomMessage);
                ChatSendMessageUtil.getInstance(AccountManager.selectedAccount).build(type, messageObject.roomId, botMessage);
                messageClickListener.sendFromBot(botMessage);
            } else if (v.getId() == ButtonActionType.JOIN_LINK) {
                // TODO: fixed this and do not use G.currentActivity
                HelperUrl.checkAndJoinToRoom(G.currentActivity, ((ArrayList<String>) v.getTag()).get(0).substring(14));
            } else if (v.getId() == ButtonActionType.WEB_LINK) {
                HelperUrl.openBrowser(((ArrayList<String>) v.getTag()).get(0));
            } else if (v.getId() == ButtonActionType.WEBVIEW_LINK) {
                messageClickListener.sendFromBot(((ArrayList<String>) v.getTag()).get(0));
            } else if (v.getId() == ButtonActionType.REQUEST_PHONE) {
                try {
                    new MaterialDialog.Builder(G.currentActivity).title(R.string.access_phone_number).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            Long identity = System.currentTimeMillis();
                            realm.executeTransaction(new Realm.Transaction() {

                                @Override
                                public void execute(Realm realm) {
                                    RealmUserInfo realmUserInfo = RealmUserInfo.getRealmUserInfo(realm);
                                    RealmRoomMessage realmRoomMessage = RealmRoomMessage.makeAdditionalData(messageObject.roomId, identity, realmUserInfo.getUserInfo().getPhoneNumber(), realmUserInfo.getUserInfo().getPhoneNumber(), 0, realm, ProtoGlobal.RoomMessageType.TEXT);
                                    MessageObject botMessage = MessageObject.create(realmRoomMessage);
                                    ChatSendMessageUtil.getInstance(AccountManager.selectedAccount).build(type, messageObject.roomId, botMessage);
                                    messageClickListener.sendFromBot(botMessage);
                                }
                            });
                        }
                    }).show();
                } catch (Exception e) {
                }
            } else if (v.getId() == ButtonActionType.REQUEST_LOCATION) {
                try {
                    new MaterialDialog.Builder(G.currentActivity).title(R.string.access_location).positiveText(R.string.ok).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {

                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            if (G.locationListener != null) {
                                isLocationFromBot = true;
                                G.locationListener.requestLocation();
                            }
                        }
                    }).show();
                } catch (Exception e) {
                }
            } else if (v.getId() == ButtonActionType.PAY_DIRECT) {
                JSONObject jsonObject = new JSONObject(((ArrayList<String>) v.getTag()).get(0));
                RealmRoom room = realm.where(RealmRoom.class).equalTo("id", messageObject.roomId).findFirst();
                new HelperFragment(G.currentActivity.getSupportFragmentManager()).loadPayment(room.getTitle(), jsonObject.getString("token"), null);
            } else if (v.getId() == ProtoGlobal.DiscoveryField.ButtonActionType.CARD_TO_CARD.getNumber()) {
                JSONObject rootJsonObject = new JSONObject(buttonEntity.getJsonObject());
                JSONObject valueObject = rootJsonObject.getJSONObject("value");
                String cardNumber = valueObject.getString("cardNumber");
                int amount = valueObject.getInt("amount");
                long userId = valueObject.getLong("userId");
                CardToCardHelper.NewCallCardToCard(G.currentActivity, userId, amount, cardNumber);
            } else if (v.getId() == ProtoGlobal.DiscoveryField.ButtonActionType.BILL_MENU.getNumber()) {
                try {
                    JSONObject jsonObject = new JSONObject(((ArrayList<String>) v.getTag()).get(0));
                    new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills, jsonObject)).setReplace(false).load();
                } catch (JSONException e) {
                    new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills)).setReplace(false).load();
                }
            } else if (v.getId() == ProtoGlobal.DiscoveryField.ButtonActionType.TRAFFIC_BILL_MENU.getNumber()) {
                try {
                    JSONObject jsonObject = new JSONObject(((ArrayList<String>) v.getTag()).get(0));
                    new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime, jsonObject)).setReplace(false).load();
                } catch (JSONException e) {
                    new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime)).setReplace(false).load();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(G.context, "دستور با خطا مواجه شد", Toast.LENGTH_LONG).show();
        }
    });
/**
 * The data was sent via the button via the view tag. Right now I only do this for the card due to lack of time with the new object
 */
}
Also used : RealmAdditional(net.iGap.realm.RealmAdditional) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) NonNull(androidx.annotation.NonNull) RealmRoom(net.iGap.realm.RealmRoom) Realm(io.realm.Realm) RealmUserInfo(net.iGap.realm.RealmUserInfo) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) JSONException(org.json.JSONException) JSONException(org.json.JSONException) AndroidRuntimeException(android.util.AndroidRuntimeException) JSONObject(org.json.JSONObject) DialogAction(com.afollestad.materialdialogs.DialogAction) RealmRoomMessage(net.iGap.realm.RealmRoomMessage) HelperFragment(net.iGap.helper.HelperFragment) MessageObject(net.iGap.structs.MessageObject)

Aggregations

MessageObject (net.iGap.structs.MessageObject)30 RealmRoomMessage (net.iGap.realm.RealmRoomMessage)18 ArrayList (java.util.ArrayList)13 File (java.io.File)11 RealmRoom (net.iGap.realm.RealmRoom)11 SuppressLint (android.annotation.SuppressLint)10 ProtoGlobal (net.iGap.proto.ProtoGlobal)10 NonNull (androidx.annotation.NonNull)9 TextView (android.widget.TextView)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 List (java.util.List)8 G (net.iGap.G)8 HelperString (net.iGap.helper.HelperString)8 View (android.view.View)7 ImageView (android.widget.ImageView)7 Realm (io.realm.Realm)7 Intent (android.content.Intent)6 ViewGroup (android.view.ViewGroup)6 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)6 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)6