├── .gitignore ├── LICENSE ├── README.md ├── ScreenShots ├── 0.png └── 1.png ├── TreeView ├── .gitignore ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── markmao │ │ └── treeview │ │ ├── MainActivity.java │ │ ├── TreeViewAdapter.java │ │ └── widget │ │ ├── BaseTreeViewAdapter.java │ │ ├── ITreeViewHeaderUpdater.java │ │ └── TreeView.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ ├── contact_list_buddy_item_bg.9.png │ ├── ic_launcher.png │ ├── indicator_expanded.9.png │ ├── indicator_unexpanded.9.png │ ├── list_conversation_press.9.png │ ├── status_online.png │ ├── status_online_btn.png │ ├── terminal_icon_ios.png │ └── terminal_icon_ios_pressed.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable │ ├── contact_list_item_bg_selector.xml │ ├── contact_list_item_buddy_name_text_color.xml │ ├── contact_list_item_buddy_signature_text_color2.xml │ ├── iphone_online.xml │ ├── list_group_item_background.xml │ ├── list_group_item_background_selected.xml │ └── list_group_item_background_unselected.xml │ ├── layout │ ├── activity_main.xml │ ├── list_group_view.xml │ ├── list_head_view.xml │ └── list_item_view.xml │ ├── menu │ └── main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Intellij project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | -------------------------------------------------------------------------------- /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, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "[]" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright [yyyy] [name of copyright owner] 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TreeView 2 | ======== 3 | 4 | An android ExpandListView like IOS's TreeView. 5 | 6 | *Note:This app developed by Android Studio* 7 | 8 | ##Screenshots 9 | ![Screenshot 0](https://raw.github.com/MarkMjw/TreeView/master/ScreenShots/0.png) 10 | 11 | ![Screenshot 1](https://raw.github.com/MarkMjw/TreeView/master/ScreenShots/1.png) 12 | 13 | License 14 | ======= 15 | 16 | Copyright (C) 2014 MarkMjw 17 | 18 | Licensed under the Apache License, Version 2.0 (the "License"); 19 | you may not use this file except in compliance with the License. 20 | You may obtain a copy of the License at 21 | 22 | http://www.apache.org/licenses/LICENSE-2.0 23 | 24 | Unless required by applicable law or agreed to in writing, software 25 | distributed under the License is distributed on an "AS IS" BASIS, 26 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | See the License for the specific language governing permissions and 28 | limitations under the License. 29 | 30 | -------------------------------------------------------------------------------- /ScreenShots/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/ScreenShots/0.png -------------------------------------------------------------------------------- /ScreenShots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/ScreenShots/1.png -------------------------------------------------------------------------------- /TreeView/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /TreeView/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | dependencies { 4 | compile 'com.android.support:appcompat-v7:+' 5 | } 6 | 7 | android { 8 | compileSdkVersion 19 9 | buildToolsVersion "19.0.3" 10 | 11 | defaultConfig { 12 | minSdkVersion 11 13 | targetSdkVersion 19 14 | } 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /TreeView/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /TreeView/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /TreeView/src/main/java/com/markmao/treeview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.markmao.treeview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import com.markmao.treeview.widget.TreeView; 8 | 9 | public class MainActivity extends ActionBarActivity { 10 | private TreeView treeView; 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | 16 | initView(); 17 | } 18 | 19 | private void initView() { 20 | treeView = (TreeView) findViewById(R.id.tree_view); 21 | treeView.setHeaderView(getLayoutInflater().inflate(R.layout.list_head_view, treeView, 22 | false)); 23 | treeView.setAdapter(new TreeViewAdapter(this, treeView)); 24 | } 25 | 26 | @Override 27 | public boolean onCreateOptionsMenu(Menu menu) { 28 | 29 | // Inflate the menu; this adds items to the action bar if it is present. 30 | getMenuInflater().inflate(R.menu.main, menu); 31 | return true; 32 | } 33 | 34 | @Override 35 | public boolean onOptionsItemSelected(MenuItem item) { 36 | // Handle action bar item clicks here. The action bar will 37 | // automatically handle clicks on the Home/Up button, so long 38 | // as you specify a parent activity in AndroidManifest.xml. 39 | switch (item.getItemId()) { 40 | case R.id.action_settings: 41 | return true; 42 | } 43 | return super.onOptionsItemSelected(item); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /TreeView/src/main/java/com/markmao/treeview/TreeViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.markmao.treeview; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.markmao.treeview.widget.BaseTreeViewAdapter; 11 | import com.markmao.treeview.widget.TreeView; 12 | 13 | /** 14 | * TreeView demo adapter 15 | * 16 | * @author markmjw 17 | * @date 2014-01-04 18 | */ 19 | public class TreeViewAdapter extends BaseTreeViewAdapter { 20 | private LayoutInflater mInflater; 21 | 22 | private String[] mGroups = { 23 | "Group 01", "Group 02", "Group 03", "Group 04", "Group 05", 24 | "Group 06", "Group 07", "Group 08", "Group 09", "Group 10", 25 | "Group 11", "Group 12", "Group 13", "Group 14", "Group 15", 26 | "Group 16", "Group 17", "Group 18", "Group 19", "Group 20"}; 27 | 28 | private String[][] mChildren = { 29 | {"Way", "Arnold", "Barry", "Chuck", "David", "Afghanistan", "Albania", "Belgium", "Lily", "Jim", "LiMing", "Jodan"}, 30 | {"Ace", "Bandit", "Cha-Cha", "Deuce", "Bahamas", "China", "Dominica", "Jim", "LiMing", "Jodan"}, 31 | {"Fluffy", "Snuggles", "Ecuador", "Ecuador", "Jim", "LiMing", "Jodan"}, 32 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 33 | {"Way", "Arnold", "Barry", "Chuck", "David", "Afghanistan", "Albania", "Belgium", "Lily", "Jim", "LiMing", "Jodan"}, 34 | {"Ace", "Bandit", "Cha-Cha", "Deuce", "Bahamas", "China", "Dominica", "Jim", "LiMing", "Jodan"}, 35 | {"Fluffy", "Snuggles", "Ecuador", "Ecuador", "Jim", "LiMing", "Jodan"}, 36 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 37 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 38 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 39 | {"Way", "Arnold", "Barry", "Chuck", "David", "Afghanistan", "Albania", "Belgium", "Lily", "Jim", "LiMing", "Jodan"}, 40 | {"Ace", "Bandit", "Cha-Cha", "Deuce", "Bahamas", "China", "Dominica", "Jim", "LiMing", "Jodan"}, 41 | {"Fluffy", "Snuggles", "Ecuador", "Ecuador", "Jim", "LiMing", "Jodan"}, 42 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 43 | {"Way", "Arnold", "Barry", "Chuck", "David", "Afghanistan", "Albania", "Belgium", "Lily", "Jim", "LiMing", "Jodan"}, 44 | {"Ace", "Bandit", "Cha-Cha", "Deuce", "Bahamas", "China", "Dominica", "Jim", "LiMing", "Jodan"}, 45 | {"Fluffy", "Snuggles", "Ecuador", "Ecuador", "Jim", "LiMing", "Jodan"}, 46 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 47 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}, 48 | {"Goldy", "Bubbles", "Iceland", "Iran", "Italy", "Jim", "LiMing", "Jodan"}}; 49 | 50 | public TreeViewAdapter(Context context, TreeView treeView) { 51 | super(treeView); 52 | 53 | mInflater = LayoutInflater.from(context); 54 | } 55 | 56 | @Override 57 | public Object getChild(int groupPosition, int childPosition) { 58 | return mChildren[groupPosition][childPosition]; 59 | } 60 | 61 | @Override 62 | public long getChildId(int groupPosition, int childPosition) { 63 | return childPosition; 64 | } 65 | 66 | @Override 67 | public int getChildrenCount(int groupPosition) { 68 | return mChildren[groupPosition].length; 69 | } 70 | 71 | @Override 72 | public Object getGroup(int groupPosition) { 73 | return mGroups[groupPosition]; 74 | } 75 | 76 | @Override 77 | public int getGroupCount() { 78 | return mGroups.length; 79 | } 80 | 81 | @Override 82 | public long getGroupId(int groupPosition) { 83 | return groupPosition; 84 | } 85 | 86 | @Override 87 | public boolean isChildSelectable(int groupPosition, int childPosition) { 88 | return true; 89 | } 90 | 91 | @Override 92 | public boolean hasStableIds() { 93 | return true; 94 | } 95 | 96 | @Override 97 | public View getChildView(int groupPosition, int childPosition, boolean isLastChild, 98 | View convertView, ViewGroup parent) { 99 | if (convertView == null) { 100 | convertView = mInflater.inflate(R.layout.list_item_view, null); 101 | } 102 | 103 | ChildHolder holder = getChildHolder(convertView); 104 | holder.name.setText(String.valueOf(getChild(groupPosition, childPosition))); 105 | holder.state.setText("Test state..."); 106 | return convertView; 107 | } 108 | 109 | private ChildHolder getChildHolder(final View view) { 110 | ChildHolder holder = (ChildHolder) view.getTag(); 111 | if (null == holder) { 112 | holder = new ChildHolder(view); 113 | view.setTag(holder); 114 | } 115 | return holder; 116 | } 117 | 118 | private class ChildHolder { 119 | TextView name; 120 | TextView state; 121 | 122 | public ChildHolder(View view) { 123 | name = (TextView) view.findViewById(R.id.contact_list_item_name); 124 | state = (TextView) view.findViewById(R.id.cpntact_list_item_state); 125 | } 126 | } 127 | 128 | @Override 129 | public View getGroupView(int groupPosition, boolean isExpanded, View convertView, 130 | ViewGroup parent) { 131 | if (convertView == null) { 132 | convertView = mInflater.inflate(R.layout.list_group_view, null); 133 | } 134 | 135 | GroupHolder holder = getGroupHolder(convertView); 136 | 137 | holder.name.setText(mGroups[groupPosition]); 138 | holder.onlineNum.setText(getChildrenCount(groupPosition) + "/" + getChildrenCount(groupPosition)); 139 | if (isExpanded) { 140 | holder.indicator.setImageResource(R.drawable.indicator_expanded); 141 | } else { 142 | holder.indicator.setImageResource(R.drawable.indicator_unexpanded); 143 | } 144 | 145 | return convertView; 146 | } 147 | 148 | private GroupHolder getGroupHolder(final View view) { 149 | GroupHolder holder = (GroupHolder) view.getTag(); 150 | if (null == holder) { 151 | holder = new GroupHolder(view); 152 | view.setTag(holder); 153 | } 154 | return holder; 155 | } 156 | 157 | private class GroupHolder { 158 | TextView name; 159 | ImageView indicator; 160 | TextView onlineNum; 161 | 162 | public GroupHolder(View view) { 163 | name = (TextView) view.findViewById(R.id.group_name); 164 | indicator = (ImageView) view.findViewById(R.id.group_indicator); 165 | onlineNum = (TextView) view.findViewById(R.id.online_count); 166 | } 167 | } 168 | 169 | @Override 170 | public void updateHeader(View header, int groupPosition, int childPosition, int alpha) { 171 | ((TextView) header.findViewById(R.id.group_name)).setText(mGroups[groupPosition]); 172 | ((TextView) header.findViewById(R.id.online_count)).setText(getChildrenCount 173 | (groupPosition) + "/" + getChildrenCount(groupPosition)); 174 | header.setAlpha(alpha); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /TreeView/src/main/java/com/markmao/treeview/widget/BaseTreeViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.markmao.treeview.widget; 2 | 3 | import android.util.SparseIntArray; 4 | import android.widget.BaseExpandableListAdapter; 5 | 6 | /** 7 | * The base adapter for TreeView. 8 | * 9 | * @author markmjw 10 | * @date 2014-01-04 11 | */ 12 | public abstract class BaseTreeViewAdapter extends BaseExpandableListAdapter implements 13 | ITreeViewHeaderUpdater { 14 | protected TreeView mTreeView; 15 | 16 | protected SparseIntArray mGroupStatusArray; 17 | 18 | public BaseTreeViewAdapter(TreeView treeView) { 19 | mTreeView = treeView; 20 | mGroupStatusArray = new SparseIntArray(); 21 | } 22 | 23 | @Override 24 | public int getHeaderState(int groupPosition, int childPosition) { 25 | final int childCount = getChildrenCount(groupPosition); 26 | if (childPosition == childCount - 1) { 27 | return STATE_VISIBLE_PART; 28 | } else if (childPosition == -1 && !mTreeView.isGroupExpanded(groupPosition)) { 29 | return STATE_GONE; 30 | } else { 31 | return STATE_VISIBLE_ALL; 32 | } 33 | } 34 | 35 | @Override 36 | public void onHeaderClick(int groupPosition, int status) { 37 | mGroupStatusArray.put(groupPosition, status); 38 | } 39 | 40 | @Override 41 | public int getHeaderClickStatus(int groupPosition) { 42 | return mGroupStatusArray.get(groupPosition, STATE_GONE); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /TreeView/src/main/java/com/markmao/treeview/widget/ITreeViewHeaderUpdater.java: -------------------------------------------------------------------------------- 1 | package com.markmao.treeview.widget; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Update interface TreeView's header . 7 | * 8 | * @author markmjw 9 | * @date 2014-01-04 10 | */ 11 | public interface ITreeViewHeaderUpdater { 12 | /** Header Gone. */ 13 | public static final int STATE_GONE = 0x00; 14 | /** Header Visible. */ 15 | public static final int STATE_VISIBLE_ALL = 0x01; 16 | /** Header Push up. */ 17 | public static final int STATE_VISIBLE_PART = 0x02; 18 | 19 | /** 20 | * Get TreeView's header state. 21 | * 22 | * @param groupPosition The group position. 23 | * @param childPosition The child position. 24 | * @return {@link #STATE_GONE}, {@link #STATE_VISIBLE_ALL}, 25 | * {@link #STATE_VISIBLE_PART} 26 | */ 27 | public int getHeaderState(int groupPosition, int childPosition); 28 | 29 | /** 30 | * Update TreeView's header. 31 | * 32 | * @param header The TreeView's header view. 33 | * @param groupPosition The group position. 34 | * @param childPosition The child position. 35 | * @param alpha The header's alpha value. 36 | */ 37 | public void updateHeader(View header, int groupPosition, int childPosition, int alpha); 38 | 39 | /** 40 | * The header view onClick. 41 | * 42 | * @param groupPosition The group position. 43 | * @param status {@link #STATE_GONE}, {@link #STATE_VISIBLE_ALL}, 44 | * {@link #STATE_VISIBLE_PART} 45 | */ 46 | public void onHeaderClick(int groupPosition, int status); 47 | 48 | /** 49 | * Get the header's state on click. 50 | * 51 | * @param groupPosition The group position. 52 | * @return {@link #STATE_GONE}, {@link #STATE_VISIBLE_ALL}, 53 | * {@link #STATE_VISIBLE_PART} 54 | */ 55 | public int getHeaderClickStatus(int groupPosition); 56 | } 57 | -------------------------------------------------------------------------------- /TreeView/src/main/java/com/markmao/treeview/widget/TreeView.java: -------------------------------------------------------------------------------- 1 | package com.markmao.treeview.widget; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.AbsListView; 10 | import android.widget.AbsListView.OnScrollListener; 11 | import android.widget.ExpandableListAdapter; 12 | import android.widget.ExpandableListView; 13 | import android.widget.ExpandableListView.OnGroupClickListener; 14 | 15 | /** 16 | * This widget extends {@link android.widget.ExpandableListView}, just like TreeView(IOS). 17 | * 18 | * @see android.widget.ExpandableListView 19 | * @author markmjw 20 | * @date 2014-01-03 21 | */ 22 | public class TreeView extends ExpandableListView implements OnScrollListener, OnGroupClickListener { 23 | private static final int MAX_ALPHA = 255; 24 | 25 | private ITreeViewHeaderUpdater mUpdater; 26 | 27 | private View mHeaderView; 28 | 29 | private boolean mHeaderVisible; 30 | 31 | private int mHeaderWidth; 32 | 33 | private int mHeaderHeight; 34 | 35 | public TreeView(Context context) { 36 | super(context); 37 | init(); 38 | } 39 | 40 | public TreeView(Context context, AttributeSet attrs) { 41 | super(context, attrs); 42 | init(); 43 | } 44 | 45 | public TreeView(Context context, AttributeSet attrs, int defStyle) { 46 | super(context, attrs, defStyle); 47 | init(); 48 | } 49 | 50 | private void init() { 51 | setSmoothScrollbarEnabled(true); 52 | 53 | setOnScrollListener(this); 54 | setOnGroupClickListener(this); 55 | } 56 | 57 | /** 58 | * Sets the list header view 59 | * 60 | * @param view 61 | */ 62 | public void setHeaderView(View view) { 63 | mHeaderView = view; 64 | AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams 65 | .MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 66 | view.setLayoutParams(lp); 67 | 68 | if (mHeaderView != null) { 69 | setFadingEdgeLength(0); 70 | } 71 | 72 | requestLayout(); 73 | } 74 | 75 | @Override 76 | public void setAdapter(ExpandableListAdapter adapter) { 77 | super.setAdapter(adapter); 78 | 79 | if(adapter instanceof ITreeViewHeaderUpdater) { 80 | mUpdater = (ITreeViewHeaderUpdater) adapter; 81 | } else { 82 | throw new IllegalArgumentException("The adapter must instanceof ITreeViewHeaderUpdater."); 83 | } 84 | } 85 | 86 | @Override 87 | public boolean onTouchEvent(MotionEvent ev) { 88 | // header view is visible 89 | if (mHeaderVisible) { 90 | float downX = 0; 91 | float downY = 0; 92 | 93 | switch (ev.getAction()) { 94 | case MotionEvent.ACTION_DOWN: 95 | downX = ev.getX(); 96 | downY = ev.getY(); 97 | if (downX <= mHeaderWidth && downY <= mHeaderHeight) { 98 | return true; 99 | } 100 | break; 101 | 102 | case MotionEvent.ACTION_UP: 103 | float x = ev.getX(); 104 | float y = ev.getY(); 105 | float offsetX = Math.abs(x - downX); 106 | float offsetY = Math.abs(y - downY); 107 | // the touch event under header view 108 | if (x <= mHeaderWidth && y <= mHeaderHeight && offsetX <= mHeaderWidth && 109 | offsetY <= mHeaderHeight) { 110 | if (mHeaderView != null) { 111 | onHeaderViewClick(); 112 | } 113 | 114 | return true; 115 | } 116 | break; 117 | 118 | default: 119 | break; 120 | } 121 | } 122 | 123 | return super.onTouchEvent(ev); 124 | } 125 | 126 | @Override 127 | public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { 128 | int status = mUpdater.getHeaderClickStatus(groupPosition); 129 | 130 | switch (status) { 131 | case ITreeViewHeaderUpdater.STATE_GONE: 132 | mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_VISIBLE_ALL); 133 | break; 134 | 135 | case ITreeViewHeaderUpdater.STATE_VISIBLE_ALL: 136 | mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_GONE); 137 | break; 138 | 139 | case ITreeViewHeaderUpdater.STATE_VISIBLE_PART: 140 | // ignore 141 | break; 142 | 143 | default: 144 | break; 145 | } 146 | 147 | return false; 148 | } 149 | 150 | @Override 151 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 152 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 153 | 154 | if (mHeaderView != null) { 155 | measureChild(mHeaderView, widthMeasureSpec, heightMeasureSpec); 156 | mHeaderWidth = mHeaderView.getMeasuredWidth(); 157 | mHeaderHeight = mHeaderView.getMeasuredHeight(); 158 | } 159 | } 160 | 161 | private int mOldState = -1; 162 | 163 | @Override 164 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 165 | super.onLayout(changed, left, top, right, bottom); 166 | 167 | final long listPosition = getExpandableListPosition(getFirstVisiblePosition()); 168 | final int groupPos = ExpandableListView.getPackedPositionGroup(listPosition); 169 | final int childPos = ExpandableListView.getPackedPositionChild(listPosition); 170 | 171 | int state = mUpdater.getHeaderState(groupPos, childPos); 172 | if (mHeaderView != null && mUpdater != null && state != mOldState) { 173 | mOldState = state; 174 | mHeaderView.layout(0, 0, mHeaderWidth, mHeaderHeight); 175 | } 176 | 177 | updateHeaderView(groupPos, childPos); 178 | } 179 | 180 | @Override 181 | protected void dispatchDraw(Canvas canvas) { 182 | super.dispatchDraw(canvas); 183 | if (mHeaderVisible) { 184 | // draw header view 185 | drawChild(canvas, mHeaderView, getDrawingTime()); 186 | } 187 | } 188 | 189 | @Override 190 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, 191 | int totalItemCount) { 192 | final long listPosition = getExpandableListPosition(firstVisibleItem); 193 | int groupPos = ExpandableListView.getPackedPositionGroup(listPosition); 194 | int childPos = ExpandableListView.getPackedPositionChild(listPosition); 195 | 196 | updateHeaderView(groupPos, childPos); 197 | } 198 | 199 | @Override 200 | public void onScrollStateChanged(AbsListView view, int scrollState) { 201 | 202 | } 203 | 204 | private void updateHeaderView(int groupPosition, int childPosition) { 205 | if (mHeaderView == null || mUpdater == null || ((ExpandableListAdapter) mUpdater) 206 | .getGroupCount() == 0) { 207 | return; 208 | } 209 | 210 | int state = mUpdater.getHeaderState(groupPosition, childPosition); 211 | 212 | switch (state) { 213 | case ITreeViewHeaderUpdater.STATE_GONE: { 214 | mHeaderVisible = false; 215 | break; 216 | } 217 | 218 | case ITreeViewHeaderUpdater.STATE_VISIBLE_ALL: { 219 | mUpdater.updateHeader(mHeaderView, groupPosition, childPosition, MAX_ALPHA); 220 | 221 | if (mHeaderView.getTop() != 0) { 222 | mHeaderView.layout(0, 0, mHeaderWidth, mHeaderHeight); 223 | } 224 | 225 | mHeaderVisible = true; 226 | break; 227 | } 228 | 229 | case ITreeViewHeaderUpdater.STATE_VISIBLE_PART: { 230 | // a part of header view visible 231 | View firstView = getChildAt(0); 232 | int bottom = null != firstView ? firstView.getBottom() : 0; 233 | 234 | int headerHeight = mHeaderView.getHeight(); 235 | int topY; 236 | int alpha; 237 | 238 | if (bottom < headerHeight) { 239 | topY = (bottom - headerHeight); 240 | alpha = MAX_ALPHA * (headerHeight + topY) / headerHeight; 241 | } else { 242 | topY = 0; 243 | alpha = MAX_ALPHA; 244 | } 245 | 246 | mUpdater.updateHeader(mHeaderView, groupPosition, childPosition, alpha); 247 | 248 | if (mHeaderView.getTop() != topY) { 249 | mHeaderView.layout(0, topY, mHeaderWidth, mHeaderHeight + topY); 250 | } 251 | 252 | mHeaderVisible = true; 253 | break; 254 | } 255 | } 256 | } 257 | 258 | private void onHeaderViewClick() { 259 | long packedPosition = getExpandableListPosition(getFirstVisiblePosition()); 260 | 261 | int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition); 262 | 263 | int status = mUpdater.getHeaderClickStatus(groupPosition); 264 | if (ITreeViewHeaderUpdater.STATE_VISIBLE_ALL == status) { 265 | collapseGroup(groupPosition); 266 | mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_GONE); 267 | } else { 268 | expandGroup(groupPosition); 269 | mUpdater.onHeaderClick(groupPosition, ITreeViewHeaderUpdater.STATE_VISIBLE_ALL); 270 | } 271 | 272 | setSelectedGroup(groupPosition); 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/contact_list_buddy_item_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/contact_list_buddy_item_bg.9.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/indicator_expanded.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/indicator_expanded.9.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/indicator_unexpanded.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/indicator_unexpanded.9.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/list_conversation_press.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/list_conversation_press.9.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/status_online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/status_online.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/status_online_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/status_online_btn.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/terminal_icon_ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/terminal_icon_ios.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xhdpi/terminal_icon_ios_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xhdpi/terminal_icon_ios_pressed.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/TreeView/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/contact_list_item_bg_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/contact_list_item_buddy_name_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/contact_list_item_buddy_signature_text_color2.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/iphone_online.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/list_group_item_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/list_group_item_background_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /TreeView/src/main/res/drawable/list_group_item_background_unselected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /TreeView/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /TreeView/src/main/res/layout/list_group_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 34 | 35 | 45 | 46 | -------------------------------------------------------------------------------- /TreeView/src/main/res/layout/list_head_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 34 | 35 | 45 | 46 | -------------------------------------------------------------------------------- /TreeView/src/main/res/layout/list_item_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 27 | 28 | 43 | 44 | 60 | 61 | -------------------------------------------------------------------------------- /TreeView/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /TreeView/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /TreeView/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 7 | -------------------------------------------------------------------------------- /TreeView/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TreeView 5 | Hello world! 6 | Settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /TreeView/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:0.10.+' 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | mavenCentral() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkMjw/TreeView/0586b34d8bcc38d2be769afdb19463e18ff869f6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Mar 01 22:19:50 GMT+08:00 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 ':TreeView' 2 | --------------------------------------------------------------------------------