Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[android] list support drag-drop feature #416

Merged
merged 12 commits into from
Jun 9, 2017

Conversation

Rowandjj
Copy link
Contributor

@Rowandjj Rowandjj commented Jun 5, 2017

use RecyclerView's ItemTouchHelper to implement drag-drop feature.

feature:

  1. support both pan and longPress gesture to trigger drag-drop;
  2. support liner/grid layout;
  3. support dragStart/dragEnd event;
  4. support excluded some cells when dragging;

extend attrs:

list:
  • draggable: whether draggable or not;
  • drag-trigger-type: which gesture type will trigger drag-drop;
cell:
  • drag-excluded: whether we should ignore current cell for dragging;
any component:
  • drag-anchor: the anchor that will trigger drag-drop

JIRA: https://issues.apache.org/jira/browse/WEEX-37

@weex-bot
Copy link

weex-bot commented Jun 5, 2017

Warnings
⚠️ No Changelog changes!
⚠️ This PR should update related documents as well.
⚠️ Potential BREAK CHANGE. Modify public in android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java without metion it in commit message. You'd better add '@notdanger' in your commit log.
Messages
📖 According to the blame info, we recommended @sospartan , @misakuo to be the reviewers.

Generated by 🚫 dangerJS


private static final String EVENT_START_DRAG = "dragstart";
private static final String EVENT_END_DRAG = "dragend";

Copy link
Contributor

@sospartan sospartan Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these unnecessary lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay


class DefaultDragHelper implements WXDragHelper {

private boolean isLongPressEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suffix 'm'

@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
if(recyclerView.getLayoutManager() instanceof GridLayoutManager || recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager){
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass the expression to the method, the final variable dragFlags is useless.

private final WXDragHelper mWXDragHelper;
private boolean enableDifferentViewTypeDrag = false;

private int dragFrom = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field suffix `m'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix?

return triggerType;
}

private boolean getExcluded(@Nullable ImmutableDomObject domObject) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to isExcluded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License header is incorrect.

* Date: 16/4/5<br/>
* Time: 上午11:34<br/>
*/
interface WXDragHelper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not suffix WX with new file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allright

@sospartan
Copy link
Contributor

Please put the PR description to JIRA. And rebase your branch to fix the travis issue.

@Rowandjj
Copy link
Contributor Author

Rowandjj commented Jun 8, 2017

https://issues.apache.org/jira/browse/WEEX-37 @sospartan

@Rowandjj Rowandjj closed this Jun 8, 2017
@Rowandjj Rowandjj reopened this Jun 8, 2017
@Rowandjj Rowandjj closed this Jun 8, 2017
@Rowandjj Rowandjj reopened this Jun 8, 2017
@asfgit asfgit merged commit 45cb5f0 into apache:0.14-dev Jun 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants