splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 384 forks source link

When adding tokens using addObjectSync, not able to see tokens #373

Closed maheshwariaanchal closed 5 years ago

maheshwariaanchal commented 5 years ago

I am trying to add tokens to the completion view using method "addObjectSync". The tokens get added because I get the callback in onTokenAdded method. But I am unable to visualize them.

Also If I add tokens using method "addObjectAsync" , sometimes I am able to see the added tokens and sometimes not, But the completion view height increases. If I fetch the tokens using "getTokens" method I get the tokens, but the tokens are not visible. Please Help me out. I am stuck past 2 days.

Thanks in Advance

mgod commented 5 years ago

I'm seeing this as well. From what I can tell, it looks like if the view has not been through a layout cycle (or had it's layout be invalidated), creating the token views is not working correctly. It seems to be working correctly in the example project, but not in my real use cases.

mgod commented 5 years ago

As a super quick fix, you can override maxTextWidth in your TokenCompleteTextView subclass with something like:

    @Override
    protected float maxTextWidth() {
        float layoutWidth = super.maxTextWidth();
        if (layoutWidth != 0) {
            return layoutWidth;
        } else {
            return Resources.getSystem().getDisplayMetrics().widthPixels;
        }
    }
mgod commented 5 years ago

This should be fixed without the workaround in 3.0.0