Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebonk committed Jun 26, 2017
2 parents c384656 + 72fb2e9 commit 3478323
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Jacob Bonk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[![](https://jitpack.io/v/jakebonk/DraggableTreeViewExample.svg)](https://jitpack.io/#jakebonk/DraggableTreeViewExample)

# DraggableTreeView
DraggableTreeView is a custom view that mimics a Tree View directory and also implements drag and drop. The tree view can go to the n-th level by default there is no limit.

## Example

![Basic Example](https://thumbs.gfycat.com/ConfusedPerkyDwarfmongoose-size_restricted.gif)

## Download library with Jitpack.io
Add this to your build.gradle file for your app.

```java
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

Add this to your dependencies in build.gradle for your project.

```java
dependencies {
compile 'com.github.jakebonk:DraggableTreeViewExample:1.0.0'
}
```

## Usage

DraggableTreeView is organized by a custom adapter called TreeViewAdapter, I included a Simple implementation of the adapter class called SimpleTreeViewAdapter.

```java
DraggableTreeView draggableTreeView = (DraggableTreeView)findViewById(R.id.dtv);
TreeNode root = new TreeNode(this);
TreeNode item = new TreeNode("Item 1");
TreeNode item2 = new TreeNode("Item 2");

TreeNode subitem = new TreeNode("Sub Item 2");
subitem.addChild(new TreeNode("Sub Sub Item 1"));
item.addChild(subitem);
item.addChild(new TreeNode("Sub Item 1"));
root.addChild(new TreeNode("Item 3"));
root.addChild(new TreeNode("Item 4"));
root.addChild(new TreeNode("Item 5"));
root.addChild(new TreeNode("Item 6"));
root.addChild(new TreeNode("Item 7"));
root.addChild(new TreeNode("Item 8"));
root.addChild(new TreeNode("Item 9"));
root.addChild(new TreeNode("Item 10"));
root.addChild(new TreeNode("Item 11"));
root.addChild(new TreeNode("Item 12"));
root.addChild(item2);
root.addChild(item);
SimpleTreeViewAdapter adapter = new SimpleTreeViewAdapter(this,root);
draggableTreeView.setAdapter(adapter);
```

You can also change both the succesful placeholder as well as the bad placeholder by passing a view through the function

```java
adapter.setBadPlaceholder(view);
```
or
```java
adapter.setPlaceholder(view);
```

By assigning the variable maxLevel a value you can define how many levels the tree view can drag to.
```java
draggableTreeView.maxLevels = 4;
```

## To-Do

There are no listeners implemented yet but I should have them within the coming few days.



0 comments on commit 3478323

Please # to comment.