kandi background
Explore Kits

drag-sort-listview | Android ListView with drag and drop reordering | Widget library

 by   bauerca Java Version: Current License: No License

 by   bauerca Java Version: Current License: No License

Download this library from

kandi X-RAY | drag-sort-listview Summary

drag-sort-listview is a Java library typically used in User Interface, Widget applications. drag-sort-listview has no bugs, it has no vulnerabilities, it has build file available and it has medium support. You can download it from GitHub.
DragSortListView (DSLV) is an extension of the Android ListView that enables drag-and-drop reordering of list items. It is a ~~major overhaul~~ complete rewrite of the [TouchInterceptor](https://github.com/android/platform_packages_apps_music/blob/master/src/com/android/music/TouchInterceptor.java) (TI) meant to give drag-sorting a polished feel. Some key features are:.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • drag-sort-listview has a medium active ecosystem.
  • It has 3219 star(s) with 1508 fork(s). There are 310 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 57 open issues and 71 have been closed. On average issues are closed in 38 days. There are 7 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of drag-sort-listview is current.
drag-sort-listview Support
Best in #Widget
Average in #Widget
drag-sort-listview Support
Best in #Widget
Average in #Widget

quality kandi Quality

  • drag-sort-listview has 0 bugs and 0 code smells.
drag-sort-listview Quality
Best in #Widget
Average in #Widget
drag-sort-listview Quality
Best in #Widget
Average in #Widget

securitySecurity

  • drag-sort-listview has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • drag-sort-listview code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
drag-sort-listview Security
Best in #Widget
Average in #Widget
drag-sort-listview Security
Best in #Widget
Average in #Widget

license License

  • drag-sort-listview does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
drag-sort-listview License
Best in #Widget
Average in #Widget
drag-sort-listview License
Best in #Widget
Average in #Widget

buildReuse

  • drag-sort-listview releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • drag-sort-listview saves you 2218 person hours of effort in developing the same functionality from scratch.
  • It has 4854 lines of code, 305 functions and 64 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
drag-sort-listview Reuse
Best in #Widget
Average in #Widget
drag-sort-listview Reuse
Best in #Widget
Average in #Widget
Top functions reviewed by kandi - BETA

kandi has reviewed drag-sort-listview and discovered the below as its top functions. This is intended to give you an instant insight into drag-sort-listview implemented functionality, and help decide if they suit your requirements.

  • Update the positions based on the set of visible positions .
    • Determine the position of a touch event .
      • Binds a view to this View .
        • Measure a child view .
          • Create dialog .
            • Create a float view
              • Initializes the Drag SortView .
                • Drops a mapping
                  • Initializes the list view .
                    • Create a new instance of DSLVFragmentClicks .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      drag-sort-listview Key Features

                      Clean drag and drop (no visual glitches; I hope!)

                      Intuitive and smooth scrolling while dragging.

                      Support for heterogeneous item heights.

                      Public startDrag() and stopDrag() methods.

                      Public interface for customizing the floating View.

                      Listeners

                      copy iconCopydownload iconDownload
                      public void drop(int from, int to);

                      Additional documentation

                      copy iconCopydownload iconDownload
                      javadoc com.mobeta.android.dslv *

                      Installation

                      copy iconCopydownload iconDownload
                      git clone https://github.com/bauerca/drag-sort-listview.git

                      Ant

                      copy iconCopydownload iconDownload
                      android update project --path ./

                      Maven

                      copy iconCopydownload iconDownload
                      mvn clean install

                      Debugging

                      copy iconCopydownload iconDownload
                      adb [-e|-d|-s device] pull /sdcard/dslv_state.txt

                      License

                      copy iconCopydownload iconDownload
                      A subclass of the Android ListView component that enables drag
                      and drop re-ordering of list items.
                      
                      Copyright 2012 Carl Bauer
                      
                      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.

                      Moving a row in sqlite (Position column)

                      copy iconCopydownload iconDownload
                      public void moveValues(int from, int to) {
                          SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
                          String query =
                                  "WITH p(from_position,to_position,max_position,min_position) AS (" +
                                          "SELECT " +
                                          "?," +
                                          "?," +
                                          "(SELECT max(" + COLUMN_5 + ") FROM " + TABLE_NAME + ")," +
                                          "(SELECT min(" + COLUMN_5 + ") FROM " + TABLE_NAME + ")), " +
                      
                                          "updates AS(" +
                                          "SELECT " + TABLE_NAME + ".id," + COLUMN_5 + " AS current, " + COLUMN_5 + " + 1 AS proposed " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " >= (SELECT to_position FROM p) " +
                                          "AND " + COLUMN_5 + " < (SELECT from_position FROM p) " +
                      
                                          "UNION SELECT " + TABLE_NAME + ".id," + COLUMN_5 + " AS current, " + COLUMN_5 + " -1 AS proposed " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " <= (SELECT to_position FROM p) " +
                                          "AND " + COLUMN_5 + " > (SELECT from_position FROM p) " +
                      
                                          "UNION SELECT " + TABLE_NAME + ".id," + COLUMN_5 + ",(SELECT to_position FROM p) " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " = (SELECT from_position FROM p) " +
                                          "AND (SELECT from_position FROM p) <> (SELECT to_position FROM p)" +
                                          "), " +
                      
                                          "finish_updates AS (" +
                                          "SELECT * FROM updates " +
                                          "WHERE max((SELECT from_position FROM p),(SELECT to_position FROM p)) <= (SELECT max_position FROM p) " +
                                          "AND min((SELECT from_position FROM p),(SELECT to_position FROM p)) >= (SELECT min_position FROM p)" +
                                          ")" +
                      
                                          "UPDATE " + TABLE_NAME + " SET " + COLUMN_5 + " = " +
                                          "(" +
                                          " SELECT proposed " +
                                          " FROM finish_updates " +
                                          " WHERE finish_updates.id = " + TABLE_NAME + ".id" +
                                          ") " +
                                          "WHERE " + TABLE_NAME + ".id IN " +
                                          "(" +
                                          " SELECT id FROM finish_updates" +
                                          ");";
                          SQLiteStatement stmnt = sqLiteDatabase.compileStatement(query);
                          stmnt.bindLong(1,from);
                          stmnt.bindLong(2,to);
                          stmnt.executeUpdateDelete();
                      }
                      

                      Community Discussions

                      Trending Discussions on drag-sort-listview
                      • Moving a row in sqlite (Position column)
                      Trending Discussions on drag-sort-listview

                      QUESTION

                      Moving a row in sqlite (Position column)

                      Asked 2020-Jan-22 at 11:02

                      So, I am currently using the DragSortListView with a SQLite database. I want to resort my database whenever im dragging an item of the ListView to a new position. Therefore I wrote a piece of code that should manage it. But if I'm moving something from a position below to a higher one, it is strangely sorted. I already looked on this code for hours and asked some friends, but I never found the solution.

                      Code

                      Method in the DatabaseHelper

                      public void moveValues(int from, int to, String sammlung){
                          SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
                          System.out.println(from + " - " + to);
                          if(from < to){
                              //This part is working properly
                              Cursor cursor = sqLiteDatabase.rawQuery("SELECT ID FROM " + TABLE_NAME + " WHERE POSITION IS " + "\"" + from + "\" AND SAMMLUNG IS " + "\"" + sammlung + "\"", null);
                              for (int i = from+1; i < to+1; i++){
                                  switchPositionValue(i, i-1);
                              }
                              ContentValues contentValues = new ContentValues();
                              contentValues.put(COLUMN_5, to);
                              cursor.moveToFirst();
                              sqLiteDatabase.update(TABLE_NAME, contentValues, "ID=?", new String[]{cursor.getInt(0)+""});
                              cursor.close();
                          }else{
                              //This is the not working part
                              Cursor cursor = sqLiteDatabase.rawQuery("SELECT ID FROM " + TABLE_NAME + " WHERE POSITION IS " + "\"" + from + "\" AND SAMMLUNG IS " + "\"" + sammlung + "\"", null);
                              for (int i = from-1; i > to-1; i--){
                                  switchPositionValue(i, i+1);
                              }
                              ContentValues contentValues = new ContentValues();
                              contentValues.put(COLUMN_5, to);
                              cursor.moveToFirst();
                              System.out.println(cursor.getInt(0));
                              //The next line destroys it. But I dont know how to fix it or what exactly is not working
                              sqLiteDatabase.update(TABLE_NAME, contentValues, "ID=?", new String[]{cursor.getInt(0)+""});
                              cursor.close();
                          }
                      }
                      

                      The parameters are: from: The position it's taken away from to: The position it's taken to sammlung: I saving all the items of different collections in one database. So it's only there to sort out only specific items.

                      Method to change the value of a row with a specific position

                      public void switchPositionValue(int before, int after){
                          SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
                          ContentValues contentValues = new ContentValues();
                          contentValues.put(COLUMN_5, after);
                          sqLiteDatabase.update(TABLE_NAME, contentValues, "POSITION=?", new String[]{before+""});
                      }
                      
                      Demonstration

                      Demonstration

                      So if you've got any idea why its behaving this strange or do know a better approach to moving a row in a database, I would really appreciate your help.

                      ANSWER

                      Answered 2020-Jan-22 at 11:02

                      Android other way SQL one (COLUMN_5 is POSITION column)

                      public void moveValues(int from, int to) {
                          SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
                          String query =
                                  "WITH p(from_position,to_position,max_position,min_position) AS (" +
                                          "SELECT " +
                                          "?," +
                                          "?," +
                                          "(SELECT max(" + COLUMN_5 + ") FROM " + TABLE_NAME + ")," +
                                          "(SELECT min(" + COLUMN_5 + ") FROM " + TABLE_NAME + ")), " +
                      
                                          "updates AS(" +
                                          "SELECT " + TABLE_NAME + ".id," + COLUMN_5 + " AS current, " + COLUMN_5 + " + 1 AS proposed " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " >= (SELECT to_position FROM p) " +
                                          "AND " + COLUMN_5 + " < (SELECT from_position FROM p) " +
                      
                                          "UNION SELECT " + TABLE_NAME + ".id," + COLUMN_5 + " AS current, " + COLUMN_5 + " -1 AS proposed " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " <= (SELECT to_position FROM p) " +
                                          "AND " + COLUMN_5 + " > (SELECT from_position FROM p) " +
                      
                                          "UNION SELECT " + TABLE_NAME + ".id," + COLUMN_5 + ",(SELECT to_position FROM p) " +
                                          "FROM " + TABLE_NAME + " " +
                                          "WHERE " + COLUMN_5 + " = (SELECT from_position FROM p) " +
                                          "AND (SELECT from_position FROM p) <> (SELECT to_position FROM p)" +
                                          "), " +
                      
                                          "finish_updates AS (" +
                                          "SELECT * FROM updates " +
                                          "WHERE max((SELECT from_position FROM p),(SELECT to_position FROM p)) <= (SELECT max_position FROM p) " +
                                          "AND min((SELECT from_position FROM p),(SELECT to_position FROM p)) >= (SELECT min_position FROM p)" +
                                          ")" +
                      
                                          "UPDATE " + TABLE_NAME + " SET " + COLUMN_5 + " = " +
                                          "(" +
                                          " SELECT proposed " +
                                          " FROM finish_updates " +
                                          " WHERE finish_updates.id = " + TABLE_NAME + ".id" +
                                          ") " +
                                          "WHERE " + TABLE_NAME + ".id IN " +
                                          "(" +
                                          " SELECT id FROM finish_updates" +
                                          ");";
                          SQLiteStatement stmnt = sqLiteDatabase.compileStatement(query);
                          stmnt.bindLong(1,from);
                          stmnt.bindLong(2,to);
                          stmnt.executeUpdateDelete();
                      }
                      

                      Source https://stackoverflow.com/questions/59849696

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install drag-sort-listview

                      Download and install the [Android sdk](http://developer.android.com/sdk/index.html). Clone/Download/Fork the repo through GitHub or via (read-only).
                      The first step is to choose File > Import or right-click in the Project Explorer and choose Import. If you don’t use E-Git to integrate Eclipse with Git, skip the rest of this paragraph. Choose "Projects from Git" as the import source. From the Git page, click Clone, and enter the URI of this repository. That’s the only text box to fill in on that page. On the following pages, choose which branches to clone (probably all of them) and where to keep the local checkout, and then click Finish. Once the clone has finished, pick your new repository from the list, and on the following page select Use the New Projects wizard. From here the process is the same even if you don’t use E-Git. Choose Android Project from Existing Code and then browse to where you checked out DSLV. You should then see two projects in the list: one named after the directory name, and the other called com.mobeta.android.demodslv.Launcher . The top one is the library project, and the bottom one the demo project. You probably want both at first, so just click Finish. Finally, to add the library to your application project, right-click your project in the Package Explorer and select Properties. Pick the "Android" page, and click "Add…​" from the bottom half. You should see a list including the DSLV project as well as any others in your workspace.

                      Support

                      There is limited documentation in the DSLV. You can check it out with Javadoc by navigating to /path/to/drag-sort-listview/src/ and typing. The javadoc can be viewed on the DSLV project page: http://bauerca.github.com/drag-sort-listview. Sorry for the many broken links at the moment. I am slowly getting to this.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Consider Popular Widget Libraries
                      Try Top Libraries by bauerca
                      Compare Widget Libraries with Highest Support
                      Compare Widget Libraries with Highest Quality
                      Compare Widget Libraries with Highest Security
                      Compare Widget Libraries with Permissive License
                      Compare Widget Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.