BoardView


Source link: https://github.com/jakebonk/BoardView

BoardView

BoardView is a custom view that allows you to be able to re-order items in a list as well as in a board. You can drag and drop items between columns as well as drag and drop columns.

Example

Download library with Jitpack.io

Add this to your build.gradle file for your app.

 allprojects {

repositories {

 ...
 maven {
 url 'https://jitpack.io' 
}

}
  
}

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

 dependencies {

 compile 'com.github.jakebonk:BoardView:1.2.0'  
}

Usage

BoardView utilizes a BoardAdapter, SimpleBoardAdapter is an example of how to extend BoardAdapter.

 BoardView boardView = (BoardView)findViewById(R.id.boardview);
  ArrayList<SimpleBoardAdapter.SimpleColumn> data = new ArrayList<>();

ArrayList<String> list = new ArrayList<String>();

list.add("Item 1");

list.add("Item 2");

list.add("Item 3");

list.add("Item 4");

data.add(new SimpleBoardAdapter.SimpleColumn("Column 1",list));

data.add(new SimpleBoardAdapter.SimpleColumn("Column 2",list));

data.add(new SimpleBoardAdapter.SimpleColumn("Column 3",list));

data.add(new SimpleBoardAdapter.SimpleColumn("Column 4",list));

data.add(new SimpleBoardAdapter.SimpleColumn("Column 5",list));

SimpleBoardAdapter boardAdapter = new SimpleBoardAdapter(this,data);

boardView.setAdapter(boardAdapter);

There are two types of drag listeners, the first is for columns

  boardView.setOnDragColumnListener(new BoardView.DragColumnStartCallback() {

 @Override

 public void startDrag(View view, int startColumnPos) {

  
}

  @Override

 public void changedPosition(View view, int startColumnPos, int newColumnPos) {

  
}

  @Override

 public void endDrag(View view, int startColumnPos, int endColumnPos) {

  
}

}
);

Similarly we can get the drag listener for items

  boardView.setOnDragItemListener(new BoardView.DragItemStartCallback() {

 @Override

 public void startDrag(View view, int startItemPos, int startColumnPos) {

  
}

  @Override

 public void changedPosition(View view, int startItemPos, int startColumnPos, int newItemPos, int newColumnPos) {

  
}

  @Override

 public void endDrag(View view, int startItemPos, int startColumnPos, int endItemPos, int endColumnPos) {

  
}

}
);

There is also a listener for when the BoardView has finished creating and assigning its views.

  boardView.setOnDoneListener(new BoardView.DoneListener() {

 @Override

 public void onDone() {

  Log.e("ee","Done");

 
}

}
);
 

This is how to set the click listener for a item, header and footer, which gives their respective positions.

boardView.setOnItemClickListener(new BoardView.ItemClickListener() {

 @Override

 public void onClick(View v, int column_pos, int item_pos) {

}

}
);

boardView.setOnHeaderClickListener(new BoardView.HeaderClickListener() {

 @Override

 public void onClick(View v, int column_pos) {

}

}
);

boardView.setOnFooterClickListener(new BoardView.FooterClickListener() {

 @Override

 public void onClick(View v, int column_pos) {

 
}

}
);
 

Creating your own BoardAdapter

Creating a custom BoardAdapter is pretty similar to that of a BaseAdapter, the main focus being to create some type of object that help you create your custom views for both headers and items. The adapter also has two new abstract methods called, isColumnLocked when true prevents the column from being draggable. isItemLocked will not allow item to be dragged to or from this column.

 @Override  public boolean isColumnLocked(int column_position) {

return false;  
}

@Override  public boolean isItemLocked(int column_position) {

  return false;  
}

Things to fix

There is a scaling issue when the column is beginning dragging or has ended dragging. I know this is an issue but I don't know of a good way to solve this at the moment. I eventually will fix it but for now I'm putting it on the back burners.

Resources

This is a library project which makes the instagram login much easier.

Task Manager is an open sourced application for managing running apps.

It makes a preview from an URL, grabbing all information (such as title, relevant texts and images).

An Android TabLayout library.

Simple color cross fade utility for Android. Supported types: RGB, ARGB, HSV, HSV (with alpha).

Convert any Drawable into filled drawable depending on progress value (.0F - 100.F). One image resource is used. No overdraw, no bitmap allocations.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes