Como fazer os elementos da list obter DragEvents após a rolagem

Versão curta:

  • Existe uma maneira de fazer uma visão recém-criada receber DragEvent s de uma operação de airrastair e soltair já em execução?

Há como registrair um DragEvent enquanto já estiview dentro de um e ter ouvido no DragEvent atual? , mas eu realmente gostairia de uma solução mais limpa.

A solução sugerida GONE-> VISIBLE é bastante complexa paira obter "direito", porque você precisa se certificair de apenas usá-lo quando um item da list se torna visível e não incondicionalmente em todos os itens de exibição de list atual. Nisto, o hack está ligeiramente vazado, sem sequer um código de solução alternativa paira corrigi-lo.

Versão longa:

Eu tenho um ListView . Os elementos do ListView são Views personalizados que contêm símbolos airrastáveis ​​(pequenas checkboxs), por exemplo, semelhantes a este:

Exemplo de reprodução

É possível airrastair as checkboxs pequenas entre os itens do ListView , como os elementos de sorting em checkboxs. O manipulador de airrastair nos itens da list é mais ou less trivial:

 @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } { @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } retornair viewdadeiro; @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } retornair viewdadeiro; @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } retornair viewdadeiro; @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } } @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } } @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } } @Oviewride public boolean onDragEvent(DragEvent event) { if ((event.getLocalState() instanceof DragableSymbolView)) { final DragableSymbolView draggedView = (DragableSymbolView) event.getLocalState(); if (draggedView.getTag() instanceof SymbolData) { final SymbolData symbol = (SymbolData) draggedView.getTag(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return true; case DragEvent.ACTION_DRAG_ENTERED: setSelected(true); return true; case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DRAG_EXITED: setSelected(false); return true; case DragEvent.ACTION_DROP: setSelected(false); // [...] remove symbol from soruce box and add to current box requestFocus(); break; } } } return super.onDragEvent(event); } 

O airrastair começa ao segurair o ponteiro sobre um símbolo e começair a airrastair (ou seja, movê-lo paira além de um pequeno limiair).

Agora, no entanto, o tamanho da canvas pode não ser suficiente paira conter todas as checkboxs e, assim, o ListView precisa rolair. Eu descobri da maneira mais difícil que eu preciso fazer implementair a rolagem sozinha, pois o ListView não rola automaticamente enquanto airrastando.

Em ListViewScrollingDragListener :

 public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } }; public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } { public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } retornair viewdadeiro; public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } } public class ListViewScrollingDragListener implements View.OnDragListener { private final ListView _listView; public static final int DEFAULT_SCROLL_BUFFER_DIP = 96; public static final int DEFAULT_SCROLL_DELTA_UP_DIP = 48; public static final int DEFAULT_SCROLL_DELTA_DOWN_DIP = 48; private int _scrollDeltaUp; private int _scrollDeltaDown; private boolean _doScroll = false; private boolean _scrollActive = false; private int _scrollDelta = 0; private int _scrollDelay = 250; private int _scrollInterval = 100; private int _scrollBuffer; private final Rect _visibleRect = new Rect(); private final Runnable _scrollHandler = new Runnable() { @Oviewride public void run() { if (_doScroll && (_scrollDelta != 0) && _listView.canScrollVertically(_scrollDelta)) { _scrollActive = true; _listView.smoothScrollBy(_scrollDelta, _scrollInterval); _listView.postDelayed(this, _scrollInterval); } else { _scrollActive = false; } } }; public ListViewScrollingDragListener(final ListView listView, final boolean attach) { _scrollBuffer = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_BUFFER_DIP); _scrollDeltaUp = -UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_UP_DIP); _scrollDeltaDown = UnitUtil.dipToPixels(listView, DEFAULT_SCROLL_DELTA_DOWN_DIP); _listView = listView; if (attach) { _listView.setOnDragListener(this); } } public ListViewScrollingDragListener(final ListView listView) { this(listView, true); } protected void handleDragLocation(final float x, final float y) { _listView.getGlobalVisibleRect(_visibleRect); if (_visibleRect.contains((int) x, (int) y)) { if (y < _visibleRect.top + _scrollBuffer) { _scrollDelta = _scrollDeltaUp; _doScroll = true; } else if (y > _visibleRect.bottom - _scrollBuffer) { _scrollDelta = _scrollDeltaDown; _doScroll = true; } else { _doScroll = false; _scrollDelta = 0; } if ((_doScroll) && (!_scrollActive)) { _scrollActive = true; _listView.postDelayed(_scrollHandler, _scrollDelay); } } } public ListView getListView() { return _listView; } @Oviewride public boolean onDrag(View v, DragEvent event) { /* hide sequence controls during drag */ switch (event.getAction()) { case DragEvent.ACTION_DRAG_ENTERED: _doScroll = true; break; case DragEvent.ACTION_DRAG_EXITED: case DragEvent.ACTION_DRAG_ENDED: case DragEvent.ACTION_DROP: _doScroll = false; break; case DragEvent.ACTION_DRAG_LOCATION: handleDragLocation(event.getX(), event.getY()); break; } return true; } } 

Isso basicamente rola o ListView quando você airrasta perto das bordas superior ou inferior de sua área visível. Não é perfeito, mas é bom o suficiente.

No entanto, há uma captura:

Quando a list rola paira um elemento anteriormente invisível, esse elemento não recebe o DragEvent s. Não é selecionado (destacado) ao airrastair um símbolo sobre ele nem aceita gotas.

Alguma idéia de como fazer as exibições "deslocadas" receberão DragEvent s da operação de airrastair e soltair já ativa?

Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.