├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── levelList.gif
│ ├── java
│ └── com
│ │ └── demo
│ │ └── multilevellist
│ │ ├── DensityUtil.java
│ │ ├── MainActivity.java
│ │ ├── TreeAdapter.java
│ │ ├── TreePoint.java
│ │ └── TreeUtils.java
│ └── res
│ ├── drawable-hdpi
│ ├── btn_check_off_normal.png
│ ├── btn_check_on_normal.png
│ ├── ic_left.png
│ ├── ic_search.png
│ ├── outline_list_collapse.png
│ └── outline_list_expand.png
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── bg_imagebutton.xml
│ ├── bg_input_filter.xml
│ ├── ic_launcher_background.xml
│ ├── select_btn_check.xml
│ ├── work_divile_line2.9.png
│ ├── work_divile_line5.9.png
│ ├── work_divile_line6.9.png
│ └── work_divile_line_bg.xml
│ ├── layout
│ ├── activity_main.xml
│ └── adapter_treeview.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── 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 | /.idea
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MultilevelList
2 | 多级列表
3 | [csdn 博客地址](https://blog.csdn.net/xu_coding/article/details/81490297)
4 | 效果图如下
5 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.demo.multilevellist"
7 | minSdkVersion 21
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:28.0.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28 | }
29 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/assets/levelList.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/assets/levelList.gif
--------------------------------------------------------------------------------
/app/src/main/java/com/demo/multilevellist/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.demo.multilevellist;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by xulc on 2018/8/7.
7 | */
8 |
9 | public class DensityUtil {
10 |
11 | public static int dip2px(Context context, float dpValue) {
12 | float scale = context.getResources().getDisplayMetrics().density;
13 | return (int) (dpValue * scale + 0.5f);
14 | }
15 |
16 | public static int px2dip(Context context, float pxValue) {
17 | float scale = context.getResources().getDisplayMetrics().density;
18 | return (int) (pxValue / scale + 0.5f);
19 | }
20 |
21 | public static float dip2pxf(Context context, int dpValue) {
22 | float scale = context.getResources().getDisplayMetrics().density;
23 | return dpValue * scale + 0.5f;
24 | }
25 |
26 | public static float dip2pxf(Context context, float dpValue) {
27 | float scale = context.getResources().getDisplayMetrics().density;
28 | return dpValue * scale + 0.5f;
29 | }
30 |
31 | /**
32 | * 将px值转换为sp值,保证文字大小不变
33 | *
34 | * @param context
35 | * @param pxValue
36 | * (DisplayMetrics类中属性scaledDensity)
37 | * @return
38 | */
39 | public static int px2sp(Context context, float pxValue) {
40 | float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
41 | return (int) (pxValue / fontScale + 0.5f);
42 | }
43 |
44 | /**
45 | * 将sp值转换为px值,保证文字大小不变
46 | *
47 | * @param context
48 | * @param spValue
49 | * (DisplayMetrics类中属性scaledDensity)
50 | * @return
51 | */
52 | public static int sp2px(Context context, float spValue) {
53 | float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
54 | return (int) (spValue * fontScale + 0.5f);
55 | }
56 |
57 | public static float sp2pxf(Context context, float spValue) {
58 | float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
59 | return spValue * fontScale + 0.5f;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/demo/multilevellist/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.demo.multilevellist;
2 | import android.support.annotation.Nullable;
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.text.Editable;
6 | import android.text.TextWatcher;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.EditText;
10 | import android.widget.ListView;
11 | import java.util.ArrayList;
12 | import java.util.Collections;
13 | import java.util.Comparator;
14 | import java.util.HashMap;
15 | import java.util.List;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | private TreeAdapter adapter;
20 | private ListView listView;
21 | private EditText et_filter;
22 | private List pointList = new ArrayList<>();
23 | private HashMap pointMap = new HashMap<>();
24 |
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView();
30 | init();
31 | addListener();
32 | }
33 |
34 |
35 | public void setContentView() {
36 | setContentView(R.layout.activity_main);
37 | }
38 |
39 |
40 | public void init() {
41 | adapter = new TreeAdapter(this, pointList, pointMap);
42 | listView = findViewById(R.id.listView);
43 | listView.setAdapter(adapter);
44 | et_filter = findViewById(R.id.et_filter);
45 | initData();
46 | }
47 |
48 | //初始化数据
49 | //数据特点:TreePoint 之间的关系特点 id是任意唯一的。 如果为根节点 PARENTID 为"0" 如果没有子节点,也就是本身是叶子节点的时候ISLEAF = "1"
50 | // DISPLAY_ORDER 是同一级中 显示的顺序
51 | //如果需要做选中 单选或者多选,只需要给TreePoint增加一个选中的属性,在ReasonAdapter中处理就好了
52 | private void initData() {
53 | pointList.clear();
54 | int id =1000;
55 | int parentId = 0;
56 | int parentId2 = 0;
57 | int parentId3 = 0;
58 | for(int i=1;i<5;i++){
59 | id++;
60 | pointList.add(new TreePoint(""+id,"分类"+i,"" + parentId,"0",i));
61 | for(int j=1;j<5;j++){
62 | if(j==1){
63 | parentId2 = id;
64 | }
65 | id++;
66 | pointList.add(new TreePoint(""+id,"分类"+i+"_"+j,""+parentId2,"0",j));
67 | for(int k=1;k<5;k++){
68 | if(k==1){
69 | parentId3 = id;
70 | }
71 | id++;
72 | pointList.add(new TreePoint(""+id,"分类"+i+"_"+j+"_"+k,""+parentId3,"1",k));
73 | }
74 | }
75 | }
76 | //打乱集合中的数据
77 | Collections.shuffle(pointList);
78 | //对集合中的数据重新排序
79 | updateData();
80 | }
81 |
82 |
83 | public void addListener() {
84 |
85 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
86 | @Override
87 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
88 | adapter.onItemClick(position);
89 | }
90 | });
91 |
92 | et_filter.addTextChangedListener(new TextWatcher() {
93 | @Override
94 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
95 |
96 | }
97 |
98 | @Override
99 | public void onTextChanged(CharSequence s, int start, int before, int count) {
100 |
101 | }
102 |
103 | @Override
104 | public void afterTextChanged(Editable s) {
105 | searchAdapter(s);
106 | }
107 | });
108 | }
109 |
110 | private void searchAdapter(Editable s) {
111 | adapter.setKeyword(s.toString());
112 | }
113 |
114 | //对数据排序 深度优先
115 | private void updateData() {
116 | for (TreePoint treePoint : pointList) {
117 | pointMap.put(treePoint.getID(), treePoint);
118 | }
119 | Collections.sort(pointList, new Comparator() {
120 | @Override
121 | public int compare(TreePoint lhs, TreePoint rhs) {
122 | int llevel = TreeUtils.getLevel(lhs, pointMap);
123 | int rlevel = TreeUtils.getLevel(rhs, pointMap);
124 | if (llevel == rlevel) {
125 | if (lhs.getPARENTID().equals(rhs.getPARENTID())) { //左边小
126 | return lhs.getDISPLAY_ORDER() > rhs.getDISPLAY_ORDER() ? 1 : -1;
127 | } else { //如果父辈id不相等
128 | //同一级别,不同父辈
129 | TreePoint ltreePoint = TreeUtils.getTreePoint(lhs.getPARENTID(), pointMap);
130 | TreePoint rtreePoint = TreeUtils.getTreePoint(rhs.getPARENTID(), pointMap);
131 | return compare(ltreePoint, rtreePoint); //父辈
132 | }
133 | } else { //不同级别
134 | if (llevel > rlevel) { //左边级别大 左边小
135 | if (lhs.getPARENTID().equals(rhs.getID())) {
136 | return 1;
137 | } else {
138 | TreePoint lreasonTreePoint = TreeUtils.getTreePoint(lhs.getPARENTID(), pointMap);
139 | return compare(lreasonTreePoint, rhs);
140 | }
141 | } else { //右边级别大 右边小
142 | if (rhs.getPARENTID().equals(lhs.getID())) {
143 | return -1;
144 | }
145 | TreePoint rreasonTreePoint = TreeUtils.getTreePoint(rhs.getPARENTID(), pointMap);
146 | return compare(lhs, rreasonTreePoint);
147 | }
148 | }
149 | }
150 | });
151 | adapter.notifyDataSetChanged();
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/java/com/demo/multilevellist/TreeAdapter.java:
--------------------------------------------------------------------------------
1 | package com.demo.multilevellist;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.annotation.IntDef;
6 | import android.text.Html;
7 | import android.text.Spanned;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.BaseAdapter;
12 | import android.widget.ImageButton;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 | import java.util.HashMap;
17 | import java.util.List;
18 |
19 |
20 |
21 | /**
22 | * Created by xulc on 2018/7/27.
23 | */
24 |
25 | public class TreeAdapter extends BaseAdapter {
26 | private Context mcontext;
27 | private Activity mActivity;
28 | private List pointList;
29 | private String keyword = "";
30 | private HashMap pointMap = new HashMap<>();
31 |
32 | private int operateMode = ModeSelect;
33 | //两种操作模式 点击 或者 选择
34 | private static final int ModeClick = 1;
35 | private static final int ModeSelect = 2;
36 |
37 | @IntDef({ModeClick,ModeSelect})
38 | public @interface Mode{
39 |
40 | }
41 |
42 | //设置操作模式
43 | public void setOperateMode(@Mode int operateMode){
44 | this.operateMode = operateMode;
45 | }
46 |
47 | public TreeAdapter(final Context mcontext, List pointList, HashMap pointMap) {
48 | this.mcontext = mcontext;
49 | this.mActivity = (Activity) mcontext;
50 | this.pointList = pointList;
51 | this.pointMap = pointMap;
52 | }
53 |
54 | /**
55 | * 搜索的时候,先关闭所有的条目,然后,按照条件,找到含有关键字的数据
56 | * 如果是叶子节点,
57 | */
58 | public void setKeyword(String keyword) {
59 | this.keyword = keyword;
60 | for (TreePoint treePoint : pointList) {
61 | treePoint.setExpand(false);
62 | }
63 | if (!"".equals(keyword)) {
64 | for (TreePoint tempTreePoint : pointList) {
65 | if (tempTreePoint.getNNAME().contains(keyword)) {
66 | if ("0".equals(tempTreePoint.getISLEAF())) { //非叶子节点
67 | tempTreePoint.setExpand(true);
68 | }
69 | //展开从最顶层到该点的所有节点
70 | openExpand(tempTreePoint);
71 | }
72 | }
73 | }
74 | this.notifyDataSetChanged();
75 | }
76 |
77 | /**
78 | * 从TreePoint开始一直展开到顶部
79 | * @param treePoint
80 | */
81 | private void openExpand(TreePoint treePoint) {
82 | if ("0".equals(treePoint.getPARENTID())) {
83 | treePoint.setExpand(true);
84 | } else {
85 | pointMap.get(treePoint.getPARENTID()).setExpand(true);
86 | openExpand(pointMap.get(treePoint.getPARENTID()));
87 | }
88 | }
89 |
90 |
91 | //第一要准确计算数量
92 | @Override
93 | public int getCount() {
94 | int count = 0;
95 | for (TreePoint tempPoint : pointList) {
96 | if ("0".equals(tempPoint.getPARENTID())) {
97 | count++;
98 | } else {
99 | if (getItemIsExpand(tempPoint.getPARENTID())) {
100 | count++;
101 | }
102 | }
103 | }
104 | return count;
105 | }
106 |
107 | //判断当前Id的tempPoint是否展开了
108 | private boolean getItemIsExpand(String ID) {
109 | for (TreePoint tempPoint : pointList) {
110 | if (ID.equals(tempPoint.getID())) {
111 | return tempPoint.isExpand();
112 | }
113 | }
114 | return false;
115 | }
116 |
117 | @Override
118 | public Object getItem(int position) {
119 | return pointList.get(convertPostion(position));
120 | }
121 |
122 | private int convertPostion(int position) {
123 | int count = 0;
124 | for (int i = 0; i < pointList.size(); i++) {
125 | TreePoint treePoint = pointList.get(i);
126 | if ("0".equals(treePoint.getPARENTID())) {
127 | count++;
128 | } else {
129 | if (getItemIsExpand(treePoint.getPARENTID())) {
130 | count++;
131 | }
132 | }
133 | if (position == (count - 1)) {
134 | return i;
135 | }
136 | }
137 | return 0;
138 | }
139 |
140 | @Override
141 | public long getItemId(int position) {
142 | return position;
143 | }
144 |
145 |
146 | @Override
147 | public View getView(int position, View convertView, ViewGroup parent) {
148 | ViewHolder holder;
149 | if (convertView == null) {
150 | convertView = LayoutInflater.from(mcontext).inflate(R.layout.adapter_treeview, null);
151 | holder = new ViewHolder();
152 | holder.text = (TextView) convertView.findViewById(R.id.text);
153 | holder.icon = (ImageView) convertView.findViewById(R.id.icon);
154 | holder.ib_select = (ImageButton) convertView.findViewById(R.id.ib_select);
155 | convertView.setTag(holder);
156 | } else {
157 | holder = (ViewHolder) convertView.getTag();
158 | }
159 | final TreePoint tempPoint = (TreePoint) getItem(position);
160 | int level = TreeUtils.getLevel(tempPoint,pointMap);
161 | holder.icon.setPadding(25 * level, holder.icon.getPaddingTop(), 0, holder.icon.getPaddingBottom());
162 | if ("0".equals(tempPoint.getISLEAF())) { //如果为父节点
163 | if (!tempPoint.isExpand()) { //不展开显示加号
164 | holder.icon.setVisibility(View.VISIBLE);
165 | holder.icon.setImageResource(R.drawable.outline_list_collapse);
166 | } else { //展开显示减号
167 | holder.icon.setVisibility(View.VISIBLE);
168 | holder.icon.setImageResource(R.drawable.outline_list_expand);
169 | }
170 | } else { //如果叶子节点,不占位显示
171 | holder.icon.setVisibility(View.INVISIBLE);
172 | }
173 | if(operateMode == ModeSelect){
174 | holder.ib_select.setVisibility(View.VISIBLE);
175 | holder.ib_select.setSelected(tempPoint.isSelected());
176 | holder.ib_select.setOnClickListener(new View.OnClickListener() {
177 | @Override
178 | public void onClick(View v) {
179 | onModeSelect(tempPoint);
180 | }
181 | });
182 | }else{
183 | holder.ib_select.setVisibility(View.GONE);
184 | }
185 | //如果存在搜索关键字
186 | if (keyword != null && !"".equals(keyword) && tempPoint.getNNAME().contains(keyword)) {
187 | int index = tempPoint.getNNAME().indexOf(keyword);
188 | int len = keyword.length();
189 | Spanned temp = Html.fromHtml(tempPoint.getNNAME().substring(0, index)
190 | + ""
191 | + tempPoint.getNNAME().substring(index, index + len) + ""
192 | + tempPoint.getNNAME().substring(index + len, tempPoint.getNNAME().length()));
193 |
194 | holder.text.setText(temp);
195 | } else {
196 | holder.text.setText(tempPoint.getNNAME());
197 | }
198 | holder.text.setCompoundDrawablePadding(DensityUtil.dip2px(mcontext, 10));
199 | return convertView;
200 | }
201 |
202 |
203 |
204 | public void onItemClick(int position) {
205 | TreePoint treePoint = (TreePoint) getItem(position);
206 | if ("1".equals(treePoint.getISLEAF())) { //点击叶子节点
207 | //处理回填
208 | Toast.makeText(mcontext, getSubmitResult(treePoint), Toast.LENGTH_SHORT).show();
209 | } else { //如果点击的是父类
210 | if (treePoint.isExpand()) {
211 | for (TreePoint tempPoint : pointList) {
212 | if (tempPoint.getPARENTID().equals(treePoint.getID())) {
213 | if ("0".equals(treePoint.getISLEAF())) {
214 | tempPoint.setExpand(false);
215 | }
216 | }
217 | }
218 | treePoint.setExpand(false);
219 | } else {
220 | treePoint.setExpand(true);
221 | }
222 | }
223 | this.notifyDataSetChanged();
224 | }
225 |
226 |
227 | //选择操作
228 | private void onModeSelect(TreePoint treePoint){
229 | if ("1".equals(treePoint.getISLEAF())) { //选择叶子节点
230 | //处理回填
231 | treePoint.setSelected(!treePoint.isSelected());
232 | } else { //选择父节点
233 | int position = pointList.indexOf(treePoint);
234 | boolean isSelect = treePoint.isSelected();
235 | treePoint.setSelected(!isSelect);
236 | if(position == -1){
237 | return ;
238 | }
239 | if(position == pointList.size()-1){
240 | return;
241 | }
242 | position++;
243 | for(;position < pointList.size();position++){
244 | TreePoint tempPoint = pointList.get(position);
245 | if(tempPoint.getPARENTID().equals(treePoint.getPARENTID())){ //如果找到和自己同级的数据就返回
246 | break;
247 | }
248 | tempPoint.setSelected(!isSelect);
249 | }
250 | }
251 | this.notifyDataSetChanged();
252 | }
253 |
254 | //选中所有的point
255 | // private void selectPoint(TreePoint treePoint) {
256 | // if(){
257 | //
258 | // }
259 | // }
260 |
261 |
262 |
263 |
264 | private String getSubmitResult(TreePoint treePoint) {
265 | StringBuilder sb = new StringBuilder();
266 | addResult(treePoint, sb);
267 | String result = sb.toString();
268 | if (result.endsWith("-")) {
269 | result = result.substring(0, result.length() - 1);
270 | }
271 | return result;
272 | }
273 |
274 | private void addResult(TreePoint treePoint, StringBuilder sb) {
275 | if (treePoint != null && sb != null) {
276 | sb.insert(0, treePoint.getNNAME() + "-");
277 | if (!"0".equals(treePoint.getPARENTID())) {
278 | addResult(pointMap.get(treePoint.getPARENTID()), sb);
279 | }
280 | }
281 | }
282 |
283 |
284 | class ViewHolder {
285 | TextView text;
286 | ImageView icon;
287 | ImageButton ib_select;
288 | }
289 |
290 | }
291 |
--------------------------------------------------------------------------------
/app/src/main/java/com/demo/multilevellist/TreePoint.java:
--------------------------------------------------------------------------------
1 | package com.demo.multilevellist;
2 |
3 | /**
4 | * Created by xulc on 2018/7/27.
5 | */
6 |
7 | public class TreePoint {
8 | private String ID; // 7241, //账号id
9 | private String NNAME; // "用户原因", //原因名称
10 | private String PARENTID; // 0, //父id 0表示父节点
11 | private String ISLEAF; //0, //是否是叶子节点 1为叶子节点
12 | private int DISPLAY_ORDER; // 1 //同一个级别的显示顺序
13 | private boolean isExpand = false; //是否展开了
14 | private boolean isSelected = false; //是否选中了
15 |
16 |
17 | public TreePoint(String ID, String NNAME, String PARENTID, String ISLEAF, int DISPLAY_ORDER) {
18 | this.ID = ID;
19 | this.NNAME = NNAME;
20 | this.PARENTID = PARENTID;
21 | this.ISLEAF = ISLEAF;
22 | this.DISPLAY_ORDER = DISPLAY_ORDER;
23 | }
24 |
25 | public String getID() {
26 | return ID;
27 | }
28 |
29 | public void setID(String ID) {
30 | this.ID = ID;
31 | }
32 |
33 | public String getNNAME() {
34 | return NNAME;
35 | }
36 |
37 | public void setNAME(String NAME) {
38 | this.NNAME = NNAME;
39 | }
40 |
41 | public String getPARENTID() {
42 | return PARENTID;
43 | }
44 |
45 | public void setPARENTID(String PARENTID) {
46 | this.PARENTID = PARENTID;
47 | }
48 |
49 | public String getISLEAF() {
50 | return ISLEAF;
51 | }
52 |
53 | public void setISLEAF(String ISLEAF) {
54 | this.ISLEAF = ISLEAF;
55 | }
56 |
57 | public int getDISPLAY_ORDER() {
58 | return DISPLAY_ORDER;
59 | }
60 |
61 | public void setDISPLAY_ORDER(int DISPLAY_ORDER) {
62 | this.DISPLAY_ORDER = DISPLAY_ORDER;
63 | }
64 |
65 | public boolean isExpand() {
66 | return isExpand;
67 | }
68 |
69 | public void setExpand(boolean expand) {
70 | isExpand = expand;
71 | }
72 |
73 | public boolean isSelected() {
74 | return isSelected;
75 | }
76 |
77 | public void setSelected(boolean selected) {
78 | isSelected = selected;
79 | }
80 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/demo/multilevellist/TreeUtils.java:
--------------------------------------------------------------------------------
1 | package com.demo.multilevellist;
2 |
3 | import android.util.Log;
4 |
5 |
6 | import java.util.HashMap;
7 |
8 | /**
9 | * Created by xulc on 2018/7/27.
10 | */
11 |
12 | public class TreeUtils {
13 | //第一级别为0
14 | public static int getLevel(TreePoint treePoint,HashMap map){
15 | if("0".equals(treePoint.getPARENTID())){
16 | return 0;
17 | }else{
18 | return 1+getLevel(getTreePoint(treePoint.getPARENTID(),map),map);
19 | }
20 | }
21 |
22 |
23 |
24 | public static TreePoint getTreePoint(String ID, HashMap map){
25 | if(map.containsKey(ID)){
26 | return map.get(ID);
27 | }
28 | Log.e("xlc","ID:" + ID);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/btn_check_off_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/btn_check_off_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/btn_check_on_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/btn_check_on_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/ic_left.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/ic_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/outline_list_collapse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/outline_list_collapse.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/outline_list_expand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable-hdpi/outline_list_expand.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_imagebutton.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_input_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_btn_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/work_divile_line2.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable/work_divile_line2.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/work_divile_line5.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable/work_divile_line5.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/work_divile_line6.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/drawable/work_divile_line6.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/work_divile_line_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
22 |
23 |
32 |
33 |
34 |
39 |
40 |
58 |
59 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/adapter_treeview.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
29 |
30 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #FFFFFF
7 | #ff2081D9
8 | #22c5eaf8
9 | #ff333333
10 | #dadada
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MultilevelList
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
13 |
14 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.5.1'
12 |
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
22 | google()
23 | jcenter()
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/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/oldbirdy/MultilevelList/f8023e128a9420fa16eefecd580efe4024d42c05/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 04 21:10:31 CST 2019
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-5.4.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'
2 |
--------------------------------------------------------------------------------