├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── allyants │ │ └── boardviewexample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── allyants │ │ │ └── boardviewexample │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── allyants │ └── boardviewexample │ └── ExampleUnitTest.java ├── boardview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── allyants │ │ └── boardview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── allyants │ │ │ └── boardview │ │ │ ├── BoardAdapter.java │ │ │ ├── BoardItem.java │ │ │ ├── BoardView.java │ │ │ ├── Item.java │ │ │ └── SimpleBoardAdapter.java │ └── res │ │ ├── drawable │ │ └── shadow_background.xml │ │ ├── layout │ │ ├── column_header.xml │ │ └── column_item.xml │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── allyants │ └── boardview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 1.8 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://jitpack.io/v/jakebonk/BoardView.svg)](https://jitpack.io/#jakebonk/BoardView) 2 | 3 | # BoardView 4 | 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. 5 | 6 | ## Example 7 | 8 | ![Basic Example](https://thumbs.gfycat.com/DeadUntidyHartebeest-size_restricted.gif) 9 | 10 | ## Download library with Jitpack.io 11 | Add this to your build.gradle file for your app. 12 | ```java 13 | allprojects { 14 | repositories { 15 | ... 16 | maven { url 'https://jitpack.io' } 17 | } 18 | } 19 | ``` 20 | 21 | Add this to your dependencies in build.gradle for your project. 22 | ```java 23 | dependencies { 24 | implementation 'com.github.jakebonk:BoardView:1.3.6' 25 | } 26 | ``` 27 | ## Usage 28 | 29 | BoardView utilizes a BoardAdapter, SimpleBoardAdapter is an example of how to extend BoardAdapter. 30 | ```java 31 | BoardView boardView = (BoardView)findViewById(R.id.boardview); 32 | ArrayList data = new ArrayList<>(); 33 | ArrayList list = new ArrayList(); 34 | list.add("Item 1"); 35 | list.add("Item 2"); 36 | list.add("Item 3"); 37 | list.add("Item 4"); 38 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 1",list)); 39 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 2",list)); 40 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 3",list)); 41 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 4",list)); 42 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 5",list)); 43 | SimpleBoardAdapter boardAdapter = new SimpleBoardAdapter(this,data); 44 | boardView.setAdapter(boardAdapter); 45 | ``` 46 | To manipulate the BoardView simply call one of the new functions in BoardAdapter 47 | 48 | ```java 49 | void removeColumn(int index) 50 | void removeItem(int column, int index) 51 | void addItem(int column,int index, Object item) 52 | void addColumn(int index, Column column) 53 | ``` 54 | 55 | I also added the ability to set Transition animations when adding items/columns. 56 | 57 | ```java 58 | void SetColumnTransition(Transition t) 59 | void SetItemTransition(Transition t) 60 | ``` 61 | 62 | There are two types of drag listeners, the first is for columns 63 | ```java 64 | boardView.setOnDragColumnListener(new BoardView.DragColumnStartCallback() { 65 | @Override 66 | public void startDrag(View view, int startColumnPos) { 67 | 68 | } 69 | 70 | @Override 71 | public void changedPosition(View view, int startColumnPos, int newColumnPos) { 72 | 73 | } 74 | 75 | @Override 76 | public void dragging(View itemView, MotionEvent event) { 77 | 78 | } 79 | 80 | @Override 81 | public void endDrag(View view, int startColumnPos, int endColumnPos) { 82 | 83 | } 84 | }); 85 | ``` 86 | Similarly we can get the drag listener for items 87 | ```java 88 | boardView.setOnDragItemListener(new BoardView.DragItemStartCallback() { 89 | @Override 90 | public void startDrag(View view, int startItemPos, int startColumnPos) { 91 | 92 | } 93 | 94 | @Override 95 | public void changedPosition(View view, int startItemPos, int startColumnPos, int newItemPos, int newColumnPos) { 96 | 97 | } 98 | 99 | @Override 100 | public void dragging(View itemView, MotionEvent event) { 101 | 102 | } 103 | 104 | @Override 105 | public void endDrag(View view, int startItemPos, int startColumnPos, int endItemPos, int endColumnPos) { 106 | 107 | } 108 | }); 109 | ``` 110 | 111 | There is also a listener for when the BoardView has finished creating and assigning its views. 112 | 113 | ```java 114 | 115 | boardView.setOnDoneListener(new BoardView.DoneListener() { 116 | @Override 117 | public void onDone() { 118 | Log.e("ee","Done"); 119 | } 120 | }); 121 | 122 | ``` 123 | 124 | This is how to set the click listener for a item, header and footer, which gives their respective positions. 125 | 126 | ```java 127 | 128 | boardView.setOnItemClickListener(new BoardView.ItemClickListener() { 129 | @Override 130 | public void onClick(View v, int column_pos, int item_pos) { 131 | 132 | } 133 | }); 134 | boardView.setOnHeaderClickListener(new BoardView.HeaderClickListener() { 135 | @Override 136 | public void onClick(View v, int column_pos) { 137 | 138 | } 139 | }); 140 | boardView.setOnFooterClickListener(new BoardView.FooterClickListener() { 141 | @Override 142 | public void onClick(View v, int column_pos) { 143 | 144 | } 145 | }); 146 | 147 | ``` 148 | 149 | By setting SetColumnSnap you can allow the BoardView to snap to the closest column when scrolling, this is activated by default. To set it back to normal just set it to false 150 | 151 | ```java 152 | 153 | boardView.SetColumnSnap(true); 154 | 155 | or 156 | 157 | boardView.SetColumnSnap(false); 158 | 159 | ``` 160 | 161 | ### Creating your own BoardAdapter 162 | 163 | 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. 164 | 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. 165 | 166 | ```java 167 | @Override 168 | public boolean isColumnLocked(int column_position) { 169 | return false; 170 | } 171 | 172 | @Override 173 | public boolean isItemLocked(int column_position) { 174 | return false; 175 | } 176 | ``` 177 | 178 | You can also set the maximum amount of items you want in a list. If -1 is returned then there will be no cap otherwise the returned value will be the cap. The example below allow only 4 items inside any given column. 179 | 180 | ```java 181 | @Override 182 | public int maxItemCount(int column_position) { 183 | return 4; 184 | } 185 | ``` 186 | 187 | ### Things to fix 188 | 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. 189 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.allyants.boardviewexample" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(path: ':boardview') 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\jbonk\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/allyants/boardviewexample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardviewexample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.allyants.boardviewexample", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/allyants/boardviewexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardviewexample; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | 9 | import com.allyants.boardview.BoardView; 10 | import com.allyants.boardview.Item; 11 | import com.allyants.boardview.SimpleBoardAdapter; 12 | 13 | import java.util.ArrayList; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | ArrayList list = new ArrayList<>(); 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | final BoardView boardView = (BoardView)findViewById(R.id.boardView); 23 | boardView.SetColumnSnap(false); 24 | boardView.SetColumnSnap(true); 25 | final ArrayList data = new ArrayList<>(); 26 | list.add(new Item("I am a very long list that is not the same size as the others. I am a multiline")); 27 | list.add(new Item("Item 1")); 28 | final ArrayList empty = new ArrayList<>(); 29 | final ArrayList test = new ArrayList<>(); 30 | test.add(new Item("Item 1")); 31 | test.add(new Item("Item 1")); 32 | test.add(new Item("Item 1")); 33 | test.add(new Item("Item 1")); 34 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 1",(ArrayList)list)); 35 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 2",(ArrayList)test)); 36 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 3",(ArrayList)empty)); 37 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 4",(ArrayList)empty)); 38 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 5",(ArrayList)empty)); 39 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 6",(ArrayList)empty)); 40 | data.add(new SimpleBoardAdapter.SimpleColumn("Column 7",(ArrayList)empty)); 41 | final SimpleBoardAdapter boardAdapter = new SimpleBoardAdapter(this,data); 42 | boardView.setAdapter(boardAdapter); 43 | boardView.setOnDoneListener(new BoardView.DoneListener() { 44 | @Override 45 | public void onDone() { 46 | Log.e("scroll","done"); 47 | } 48 | }); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BoardViewExample 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/allyants/boardviewexample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardviewexample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /boardview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /boardview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.3.1' 30 | testCompile 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /boardview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\jbonk\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /boardview/src/androidTest/java/com/allyants/boardview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.allyants.boardview.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /boardview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /boardview/src/main/java/com/allyants/boardview/BoardAdapter.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import android.content.Context; 4 | import android.transition.Fade; 5 | import android.transition.Transition; 6 | import android.transition.TransitionManager; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.LinearLayout; 10 | import android.widget.ScrollView; 11 | 12 | import java.util.ArrayList; 13 | 14 | /** 15 | * Created by jbonk on 6/12/2017. 16 | */ 17 | 18 | public abstract class BoardAdapter{ 19 | 20 | Context context; 21 | Transition transition = new Fade(); 22 | Transition boardViewTransition = new Fade(); 23 | public ArrayList columns = new ArrayList<>(); 24 | public BoardAdapter(Context context){ 25 | this.context = context; 26 | } 27 | public BoardView boardView; 28 | 29 | public void createColumns(){ 30 | ArrayList tmp = new ArrayList<>(); 31 | for(int i = 0; i < getColumnCount();i++){ 32 | ArrayList views = new ArrayList<>(); 33 | Column column = new Column(createHeaderView(context,createHeaderObject(i),i),views,createFooterView(context,createFooterObject(i),i)); 34 | for(int j = 0; j < getItemCount(i);j++){ 35 | column.objects.add(createItemObject(i,j)); 36 | views.add(createItemView(context,createHeaderObject(i),createItemObject(i,j),i,j)); 37 | } 38 | column.items_locked = isItemLocked(i); 39 | column.column_locked = isColumnLocked(i); 40 | column.header_object = createHeaderObject(i); 41 | column.footer_object = createFooterObject(i); 42 | tmp.add(column); 43 | } 44 | columns = tmp; 45 | } 46 | 47 | public void SetItemTransition(Transition t){ 48 | transition = t; 49 | } 50 | 51 | public void SetColumnTransition(Transition t){ 52 | boardViewTransition = t; 53 | } 54 | 55 | public static class Column{ 56 | public View header; 57 | public Object header_object; 58 | public Object footer_object; 59 | public View footer; 60 | public Boolean column_locked = false; 61 | public Boolean items_locked = false; 62 | public ArrayList views = new ArrayList<>(); 63 | public ArrayList objects = new ArrayList<>(); 64 | 65 | public Column(){ 66 | this.footer_object = "Foot"; 67 | this.header_object = "Header"; 68 | } 69 | 70 | public Column(View header, ArrayList views,View footer){ 71 | this.header = header; 72 | this.views = views; 73 | this.footer = footer; 74 | } 75 | 76 | } 77 | 78 | public Object getHeaderObject(int column_position){ 79 | return columns.get(column_position).header_object; 80 | } 81 | 82 | public Object getItemObject(int column_position,int item_position){ 83 | return columns.get(column_position).objects.get(item_position); 84 | } 85 | 86 | public void addColumn(int index, Column column){ 87 | columns.add(index,column); 88 | for(int j = 0; j < getItemCount(index);j++){ 89 | column.objects.add(createItemObject(index,j)); 90 | column.views.add(createItemView(context,createHeaderObject(index),createItemObject(index,j),index,j)); 91 | } 92 | column.items_locked = isItemLocked(index); 93 | column.column_locked = isColumnLocked(index); 94 | column.header_object = createHeaderObject(index); 95 | column.footer_object = createFooterObject(index); 96 | column.header = createHeaderView(context,column.header_object,index); 97 | column.footer = createFooterView(context,column.footer_object,index); 98 | TransitionManager.beginDelayedTransition(boardView, boardViewTransition); 99 | boardView.addColumnList(column.header,column.views,column.footer,index); 100 | } 101 | 102 | public void removeColumn(int index){ 103 | BoardItem item = (BoardItem)((ViewGroup)((ViewGroup)boardView.getChildAt(0)).getChildAt(0)).getChildAt(index); 104 | ViewGroup group = ((ViewGroup) item.getParent()); 105 | ((ViewGroup)item.getParent()).removeView(item); 106 | columns.remove(index); 107 | group.invalidate(); 108 | } 109 | 110 | public void removeItem(int column, int index){ 111 | BoardItem item = (BoardItem)((ViewGroup)((ViewGroup)boardView.getChildAt(0)).getChildAt(0)).getChildAt(column); 112 | ScrollView scrollView = (ScrollView)item.getChildAt(1); 113 | LinearLayout llColumn = (LinearLayout)scrollView.getChildAt(0); 114 | llColumn.removeViewAt(index); 115 | llColumn.invalidate(); 116 | columns.get(column).objects.remove(index); 117 | columns.get(column).views.remove(index); 118 | } 119 | 120 | public void addItem(int column,int index, Object item){ 121 | BoardItem boardItem = (BoardItem)((ViewGroup)((ViewGroup)boardView.getChildAt(0)).getChildAt(0)).getChildAt(column); 122 | TransitionManager.beginDelayedTransition(boardItem, transition); 123 | ScrollView scrollView = (ScrollView)boardItem.getChildAt(1); 124 | LinearLayout llColumn = (LinearLayout)scrollView.getChildAt(0); 125 | columns.get(column).objects.add(index,item); 126 | View v = createItemView(context,columns.get(column).header_object,item,column,index); 127 | llColumn.addView(v,index); 128 | boardView.addBoardItem(v,column); 129 | llColumn.invalidate(); 130 | columns.get(column).views.add(index,v); 131 | } 132 | 133 | public abstract int getColumnCount(); 134 | public abstract int getItemCount(int column_position); 135 | public abstract int maxItemCount(int column_position); 136 | public abstract Object createHeaderObject(int column_position); 137 | public abstract Object createFooterObject(int column_position); 138 | public abstract Object createItemObject(int column_position,int item_position); 139 | public abstract boolean isColumnLocked(int column_position); 140 | public abstract boolean isItemLocked(int column_position); 141 | public abstract View createItemView(Context context,Object header_object, Object item,int column_position,int item_position); 142 | public abstract View createHeaderView(Context context,Object header_object,int column_position); 143 | public abstract View createFooterView(Context context,Object footer_object,int column_position); 144 | 145 | } 146 | -------------------------------------------------------------------------------- /boardview/src/main/java/com/allyants/boardview/BoardItem.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.widget.LinearLayout; 6 | 7 | /** 8 | * Created by jbonk on 4/19/2017. 9 | */ 10 | 11 | public class BoardItem extends LinearLayout { 12 | int originalWidth = 0; 13 | int originalHeight = 0; 14 | private float scale = 1f; 15 | public BoardItem(Context context) { 16 | super(context); 17 | } 18 | 19 | public BoardItem(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | } 22 | 23 | public BoardItem(Context context, AttributeSet attrs, int defStyleAttr) { 24 | super(context, attrs, defStyleAttr); 25 | } 26 | 27 | public void init(){ 28 | // originalHeight = 0; 29 | // originalWidth = 0; 30 | } 31 | 32 | public void setScale(float scale){ 33 | this.scale = scale; 34 | } 35 | 36 | public float getScale(){ 37 | return scale; 38 | } 39 | 40 | @Override 41 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 42 | 43 | if(getHeight() > 0 && getWidth() > 0 && scale != 1f) { 44 | if(originalWidth == 0){ 45 | originalWidth = getWidth(); 46 | } 47 | if(originalHeight == 0){ 48 | originalHeight = getHeight(); 49 | } 50 | this.setMeasuredDimension((int) (originalWidth * scale), (int) (originalHeight * scale)); 51 | }else { 52 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /boardview/src/main/java/com/allyants/boardview/BoardView.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Canvas; 7 | import android.graphics.Color; 8 | import android.graphics.Paint; 9 | import android.graphics.Rect; 10 | import android.graphics.drawable.BitmapDrawable; 11 | import android.os.Handler; 12 | import android.support.annotation.Nullable; 13 | import android.support.v4.view.ViewCompat; 14 | import android.util.AttributeSet; 15 | import android.util.DisplayMetrics; 16 | import android.util.Log; 17 | import android.view.MotionEvent; 18 | import android.view.VelocityTracker; 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.view.ViewParent; 22 | import android.view.animation.Animation; 23 | import android.view.animation.DecelerateInterpolator; 24 | import android.view.animation.ScaleAnimation; 25 | import android.widget.FrameLayout; 26 | import android.widget.HorizontalScrollView; 27 | import android.widget.LinearLayout; 28 | import android.widget.ScrollView; 29 | import android.widget.Scroller; 30 | 31 | import java.util.ArrayList; 32 | 33 | /** 34 | * Created by jbonk on 4/17/2017. 35 | */ 36 | 37 | public class BoardView extends FrameLayout { 38 | 39 | private static final float GLOBAL_SCALE = 0.6f; 40 | private static final int SCROLL_ANIMATION_DURATION = 325; 41 | private boolean mCellIsMobile = false; 42 | private BitmapDrawable mHoverCell; 43 | private Rect mHoverCellCurrentBounds; 44 | private Rect mHoverCellOriginalBounds; 45 | private boolean columnSnap; 46 | private boolean isTouched; 47 | private boolean isSnapping; 48 | 49 | private int HEADER_ID = generateViewId(); 50 | 51 | private int background_color; 52 | 53 | private HorizontalScrollView mRootLayout; 54 | private LinearLayout mParentLayout; 55 | 56 | private int originalPosition = -1; 57 | private int originalItemPosition = -1; 58 | 59 | public void setBackgroundColor(int color){ 60 | background_color = color; 61 | } 62 | 63 | public int getBackgroundColor(){ 64 | return background_color; 65 | } 66 | 67 | private DoneListener mDoneCallback = new DoneListener() { 68 | @Override 69 | public void onDone() { 70 | 71 | } 72 | }; 73 | 74 | private FooterClickListener footerClickListener = new FooterClickListener() { 75 | @Override 76 | public void onClick(View v, int column_pos) { 77 | 78 | } 79 | }; 80 | 81 | private HeaderClickListener headerClickListener = new HeaderClickListener() { 82 | @Override 83 | public void onClick(View v, int column_pos) { 84 | 85 | } 86 | }; 87 | 88 | private ItemClickListener itemClickListener = new ItemClickListener() { 89 | @Override 90 | public void onClick(View v, int column_pos, int item_pos) { 91 | 92 | } 93 | }; 94 | 95 | private DragColumnStartCallback mDragColumnStartCallback = new DragColumnStartCallback() { 96 | @Override 97 | public void startDrag(View itemView, int originalPosition) { 98 | 99 | } 100 | 101 | @Override 102 | public void changedPosition(View itemView, int originalPosition, int newPosition) { 103 | 104 | } 105 | 106 | @Override 107 | public void dragging(View itemView, MotionEvent event) { 108 | 109 | } 110 | 111 | @Override 112 | public void endDrag(View itemView, int originalPosition, int newPosition) { 113 | 114 | } 115 | }; 116 | 117 | private DragItemStartCallback mDragItemStartCallback = new DragItemStartCallback() { 118 | @Override 119 | public void startDrag(View itemView, int originalPosition,int originalColumn) { 120 | 121 | } 122 | 123 | @Override 124 | public void changedPosition(View itemView, int originalPosition,int originalColumn, int newPosition, int newColumn) { 125 | 126 | } 127 | 128 | @Override 129 | public void dragging(View itemView, MotionEvent event) { 130 | 131 | } 132 | 133 | @Override 134 | public void endDrag(View itemView, int originalPosition,int originalColumn, int newPosition, int newColumn) { 135 | 136 | } 137 | }; 138 | 139 | public boolean constWidth = true; 140 | 141 | private final int LINE_THICKNESS = 15; 142 | 143 | private boolean can_scroll = false; 144 | private boolean created = false; 145 | 146 | private int mLastEventX = -1; 147 | private int mLastEventY = -1; 148 | private Scroller mScroller; 149 | 150 | public interface DragColumnStartCallback{ 151 | void startDrag(View itemView, int originalPosition); 152 | void changedPosition(View itemView, int originalPosition, int newPosition); 153 | void dragging(View itemView, MotionEvent event); 154 | void endDrag(View itemView, int originalPosition, int newPosition); 155 | } 156 | 157 | public interface DragItemStartCallback{ 158 | void startDrag(View itemView, int originalPosition,int originalColumn); 159 | void changedPosition(View itemView, int originalPosition,int originalColumn, int newPosition, int newColumn); 160 | void dragging(View itemView, MotionEvent event); 161 | void endDrag(View itemView, int originalPosition,int originalColumn, int newPosition, int newColumn); 162 | } 163 | 164 | public interface FooterClickListener{ 165 | void onClick(View v,int column_pos); 166 | } 167 | 168 | 169 | public interface HeaderClickListener{ 170 | void onClick(View v,int column_pos); 171 | } 172 | 173 | public interface ItemClickListener{ 174 | void onClick(View v,int column_pos,int item_pos); 175 | } 176 | 177 | public void setOnHeaderClickListener(HeaderClickListener headerClickListener){ 178 | this.headerClickListener = headerClickListener; 179 | } 180 | 181 | public void setOnFooterClickListener(FooterClickListener footerClickListener){ 182 | this.footerClickListener = footerClickListener; 183 | } 184 | 185 | public void setOnItemClickListener(ItemClickListener itemClickListener){ 186 | this.itemClickListener = itemClickListener; 187 | } 188 | 189 | public void setOnDragColumnListener(DragColumnStartCallback dragStartCallback){ 190 | mDragColumnStartCallback = dragStartCallback; 191 | } 192 | 193 | public void setOnDragItemListener(DragItemStartCallback dragStartCallback){ 194 | mDragItemStartCallback = dragStartCallback; 195 | } 196 | 197 | public void setOnDoneListener(DoneListener onDoneListener){ 198 | mDoneCallback = onDoneListener; 199 | } 200 | 201 | long last_swap = System.currentTimeMillis(); 202 | long last_swap_item = System.currentTimeMillis(); 203 | 204 | final long ANIM_TIME = 300; 205 | long mDelaySwap = 400; 206 | long mDelaySwapItem = 400; 207 | 208 | private int mLastSwap = -1; 209 | private int mDownY = -1; 210 | private int mDownX = -1; 211 | 212 | private boolean mSwapped = false; 213 | private boolean canDragHorizontal = true; 214 | private boolean canDragVertical = true; 215 | 216 | private boolean mCellSubIsMobile = false; 217 | 218 | private int mTotalOffsetX = 0; 219 | private int mTotalOffsetY = 0; 220 | 221 | public BoardAdapter boardAdapter; 222 | 223 | private View mobileView; 224 | 225 | public BoardView(Context context) { 226 | super(context); 227 | } 228 | 229 | public BoardView(Context context, AttributeSet attrs) { 230 | super(context, attrs); 231 | TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.BoardView,0,0); 232 | try { 233 | background_color = ta.getColor(R.styleable.BoardView_boardItemBackground,Color.TRANSPARENT); 234 | }finally{ 235 | ta.recycle(); 236 | } 237 | } 238 | 239 | public BoardView(Context context, AttributeSet attrs, int defStyleAttr) { 240 | super(context, attrs, defStyleAttr); 241 | TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.BoardView,0,0); 242 | try { 243 | background_color = ta.getColor(R.styleable.BoardView_boardItemBackground,Color.TRANSPARENT); 244 | }finally{ 245 | ta.recycle(); 246 | } 247 | } 248 | 249 | public interface DoneListener { 250 | void onDone(); 251 | } 252 | 253 | public void setAdapter(BoardAdapter boardAdapter){ 254 | this.boardAdapter = boardAdapter; 255 | Log.e("set","adapter"); 256 | boardAdapter.boardView = this; 257 | mParentLayout.removeAllViews(); 258 | boardAdapter.createColumns(); 259 | for(int i = 0;i < boardAdapter.columns.size();i++){ 260 | BoardAdapter.Column column = boardAdapter.columns.get(i); 261 | addColumnList(column.header,column.views,column.footer,i); 262 | } 263 | } 264 | 265 | @Override 266 | protected void onFinishInflate() { 267 | super.onFinishInflate(); 268 | mRootLayout = new HorizontalScrollView(getContext()); 269 | mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); 270 | mParentLayout = new LinearLayout(getContext()); 271 | mParentLayout.setOrientation(LinearLayout.HORIZONTAL); 272 | mScroller = new Scroller(mRootLayout.getContext(), new DecelerateInterpolator(1.2f)); 273 | mParentLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); 274 | mRootLayout.addView(mParentLayout); 275 | addView(mRootLayout); 276 | SetColumnSnap(true); 277 | } 278 | 279 | @Override 280 | protected void dispatchDraw(Canvas canvas) { 281 | super.dispatchDraw(canvas); 282 | if(!created){ 283 | created = true; 284 | mDoneCallback.onDone(); 285 | } 286 | if(mHoverCell != null){ 287 | mHoverCell.draw(canvas); 288 | } 289 | } 290 | 291 | @Override 292 | public boolean onInterceptTouchEvent(MotionEvent event) { 293 | boolean colValue = handleColumnDragEvent(event); 294 | return colValue || super.onInterceptTouchEvent(event); 295 | } 296 | 297 | @Override 298 | public boolean onTouchEvent(MotionEvent event) { 299 | boolean colValue = handleColumnDragEvent(event); 300 | return colValue || super.onTouchEvent(event); 301 | } 302 | 303 | public int getStatusBarHeight() { 304 | int result = 0; 305 | int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); 306 | if (resourceId > 0) { 307 | result = getResources().getDimensionPixelSize(resourceId); 308 | } 309 | return result; 310 | } 311 | 312 | VelocityTracker mVelocityTracker = VelocityTracker.obtain(); 313 | public void SetColumnSnap(boolean columnSnap){ 314 | this.columnSnap = columnSnap; 315 | mRootLayout.setOnTouchListener(new OnTouchListener() { 316 | @Override 317 | public boolean onTouch(View v, MotionEvent event) { 318 | isTouched = true; 319 | isSnapping = false; 320 | switch (event.getAction()){ 321 | case MotionEvent.ACTION_DOWN: 322 | mVelocityTracker.clear(); 323 | mVelocityTracker.addMovement(event); 324 | break; 325 | case MotionEvent.ACTION_MOVE: 326 | mVelocityTracker.addMovement(event); 327 | mVelocityTracker.computeCurrentVelocity(1000); 328 | break; 329 | case MotionEvent.ACTION_UP: 330 | isTouched = false; 331 | if(Math.abs(mVelocityTracker.getXVelocity()) < 230){ 332 | int pos = getPositionInListX(mRootLayout.getWidth()/2,mParentLayout); 333 | scrollToColumn(pos,true); 334 | } 335 | break; 336 | } 337 | return false; 338 | } 339 | }); 340 | if(this.columnSnap) { 341 | mRootLayout.setOnScrollChangeListener(onScrollChangeListener); 342 | }else{ 343 | mRootLayout.setOnScrollChangeListener(null); 344 | } 345 | } 346 | 347 | OnScrollChangeListener onScrollChangeListener = new OnScrollChangeListener() { 348 | @Override 349 | public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { 350 | if(!isTouched && !isSnapping && mParentLayout.getChildCount() > 0) { 351 | int deltaX = Math.abs(oldScrollX - scrollX); 352 | if(deltaX < 3){ 353 | //Scroll To closest column 354 | isSnapping = true; 355 | int[] location = new int[2]; 356 | mParentLayout.getLocationOnScreen(location); 357 | int offset = (mParentLayout.getChildAt(0).getWidth())/2; 358 | if(oldScrollX - scrollX <= 0){ 359 | offset *= 2; 360 | } 361 | int x = scrollX+location[0]+offset; 362 | int pos = getPositionInListX(x,mParentLayout); 363 | scrollToColumn(pos,true); 364 | } 365 | } 366 | } 367 | }; 368 | 369 | public void scrollToColumn(int column,boolean animate){ 370 | if(column >= 0) { 371 | View childView = mParentLayout.getChildAt(column); 372 | if(childView != null) { 373 | final int newX = childView.getLeft() - (int) (((getMeasuredWidth() - childView.getMeasuredWidth()) / 2)); 374 | if (animate) { 375 | mRootLayout.post(new Runnable() { 376 | @Override 377 | public void run() { 378 | mRootLayout.smoothScrollTo(newX, 0); 379 | } 380 | }); 381 | } else { 382 | mRootLayout.scrollTo(newX, 0); 383 | } 384 | } 385 | } 386 | } 387 | 388 | public boolean handleColumnDragEvent(MotionEvent event){ 389 | switch (event.getAction() & MotionEvent.ACTION_MASK) { 390 | case MotionEvent.ACTION_DOWN: 391 | mDownX = (int)event.getX(); 392 | mDownY = (int)event.getRawY(); 393 | break; 394 | case MotionEvent.ACTION_MOVE: 395 | if(mDownY == -1){ 396 | mDownY = (int)event.getRawY(); 397 | 398 | } 399 | if(mDownX == -1){ 400 | mDownX = (int)event.getX(); 401 | } 402 | 403 | mLastEventX = (int) event.getX(); 404 | mLastEventY = (int) event.getRawY(); 405 | int deltaX = mLastEventX - mDownX; 406 | int deltaY = mLastEventY - mDownY; 407 | 408 | if(mCellSubIsMobile){ 409 | if(mDragItemStartCallback != null) 410 | mDragItemStartCallback.dragging(mobileView,event); 411 | int offsetX = 0; 412 | if(canDragHorizontal){ 413 | offsetX = deltaX; 414 | } 415 | int offsetY = mHoverCellOriginalBounds.top; 416 | if(canDragVertical){ 417 | offsetY = mHoverCellOriginalBounds.top + deltaY; 418 | } 419 | mHoverCell.setBounds(rotatedBounds(mHoverCellCurrentBounds,0.0523599f)); 420 | mHoverCellCurrentBounds.offsetTo(offsetX, 421 | mLastEventY - 330); 422 | invalidate(); 423 | handleItemSwitchHorizontal(); 424 | return true; 425 | }else if (mCellIsMobile) { 426 | if(mDragColumnStartCallback != null) 427 | mDragColumnStartCallback.dragging(mobileView,event); 428 | int offsetX = 0; 429 | if(canDragHorizontal){ 430 | offsetX = deltaX; 431 | } 432 | int offsetY = mHoverCellOriginalBounds.top; 433 | if(canDragVertical){ 434 | offsetY = mHoverCellOriginalBounds.top + deltaY + mTotalOffsetY; 435 | } 436 | mHoverCell.setBounds(rotatedBounds(mHoverCellCurrentBounds,0.0523599f)); 437 | mHoverCellCurrentBounds.offsetTo(offsetX, 438 | offsetY); 439 | invalidate(); 440 | handleColumnSwitchHorizontal(); 441 | 442 | return true; 443 | } 444 | break; 445 | case MotionEvent.ACTION_UP: 446 | touchEventsCancelled(); 447 | break; 448 | case MotionEvent.ACTION_CANCEL: 449 | touchEventsCancelled(); 450 | break; 451 | case MotionEvent.ACTION_POINTER_UP: 452 | /* If a multitouch event took place and the original touch dictating 453 | * the movement of the hover cell has ended, then the dragging event 454 | * ends and the hover cell is animated to its corresponding position 455 | * in the listview. */ 456 | // pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> 457 | // MotionEvent.ACTION_POINTER_INDEX_SHIFT; 458 | // final int pointerId = event.getPointerId(pointerIndex); 459 | // if (pointerId == mActivePointerId) { 460 | // 461 | // } 462 | break; 463 | default: 464 | break; 465 | } 466 | return false; 467 | } 468 | 469 | @Override 470 | public void computeScroll() { 471 | if (!mScroller.isFinished() && mScroller.computeScrollOffset()) { 472 | int x = mScroller.getCurrX(); 473 | int y = mScroller.getCurrY(); 474 | if (getScrollX() != x || getScrollY() != y) { 475 | scrollTo(x, y); 476 | } 477 | 478 | ViewCompat.postInvalidateOnAnimation(this); 479 | } else { 480 | super.computeScroll(); 481 | } 482 | } 483 | 484 | //checks if item should be switched between columns 485 | private void handleItemSwitchHorizontal(){ 486 | int itemPos = ((LinearLayout)(mobileView.getParent())).indexOfChild(mobileView); 487 | View aboveView = ((LinearLayout)(mobileView.getParent())).getChildAt(itemPos - 1); 488 | View belowView = ((LinearLayout)(mobileView.getParent())).getChildAt(itemPos + 1); 489 | int[] location = new int[2]; 490 | mobileView.getLocationOnScreen(location); 491 | int[] parentLocation = new int[2]; 492 | ScrollView parent = ((ScrollView)((LinearLayout)mobileView.getParent()).getParent()); 493 | parent.getLocationOnScreen(parentLocation); 494 | if(mLastEventY < parentLocation[1]+200){ 495 | parent.smoothScrollBy(0,-10); 496 | } 497 | if(mLastEventY > parentLocation[1]+parent.getHeight()-200){ 498 | parent.smoothScrollBy(0,10); 499 | } 500 | int columnPos = mParentLayout.indexOfChild((View)(mobileView.getParent().getParent().getParent())); 501 | //swapping above 502 | if(aboveView != null){ 503 | int[] locationAbove = new int[2]; 504 | aboveView.getLocationInWindow(locationAbove); 505 | 506 | if(locationAbove[1]+aboveView.getHeight()/2 > mLastEventY){ 507 | switchItemFromPosition(-1,mobileView); 508 | } 509 | } 510 | //swapping below 511 | if(belowView != null){ 512 | int[] locationBelow = new int[2]; 513 | belowView.getLocationOnScreen(locationBelow); 514 | if(locationBelow[1] + belowView.getHeight()/2 < mLastEventY){ 515 | switchItemFromPosition(1,mobileView); 516 | } 517 | } 518 | 519 | int leftPos = 1; 520 | while (columnPos - leftPos > 0 && boardAdapter.columns.get(columnPos - leftPos).items_locked){ 521 | leftPos++; 522 | } 523 | if(columnPos-leftPos >= 0 && columnPos-leftPos < boardAdapter.columns.size()) { 524 | while (boardAdapter.maxItemCount(columnPos - leftPos) != -1 && boardAdapter.maxItemCount(columnPos - leftPos) <= boardAdapter.columns.get(columnPos - leftPos).objects.size() && columnPos - leftPos != 0) { 525 | leftPos++; 526 | } 527 | } 528 | View leftView = mParentLayout.getChildAt(columnPos - leftPos); 529 | View currentView = mParentLayout.getChildAt(columnPos); 530 | int rightPos = 1; 531 | while(boardAdapter.columns.size() > columnPos+rightPos && boardAdapter.columns.get(columnPos + rightPos).items_locked){ 532 | rightPos++; 533 | } 534 | if(columnPos + rightPos >= 0 && columnPos + rightPos < boardAdapter.columns.size()) { 535 | while (boardAdapter.maxItemCount(columnPos + rightPos) != -1 && columnPos + rightPos != boardAdapter.columns.size() && boardAdapter.maxItemCount(columnPos + rightPos) <= boardAdapter.columns.get(columnPos + rightPos).objects.size()) { 536 | rightPos++; 537 | } 538 | } 539 | View rightView = mParentLayout.getChildAt(columnPos + rightPos); 540 | View firstLeftView = mParentLayout.getChildAt(columnPos-1); 541 | View firstRightView = mParentLayout.getChildAt(columnPos+1); 542 | 543 | if(leftView != null){ 544 | int[] locationLeft = new int[2]; 545 | firstLeftView.getLocationOnScreen(locationLeft); 546 | if (locationLeft[0] + leftView.getWidth() > mLastEventX) { 547 | int pos = ((LinearLayout)mobileView.getParent()).indexOfChild(mobileView); 548 | if(last_swap_item <= System.currentTimeMillis() - mDelaySwapItem) { 549 | last_swap_item = System.currentTimeMillis(); 550 | if(((LinearLayout)mobileView.getParent()) != null) { 551 | scrollToColumn(columnPos-leftPos,true); 552 | if(boardAdapter.maxItemCount(columnPos-leftPos) == -1 || boardAdapter.maxItemCount(columnPos-leftPos) > boardAdapter.columns.get(columnPos-leftPos).objects.size()) { 553 | ((LinearLayout) mobileView.getParent()).removeViewAt(pos); 554 | LinearLayout layout = ((LinearLayout) ((ScrollView) ((ViewGroup) leftView).getChildAt(1)).getChildAt(0)); 555 | layout.addView(mobileView, getPositionInListY(mLastEventY, layout)); 556 | int newItemPos = ((LinearLayout) ((ViewGroup) leftView).getChildAt(0)).indexOfChild(mobileView) - 1; 557 | int newColumnPos = ((LinearLayout) mobileView.getParent().getParent().getParent()).indexOfChild((View) (mobileView.getParent().getParent())); 558 | mDragItemStartCallback.changedPosition(mobileView, originalItemPosition, originalPosition, newItemPos, newColumnPos); 559 | } 560 | } 561 | } 562 | } 563 | } 564 | if(rightView != null){ 565 | int[] locationRight = new int[2]; 566 | firstRightView.getLocationOnScreen(locationRight); 567 | if (locationRight[0] < mLastEventX) { 568 | int pos = ((LinearLayout)mobileView.getParent()).indexOfChild(mobileView); 569 | if(last_swap_item <= System.currentTimeMillis() - mDelaySwapItem) { 570 | last_swap_item = System.currentTimeMillis(); 571 | if(((LinearLayout)mobileView.getParent()) != null) { 572 | scrollToColumn(columnPos+rightPos,true); 573 | if(boardAdapter.maxItemCount(columnPos+rightPos) == -1 || boardAdapter.maxItemCount(columnPos+rightPos) > boardAdapter.columns.get(columnPos+rightPos).objects.size()) { 574 | ((LinearLayout) mobileView.getParent()).removeViewAt(pos); 575 | LinearLayout layout = ((LinearLayout) ((ScrollView) ((ViewGroup) rightView).getChildAt(1)).getChildAt(0)); 576 | layout.addView(mobileView, getPositionInListY(mLastEventY, layout)); 577 | int newItemPos = ((LinearLayout) ((ViewGroup) rightView).getChildAt(0)).indexOfChild(mobileView) - 1; 578 | int newColumnPos = ((LinearLayout) mobileView.getParent().getParent().getParent()).indexOfChild((View) (mobileView.getParent().getParent())); 579 | mDragItemStartCallback.changedPosition(mobileView, originalItemPosition, originalPosition, newItemPos, newColumnPos); 580 | } 581 | } 582 | } 583 | } 584 | } 585 | 586 | } 587 | 588 | //Gets the position of a item inside a list based on the y offset 589 | public int getPositionInListY(int y,LinearLayout layout){ 590 | for(int i = 0; i < layout.getChildCount();i++){ 591 | int[] location = new int[2]; 592 | View view = layout.getChildAt(i); 593 | view.getLocationOnScreen(location); 594 | if(y > location[1] && y < location[1]+view.getHeight()){ 595 | return i; 596 | } 597 | } 598 | return 0; 599 | } 600 | 601 | //Gets the position of a item inside a list based on the y offset 602 | public int getPositionInListX(int x,LinearLayout layout){ 603 | for(int i = 0; i < layout.getChildCount();i++){ 604 | int[] location = new int[2]; 605 | View view = layout.getChildAt(i); 606 | int end = layout.getWidth(); 607 | if(layout.getChildCount() > i+1){ 608 | int[] end_location = new int[2]; 609 | layout.getChildAt(i+1).getLocationOnScreen(end_location); 610 | end = end_location[0]; 611 | } 612 | view.getLocationOnScreen(location); 613 | if(x >= location[0] && x <= end){ 614 | return i; 615 | } 616 | } 617 | return 0; 618 | } 619 | 620 | //Change int change to position to fix problem with starting from the bottom 621 | private void switchItemFromPosition(int change,View view){ 622 | LinearLayout parentLayout = (LinearLayout)(view.getParent()); 623 | int columnPos = parentLayout.indexOfChild(view); 624 | if (columnPos + change >= 0 && columnPos + change < parentLayout.getChildCount()) { 625 | parentLayout.removeView(view); 626 | parentLayout.addView(view, columnPos + change); 627 | if (mDragItemStartCallback != null) { 628 | int newPos = parentLayout.indexOfChild(view); 629 | last_swap = System.currentTimeMillis(); 630 | mLastSwap = newPos; 631 | int newColumnPos = ((LinearLayout) mobileView.getParent().getParent().getParent().getParent()).indexOfChild((View) (mobileView.getParent().getParent().getParent())); 632 | mDragItemStartCallback.changedPosition(view, originalItemPosition, originalPosition, newPos, newColumnPos); 633 | } 634 | } 635 | } 636 | 637 | private void handleColumnSwitchHorizontal(){ 638 | if(can_scroll && last_swap <= System.currentTimeMillis()-mDelaySwap) { 639 | int columnPos = mParentLayout.indexOfChild(mobileView); 640 | View leftView = mParentLayout.getChildAt(columnPos - 1); 641 | View rightView = mParentLayout.getChildAt(columnPos + 1); 642 | 643 | int[] locationRight = new int[2]; 644 | if (rightView != null) { 645 | rightView.getLocationOnScreen(locationRight); 646 | if (locationRight[0] < mLastEventX) { 647 | //Scroll to the right 648 | switchColumnFromPosition(1,mobileView); 649 | if (locationRight[0] + (rightView.getWidth() / 2) < mLastEventX) { 650 | 651 | } 652 | } 653 | } 654 | 655 | int[] locationLeft = new int[2]; 656 | if (leftView != null) { 657 | leftView.getLocationOnScreen(locationLeft); 658 | if (locationLeft[0] + leftView.getWidth() > mLastEventX) { 659 | //Scroll to the right 660 | switchColumnFromPosition(-1,mobileView); 661 | //mRootLayout.scrollBy(-1 * 2, 0); 662 | if (locationLeft[0] + (leftView.getWidth() / 2) > mLastEventX) { 663 | 664 | } 665 | } 666 | } 667 | } 668 | } 669 | 670 | private void switchColumnFromPosition(int change,View view){ 671 | int columnPos = mParentLayout.indexOfChild(view); 672 | if(columnPos+change >= 0 && last_swap <= System.currentTimeMillis()-mDelaySwap) { 673 | mParentLayout.removeView(view); 674 | mParentLayout.addView(view, columnPos + change); 675 | if(mDragColumnStartCallback != null){ 676 | int newPos = mParentLayout.indexOfChild(view); 677 | last_swap = System.currentTimeMillis(); 678 | mLastSwap = newPos; 679 | Handler handlerTimer = new Handler(); 680 | handlerTimer.postDelayed(new Runnable(){ 681 | public void run() { 682 | scrollToColumn(mLastSwap,true); 683 | }}, 0); 684 | mDragColumnStartCallback.changedPosition(((LinearLayout)view).getChildAt(0),originalPosition,newPos); 685 | } 686 | } 687 | } 688 | 689 | private void touchEventsCancelled() { 690 | if(mCellSubIsMobile){ 691 | mobileView.setVisibility(VISIBLE); 692 | mHoverCell = null; 693 | invalidate(); 694 | LinearLayout parentLayout = (LinearLayout)(mobileView.getParent().getParent().getParent().getParent()); 695 | int columnPos = parentLayout.indexOfChild((View)(mobileView.getParent().getParent().getParent())); 696 | int pos = ((LinearLayout)mobileView.getParent()).indexOfChild(mobileView); 697 | View tmpView = boardAdapter.columns.get(originalPosition).views.get(originalItemPosition); 698 | boardAdapter.columns.get(originalPosition).views.remove(originalItemPosition); 699 | boardAdapter.columns.get(columnPos).views.add(pos, tmpView); 700 | Object tmpObject = boardAdapter.columns.get(originalPosition).objects.get(originalItemPosition); 701 | boardAdapter.columns.get(originalPosition).objects.remove(originalItemPosition); 702 | boardAdapter.columns.get(columnPos).objects.add(pos, tmpObject); 703 | if (mDragItemStartCallback != null) { 704 | mDragItemStartCallback.endDrag(mobileView, originalItemPosition,originalPosition, pos, columnPos); 705 | } 706 | }else if(mCellIsMobile){ 707 | for(int i = 0;i < mParentLayout.getChildCount();i++){ 708 | BoardItem parentView = (BoardItem)mParentLayout.getChildAt(i);//Gets the parent layout 709 | for(int j = 0;j < parentView.getChildCount();j++) { 710 | View childView = ((LinearLayout) parentView).getChildAt(j); 711 | scrollToColumn(originalPosition, true); 712 | scaleView(childView, parentView, GLOBAL_SCALE, 1f); 713 | } 714 | } 715 | mobileView.setVisibility(VISIBLE); 716 | mHoverCell = null; 717 | invalidate(); 718 | if(mDragColumnStartCallback != null){ 719 | int columnPos = mParentLayout.indexOfChild(mobileView); 720 | scrollToColumn(columnPos,true); 721 | BoardAdapter.Column column = boardAdapter.columns.get(originalPosition); 722 | boardAdapter.columns.remove(originalPosition); 723 | boardAdapter.columns.add(columnPos,column); 724 | mDragColumnStartCallback.endDrag(((LinearLayout)mobileView).getChildAt(0),originalPosition,columnPos); 725 | } 726 | } 727 | 728 | mDownX = -1; 729 | mDownY = -1; 730 | mCellSubIsMobile = false; 731 | mCellIsMobile = false; 732 | } 733 | 734 | Handler handler = new Handler(); 735 | 736 | public void scaleView(final View v, final BoardItem parent, final float startScale, final float endScale) { 737 | final Animation anim = new ScaleAnimation( 738 | startScale, endScale, // Start and end values for the X axis scaling 739 | startScale, endScale, // Start and end values for the Y axis scaling 740 | Animation.RELATIVE_TO_SELF,0f, // Pivot point of X scaling 741 | Animation.RELATIVE_TO_SELF, 0f); // Pivot point of Y scaling 742 | anim.setFillAfter(true); // Needed to keep the result of the animation 743 | anim.setFillBefore(false); 744 | anim.setFillEnabled(true); 745 | anim.setDuration(ANIM_TIME); 746 | v.startAnimation(anim); 747 | final long startTime = System.currentTimeMillis(); 748 | anim.setAnimationListener(new Animation.AnimationListener() { 749 | @Override 750 | public void onAnimationStart(Animation animation) { 751 | handler.post(createRunnable(parent,startTime,startScale,endScale)); 752 | parent.init(); 753 | can_scroll = false; 754 | } 755 | 756 | @Override 757 | public void onAnimationEnd(Animation animation) { 758 | parent.setScale(endScale); 759 | scrollToColumn(mLastSwap,true); 760 | parent.requestLayout(); 761 | parent.invalidate(); 762 | can_scroll = true; 763 | 764 | } 765 | 766 | @Override 767 | public void onAnimationRepeat(Animation animation) { 768 | 769 | } 770 | }); 771 | } 772 | 773 | private Runnable createRunnable(final BoardItem parent, final long startTime, final float startScale, final float endScale){ 774 | Runnable runnable = new Runnable() { 775 | @Override 776 | public void run() { 777 | long time = System.currentTimeMillis()-startTime; 778 | float scale_time = time/(float)ANIM_TIME; 779 | if(scale_time > 1){ 780 | scale_time = 1; 781 | } 782 | scrollToColumn(mLastSwap,true); 783 | parent.setScale(startScale + (endScale - startScale)*scale_time); 784 | parent.requestLayout(); 785 | parent.invalidate(); 786 | if(scale_time != 1) { 787 | handler.postDelayed(this,10); 788 | } 789 | } 790 | }; 791 | return runnable; 792 | } 793 | 794 | private ViewGroup removeParent(View view){ 795 | if(view == null){ 796 | return null; 797 | } 798 | ViewGroup viewGroup = ((ViewGroup)view.getParent()); 799 | if(viewGroup != null){ 800 | viewGroup.removeView(view); 801 | } 802 | return viewGroup; 803 | } 804 | 805 | public void notifyDataSetChanged(){ 806 | for(int column_pos = 0; column_pos < boardAdapter.columns.size(); column_pos++) { 807 | if(boardAdapter.columns.get(column_pos).header != null) { 808 | ViewGroup parent_header = removeParent(boardAdapter.columns.get(column_pos).header); 809 | boardAdapter.columns.get(column_pos).header = boardAdapter.createHeaderView(getContext(), boardAdapter.columns.get(column_pos).header_object, column_pos); 810 | parent_header.addView(boardAdapter.columns.get(column_pos).header); 811 | ViewGroup layout = (ViewGroup)parent_header.getParent(); 812 | boardAdapter.columns.get(column_pos).header.setOnClickListener(createHeaderOnClickListener(layout)); 813 | boardAdapter.columns.get(column_pos).header.setOnLongClickListener(createHeaderOnLongClickListener(parent_header,layout)); 814 | 815 | } 816 | if(boardAdapter.columns.get(column_pos).footer != null) { 817 | ViewGroup parent_footer = removeParent(boardAdapter.columns.get(column_pos).footer); 818 | boardAdapter.columns.get(column_pos).footer = boardAdapter.createFooterView(getContext(), boardAdapter.columns.get(column_pos).footer_object, column_pos); 819 | parent_footer.addView(boardAdapter.columns.get(column_pos).footer); 820 | } 821 | } 822 | } 823 | 824 | private OnClickListener createHeaderOnClickListener(final View parent_layout){ 825 | return new OnClickListener() { 826 | @Override 827 | public void onClick(View v) { 828 | int pos = mParentLayout.indexOfChild(parent_layout); 829 | scrollToColumn(pos,true); 830 | headerClickListener.onClick(v,pos); 831 | } 832 | }; 833 | } 834 | 835 | private OnLongClickListener createHeaderOnLongClickListener(final ViewGroup layout,final View parent_layout){ 836 | return new OnLongClickListener() { 837 | @Override 838 | public boolean onLongClick(View v) { 839 | if (mDragColumnStartCallback == null) { 840 | return false; 841 | } 842 | originalPosition = mParentLayout.indexOfChild(parent_layout); 843 | mDragColumnStartCallback.startDrag(layout, originalPosition); 844 | mLastSwap = originalPosition; 845 | for (int i = 0; i < mParentLayout.getChildCount(); i++) { 846 | BoardItem parentView = (BoardItem) mParentLayout.getChildAt(i);//Gets the parent layout 847 | for (int j = 0; j < parentView.getChildCount(); j++) { 848 | View childView = ((LinearLayout) parentView).getChildAt(j); 849 | scrollToColumn(originalPosition, true); 850 | scaleView(childView, parentView, 1f, GLOBAL_SCALE); 851 | } 852 | } 853 | 854 | scrollToColumn(originalPosition, false); 855 | mCellIsMobile = true; 856 | mobileView = (View) (parent_layout); 857 | mHoverCell = getAndAddHoverView(mobileView, GLOBAL_SCALE); 858 | mobileView.setVisibility(INVISIBLE); 859 | return false; 860 | } 861 | }; 862 | } 863 | 864 | private OnClickListener createFooterOnClickListener(final View parent_layout){ 865 | return new OnClickListener() { 866 | @Override 867 | public void onClick(View v) { 868 | int column_pos = mParentLayout.indexOfChild(parent_layout); 869 | footerClickListener.onClick(v,column_pos); 870 | } 871 | }; 872 | } 873 | 874 | public void addColumnList(@Nullable View header, ArrayList items, @Nullable final View footer,int column_pos){ 875 | final BoardItem parent_layout = new BoardItem(getContext()); 876 | parent_layout.setBackgroundColor(background_color); 877 | final LinearLayout layout = new LinearLayout(getContext()); 878 | final ScrollView scroll_view = new ScrollView(getContext()); 879 | ScrollView.LayoutParams scrollParams = new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.WRAP_CONTENT); 880 | scroll_view.setLayoutParams(scrollParams); 881 | final LinearLayout layout_children = new LinearLayout(getContext()); 882 | layout_children.setOrientation(LinearLayout.VERTICAL); 883 | layout.setOrientation(LinearLayout.VERTICAL); 884 | parent_layout.setOrientation(LinearLayout.VERTICAL); 885 | if(constWidth) { 886 | int margin = calculatePixelFromDensity(8); 887 | LayoutParams params = new LayoutParams(calculatePixelFromDensity(240), LayoutParams.WRAP_CONTENT); 888 | LayoutParams parent_params = new LayoutParams(calculatePixelFromDensity(240), LayoutParams.WRAP_CONTENT); 889 | layout.setLayoutParams(params); 890 | parent_params.setMargins(margin,margin,margin,margin); 891 | parent_layout.setLayoutParams(parent_params); 892 | }else { 893 | int margin = calculatePixelFromDensity(8); 894 | LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 895 | LayoutParams parent_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 896 | layout.setLayoutParams(params); 897 | parent_params.setMargins(margin,margin,margin,margin); 898 | parent_layout.setLayoutParams(parent_params); 899 | } 900 | parent_layout.addView(layout); 901 | if(header != null){ 902 | header.setId(HEADER_ID); 903 | removeParent(header); 904 | layout.addView(header); 905 | header.setOnClickListener(createHeaderOnClickListener(parent_layout)); 906 | if(!boardAdapter.columns.get(column_pos).column_locked) { 907 | header.setOnLongClickListener(createHeaderOnLongClickListener(layout,parent_layout)); 908 | } 909 | } 910 | parent_layout.addView(scroll_view); 911 | scroll_view.addView(layout_children); 912 | for(int i = 0;i < items.size();i++){ 913 | final View view = items.get(i); 914 | removeParent(view); 915 | layout_children.addView(view); 916 | addBoardItem(view,column_pos); 917 | } 918 | if(footer != null) { 919 | removeParent(footer); 920 | final LinearLayout footer_layout = new LinearLayout(getContext()); 921 | footer_layout.setOrientation(LinearLayout.VERTICAL); 922 | final LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 923 | params.setMargins(0,200*-1,0,0); 924 | layout.addView(footer); 925 | footer_layout.setLayoutParams(params); 926 | parent_layout.addView(footer_layout); 927 | footer.setOnClickListener(createFooterOnClickListener(parent_layout)); 928 | footer.post(new Runnable() { 929 | @Override 930 | public void run() { 931 | scroll_view.setPadding(0,0,0,footer.getHeight()); 932 | final LinearLayout.LayoutParams new_params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 933 | new_params.setMargins(0,footer.getHeight()*-1,0,0); 934 | removeParent(footer); 935 | footer_layout.setLayoutParams(new_params); 936 | footer_layout.addView(footer); 937 | } 938 | }); 939 | } 940 | mParentLayout.addView(parent_layout,column_pos); 941 | } 942 | 943 | public void addBoardItem(final View view, final int column_pos){ 944 | view.setOnClickListener(new OnClickListener() { 945 | @Override 946 | public void onClick(View v) { 947 | LinearLayout layout = (LinearLayout)view.getParent(); 948 | BoardItem parent_layout = (BoardItem)layout.getParent().getParent(); 949 | int pos = mParentLayout.indexOfChild(parent_layout); 950 | int i = layout.indexOfChild(view); 951 | itemClickListener.onClick(view,pos, i); 952 | } 953 | }); 954 | if(!boardAdapter.columns.get(column_pos).items_locked) { 955 | view.setOnLongClickListener(new OnLongClickListener() { 956 | @Override 957 | public boolean onLongClick(View v) { 958 | if (mDragItemStartCallback == null) { 959 | return false; 960 | } 961 | originalPosition = mParentLayout.indexOfChild((LinearLayout) ((LinearLayout) view.getParent()).getParent().getParent()); 962 | originalItemPosition = ((LinearLayout) view.getParent()).indexOfChild(view); 963 | mDragItemStartCallback.startDrag(view, originalItemPosition,originalPosition); 964 | mCellSubIsMobile = true; 965 | mobileView = (View) (view); 966 | mHoverCell = getAndAddHoverView(mobileView, 1); 967 | mobileView.setVisibility(INVISIBLE); 968 | return false; 969 | } 970 | }); 971 | } 972 | } 973 | 974 | private int calculatePixelFromDensity(float dp){ 975 | DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); 976 | float fpixels = metrics.density * dp; 977 | int pixels = (int) (fpixels + 0.5f); 978 | return pixels; 979 | } 980 | 981 | private BitmapDrawable getAndAddHoverView(View v, float scale){ 982 | int w = v.getWidth(); 983 | int h = v.getHeight(); 984 | int top = v.getTop(); 985 | int left = v.getLeft(); 986 | 987 | Bitmap b = getBitmapWithBorder(v,scale); 988 | BitmapDrawable drawable = new BitmapDrawable(getResources(),b); 989 | mHoverCellOriginalBounds = new Rect(left,top,left+w,top+h); 990 | mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds); 991 | drawable.setBounds(mHoverCellCurrentBounds); 992 | return drawable; 993 | } 994 | 995 | private Bitmap getBitmapWithBorder(View v, float scale) { 996 | Bitmap bitmap = getBitmapFromView(v,0); 997 | Bitmap b = getBitmapFromView(v,1); 998 | Canvas can = new Canvas(bitmap); 999 | Paint paint = new Paint(); 1000 | paint.setAlpha(150); 1001 | can.scale(scale,scale,mDownX,mDownY); 1002 | can.rotate(3); 1003 | can.drawBitmap(b,0,0,paint); 1004 | return bitmap; 1005 | } 1006 | 1007 | private Bitmap getBitmapFromView(View v, float scale){ 1008 | double radians = 0.0523599f; 1009 | double s = Math.abs(Math.sin(radians)); 1010 | double c = Math.abs(Math.cos(radians)); 1011 | int width = (int)(v.getHeight()*s + v.getWidth()*c); 1012 | int height = (int)(v.getWidth()*s + v.getHeight()*c); 1013 | Bitmap bitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888); 1014 | Canvas canvas = new Canvas(bitmap); 1015 | canvas.scale(scale,scale); 1016 | v.draw(canvas); 1017 | return bitmap; 1018 | } 1019 | 1020 | private Rect rotatedBounds(Rect tmp,double radians){ 1021 | double s = Math.abs(Math.sin(radians)); 1022 | double c = Math.abs(Math.cos(radians)); 1023 | int width = (int)(tmp.height()*s + tmp.width()*c); 1024 | int height = (int)(tmp.width()*s + tmp.height()*c); 1025 | 1026 | return new Rect(tmp.left,tmp.top,tmp.left+width,tmp.top+height); 1027 | } 1028 | 1029 | } 1030 | -------------------------------------------------------------------------------- /boardview/src/main/java/com/allyants/boardview/Item.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | /** 4 | * Created by jbonk on 5/5/2018. 5 | */ 6 | 7 | public class Item{ 8 | 9 | public String item; 10 | 11 | public Item(String item){ 12 | this.item = item; 13 | } 14 | 15 | public String toString(){ 16 | return item; 17 | } 18 | } -------------------------------------------------------------------------------- /boardview/src/main/java/com/allyants/boardview/SimpleBoardAdapter.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by jbonk on 6/12/2017. 11 | */ 12 | 13 | public class SimpleBoardAdapter extends BoardAdapter{ 14 | int header_resource; 15 | int item_resource; 16 | public SimpleBoardAdapter instance; 17 | 18 | public SimpleBoardAdapter(Context context, ArrayList data) { 19 | super(context); 20 | instance = this; 21 | this.columns = (ArrayList)data; 22 | this.header_resource = R.layout.column_header; 23 | this.item_resource = R.layout.column_item; 24 | } 25 | 26 | @Override 27 | public int getColumnCount() { 28 | return columns.size(); 29 | } 30 | 31 | @Override 32 | public int getItemCount(int column_position) { 33 | return columns.get(column_position).objects.size(); 34 | } 35 | 36 | @Override 37 | public Object createHeaderObject(int column_position) { 38 | return columns.get(column_position).header_object; 39 | } 40 | 41 | @Override 42 | public Object createFooterObject(int column_position) { 43 | return "Footer "+ String.valueOf(column_position); 44 | } 45 | 46 | @Override 47 | public Object createItemObject(int column_position, int item_position) { 48 | return columns.get(column_position).objects.get(item_position); 49 | } 50 | 51 | @Override 52 | public boolean isColumnLocked(int column_position) { 53 | return false; 54 | } 55 | 56 | @Override 57 | public boolean isItemLocked(int column_position) { 58 | return false; 59 | } 60 | 61 | @Override 62 | public View createItemView(Context context,Object header_object,Object item_object,int column_position, int item_position) { 63 | View item = View.inflate(context, item_resource, null); 64 | TextView textView = (TextView)item.findViewById(R.id.textView); 65 | textView.setText(columns.get(column_position).objects.get(item_position).toString()); 66 | return item; 67 | } 68 | 69 | @Override 70 | public int maxItemCount(int column_position) { 71 | return 4; 72 | } 73 | 74 | @Override 75 | public void createColumns() { 76 | super.createColumns(); 77 | } 78 | 79 | @Override 80 | public View createHeaderView(Context context,Object header_object,int column_position) { 81 | View column = View.inflate(context, header_resource, null); 82 | TextView textView = (TextView)column.findViewById(R.id.textView); 83 | textView.setText(columns.get(column_position).header_object.toString()); 84 | return column; 85 | } 86 | 87 | @Override 88 | public View createFooterView(Context context, Object footer_object, int column_position) { 89 | View footer = View.inflate(context, header_resource, null); 90 | TextView textView = (TextView)footer.findViewById(R.id.textView); 91 | textView.setText((String)footer_object); 92 | return footer; 93 | } 94 | 95 | public static class SimpleColumn extends Column{ 96 | public String title; 97 | public SimpleColumn(String title, ArrayList items){ 98 | super(); 99 | this.title = title; 100 | this.header_object = new Item(title); 101 | this.objects = items; 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /boardview/src/main/res/drawable/shadow_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /boardview/src/main/res/layout/column_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | -------------------------------------------------------------------------------- /boardview/src/main/res/layout/column_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | -------------------------------------------------------------------------------- /boardview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /boardview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BoardView 3 | 4 | -------------------------------------------------------------------------------- /boardview/src/test/java/com/allyants/boardview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.allyants.boardview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakebonk/BoardView/6a3d0c2b4656c109fdacf7c3cd91e62b730e31a5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':boardview' 2 | --------------------------------------------------------------------------------