mabbas007 / TagsEditText

Android EditText for view tags or chips
Apache License 2.0
694 stars 124 forks source link

directly scroll bottom when we scroll for go top (scroll not working) #48

Open birjubhatt opened 6 years ago

birjubhatt commented 6 years ago

i enter 50 tags...when i scroll to show my 1st tag then directly pointed my last tag...how to i show my 1 st tag and remove that directly move to bottom scroll ?

pianomar commented 6 years ago

What's actually happening is that it's deleting the tag you touched, which is activating the TagsChanged listener I presume, and setting the focus on the end, I found that out and I tried fixing it so the touch down and up deletes the tag, while the moving scrolls. This is what I had to do:

tagsEditText.setOnTouchListener((v, event) -> {
                switch (event.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_UP:
                        tagsEditText.setMovementMethod(new LinkMovementMethod());
                        break;
                    case MotionEvent.ACTION_MOVE:
                        tagsEditText.setMovementMethod(new ScrollingMovementMethod());
                        tagsEditText.setToDeleteTag(false);
                        break;
                    case MotionEvent.ACTION_DOWN:
                        tagsEditText.setMovementMethod(new ScrollingMovementMethod());
                        tagsEditText.setToDeleteTag(true);
                        break;
                }
            return false;
        });

Now in the onClick in the method addTagSpan, you would surround the onClick method with


if (mToDeleteTag) {

}