Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setContent 导致主线程消息产生大量消息 #82

Open
mrjoechen opened this issue Dec 24, 2022 · 1 comment
Open

setContent 导致主线程消息产生大量消息 #82

mrjoechen opened this issue Dec 24, 2022 · 1 comment

Comments

@mrjoechen
Copy link

#ExpandableTextView.java

   /**
     * 设置内容
     *
     * @param content
     */
    public void setContent(final String content) {
        mContent = content;
        if (isAttached)
            doSetContent();
    }

    /**
     * 实际设置内容的
     */
    private void doSetContent() {
        if (mContent == null) {
            return;
        }
        currentLines = mLimitLines;

        if (mWidth <= 0) {
            if (getWidth() > 0)
                mWidth = getWidth() - getPaddingLeft() - getPaddingRight();
        }

        if (mWidth <= 0) {
            if (retryTime > 10) {
                setText(DEFAULT_CONTENT);
            }
            this.post(new Runnable() {
                @Override
                public void run() {
                    retryTime++;
                    setContent(mContent.toString());
                }
            });
        } else {
            setRealContent(mContent.toString());
        }
    }

没人觉得这段代码有问题么,一直在往主线程抛消息

@bhx844759816
Copy link

这个地方处理不当会导致主线程的IdleHandler不被执行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants