android-floating-action-button icon indicating copy to clipboard operation
android-floating-action-button copied to clipboard

Issue with touch delegate

Open yuanliu666 opened this issue 7 years ago • 0 comments

I came into a weird problem in my app. I use a global floating action menu and show hide different floating action buttons across a view pager. The problem is that for some cases the text view title has a wrong click action.
After a little bit research I believe this is a bug. So the code uses mTouchDelegateGroup to store touch delegates, but it's only cleared when the layout is changed:

  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    switch (mExpandDirection) {
    case EXPAND_UP:
    case EXPAND_DOWN:
      boolean expandUp = mExpandDirection == EXPAND_UP;

      if (changed) {
        mTouchDelegateGroup.clearTouchDelegates();
      }
...

Therefore, if somehow the size is not changed, the touch delegates are not cleared, which will cause problem. For my case, when the number of buttons remains unchanged after show hide.
Currently I have not come up with a good solution without modifying the source code. A working solution is to force layout plus extend the floating action menu and always set changed to true.
Let me know if there are better solutions or any problems. Thanks.

yuanliu666 avatar Jan 04 '18 21:01 yuanliu666