Git Product home page Git Product logo

dragdroplistview's Introduction

DragDropListView project

This project can help developers implement drag and drop effects quickly.

Gradle

dependencies {
    ...
    compile 'cc.solart:dragdrop:1.1.0'
}

Usage

you can use DragDropListView as GridView, just adding two attributes. <attr name="fixed_type" format="boolean"/>,<attr name="anim_duration" format="integer"/>

<cc.solart.dragdrop.DragDropListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:divider="@null"
        android:horizontalSpacing="5dip"
        android:verticalSpacing="5dip"
        android:fadingEdge="none"
        android:nestedScrollingEnabled="true"
        android:numColumns="4"
        app:fixed_type="true"/>

you must layout a ImageView for drag shadow

<FrameLayout
        android:id="@+id/activity_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/tile_drag_shadow_overlay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:importantForAccessibility="no"
            android:visibility="gone" />
    </FrameLayout>
   final ImageView dragShadowOverlay =
                (ImageView) findViewById(R.id.tile_drag_shadow_overlay);
   mListView.setDragShadowOverlay(dragShadowOverlay);

and you must extend AbsTileAdapter to implement two abstract methods that are necessary. You must implement IDragEntity interface in order to ensure that you are properly ordered.

public class SimpleTileAdapter extends AbsTileAdapter {
    private TileView.OnSelectedListener mListener;
    public SimpleTileAdapter(Context context, DragDropListener dragDropListener, TileView.OnSelectedListener listener) {
        super(context, dragDropListener);
        ...
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ...
    }

    @Override
    protected IDragEntity getDragEntity(View view) {
        ...
    }
}
   mListView.getDragDropController().addOnDragDropListener(mSimpleTileAdapter);

See examples in detail.

Changelog

  • 1.0.0
    • Initial release
  • 1.1.0
    • Added some position does not drag and drop

License

Copyright 2015 - 2016 solartisan/imilk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.

dragdroplistview's People

Contributors

solartcc avatar

Watchers

James Cloos avatar Jacky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.