├── README.txt
├── TreeView
├── .classpath
├── .project
├── AndroidManifest.xml
├── assets
│ └── datadir
│ │ ├── .svn
│ │ ├── all-wcprops
│ │ ├── entries
│ │ ├── format
│ │ ├── prop-base
│ │ │ └── cableinfo.db.svn-base
│ │ └── text-base
│ │ │ └── cableinfo.db.svn-base
│ │ └── TreeViewData.db
├── bin
│ ├── TreeView.apk
│ ├── classes.dex
│ ├── classes
│ │ └── com
│ │ │ └── tochange
│ │ │ └── yang
│ │ │ ├── R$attr.class
│ │ │ ├── R$color.class
│ │ │ ├── R$dimen.class
│ │ │ ├── R$drawable.class
│ │ │ ├── R$id.class
│ │ │ ├── R$layout.class
│ │ │ ├── R$menu.class
│ │ │ ├── R$string.class
│ │ │ ├── R$style.class
│ │ │ ├── R.class
│ │ │ ├── TestTreeViewActivity$1.class
│ │ │ ├── TestTreeViewActivity$2.class
│ │ │ ├── TestTreeViewActivity$LoadDataToAppSpaceTask.class
│ │ │ └── TestTreeViewActivity.class
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ ├── ic_action_search.png
│ │ │ └── ic_launcher.png
│ │ ├── drawable-ldpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ ├── ic_action_search.png
│ │ │ └── ic_launcher.png
│ │ └── drawable-xhdpi
│ │ │ ├── ic_action_search.png
│ │ │ └── ic_launcher.png
│ └── resources.ap_
├── gen
│ └── com
│ │ └── tochange
│ │ └── yang
│ │ └── R.java
├── proguard.cfg
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── layout
│ │ ├── activity_test.xml
│ │ └── commonchooselayout.xml
│ ├── menu
│ │ └── activity_test.xml
│ ├── values-large
│ │ └── dimens.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── values-v14
│ │ └── styles.xml
│ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── com
│ └── tochange
│ └── yang
│ └── TestTreeViewActivity.java
├── TreeViewLib
├── .classpath
├── .project
├── AndroidManifest.xml
├── bin
│ ├── classes
│ │ └── com
│ │ │ └── tochange
│ │ │ └── yang
│ │ │ ├── DatabaseStruct.class
│ │ │ ├── DbToAdapter.class
│ │ │ ├── LoadTreeTask$1.class
│ │ │ ├── LoadTreeTask.class
│ │ │ ├── R$attr.class
│ │ │ ├── R$color.class
│ │ │ ├── R$dimen.class
│ │ │ ├── R$drawable.class
│ │ │ ├── R$id.class
│ │ │ ├── R$layout.class
│ │ │ ├── R$menu.class
│ │ │ ├── R$string.class
│ │ │ ├── R$style.class
│ │ │ ├── R.class
│ │ │ ├── TreeListAdapter$1.class
│ │ │ ├── TreeListAdapter$2.class
│ │ │ ├── TreeListAdapter$3.class
│ │ │ ├── TreeListAdapter$Holder.class
│ │ │ ├── TreeListAdapter$OnTreeCallBack.class
│ │ │ ├── TreeListAdapter.class
│ │ │ ├── TreeNode.class
│ │ │ └── log.class
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ ├── ic_action_search.png
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ ├── ic_action_search.png
│ │ │ ├── ic_launcher.png
│ │ │ ├── tree_expand_off_nr.png
│ │ │ └── tree_expand_on_nr.png
│ │ └── drawable-xhdpi
│ │ │ ├── ic_action_search.png
│ │ │ └── ic_launcher.png
│ └── treeviewlib.jar
├── gen
│ └── com
│ │ └── tochange
│ │ └── yang
│ │ └── R.java
├── proguard.cfg
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ ├── ic_action_search.png
│ │ ├── ic_launcher.png
│ │ ├── tree_expand_off_nr.png
│ │ ├── tree_expand_on_nr.png
│ │ └── treelist_selector_bg.xml
│ ├── drawable-xhdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── layout
│ │ ├── activity_main.xml
│ │ ├── tree_item.xml
│ │ └── tree_lay.xml
│ ├── menu
│ │ └── activity_main.xml
│ ├── values-large
│ │ └── dimens.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── values-v14
│ │ └── styles.xml
│ └── values
│ │ ├── color.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── com
│ └── tochange
│ └── yang
│ ├── DatabaseStruct.java
│ ├── DbToAdapter.java
│ ├── LoadTreeTask.java
│ ├── TreeListAdapter.java
│ ├── TreeNode.java
│ └── log.java
└── device-2014-04-10-224251.png
/README.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/README.txt
--------------------------------------------------------------------------------
/TreeView/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TreeView/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TreeView
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/TreeView/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/TreeView/assets/datadir/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 85
4 | /svn/DC-4601/!svn/ver/3451/01editing/03coding/trunk/AndroidUI/DC4601_new/assets/cable
5 | END
6 | cableinfo.db
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 98
10 | /svn/DC-4601/!svn/ver/3451/01editing/03coding/trunk/AndroidUI/DC4601_new/assets/cable/cableinfo.db
11 | END
12 |
--------------------------------------------------------------------------------
/TreeView/assets/datadir/.svn/entries:
--------------------------------------------------------------------------------
1 | 8
2 |
3 | dir
4 | 3700
5 | http://172.16.1.105/svn/DC-4601/01editing/03coding/trunk/AndroidUI/DC4601_new/assets/cable
6 | http://172.16.1.105/svn/DC-4601
7 |
8 |
9 |
10 | 2013-11-13T04:33:21.500000Z
11 | 3451
12 | yangxj
13 |
14 |
15 | svn:special svn:externals svn:needs-lock
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 3e1aeaa0-ac72-4245-81cf-fac690dc179a
28 |
29 | cablepic
30 | dir
31 |
32 | cableinfo.db
33 | file
34 |
35 |
36 |
37 |
38 | 2013-11-13T04:27:30.855803Z
39 | a5604208ddaf76f7d6a60c41abfdd7d1
40 | 2013-11-13T04:33:21.500000Z
41 | 3451
42 | yangxj
43 | has-props
44 |
45 |
--------------------------------------------------------------------------------
/TreeView/assets/datadir/.svn/format:
--------------------------------------------------------------------------------
1 | 8
2 |
--------------------------------------------------------------------------------
/TreeView/assets/datadir/.svn/prop-base/cableinfo.db.svn-base:
--------------------------------------------------------------------------------
1 | K 13
2 | svn:mime-type
3 | V 24
4 | application/octet-stream
5 | END
6 |
--------------------------------------------------------------------------------
/TreeView/assets/datadir/.svn/text-base/cableinfo.db.svn-base:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/assets/datadir/.svn/text-base/cableinfo.db.svn-base
--------------------------------------------------------------------------------
/TreeView/assets/datadir/TreeViewData.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/assets/datadir/TreeViewData.db
--------------------------------------------------------------------------------
/TreeView/bin/TreeView.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/TreeView.apk
--------------------------------------------------------------------------------
/TreeView/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes.dex
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$attr.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$color.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$color.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$dimen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$dimen.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$drawable.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$id.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$layout.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$menu.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$string.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R$style.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/R.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$1.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$2.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$LoadDataToAppSpaceTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity$LoadDataToAppSpaceTask.class
--------------------------------------------------------------------------------
/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/classes/com/tochange/yang/TestTreeViewActivity.class
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/bin/resources.ap_
--------------------------------------------------------------------------------
/TreeView/gen/com/tochange/yang/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.tochange.yang;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class color {
14 | public static final int black=0x7f040002;
15 | public static final int text=0x7f040000;
16 | public static final int tree_node_bg=0x7f040001;
17 | }
18 | public static final class dimen {
19 | public static final int act_padding=0x7f050008;
20 | public static final int app_data_offset=0x7f050007;
21 | public static final int con_padding=0x7f050009;
22 | public static final int content_title=0x7f050004;
23 | public static final int content_tool=0x7f050005;
24 | public static final int content_tool_btn_height=0x7f050006;
25 | public static final int l_text_size=0x7f05000d;
26 | public static final int padding_large=0x7f05000c;
27 | public static final int padding_medium=0x7f05000b;
28 | public static final int padding_small=0x7f05000a;
29 | public static final int treenode_height=0x7f050000;
30 | public static final int treenode_icon_width=0x7f050003;
31 | public static final int treenode_line_offset=0x7f050002;
32 | public static final int treenode_offset=0x7f050001;
33 | }
34 | public static final class drawable {
35 | public static final int ic_action_search=0x7f020000;
36 | public static final int ic_launcher=0x7f020001;
37 | public static final int tree_expand_off_nr=0x7f020002;
38 | public static final int tree_expand_on_nr=0x7f020003;
39 | public static final int treelist_selector_bg=0x7f020004;
40 | }
41 | public static final class id {
42 | public static final int cancel_btn=0x7f090005;
43 | public static final int commonchoose_blank=0x7f090004;
44 | public static final int confirm_btn=0x7f090003;
45 | public static final int iv_app=0x7f09000d;
46 | public static final int iv_expanded=0x7f090008;
47 | public static final int iv_node=0x7f090009;
48 | public static final int lay_blank=0x7f090007;
49 | public static final int lay_content=0x7f090006;
50 | public static final int lay_tv_content=0x7f09000a;
51 | public static final int lv_tree=0x7f09000f;
52 | public static final int menu_settings=0x7f090010;
53 | public static final int t1=0x7f090000;
54 | public static final int t2=0x7f090001;
55 | public static final int tree=0x7f090002;
56 | public static final int tv_appdata=0x7f09000e;
57 | public static final int tv_description=0x7f09000b;
58 | public static final int tv_second_title=0x7f09000c;
59 | }
60 | public static final class layout {
61 | public static final int activity_main=0x7f030000;
62 | public static final int activity_test=0x7f030001;
63 | public static final int commonchooselayout=0x7f030002;
64 | public static final int tree_item=0x7f030003;
65 | public static final int tree_lay=0x7f030004;
66 | }
67 | public static final class menu {
68 | public static final int activity_main=0x7f080000;
69 | public static final int activity_test=0x7f080001;
70 | }
71 | public static final class string {
72 | public static final int app_name=0x7f060000;
73 | public static final int hello_world=0x7f060001;
74 | public static final int menu_settings=0x7f060002;
75 | public static final int title_activity_main=0x7f060003;
76 | public static final int title_activity_test=0x7f060004;
77 | }
78 | public static final class style {
79 | public static final int AppTheme=0x7f070000;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/TreeView/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/TreeView/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-16
12 | android.library.reference.1=../TreeViewLib
13 |
--------------------------------------------------------------------------------
/TreeView/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeView/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeView/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeView/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
36 |
37 |
40 |
41 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/TreeView/res/layout/commonchooselayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
23 |
24 |
25 |
33 |
34 |
--------------------------------------------------------------------------------
/TreeView/res/menu/activity_test.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/TreeView/res/values-large/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/TreeView/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeView/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeView/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeView/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestTreeView
4 | Hello world!
5 | Settings
6 | TreeView
7 |
8 |
--------------------------------------------------------------------------------
/TreeView/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeView/src/com/tochange/yang/TestTreeViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | import android.app.Activity;
9 | import android.app.ProgressDialog;
10 | import android.content.Context;
11 | import android.content.SharedPreferences;
12 | import android.os.AsyncTask;
13 | import android.os.Bundle;
14 | import android.view.Menu;
15 | import android.view.View;
16 | import android.widget.Button;
17 | import android.widget.LinearLayout;
18 | import android.widget.TextView;
19 |
20 | public class TestTreeViewActivity extends Activity
21 | {
22 | @Override
23 | protected void onStop()
24 | {
25 | super.onStop();
26 | mLoadTreeTask.exit();
27 | }
28 |
29 | private SharedPreferences mSharedPreferences;
30 |
31 | private LoadTreeTask mLoadTreeTask;
32 |
33 | private TextView mResultTextView;
34 |
35 | private ProgressDialog mDataGetProgressDialog;
36 |
37 | private String mDirToBeCopyInAsset = "datadir";
38 |
39 | private log log = new log();
40 |
41 | @Override
42 | public void onCreate(Bundle savedInstanceState)
43 | {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_test);
46 | log.intLog("TestActivity", true);
47 |
48 | final LinearLayout treeLayout = (LinearLayout) findViewById(R.id.tree);
49 | final Button closeBtn = (Button) findViewById(R.id.cancel_btn);
50 | final Button openBtn = (Button) findViewById(R.id.confirm_btn);
51 | mResultTextView = (TextView) findViewById(R.id.t2);
52 |
53 | mSharedPreferences = getSharedPreferences("treenode",
54 | Context.MODE_PRIVATE);
55 | mResultTextView.setText(mSharedPreferences.getString("pcs_name",
56 | "default treenode's name"));
57 |
58 | final DatabaseStruct dbStruct = new DatabaseStruct();
59 | if (initialData(dbStruct))
60 | {
61 | File f = new File(dbStruct.dbPath);
62 | if (!f.exists())
63 | new LoadDataToAppSpaceTask(this).execute(mDirToBeCopyInAsset);
64 |
65 | closeBtn.setEnabled(false);
66 | closeBtn.setOnClickListener(new View.OnClickListener() {
67 |
68 | @Override
69 | public void onClick(View v)
70 | {
71 | treeLayout.setVisibility(View.GONE);
72 | mSharedPreferences.edit()
73 | .putString("pcs_name", mLoadTreeTask.getPcsName())
74 | .commit();
75 | mSharedPreferences.edit()
76 | .putString("pcs_id", mLoadTreeTask.getPcsID())
77 | .commit();
78 | mSharedPreferences.edit()
79 | .putString("pcs_code", mLoadTreeTask.getPcsCode())
80 | .commit();
81 | closeBtn.setEnabled(false);
82 | openBtn.setEnabled(true);
83 | mResultTextView.setText(mLoadTreeTask.getPcsName());
84 | }
85 | });
86 |
87 | openBtn.setOnClickListener(new View.OnClickListener() {
88 |
89 | @Override
90 | public void onClick(View v)
91 | {
92 | long t1 = System.currentTimeMillis();
93 | treeLayout.setVisibility(View.VISIBLE);
94 | if (mLoadTreeTask == null)
95 | {
96 | mLoadTreeTask = new LoadTreeTask(TestTreeViewActivity.this,
97 | dbStruct, treeLayout, mSharedPreferences
98 | .getString("pcs_id", "unknow id"),
99 | mSharedPreferences.getString("pcs_name",
100 | "unknow name"));
101 | mLoadTreeTask.execute();
102 | }
103 | else
104 | mLoadTreeTask
105 | .setTreeListViewPosition(mSharedPreferences
106 | .getString("pcs_id", "unknow id"));
107 | closeBtn.setEnabled(true);
108 | openBtn.setEnabled(false);
109 | log.e("all time =" + (System.currentTimeMillis() - t1));
110 | }
111 | });
112 | }
113 | }
114 |
115 | private boolean initialData(DatabaseStruct dbStruct)
116 | {
117 | dbStruct.fieldName = "name";
118 | dbStruct.fieldRemark = "remark";
119 | dbStruct.fieldID = "ID";
120 | dbStruct.fieldIDParent = "parentID";
121 | dbStruct.tableName = "TreeViewData";
122 | dbStruct.rootFieldID = 1;
123 | dbStruct.dbPath = getFilesDir().getAbsolutePath().replace("files",
124 | mDirToBeCopyInAsset)
125 | + "/" + dbStruct.tableName + ".db";// maybe problem
126 | return true;
127 | }
128 |
129 | @Override
130 | public boolean onCreateOptionsMenu(Menu menu)
131 | {
132 | getMenuInflater().inflate(R.menu.activity_test, menu);
133 | return true;
134 | }
135 |
136 | private class LoadDataToAppSpaceTask extends
137 | AsyncTask
138 | {
139 | Context mContext;
140 |
141 | public LoadDataToAppSpaceTask(Context contex)
142 | {
143 | mContext = contex;
144 | }
145 |
146 | @Override
147 | protected void onPreExecute()
148 | {
149 | if (null == mDataGetProgressDialog
150 | || !mDataGetProgressDialog.isShowing())
151 | {
152 | mDataGetProgressDialog = ProgressDialog.show(mContext, null,
153 | "loading data to app space..", false, false);
154 | }
155 | }
156 |
157 | @Override
158 | protected String doInBackground(String... params)
159 | {
160 | copyDbPic(mContext, params[0]);
161 | return null;
162 | }
163 |
164 | @Override
165 | protected void onPostExecute(String result)
166 | {
167 | if (mDataGetProgressDialog != null)
168 | {
169 | mDataGetProgressDialog.dismiss();
170 | }
171 | }
172 |
173 | public void copyDbPic(Context contex, String path)
174 | {
175 | try
176 | {
177 | String str[] = contex.getAssets().list(path);
178 | if (str.length > 0)
179 | {// dir
180 | File file = new File(contex.getFilesDir().getAbsolutePath()
181 | .replace("files", path));
182 | file.mkdirs();
183 | for (String string : str)
184 | {
185 | path = path + "/" + string;
186 | copyDbPic(contex, path);
187 | path = path.substring(0, path.lastIndexOf('/'));
188 | }
189 | }
190 | else
191 | {// files
192 | InputStream is = contex.getAssets().open(path);
193 | FileOutputStream fos = new FileOutputStream(new File(contex
194 | .getFilesDir().getAbsolutePath()
195 | .replace("files", path)));
196 | byte[] buffer = new byte[1024];
197 | int count = 0;
198 | while (true)
199 | {
200 | count++;
201 | int len = is.read(buffer);
202 | if (len == -1)
203 | {
204 | break;
205 | }
206 | fos.write(buffer, 0, len);
207 | }
208 | is.close();
209 | fos.close();
210 | }
211 | }
212 | catch (IOException e)
213 | {
214 | e.printStackTrace();
215 | }
216 | }
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/TreeViewLib/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TreeViewLib/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TreeViewLib
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/TreeViewLib/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/DatabaseStruct.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/DatabaseStruct.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/DbToAdapter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/DbToAdapter.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/LoadTreeTask$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/LoadTreeTask$1.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/LoadTreeTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/LoadTreeTask.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$attr.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$color.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$color.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$dimen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$dimen.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$drawable.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$id.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$layout.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$menu.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$string.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R$style.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/R.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$1.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$2.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$3.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$Holder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$Holder.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$OnTreeCallBack.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter$OnTreeCallBack.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeListAdapter.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/TreeNode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/TreeNode.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/classes/com/tochange/yang/log.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/classes/com/tochange/yang/log.class
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-mdpi/tree_expand_off_nr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-mdpi/tree_expand_off_nr.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-mdpi/tree_expand_on_nr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-mdpi/tree_expand_on_nr.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/bin/treeviewlib.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/bin/treeviewlib.jar
--------------------------------------------------------------------------------
/TreeViewLib/gen/com/tochange/yang/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.tochange.yang;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class color {
14 | public static int black=0x7f040002;
15 | public static int text=0x7f040000;
16 | public static int tree_node_bg=0x7f040001;
17 | }
18 | public static final class dimen {
19 | public static int act_padding=0x7f050008;
20 | public static int app_data_offset=0x7f050007;
21 | public static int con_padding=0x7f050009;
22 | public static int content_title=0x7f050004;
23 | public static int content_tool=0x7f050005;
24 | public static int content_tool_btn_height=0x7f050006;
25 | public static int l_text_size=0x7f05000d;
26 | public static int padding_large=0x7f05000c;
27 | public static int padding_medium=0x7f05000b;
28 | public static int padding_small=0x7f05000a;
29 | public static int treenode_height=0x7f050000;
30 | public static int treenode_icon_width=0x7f050003;
31 | public static int treenode_line_offset=0x7f050002;
32 | public static int treenode_offset=0x7f050001;
33 | }
34 | public static final class drawable {
35 | public static int ic_action_search=0x7f020000;
36 | public static int ic_launcher=0x7f020001;
37 | public static int tree_expand_off_nr=0x7f020002;
38 | public static int tree_expand_on_nr=0x7f020003;
39 | public static int treelist_selector_bg=0x7f020004;
40 | }
41 | public static final class id {
42 | public static int iv_app=0x7f090007;
43 | public static int iv_expanded=0x7f090002;
44 | public static int iv_node=0x7f090003;
45 | public static int lay_blank=0x7f090001;
46 | public static int lay_content=0x7f090000;
47 | public static int lay_tv_content=0x7f090004;
48 | public static int lv_tree=0x7f090009;
49 | public static int menu_settings=0x7f09000a;
50 | public static int tv_appdata=0x7f090008;
51 | public static int tv_description=0x7f090005;
52 | public static int tv_second_title=0x7f090006;
53 | }
54 | public static final class layout {
55 | public static int activity_main=0x7f030000;
56 | public static int tree_item=0x7f030001;
57 | public static int tree_lay=0x7f030002;
58 | }
59 | public static final class menu {
60 | public static int activity_main=0x7f080000;
61 | }
62 | public static final class string {
63 | public static int app_name=0x7f060000;
64 | public static int hello_world=0x7f060001;
65 | public static int menu_settings=0x7f060002;
66 | public static int title_activity_main=0x7f060003;
67 | }
68 | public static final class style {
69 | public static int AppTheme=0x7f070000;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/TreeViewLib/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/TreeViewLib/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-16
12 | android.library=true
13 |
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-mdpi/tree_expand_off_nr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-mdpi/tree_expand_off_nr.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-mdpi/tree_expand_on_nr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-mdpi/tree_expand_on_nr.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-mdpi/treelist_selector_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/TreeViewLib/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/TreeViewLib/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TreeViewLib/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/TreeViewLib/res/layout/tree_item.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
18 |
19 |
20 |
24 |
25 |
30 |
31 |
38 |
39 |
45 |
46 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/TreeViewLib/res/layout/tree_lay.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
27 |
28 |
33 |
34 |
38 |
39 |
46 |
47 |
48 |
49 |
52 |
53 |
54 |
58 |
59 |
62 |
63 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/TreeViewLib/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values-large/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #8BB6F2
5 | #BBD6F2
6 | #000000
7 |
8 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 40dp
4 | 7dp
5 | 5dp
6 | 30dp
7 |
8 | 40dp
9 | 40dp
10 | 30dp
11 | 5dp
12 | 15dp
13 | 10dp
14 |
15 | 10dp
16 | 15dp
17 | 20dp
18 |
19 | 18sp
20 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | TreeViewLibApp
4 | Hello world!
5 | Settings
6 | MainActivity
7 |
8 |
--------------------------------------------------------------------------------
/TreeViewLib/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/DatabaseStruct.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | class DatabaseStruct
4 | {
5 | public String dbPath;
6 |
7 | public String tableName;
8 |
9 | public String fieldID;
10 |
11 | public String fieldIDParent;
12 |
13 | public String fieldName;
14 |
15 | public String fieldRemark;
16 |
17 | public int rootFieldID;
18 | }
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/DbToAdapter.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import java.io.File;
4 | import java.util.ArrayList;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import android.content.ContentValues;
10 | import android.database.Cursor;
11 | import android.database.sqlite.SQLiteDatabase;
12 |
13 | public class DbToAdapter
14 | {
15 | public final static String KEY_ID = "id";
16 |
17 | public final static String KEY_PARENT_ID = "parentid";
18 |
19 | public final static String KEY_PCSCODE = "pcscode";
20 |
21 | public final static String KEY_LOAD = "loaded";
22 |
23 | public final static String KEY_CHILD_ORDER = "childrenorder";
24 |
25 | public static String ROOT_PCSID;
26 |
27 | private String FIELD_NAME;
28 |
29 | private String FIELD_REMARK;
30 |
31 | private String FIELD_ID;
32 |
33 | private String FIELD_ID_PARENT;
34 |
35 | private final String TABLE_NAME;
36 |
37 | private final String DBPATH;
38 |
39 | private int ROOT_PCSID_INT;
40 |
41 | private final int mIcon = -1;
42 |
43 | private String mLastPcsCodeInDb;
44 |
45 | private TreeListAdapter mTreeListAdapter;
46 |
47 | private boolean mAlreadyNotify = false;
48 |
49 | private ArrayList mParentIDList = new ArrayList();
50 |
51 | private String mFirstIDInParentList;
52 |
53 | private SQLiteDatabase mDb;
54 |
55 | private log log = new log();
56 |
57 | public void colseCursorAndSql(Cursor cur, SQLiteDatabase db)
58 | {
59 | if (cur == null && db == null)
60 | if (mDb.isOpen())
61 | mDb.close();
62 | if (cur != null && !cur.isClosed())
63 | cur.close();
64 | if (db != null && db.isOpen())
65 | db.close();
66 | }
67 |
68 | public ArrayList getParentIDList(String id)
69 | {
70 | // if (!mParentIDList.isEmpty())
71 | // log.e("1 mParentIDList[0]=" + mParentIDList.get(0) + " id=" + id);
72 | if (!mParentIDList.isEmpty() && !id.equals(mParentIDList.get(0)))
73 | {
74 | mParentIDList.clear();
75 | // mLastPcsCodeInDb = id;// dangerous
76 | if (!isSameParentWithLastNode(id))
77 | {
78 | String parentID = getparentID(mFirstIDInParentList);
79 | TreeNode node = findNodeByID(
80 | mTreeListAdapter.getAllLoadNodeList(), parentID);
81 |
82 | mTreeListAdapter.setNodeExpandOrNot(node);
83 | }
84 | mFirstIDInParentList = id;
85 |
86 | putParentPcsCodeList(id);
87 | }
88 | return mParentIDList;
89 | }
90 |
91 | public DbToAdapter(String pcsCode, DatabaseStruct dbStructure)
92 | {
93 | mFirstIDInParentList = mLastPcsCodeInDb = pcsCode;
94 | FIELD_NAME = dbStructure.fieldName;
95 | FIELD_REMARK = dbStructure.fieldRemark;
96 | FIELD_ID = dbStructure.fieldID;
97 | FIELD_ID_PARENT = dbStructure.fieldIDParent;
98 | TABLE_NAME = dbStructure.tableName;
99 | DBPATH = dbStructure.dbPath;
100 | ROOT_PCSID_INT = dbStructure.rootFieldID;
101 | ROOT_PCSID = String.valueOf(ROOT_PCSID_INT - 1);
102 |
103 | if (mDb == null)
104 | mDb = SQLiteDatabase.openDatabase(DBPATH, null,
105 | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
106 | log.intLog("DbToAdapter", true);
107 | }
108 |
109 | private String getparentID(String id)
110 | {
111 | String parentID = null;
112 |
113 | String sql = "select " + FIELD_ID + ", " + FIELD_ID_PARENT + " from "
114 | + TABLE_NAME + " where " + FIELD_ID + " = '" + id + "'";
115 | Cursor cur = mDb.rawQuery(sql, null);
116 | if (cur != null && cur.moveToFirst())
117 | parentID = cur.getString(cur.getColumnIndex(FIELD_ID_PARENT));
118 | colseCursorAndSql(cur, null);
119 | return parentID;
120 | }
121 |
122 | private TreeNode findNodeByID(List mShowNodeList, String id)
123 | {
124 | TreeNode tmp = null;
125 | int nodeSize = mShowNodeList.size();
126 | for (int i = 0; i < nodeSize; i++)
127 | {
128 | tmp = mShowNodeList.get(i);
129 | if (tmp.getValueMap().get(KEY_ID).equals(id))
130 | {
131 | break;
132 | }
133 | }
134 | return tmp;
135 | }
136 |
137 | private boolean isSameParentWithLastNode(String id)
138 | {
139 | String parentID = null;
140 | String lastParentID = null;
141 |
142 | String sql = "select " + FIELD_ID + ", " + FIELD_ID_PARENT + " from "
143 | + TABLE_NAME + " where " + FIELD_ID + " = '" + id + "'";
144 | Cursor cur = mDb.rawQuery(sql, null);
145 | if (cur != null && cur.moveToFirst())
146 | parentID = cur.getString(cur.getColumnIndex(FIELD_ID_PARENT));
147 | if (cur != null && !cur.isClosed())
148 | cur.close();
149 |
150 | sql = "select " + FIELD_ID + ", " + FIELD_ID_PARENT + " from "
151 | + TABLE_NAME + " where " + FIELD_ID + " = '"
152 | + mFirstIDInParentList + "'";
153 | cur = mDb.rawQuery(sql, null);
154 | if (cur != null && cur.moveToFirst())
155 | lastParentID = cur.getString(cur.getColumnIndex(FIELD_ID_PARENT));
156 | if (cur != null && !cur.isClosed())
157 | cur.close();
158 |
159 | colseCursorAndSql(cur, null);
160 | return parentID.equals(lastParentID);
161 | }
162 |
163 | private String getRootName(SQLiteDatabase db)
164 | {
165 | String pcsName = "default pcsname";
166 | String sql = "select " + FIELD_NAME + ", " + FIELD_ID_PARENT
167 | + " from " + TABLE_NAME + " where " + FIELD_ID_PARENT + " = '"
168 | + ROOT_PCSID + "'";
169 | Cursor cur = db.rawQuery(sql, null);
170 |
171 | if (cur != null && cur.moveToFirst())
172 | pcsName = cur.getString(cur.getColumnIndex(FIELD_NAME));
173 | if (cur != null && !cur.isClosed())
174 | cur.close();
175 | return pcsName;
176 | }
177 |
178 | // load 3 levels
179 | public void loadDefaultTree(TreeNode parent)
180 | {
181 | log.e("mParentIDList=" + mParentIDList.toString());
182 | if (!mDb.isOpen())
183 | mDb = SQLiteDatabase.openDatabase(DBPATH, null,
184 | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
185 | mDb.beginTransaction();
186 |
187 | Map mp1 = new HashMap();
188 | mp1.put(KEY_ID, String.valueOf(ROOT_PCSID_INT));
189 | mp1.put(KEY_PCSCODE, String.valueOf(ROOT_PCSID_INT));
190 | mp1.put(KEY_LOAD, true);
191 | mp1.put(KEY_CHILD_ORDER, ROOT_PCSID_INT - 1);
192 | mp1.put(KEY_PARENT_ID, ROOT_PCSID_INT - 1);
193 | parent.setDescription(getRootName(mDb));
194 | parent.setValueMap(mp1);
195 | parent.setExpanded(true);
196 |
197 | String sql = "select " + FIELD_NAME + ", " + FIELD_REMARK + ", "
198 | + FIELD_ID_PARENT + ", " + FIELD_ID + " from " + TABLE_NAME
199 | + " where " + FIELD_ID_PARENT + " = '"
200 | + String.valueOf(ROOT_PCSID_INT) + "'";
201 | Cursor cur = mDb.rawQuery(sql, null);
202 | if (cur != null && cur.moveToFirst())
203 | {
204 | int childOrder = 0;
205 | do
206 | {
207 | String pcsName = cur.getString(cur.getColumnIndex(FIELD_NAME));
208 | String pcsCode = cur
209 | .getString(cur.getColumnIndex(FIELD_REMARK));
210 | String pcsID = cur.getString(cur.getColumnIndex(FIELD_ID));
211 |
212 | TreeNode node = new TreeNode(parent, pcsName, mIcon);
213 | Map mp = new HashMap();
214 | mp.put(KEY_PCSCODE, pcsCode);
215 | mp.put(KEY_ID, pcsID);
216 | mp.put(KEY_LOAD, false);
217 | mp.put(KEY_CHILD_ORDER, childOrder);
218 | mp.put(KEY_PARENT_ID, ROOT_PCSID_INT);
219 | node.setValueMap(mp);
220 | if (!mLastPcsCodeInDb.equals(pcsID)
221 | && mParentIDList.contains(pcsID))
222 | node.setExpanded(true);
223 | parent.addChildNode(node);
224 | childOrder++;
225 |
226 | // log.e(TAG, "add to=" + pcsName);
227 | addChildNode(mDb, node, pcsID);
228 | }
229 | while (cur.moveToNext());
230 | }
231 | if (parent.getChildren() != null)
232 | {
233 | parent.setDescription(parent.getDescription() + "("
234 | + parent.getChildren().size() + ")");
235 | }
236 | mDb.setTransactionSuccessful();
237 | mDb.endTransaction();
238 | colseCursorAndSql(cur, mDb);
239 | }
240 |
241 | public void loadTreeNode(String pcsCode, TreeListAdapter adapter)
242 | {
243 | mTreeListAdapter = adapter;
244 | List allNodeList = adapter.getAllLoadNodeList();
245 |
246 | for (int i = mParentIDList.size() - 1; i >= 0; i--)
247 | {
248 | String tempId = mParentIDList.get(i);
249 | TreeNode n = null;
250 | int size = allNodeList.size();
251 | for (int j = 0; j < size; j++)
252 | {
253 | if (((String) allNodeList.get(j).getValueMap().get(KEY_ID))
254 | .equals(tempId))
255 | {
256 | n = allNodeList.get(j);
257 | if (!mAlreadyNotify && mTreeListAdapter != null
258 | && tempId.equals(mLastPcsCodeInDb))
259 | {
260 | mAlreadyNotify = true;
261 | mTreeListAdapter.setSelectorNode(n);
262 | }
263 | break;
264 | }
265 | }
266 | if (n != null)
267 | {
268 | Map mp1 = n.getValueMap();
269 | if (!(Boolean) mp1.get(KEY_LOAD))
270 | adapter.imitateDoOnClick(n);
271 | }
272 | }
273 | }
274 |
275 | public void putParentPcsCodeList(String pcsID)
276 | {
277 | // log.e("putparentlist id=" + pcsID);
278 | String sql = "select " + FIELD_ID_PARENT + ", " + FIELD_ID + " from "
279 | + TABLE_NAME + " where " + FIELD_ID + " = '" + pcsID + "'";
280 | Cursor cur = mDb.rawQuery(sql, null);
281 | if (mParentIDList.contains(ROOT_PCSID) || pcsID.equals(ROOT_PCSID))
282 | {
283 | mParentIDList.add(0, mFirstIDInParentList);
284 | colseCursorAndSql(cur, null);
285 | return;
286 | }
287 | File f = new File(DBPATH);
288 | if (!f.exists())
289 | {
290 | log.e("db does not exist");
291 | colseCursorAndSql(cur, mDb);
292 | return;
293 | }
294 | String parentCode = null;
295 | if (cur != null && cur.moveToFirst())
296 | {
297 | parentCode = cur.getString(cur.getColumnIndex(FIELD_ID_PARENT));
298 | mParentIDList.add(parentCode);
299 | }
300 | else
301 | {
302 | log.e("last pcsCode does not exist");
303 | colseCursorAndSql(cur, mDb);
304 | return;
305 | }
306 | colseCursorAndSql(cur, null);
307 | putParentPcsCodeList(parentCode);
308 | }
309 |
310 | public void addChildNode(SQLiteDatabase db, TreeNode parent, String id)
311 | {
312 | addChildNode(db, parent, id, false);
313 | }
314 |
315 | public void addChildNode(SQLiteDatabase db, TreeNode parent, String id,
316 | boolean haveToNotify)
317 | {
318 | if (!mDb.isOpen())
319 | {
320 | mDb = SQLiteDatabase.openDatabase(DBPATH, null,
321 | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
322 | }
323 | String sql = "select " + FIELD_NAME + ", " + FIELD_REMARK + ", "
324 | + FIELD_ID + ", " + FIELD_ID_PARENT + " from " + TABLE_NAME
325 | + " where " + FIELD_ID_PARENT + " = '" + id + "'";
326 | Cursor cur = mDb.rawQuery(sql, null);
327 | if (cur != null && cur.moveToFirst())
328 | {
329 | int childOrder = 0;
330 | int parentID = (Integer) parent.getValueMap().get(KEY_PARENT_ID);
331 | do
332 | {
333 | String pcsName = cur.getString(cur.getColumnIndex(FIELD_NAME));
334 | String pcsCode = cur
335 | .getString(cur.getColumnIndex(FIELD_REMARK));
336 | String pcsID = cur.getString(cur.getColumnIndex(FIELD_ID));
337 |
338 | TreeNode node = new TreeNode(parent, pcsName, mIcon);
339 | Map mp = new HashMap();
340 | mp.put(KEY_ID, pcsID);
341 | mp.put(KEY_PCSCODE, pcsCode);
342 | mp.put(KEY_LOAD, false);
343 | mp.put(KEY_CHILD_ORDER, childOrder);
344 | mp.put(KEY_PARENT_ID, parentID);
345 | node.setValueMap(mp);
346 |
347 | parent.addChildNode(node);
348 | childOrder++;
349 | if (!mAlreadyNotify && haveToNotify && mTreeListAdapter != null
350 | && pcsID.equals(mLastPcsCodeInDb))
351 | {
352 | mAlreadyNotify = true;
353 | mTreeListAdapter.setSelectorNode(node);
354 | // log.e(TAG, "done leaf set=" + pcsName);
355 | }
356 | log.e("add=" + pcsName + " " + pcsCode + " " + pcsID);
357 | }
358 | while (cur.moveToNext());
359 |
360 | if (parent.getChildren() != null)
361 | {
362 | parent.setDescription(parent.getDescription().replaceAll(
363 | "\\([0-9]+\\)", "")
364 | + "(" + parent.getChildren().size() + ")");
365 | }
366 |
367 | // default load 3 levels, when haveToNotify==false,regard as haven't
368 | // load
369 | if (parent.getLevel() > 1 && id.equals(mLastPcsCodeInDb))
370 | {
371 | Map mp = parent.getValueMap();
372 | mp.put(KEY_LOAD, true);
373 | parent.setValueMap(mp);
374 | }
375 |
376 | // last chosen id in parent list
377 | if (haveToNotify && mTreeListAdapter != null
378 | && id.equals(mLastPcsCodeInDb))
379 | {
380 | parent.setExpanded(false);
381 | mTreeListAdapter.setSelectorNode(parent);
382 | }
383 |
384 | if (haveToNotify)
385 | {
386 | if (!id.equals(mLastPcsCodeInDb) && mParentIDList.contains(id))
387 | parent.setExpanded(true);
388 | else
389 | parent.setExpanded(false);
390 |
391 | }
392 | }
393 | if (haveToNotify)
394 | colseCursorAndSql(cur, null);
395 | else if (cur != null && !cur.isClosed())
396 | cur.close();
397 | }
398 | }
399 |
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/LoadTreeTask.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | import android.app.ProgressDialog;
8 | import android.content.Context;
9 | import android.os.AsyncTask;
10 | import android.view.Gravity;
11 | import android.widget.LinearLayout;
12 | import android.widget.ListView;
13 | import android.widget.Toast;
14 |
15 | import com.tochange.yang.TreeListAdapter.OnTreeCallBack;
16 |
17 | public class LoadTreeTask extends AsyncTask
18 | {
19 | private TreeListAdapter mTreeListAdapter;
20 |
21 | private DbToAdapter mDbToAdapter;
22 |
23 | private TreeNode mRoot;
24 |
25 | private long mStartTime, t1, t2, t3;
26 |
27 | private String mPcsName, mPcsCode, mPcsID, mLastPcsIDInDb;
28 |
29 | private ProgressDialog mDataGetProgressDialog;
30 |
31 | private Context mContext;
32 |
33 | private LinearLayout mContainTreeLayout;
34 |
35 | private DatabaseStruct mDbStruct;
36 |
37 | private ListView mTreeListView;
38 |
39 | private log log = new log();
40 |
41 | public String getPcsName()
42 | {
43 | return mPcsName;
44 | }
45 |
46 | public String getPcsCode()
47 | {
48 | return mPcsCode;
49 | }
50 |
51 | public String getPcsID()
52 | {
53 | return mPcsID;
54 | }
55 |
56 | public void exit()
57 | {
58 | mDbToAdapter.colseCursorAndSql(null, null);
59 | }
60 |
61 | public void setTreeListViewPosition(String id)
62 | {
63 | mTreeListView.setSelection(mTreeListAdapter.getTreeListPosition(id));
64 | // mTreeListAdapter.notifyDataSetChanged();//no need?
65 | }
66 |
67 | public LoadTreeTask(Context c, DatabaseStruct dbStruct, LinearLayout l,
68 | String id, String pcsName)
69 | {
70 | mStartTime = System.currentTimeMillis();
71 | mContext = c;
72 | mDbStruct = dbStruct;
73 | mContainTreeLayout = l;
74 | mTreeListView = (ListView) mContainTreeLayout
75 | .findViewById(R.id.lv_tree);
76 |
77 | if (id.equals("") || id.equals(""))
78 | {
79 | mLastPcsIDInDb = DbToAdapter.ROOT_PCSID;
80 | }
81 | else
82 | {
83 | mLastPcsIDInDb = id;
84 | }
85 |
86 | log.intLog("LoadTreeTask", true);
87 | }
88 |
89 | @Override
90 | protected void onPreExecute()
91 | {
92 | if (null == mDataGetProgressDialog
93 | || !mDataGetProgressDialog.isShowing())
94 | {
95 | mDataGetProgressDialog = ProgressDialog.show(mContext, null,
96 | "loading data..", false, false);
97 | }
98 | }
99 |
100 | private TreeNode getRoot(String LastPcsIDInDb)
101 | {
102 | TreeNode root = new TreeNode(null, "default pcsname", -1);
103 | log.e("t1.1 =" + (System.currentTimeMillis() - mStartTime));
104 | mDbToAdapter.putParentPcsCodeList(LastPcsIDInDb);
105 | log.e("t1.2 =" + (System.currentTimeMillis() - mStartTime));
106 | mDbToAdapter.loadDefaultTree(root);
107 | log.e("t1.3 =" + (System.currentTimeMillis() - mStartTime));
108 | return root;
109 | }
110 |
111 | @Override
112 | protected String doInBackground(String... params)
113 | {
114 | if (mDbToAdapter == null)
115 | mDbToAdapter = new DbToAdapter(mLastPcsIDInDb, mDbStruct);
116 | mRoot = getRoot(mLastPcsIDInDb);
117 |
118 | mTreeListAdapter = new TreeListAdapter(mContext, mRoot, true);
119 |
120 | mTreeListAdapter.setOnTreeCallBack(new OnTreeCallBack() {
121 | @Override
122 | public boolean onSelectNode(TreeNode node)
123 | {
124 | if (node != null)
125 | {
126 | mPcsName = node.getDescription().replaceAll("\\([0-9]+\\)",
127 | "");
128 | mPcsCode = (String) node.getValueMap().get(
129 | DbToAdapter.KEY_PCSCODE);
130 | mPcsID = (String) node.getValueMap()
131 | .get(DbToAdapter.KEY_ID);
132 | // log.e( "setting:" + mPcsCode);
133 | }
134 | return true;
135 | }
136 |
137 | @Override
138 | public void onNodeExpand(TreeNode node)
139 | {
140 |
141 | Map mp = node.getValueMap();
142 | boolean haveLoad = (Boolean) mp.get(DbToAdapter.KEY_LOAD);
143 | // level > 1 means haven't preload
144 | if (!haveLoad && node.getLevel() > 1)
145 | {
146 | // mp.put(DbToAdapter.KEY_LOAD, true);
147 | // node.setValueMap(mp);
148 |
149 | // load direct line only
150 | // String id = (String) mp.get(CobwebDeal.KEY_ID);
151 | // ((CobwebDeal) mDbToAdapter)
152 | // .addChildNode(node, id, true);
153 |
154 | // load collateral also thus it can be clicked
155 | TreeNode parent = node.getParent();
156 | List childs = parent.getChildren();
157 | if (childs != null)
158 | {
159 | int size = childs.size();
160 | for (int i = 0; i < size; ++i)
161 | {
162 | TreeNode tn = childs.get(i);
163 | mp = tn.getValueMap();
164 | String idd = (String) mp.get(DbToAdapter.KEY_ID);
165 | if (!(Boolean) mp.get(DbToAdapter.KEY_LOAD))
166 | {
167 | mDbToAdapter.addChildNode(null, tn, idd, true);
168 | // mp.put("load", true);
169 | tn.setValueMap(mp);
170 | }
171 | }
172 | mp = parent.getValueMap();
173 | mp.put(DbToAdapter.KEY_LOAD, true);
174 | // log.e("set true=----1----------------------------" + parent.getDescription());
175 | parent.setValueMap(mp);
176 | }
177 | }
178 | }
179 |
180 | @Override
181 | public void onNodeExpandOrNot(TreeNode node)
182 | {
183 | if (node.getExpanded())
184 | {
185 | Map mp = node.getValueMap();
186 | boolean hasLoaded = (Boolean) mp.get(DbToAdapter.KEY_LOAD);
187 |
188 | // log.e("!hasLoaded =" + node.getDescription() + " " + !hasLoaded);
189 |
190 | if (!hasLoaded)
191 | {
192 |
193 | List childList = node.getChildren();
194 |
195 | // log.e("!null" + (childList == null));
196 |
197 | if (childList != null)
198 | {
199 | int size = childList.size();
200 | for (int i = 0; i < size; ++i)
201 | {
202 | TreeNode childNode = childList.get(i);
203 | mp = childNode.getValueMap();
204 | String id = (String) mp.get(DbToAdapter.KEY_ID);
205 |
206 | log.e("load grandchild id = " + id);
207 |
208 | if (!(Boolean) mp.get(DbToAdapter.KEY_LOAD))
209 | {
210 | mDbToAdapter.addChildNode(null, childNode,
211 | id, true);
212 | // mp.put(DbToAdapter.KEY_LOAD, true);
213 | // childNode.setValueMap(mp);
214 |
215 | if (childNode.isLeaf())
216 | continue;
217 | List grandchildren = childNode
218 | .getChildren();
219 | int size1 = grandchildren.size();
220 | for (int j = 0; j < size1; j++)
221 | {
222 | mTreeListAdapter
223 | .establishNodeList(grandchildren
224 | .get(j));
225 | }
226 | }
227 | }
228 | mp.put(DbToAdapter.KEY_LOAD, true);
229 | // log.e("set true=-------2-------------------------" + node.getDescription());
230 | node.setValueMap(mp);
231 | }
232 | }
233 | }
234 | }
235 |
236 | @Override
237 | public ArrayList getParentIDList(String id)
238 | {
239 | return mDbToAdapter.getParentIDList(id);
240 | }
241 |
242 | });
243 |
244 | log.e("t2 =" + (System.currentTimeMillis() - mStartTime));
245 | mDbToAdapter.loadTreeNode(mLastPcsIDInDb, mTreeListAdapter);
246 | return null;
247 | }
248 |
249 | @Override
250 | protected void onPostExecute(String result)
251 | {
252 | if (mDataGetProgressDialog != null)
253 | {
254 | mDataGetProgressDialog.dismiss();
255 | }
256 |
257 | mTreeListView.setAdapter(mTreeListAdapter);
258 | mTreeListView.setSelection(mTreeListAdapter
259 | .getTreeListPosition(mLastPcsIDInDb));
260 | // mTreeListView.requestFocusFromTouch();//no need?
261 |
262 | log.e("t3 =" + (System.currentTimeMillis() - mStartTime));
263 |
264 | long l2 = System.currentTimeMillis();
265 | Toast toast = Toast.makeText(mContext, "loading tree takes:"
266 | + ((l2 - mStartTime) / 1000) + "." + (l2 - mStartTime) % 1000
267 | + "s", Toast.LENGTH_SHORT);
268 | toast.setGravity(Gravity.BOTTOM, 0, 0);
269 | toast.show();
270 |
271 | }
272 |
273 | }
274 |
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/TreeListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedList;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import android.content.Context;
9 | import android.content.res.Resources;
10 | import android.graphics.Bitmap;
11 | import android.graphics.Bitmap.Config;
12 | import android.graphics.Canvas;
13 | import android.graphics.Color;
14 | import android.graphics.DashPathEffect;
15 | import android.graphics.Paint;
16 | import android.graphics.Paint.Style;
17 | import android.graphics.PathEffect;
18 | import android.graphics.drawable.BitmapDrawable;
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import android.widget.BaseAdapter;
23 | import android.widget.ImageView;
24 | import android.widget.LinearLayout;
25 | import android.widget.LinearLayout.LayoutParams;
26 | import android.widget.TextView;
27 |
28 | public class TreeListAdapter extends BaseAdapter
29 | {
30 |
31 | private Context mContext;
32 |
33 | private int mJumpToPosition;
34 |
35 | private TreeNode mRoot;
36 |
37 | private List mAllNodeList = new ArrayList();
38 |
39 | private List mShowNodeList = new ArrayList();
40 |
41 | private List mShowNodeIDList = new LinkedList();
42 |
43 | private TreeNode mSelectedNode;
44 |
45 | private OnTreeCallBack mOnTreeCallBack;
46 |
47 | private LayoutInflater mInflater;
48 |
49 | // expand node icon
50 | private int mExpandOnIcon = R.drawable.tree_expand_on_nr;
51 |
52 | private int mExpandOffIcon = R.drawable.tree_expand_off_nr;
53 |
54 | private boolean mShowRoot = true;
55 |
56 | private log log = new log() ;
57 |
58 | public TreeListAdapter(Context con, TreeNode root, boolean bShowRoot)
59 | {
60 | mContext = con;
61 | mInflater = (LayoutInflater) con
62 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
63 | mRoot = root;
64 | mShowRoot = bShowRoot;
65 | establishNodeList(mRoot);
66 | setNodeListToShow();
67 |
68 | log.intLog("TreeListAdapter", true);
69 | }
70 |
71 | public boolean getShowRoot()
72 | {
73 | return mShowRoot;
74 | }
75 |
76 | public List getAllLoadNodeList()
77 | {
78 | return mAllNodeList;
79 | }
80 |
81 | public void setShowRoot(boolean show)
82 | {
83 | if (mShowRoot != show)
84 | {
85 | mShowRoot = show;
86 | setNodeListToShow();
87 | notifyDataSetChanged();
88 | }
89 | }
90 |
91 | public void setOnTreeCallBack(OnTreeCallBack onTreeCallBack)
92 | {
93 | mOnTreeCallBack = onTreeCallBack;
94 | }
95 |
96 | // all nodes
97 | public void establishNodeList(TreeNode node)
98 | {
99 | if (node == null)
100 | return;
101 | mAllNodeList.add(node);
102 | if (node.isLeaf())
103 | return;
104 | List children = node.getChildren();
105 | int size = children.size();
106 | for (int i = 0; i < size; i++)
107 | {
108 | establishNodeList(children.get(i));
109 | }
110 | }
111 |
112 | // all prepared to be shown
113 | private void setNodeListToShow()
114 | {
115 | this.mShowNodeList.clear();
116 | mShowNodeIDList.clear();
117 | establishNodeListToShow(this.mRoot);
118 | }
119 |
120 | private void establishNodeListToShow(TreeNode node)
121 | {
122 | if (mShowRoot || mRoot != node)
123 | {
124 | mShowNodeList.add(node);
125 | mShowNodeIDList.add(Integer.valueOf((String) node.getValueMap()
126 | .get(DbToAdapter.KEY_ID)));
127 | }
128 | if (node != null && node.getExpanded() && !node.isLeaf()
129 | && node.getChildren() != null)
130 | {
131 | List children = node.getChildren();
132 | int size = children.size();
133 | for (int i = 0; i < size; i++)
134 | {
135 | establishNodeListToShow(children.get(i));
136 | }
137 | }
138 | }
139 |
140 | private void changeNodeExpandOrFold(TreeNode node)
141 | {
142 | boolean flag = node.getExpanded();
143 | node.setExpanded(!flag);
144 | }
145 |
146 | public TreeNode getSelectorNode()
147 | {
148 | return mSelectedNode;
149 | }
150 |
151 | public int getCount()
152 | {
153 | return mShowNodeList.size();
154 | }
155 |
156 | public Object getItem(int arg0)
157 | {
158 | return mShowNodeList.get(arg0);
159 | }
160 |
161 | public long getItemId(int arg0)
162 | {
163 | return arg0;
164 | }
165 |
166 | public View getView(final int position, View view, ViewGroup parent)
167 | {
168 | Holder holder = null;
169 | if (view != null)
170 | {
171 | holder = (Holder) view.getTag();
172 | }
173 | else
174 | {
175 | holder = new Holder();
176 | view = this.mInflater.inflate(R.layout.tree_item, null);
177 | holder.layBlank = (LinearLayout) view.findViewById(R.id.lay_blank);
178 | // holder.nodeIcon = (ImageView) view.findViewById(R.id.iv_node);
179 | holder.expandOrNot = (ImageView) view
180 | .findViewById(R.id.iv_expanded);
181 | holder.layTextContent = (LinearLayout) view
182 | .findViewById(R.id.lay_tv_content);
183 | holder.description = (TextView) view
184 | .findViewById(R.id.tv_description);
185 | // holder.secondTitle = (TextView) view
186 | // .findViewById(R.id.tv_second_title);
187 | view.setTag(holder);
188 | }
189 |
190 | TreeNode node = this.mShowNodeList.get(position);
191 | if (node == null)
192 | return null;
193 | view.setOnClickListener(new View.OnClickListener() {
194 |
195 | @Override
196 | public void onClick(View v)
197 | {
198 | TreeNode node = mShowNodeList.get(position);
199 | onClickNodeExpandOrFoldIcon(node);
200 | }
201 | });
202 | // set icon present expand or not expand
203 | if (!node.isLeaf())
204 | {
205 | holder.expandOrNot
206 | .setImageResource(node.getExpanded() ? mExpandOnIcon
207 | : mExpandOffIcon);
208 | holder.expandOrNot.setVisibility(View.VISIBLE);
209 | }
210 | else
211 | {
212 | holder.expandOrNot.setVisibility(View.GONE);
213 | }
214 | holder.expandOrNot.setOnClickListener(new View.OnClickListener() {
215 | @Override
216 | public void onClick(View v)
217 | {
218 | TreeNode node = mShowNodeList.get(position);
219 | onClickNodeExpandOrFoldIcon(node);
220 | }
221 | });
222 |
223 | // holder.nodeIcon.setOnClickListener(new View.OnClickListener() {
224 | // @Override
225 | // public void onClick(View v)
226 | // {
227 | // // TODO Auto-generated method stub
228 | // TreeNode node = mShowNodeList.get(position);
229 | // onClickNodeIcon(node);
230 | // }
231 | // });
232 |
233 | holder.description.setText(node.getDescription());
234 | // String title = node.getSecondTitle();
235 | // if (title == null || title.equals(""))
236 | // {
237 | // holder.secondTitle.setVisibility(View.GONE);
238 | // }
239 | // else
240 | // {
241 | // holder.secondTitle.setVisibility(View.VISIBLE);
242 | // holder.secondTitle.setText(node.getSecondTitle());
243 | // }
244 |
245 | holder.layTextContent.setOnClickListener(new View.OnClickListener() {
246 | @Override
247 | public void onClick(View v)
248 | {
249 | TreeNode node = mShowNodeList.get(position);
250 | doOnClick(node);
251 | }
252 | });
253 |
254 | // horizon offset of dotted line
255 | LayoutParams lp = (LayoutParams) holder.layBlank.getLayoutParams();
256 |
257 | int n = node.getLevel();
258 | int nf = n + (node.isLeaf() ? 1 : 0);
259 | Resources res = mContext.getResources();
260 | int nw = res.getDimensionPixelSize(R.dimen.treenode_icon_width);
261 | if (!mShowRoot)
262 | {
263 | if (nf > 0)
264 | {
265 | nf--;
266 | }
267 | n--;
268 | }
269 | nw = nf * nw + res.getDimensionPixelSize(R.dimen.treenode_offset);
270 | lp.width = nw;
271 | holder.layBlank.setLayoutParams(lp);
272 | Bitmap bitmap = createBitmap(node, n, nw, mContext.getResources()
273 | .getDimensionPixelSize(R.dimen.treenode_height));
274 | if (bitmap != null)
275 | {
276 | holder.layBlank.setBackgroundDrawable(new BitmapDrawable(bitmap));
277 | }
278 | else
279 | {
280 | holder.layBlank.setBackgroundColor(Color.TRANSPARENT);
281 | }
282 | if (node == mSelectedNode)
283 | {
284 | view.findViewById(R.id.lay_tv_content).setBackgroundColor(
285 | mContext.getResources().getColor(R.color.tree_node_bg));
286 | }
287 | else
288 | {
289 | view.findViewById(R.id.lay_tv_content).setBackgroundResource(
290 | R.drawable.treelist_selector_bg);
291 | }
292 | return view;
293 | }
294 |
295 | public Bitmap createBitmap(TreeNode node, int lev, int w, int h)
296 | {
297 | Bitmap bitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);
298 | if (lev <= 0 || w <= 0 || h <= 0)
299 | {
300 | return null;
301 | }
302 | Resources res = mContext.getResources();
303 | int offW = res.getDimensionPixelSize(R.dimen.treenode_offset);
304 | int iconW = res.getDimensionPixelSize(R.dimen.treenode_icon_width);
305 | int color = res.getColor(R.color.black);
306 | Canvas canvas = new Canvas(bitmap);
307 | Paint paint = new Paint();
308 | paint.setStyle(Style.STROKE);
309 | PathEffect effect = new DashPathEffect(new float[] { 2, 2 }, 1);
310 | paint.setPathEffect(effect);
311 | paint.setStrokeWidth(1);
312 | paint.setColor(color);
313 | paint.setAntiAlias(true);
314 | int start = offW + iconW / 2;
315 |
316 | int y = h;
317 | int x = start;
318 | for (int i = 0; i < lev; ++i)
319 | {
320 | y = h;
321 | x = start + i * iconW;
322 | if (i == lev - 1)
323 | {// leaf: draw dotted line half in vertical orientation
324 | y = isLastChildNode(node, 1) ? (h / 2) : h;
325 | canvas.drawLine(x, 0, x, y, paint);
326 | }
327 | else
328 | {
329 | if (!isLastChildNode(node, lev - i))
330 | {
331 | canvas.drawLine(x, 0, x, y, paint);
332 | }
333 | }
334 | }
335 | int line = (node.isLeaf() && node.getIcon() == -1) ? res
336 | .getDimensionPixelSize(R.dimen.treenode_line_offset) : 0;
337 | canvas.drawLine(x, h / 2, w - line, h / 2, paint);
338 | return bitmap;
339 | }
340 |
341 | private boolean isLastChildNode(TreeNode node, int lev)
342 | {
343 | boolean last = true;
344 | TreeNode child = node;
345 | TreeNode parent = child;
346 | int i = 0;
347 | for (i = 0; i < lev; ++i)
348 | {
349 | parent = child.getParent();
350 | if (parent == null)
351 | {
352 | break;
353 | }
354 | if (i == lev - 1)
355 | {
356 | List childList = parent.getChildren();
357 | if (childList != null && childList.size() > 0)
358 | {
359 | last = (childList.get(childList.size() - 1) == child);
360 | }
361 | }
362 | else
363 | {
364 | child = parent;
365 | }
366 | }
367 |
368 | return last;
369 | }
370 |
371 | public void doOnClick(TreeNode node)
372 | {
373 | setSelectorNode(node);
374 | if (!node.isLeaf())
375 | {
376 | setNodeExpandOrNot(node);
377 | }
378 | }
379 |
380 | public void imitateDoOnClick(TreeNode node)
381 | {
382 |
383 | if (!node.getExpanded())
384 | {
385 | if (mOnTreeCallBack != null)
386 | {
387 | mOnTreeCallBack.onNodeExpand(node);
388 | }
389 | setNodeListToShow();
390 | notifyDataSetChanged();
391 | }
392 | }
393 |
394 | public void setSelectorNode(TreeNode node)
395 | {
396 | if (mSelectedNode != node)
397 | {
398 | mSelectedNode = node;
399 | // notifyDataSetChanged();
400 |
401 | if (mOnTreeCallBack != null)
402 | {
403 | if (!mOnTreeCallBack.onSelectNode(node))
404 | {
405 | return;
406 | }
407 | log.e("last node:" + node.getDescription());
408 | if (!mShowNodeIDList.contains(Integer.valueOf((String) node
409 | .getValueMap().get(DbToAdapter.KEY_ID))))
410 | {
411 | establishNodeListToShow(node);// put this node into show
412 | // list
413 | }
414 | notifyDataSetChanged();
415 | }
416 | }
417 | }
418 |
419 | public boolean calulateListViewPosition(String lastid)
420 | {
421 | ArrayList parentList = mOnTreeCallBack.getParentIDList(lastid);
422 | if (!parentList.isEmpty())
423 | {
424 | log.e("..." + parentList.get(0));
425 | int size = parentList.size();
426 | mJumpToPosition = -1;
427 |
428 | for (int j = (size - 1) - 1; j >= 0; j--)
429 | {
430 | String id = parentList.get(j);
431 | int nodeSize = mShowNodeList.size();
432 | for (int i = 0; i < nodeSize; i++)
433 | {
434 | Map mp = mShowNodeList.get(i).getValueMap();
435 |
436 | log.e("foreach=" + j + " " + id + " "
437 | + mp.get(DbToAdapter.KEY_ID) + " "
438 | + mShowNodeList.get(i).getDescription());
439 |
440 | if (mp != null
441 | && ((String) mp.get(DbToAdapter.KEY_ID)).equals(id))
442 | {
443 | mJumpToPosition += (Integer) mp
444 | .get(DbToAdapter.KEY_CHILD_ORDER) + 1;
445 | log.e("found mJumpToPosition= " + mJumpToPosition);
446 | break;
447 | }
448 | }
449 | }
450 |
451 | log.e("position=" + mJumpToPosition);
452 | }
453 | else
454 | mJumpToPosition = 0;
455 | return true;
456 | }
457 |
458 | public int getTreeListPosition(String id)
459 |
460 | {
461 | if (calulateListViewPosition(id))
462 | return mJumpToPosition;
463 | else
464 | return -1;
465 | }
466 |
467 | public void setNodeExpandOrNot(TreeNode node)
468 | {
469 | if (!node.isLeaf())
470 | {
471 | changeNodeExpandOrFold(node);
472 | if (mOnTreeCallBack != null)
473 | {
474 | mOnTreeCallBack.onNodeExpandOrNot(node);
475 | }
476 | setNodeListToShow();
477 | notifyDataSetChanged();
478 | }
479 | }
480 |
481 | public int setNodeShow(TreeNode node)
482 | {
483 | TreeNode parent = node.getParent();
484 | while (parent != null)
485 | {
486 | parent.setExpanded(true);
487 | parent = parent.getParent();
488 | }
489 | setNodeListToShow();
490 | int i = 0;
491 | int size = mShowNodeList.size();
492 | for (i = 0; i < size; ++i)
493 | {
494 | if (node == mShowNodeList.get(i))
495 | {
496 | break;
497 | }
498 | }
499 | if (i >= mShowNodeList.size())
500 | {
501 | i = -1;
502 | }
503 | notifyDataSetChanged();
504 |
505 | return i;
506 | }
507 |
508 | public boolean onClickNodeIcon(TreeNode node)
509 | {
510 |
511 | return onClickNodeExpandOrFoldIcon(node);
512 | }
513 |
514 | public boolean onClickNodeExpandOrFoldIcon(TreeNode node)
515 | {
516 | if (!node.isLeaf())
517 | {
518 | this.changeNodeExpandOrFold(node);
519 | this.setNodeListToShow();
520 | this.notifyDataSetChanged();
521 | }
522 | return true;
523 | }
524 |
525 | public class Holder
526 | {
527 | LinearLayout layBlank;
528 |
529 | ImageView nodeIcon;
530 |
531 | ImageView expandOrNot;
532 |
533 | TextView description;
534 |
535 | TextView secondTitle;
536 |
537 | LinearLayout layTextContent;
538 |
539 | }
540 |
541 | public interface OnTreeCallBack
542 | {
543 | public boolean onSelectNode(TreeNode node);
544 |
545 | // manual click node to expand or not
546 | public void onNodeExpandOrNot(TreeNode node);
547 |
548 | // imitate expand
549 | public void onNodeExpand(TreeNode node);
550 |
551 | public ArrayList getParentIDList(String id);
552 | }
553 | }
554 |
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/TreeNode.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 | import java.util.UUID;
7 |
8 | public class TreeNode
9 | {
10 | private TreeNode mParent;
11 |
12 | private List mChildList;
13 |
14 | private String mOid;
15 |
16 | private String mName;
17 |
18 | private String mSecondTitle;
19 |
20 | private boolean mIsExpanded = false;
21 |
22 | private int mIcon = -1;
23 |
24 | private Map mValueMap;
25 |
26 | public TreeNode(TreeNode parent, String description, int icon)
27 | {
28 | this.mParent = parent;
29 | this.mOid = UUID.randomUUID().toString();
30 | this.mName = description;
31 | this.mIcon = icon;
32 | }
33 |
34 | public void setValueMap(Map valueMap)
35 | {
36 | mValueMap = valueMap;
37 | }
38 |
39 | public Map getValueMap()
40 | {
41 | return mValueMap;
42 | }
43 |
44 | public void setSecondTitle(String value)
45 | {
46 | this.mSecondTitle = value;
47 | }
48 |
49 | public String getSecondTitle()
50 | {
51 | return this.mSecondTitle;
52 | }
53 |
54 | public void setIcon(int icon)
55 | {
56 | this.mIcon = icon;
57 | }
58 |
59 | public int getIcon()
60 | {
61 | return this.mIcon;
62 | }
63 |
64 | public String getDescription()
65 | {
66 | return this.mName;
67 | }
68 |
69 | public void setDescription(String name)
70 | {
71 | this.mName = name;
72 | }
73 |
74 | public String getOid()
75 | {
76 | return this.mOid;
77 | }
78 |
79 | public boolean isLeaf()
80 | {
81 | return mChildList == null || mChildList.size() == 0;
82 | }
83 |
84 | // root level is 0
85 | public int getLevel()
86 | {
87 | return mParent == null ? 0 : mParent.getLevel() + 1;
88 | }
89 |
90 | public void setExpanded(boolean isExpanded)
91 | {
92 | this.mIsExpanded = isExpanded;
93 | }
94 |
95 | public boolean getExpanded()
96 | {
97 | return this.mIsExpanded;
98 | }
99 |
100 | public void addChildNode(TreeNode child)
101 | {
102 | if (mChildList == null)
103 | {
104 | mChildList = new ArrayList();
105 | }
106 | mChildList.add(child);
107 | }
108 |
109 | public void clearChildren()
110 | {
111 | if (!mChildList.equals(null))
112 | {
113 | mChildList.clear();
114 | }
115 | }
116 |
117 | public boolean isRoot()
118 | {
119 | return mParent.equals(null) ? true : false;
120 | }
121 |
122 | public final List getChildren()
123 | {
124 | return mChildList;
125 | }
126 |
127 | public TreeNode getParent()
128 | {
129 | return mParent;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/TreeViewLib/src/com/tochange/yang/log.java:
--------------------------------------------------------------------------------
1 | package com.tochange.yang;
2 |
3 | import android.util.Log;
4 |
5 | public class log
6 | {
7 |
8 | private String nTag;
9 |
10 | private boolean mPrintLog;
11 |
12 | public void intLog(String tag, boolean pritLog)
13 | {
14 | nTag = tag;
15 | mPrintLog = !pritLog;
16 | }
17 |
18 | public void e(String msg)
19 | {
20 | if (mPrintLog)
21 | Log.e(nTag, msg);
22 | }
23 |
24 | public void w(String msg)
25 | {
26 | if (mPrintLog)
27 | Log.w(nTag, msg);
28 | }
29 |
30 | public void i(String msg)
31 | {
32 | if (mPrintLog)
33 | Log.i(nTag, msg);
34 | }
35 |
36 | public void d(String msg)
37 | {
38 | if (mPrintLog)
39 | Log.d(nTag, msg);
40 | }
41 |
42 | public void v(String msg)
43 | {
44 | if (mPrintLog)
45 | Log.v(nTag, msg);
46 | }
47 | }
--------------------------------------------------------------------------------
/device-2014-04-10-224251.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tochange/TreeView/80f3bad4e36e35b70829fb01361e2a3da4ad223d/device-2014-04-10-224251.png
--------------------------------------------------------------------------------