├── .gitignore
├── LICENSE
├── README-cn.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── baiiu
│ │ └── dropdownmenu
│ │ ├── DropMenuAdapter.java
│ │ ├── MainActivity.java
│ │ ├── entity
│ │ ├── FilterType.java
│ │ └── FilterUrl.java
│ │ ├── fragmentSample
│ │ ├── FilterActivity.java
│ │ └── FilterFragment.java
│ │ └── view
│ │ ├── betterDoubleGrid
│ │ ├── BetterDoubleGridView.java
│ │ ├── DoubleGridAdapter.java
│ │ └── holder
│ │ │ ├── ItemViewHolder.java
│ │ │ └── TitleViewHolder.java
│ │ └── doubleGrid
│ │ ├── DoubleGridView.java
│ │ └── GridViewInScrollView.java
│ └── res
│ ├── drawable
│ ├── news_article_icon_gray_line_4.xml
│ ├── rect_blue_stroke.xml
│ ├── rect_grey_stroke.xml
│ ├── selector_double_grid.xml
│ └── selector_filter_grid.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── holder_item.xml
│ ├── holder_title.xml
│ ├── merge_filter_double_grid.xml
│ └── merge_filter_third.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── filter-lib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── baiiu
│ │ └── filter
│ │ ├── DropDownMenu.java
│ │ ├── adapter
│ │ ├── BaseBaseAdapter.java
│ │ ├── MenuAdapter.java
│ │ └── SimpleTextAdapter.java
│ │ ├── interfaces
│ │ ├── OnFilterDoneListener.java
│ │ └── OnFilterItemClickListener.java
│ │ ├── typeview
│ │ ├── DoubleListView.java
│ │ ├── SingleGridView.java
│ │ └── SingleListView.java
│ │ ├── util
│ │ ├── CommonUtil.java
│ │ ├── SimpleAnimationListener.java
│ │ └── UIUtil.java
│ │ └── view
│ │ ├── FilterCheckedTextView.java
│ │ └── FixedTabIndicator.java
│ └── res
│ ├── anim
│ ├── alpha_to_one.xml
│ ├── alpha_to_zero.xml
│ ├── top_in.xml
│ └── top_out.xml
│ ├── drawable-xxhdpi
│ ├── common_filter_arrow_down.png
│ └── common_filter_arrow_up.png
│ ├── drawable
│ ├── layer_filter_checked.xml
│ ├── layer_filter_unchecked.xml
│ ├── level_filter.xml
│ ├── selector_filter_left.xml
│ └── selector_tv_filter.xml
│ ├── layout
│ ├── lv_item_filter.xml
│ └── merge_filter_list.xml
│ └── values
│ ├── color.xml
│ ├── ids.xml
│ └── strings.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
└── dropDownMenu.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | /local.properties
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README-cn.md:
--------------------------------------------------------------------------------
1 | ##DropDownMenu
2 | [](https://android-arsenal.com/details/1/3803)
3 |
4 |
5 |
6 | 筛选器. 尽管之前有很多人写,站在别人基础上重新写了一版,适配各种数据model.
7 | 现在的代码已经很清晰明了,模块分明.
8 |
9 | ##特点
10 | 1. 使用 Adapter模式 添加筛选器条目.使代码清晰可见,便于维护.
11 | 2. 使用泛型支持各种数据数据model. 提供三种泛型View类, 单列ListView,双列ListView 和 单个GridView, sample中还提供了两个GridView的示例.
12 | 3. 自己写FilterCheckedView,支持checked属性,使用selector就可配置选中样式.配合AbsListView.setChecked()使用
13 | 4. 使用FilterUrl作为中介,toString()方法获取到所拼接url,隔离了数据和View,使代码更清晰.
14 |
15 | ##ScreenShot
16 | 
17 |
18 |
19 |
20 | ##使用
21 | 布局文件
22 | ```
23 |
27 |
28 |
34 |
35 | ```
36 |
37 | 代码中:
38 | ```java
39 | //代码中设置Adapter.
40 | dropDownView.setMenuAdapter(new DropMenuAdapter(this, titleList));
41 | ```
42 |
43 | DropMenuAdapter中:
44 | ```
45 | @Override
46 | public int getMenuCount() {
47 | return titles.length;
48 | }
49 |
50 | @Override
51 | public String getMenuTitle(int position) {
52 | return titles[position];
53 | }
54 |
55 | @Override
56 | public int getBottomMargin(int position) {
57 | return 0;
58 | }
59 |
60 | @Override
61 | public View getView(int position, FrameLayout parentContainer) {
62 | ...
63 | return createSingleListView();
64 | }
65 | ```
66 |
67 | 添加SingleListView
68 | ```java
69 | private View createSingleListView() {
70 | SingleListView singleListView = new SingleListView(mContext)
71 | .adapter(new SimpleTextAdapter(null, mContext) {
72 | @Override
73 | public String provideText(String string) {
74 | return string;
75 | }
76 | })
77 | .onItemClick(new OnFilterItemClickListener() {
78 | @Override
79 | public void onItemClick(String item) {
80 | FilterUrl.instance().singleListPosition = item;
81 |
82 | FilterUrl.instance().position = 0;
83 | FilterUrl.instance().positionTitle = item;
84 |
85 | if (onFilterDoneListener != null) {
86 | onFilterDoneListener.onFilterDone(0, "", "");
87 | }
88 | }
89 | });
90 |
91 | //初始化数据
92 | singleListView.setList(list, -1);//默认不选中
93 | }
94 | ```
95 |
96 |
97 | ## License
98 | Copyright (C) 2016 zhe zhu
99 |
100 | Licensed under the Apache License, Version 2.0 (the "License");
101 | you may not use this file except in compliance with the License.
102 | You may obtain a copy of the License at
103 |
104 | http://www.apache.org/licenses/LICENSE-2.0
105 |
106 | Unless required by applicable law or agreed to in writing, software
107 | distributed under the License is distributed on an "AS IS" BASIS,
108 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
109 | See the License for the specific language governing permissions and
110 | limitations under the License.
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## DropDownMenu
2 | [](https://android-arsenal.com/details/1/3803)
3 |
4 |
5 | This is a DropDownMenu with the advantage of all the dropDownMenus by others before,
6 | I have written it for several times, Now the code is most clearly.
7 |
8 | [中文文档](README-cn.md)
9 |
10 | ##Feature
11 | 1. use Adapter to add the SubDropDownMenu. Override the `getView()` method to supply the wantted view.
12 | 2. use Generic to make all kinds of model(pojo,javabean...) can be used.
13 | 3. use FilterCheckedView which implements `Checkable`, so you can use selector to respond to all user action.
14 | 4. use FilterUrl to save the current choosen data, only override `toString()` you will get the url.
15 |
16 | ##ScreenShot
17 | 
18 |
19 | ## Usage
20 | the xml:
21 | ```xml
22 |
26 |
27 |
33 |
34 | ```
35 |
36 | the JavaCode:
37 | ```java
38 | //set the Adapter.
39 | dropDownView.setMenuAdapter(new DropMenuAdapter(this, titleList));
40 | ```
41 |
42 | the DropMenuAdapter:
43 | ```java
44 | @Override
45 | public int getMenuCount() {
46 | return titles.length;
47 | }
48 |
49 | @Override
50 | public String getMenuTitle(int position) {
51 | return titles[position];
52 | }
53 |
54 | @Override
55 | public int getBottomMargin(int position) {
56 | return 0;
57 | }
58 |
59 | @Override
60 | public View getView(int position, FrameLayout parentContainer) {
61 | ...
62 | return createSingleListView();
63 | }
64 | ```
65 |
66 | add a SingleListView:
67 | ```java
68 | private View createSingleListView() {
69 |
70 | SingleListView singleListView = new SingleListView(mContext)
71 | .adapter(new SimpleTextAdapter(null, mContext) {
72 | @Override
73 | public String provideText(String string) {
74 | return string;
75 | }
76 | })
77 | .onItemClick(new OnFilterItemClickListener() {
78 | @Override
79 | public void onItemClick(String item) {
80 | FilterUrl.instance().singleListPosition = item;
81 |
82 | FilterUrl.instance().position = 0;
83 | FilterUrl.instance().positionTitle = item;
84 |
85 | if (onFilterDoneListener != null) {
86 | onFilterDoneListener.onFilterDone(0, "", "");
87 | }
88 | }
89 | });
90 |
91 | //初始化数据
92 | singleListView.setList(list, -1);//默认不选中
93 | }
94 | ```
95 |
96 |
97 | ## License
98 | Copyright (C) 2016 zhe zhu
99 |
100 | Licensed under the Apache License, Version 2.0 (the "License");
101 | you may not use this file except in compliance with the License.
102 | You may obtain a copy of the License at
103 |
104 | http://www.apache.org/licenses/LICENSE-2.0
105 |
106 | Unless required by applicable law or agreed to in writing, software
107 | distributed under the License is distributed on an "AS IS" BASIS,
108 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
109 | See the License for the specific language governing permissions and
110 | limitations under the License.
111 |
112 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 |
6 | defaultConfig {
7 | applicationId "com.baiiu.dropdownmenu"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation project(':filter-lib')
24 | testImplementation 'junit:junit:4.12'
25 | implementation 'com.android.support:appcompat-v7:25.4.0'
26 | implementation 'com.jakewharton:butterknife:8.8.1'
27 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
28 | implementation 'com.android.support:recyclerview-v7:25.4.0'
29 | }
30 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/baiiu/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/DropMenuAdapter.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu;
2 |
3 | import android.content.Context;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.widget.FrameLayout;
7 |
8 | import com.baiiu.dropdownmenu.view.betterDoubleGrid.BetterDoubleGridView;
9 | import com.baiiu.filter.adapter.MenuAdapter;
10 | import com.baiiu.filter.adapter.SimpleTextAdapter;
11 | import com.baiiu.filter.interfaces.OnFilterDoneListener;
12 | import com.baiiu.filter.interfaces.OnFilterItemClickListener;
13 | import com.baiiu.filter.typeview.DoubleListView;
14 | import com.baiiu.filter.typeview.SingleGridView;
15 | import com.baiiu.filter.typeview.SingleListView;
16 | import com.baiiu.filter.util.CommonUtil;
17 | import com.baiiu.filter.util.UIUtil;
18 | import com.baiiu.filter.view.FilterCheckedTextView;
19 | import com.baiiu.dropdownmenu.entity.FilterType;
20 | import com.baiiu.dropdownmenu.entity.FilterUrl;
21 | import com.baiiu.dropdownmenu.view.doubleGrid.DoubleGridView;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | /**
27 | * author: baiiu
28 | * date: on 16/1/17 21:14
29 | * description:
30 | */
31 | public class DropMenuAdapter implements MenuAdapter {
32 | private final Context mContext;
33 | private OnFilterDoneListener onFilterDoneListener;
34 | private String[] titles;
35 |
36 | public DropMenuAdapter(Context context, String[] titles, OnFilterDoneListener onFilterDoneListener) {
37 | this.mContext = context;
38 | this.titles = titles;
39 | this.onFilterDoneListener = onFilterDoneListener;
40 | }
41 |
42 | @Override
43 | public int getMenuCount() {
44 | return titles.length;
45 | }
46 |
47 | @Override
48 | public String getMenuTitle(int position) {
49 | return titles[position];
50 | }
51 |
52 | @Override
53 | public int getBottomMargin(int position) {
54 | if (position == 3) {
55 | return 0;
56 | }
57 |
58 | return UIUtil.dp(mContext, 140);
59 | }
60 |
61 | @Override
62 | public View getView(int position, FrameLayout parentContainer) {
63 | View view = parentContainer.getChildAt(position);
64 |
65 | switch (position) {
66 | case 0:
67 | view = createSingleListView();
68 | break;
69 | case 1:
70 | view = createDoubleListView();
71 | break;
72 | case 2:
73 | view = createSingleGridView();
74 | break;
75 | case 3:
76 | // view = createDoubleGrid();
77 | view = createBetterDoubleGrid();
78 | break;
79 | }
80 |
81 | return view;
82 | }
83 |
84 | private View createSingleListView() {
85 | SingleListView singleListView = new SingleListView(mContext)
86 | .adapter(new SimpleTextAdapter(null, mContext) {
87 | @Override
88 | public String provideText(String string) {
89 | return string;
90 | }
91 |
92 | @Override
93 | protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
94 | int dp = UIUtil.dp(mContext, 15);
95 | checkedTextView.setPadding(dp, dp, 0, dp);
96 | }
97 | })
98 | .onItemClick(new OnFilterItemClickListener() {
99 | @Override
100 | public void onItemClick(String item) {
101 | FilterUrl.instance().singleListPosition = item;
102 |
103 | FilterUrl.instance().position = 0;
104 | FilterUrl.instance().positionTitle = item;
105 |
106 | onFilterDone();
107 | }
108 | });
109 |
110 | List list = new ArrayList<>();
111 | for (int i = 0; i < 10; ++i) {
112 | list.add("" + i);
113 | }
114 | singleListView.setList(list, -1);
115 |
116 | return singleListView;
117 | }
118 |
119 |
120 | private View createDoubleListView() {
121 | DoubleListView comTypeDoubleListView = new DoubleListView(mContext)
122 | .leftAdapter(new SimpleTextAdapter(null, mContext) {
123 | @Override
124 | public String provideText(FilterType filterType) {
125 | return filterType.desc;
126 | }
127 |
128 | @Override
129 | protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
130 | checkedTextView.setPadding(UIUtil.dp(mContext, 44), UIUtil.dp(mContext, 15), 0, UIUtil.dp(mContext, 15));
131 | }
132 | })
133 | .rightAdapter(new SimpleTextAdapter(null, mContext) {
134 | @Override
135 | public String provideText(String s) {
136 | return s;
137 | }
138 |
139 | @Override
140 | protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
141 | checkedTextView.setPadding(UIUtil.dp(mContext, 30), UIUtil.dp(mContext, 15), 0, UIUtil.dp(mContext, 15));
142 | checkedTextView.setBackgroundResource(android.R.color.white);
143 | }
144 | })
145 | .onLeftItemClickListener(new DoubleListView.OnLeftItemClickListener() {
146 | @Override
147 | public List provideRightList(FilterType item, int position) {
148 | List child = item.child;
149 | if (CommonUtil.isEmpty(child)) {
150 | FilterUrl.instance().doubleListLeft = item.desc;
151 | FilterUrl.instance().doubleListRight = "";
152 |
153 | FilterUrl.instance().position = 1;
154 | FilterUrl.instance().positionTitle = item.desc;
155 |
156 | onFilterDone();
157 | }
158 |
159 | return child;
160 | }
161 | })
162 | .onRightItemClickListener(new DoubleListView.OnRightItemClickListener() {
163 | @Override
164 | public void onRightItemClick(FilterType item, String string) {
165 | FilterUrl.instance().doubleListLeft = item.desc;
166 | FilterUrl.instance().doubleListRight = string;
167 |
168 | FilterUrl.instance().position = 1;
169 | FilterUrl.instance().positionTitle = string;
170 |
171 | onFilterDone();
172 | }
173 | });
174 |
175 |
176 | List list = new ArrayList<>();
177 |
178 | //第一项
179 | FilterType filterType = new FilterType();
180 | filterType.desc = "10";
181 | list.add(filterType);
182 |
183 | //第二项
184 | filterType = new FilterType();
185 | filterType.desc = "11";
186 | List childList = new ArrayList<>();
187 | for (int i = 0; i < 13; ++i) {
188 | childList.add("11" + i);
189 | }
190 | filterType.child = childList;
191 | list.add(filterType);
192 |
193 | //第三项
194 | filterType = new FilterType();
195 | filterType.desc = "12";
196 | childList = new ArrayList<>();
197 | for (int i = 0; i < 3; ++i) {
198 | childList.add("12" + i);
199 | }
200 | filterType.child = childList;
201 | list.add(filterType);
202 |
203 | //初始化选中.
204 | comTypeDoubleListView.setLeftList(list, 1);
205 | comTypeDoubleListView.setRightList(list.get(1).child, -1);
206 | comTypeDoubleListView.getLeftListView().setBackgroundColor(mContext.getResources().getColor(R.color.b_c_fafafa));
207 |
208 | return comTypeDoubleListView;
209 | }
210 |
211 |
212 | private View createSingleGridView() {
213 | SingleGridView singleGridView = new SingleGridView(mContext)
214 | .adapter(new SimpleTextAdapter(null, mContext) {
215 | @Override
216 | public String provideText(String s) {
217 | return s;
218 | }
219 |
220 | @Override
221 | protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
222 | checkedTextView.setPadding(0, UIUtil.dp(context, 3), 0, UIUtil.dp(context, 3));
223 | checkedTextView.setGravity(Gravity.CENTER);
224 | checkedTextView.setBackgroundResource(R.drawable.selector_filter_grid);
225 | }
226 | })
227 | .onItemClick(new OnFilterItemClickListener() {
228 | @Override
229 | public void onItemClick(String item) {
230 | FilterUrl.instance().singleGridPosition = item;
231 |
232 | FilterUrl.instance().position = 2;
233 | FilterUrl.instance().positionTitle = item;
234 |
235 | onFilterDone();
236 |
237 | }
238 | });
239 |
240 | List list = new ArrayList<>();
241 | for (int i = 20; i < 39; ++i) {
242 | list.add(String.valueOf(i));
243 | }
244 | singleGridView.setList(list, -1);
245 |
246 |
247 | return singleGridView;
248 | }
249 |
250 |
251 | private View createBetterDoubleGrid() {
252 |
253 | List phases = new ArrayList<>();
254 | for (int i = 0; i < 10; ++i) {
255 | phases.add("3top" + i);
256 | }
257 | List areas = new ArrayList<>();
258 | for (int i = 0; i < 10; ++i) {
259 | areas.add("3bottom" + i);
260 | }
261 |
262 |
263 | return new BetterDoubleGridView(mContext)
264 | .setmTopGridData(phases)
265 | .setmBottomGridList(areas)
266 | .setOnFilterDoneListener(onFilterDoneListener)
267 | .build();
268 | }
269 |
270 |
271 | private View createDoubleGrid() {
272 | DoubleGridView doubleGridView = new DoubleGridView(mContext);
273 | doubleGridView.setOnFilterDoneListener(onFilterDoneListener);
274 |
275 |
276 | List phases = new ArrayList<>();
277 | for (int i = 0; i < 10; ++i) {
278 | phases.add("3top" + i);
279 | }
280 | doubleGridView.setTopGridData(phases);
281 |
282 | List areas = new ArrayList<>();
283 | for (int i = 0; i < 10; ++i) {
284 | areas.add("3bottom" + i);
285 | }
286 | doubleGridView.setBottomGridList(areas);
287 |
288 | return doubleGridView;
289 | }
290 |
291 |
292 | private void onFilterDone() {
293 | if (onFilterDoneListener != null) {
294 | onFilterDoneListener.onFilterDone(0, "", "");
295 | }
296 | }
297 |
298 | }
299 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.View;
8 | import android.widget.TextView;
9 | import butterknife.BindView;
10 | import butterknife.ButterKnife;
11 | import com.baiiu.dropdownmenu.entity.FilterUrl;
12 | import com.baiiu.dropdownmenu.fragmentSample.FilterActivity;
13 | import com.baiiu.filter.DropDownMenu;
14 | import com.baiiu.filter.interfaces.OnFilterDoneListener;
15 |
16 | public class MainActivity extends AppCompatActivity implements OnFilterDoneListener, View.OnClickListener {
17 |
18 | @BindView(R.id.dropDownMenu) DropDownMenu dropDownMenu;
19 | @BindView(R.id.mFilterContentView) TextView mFilterContentView;
20 |
21 | @Override protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 | ButterKnife.bind(this);
25 |
26 | Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
27 | setSupportActionBar(toolbar);
28 |
29 | initFilterDropDownView();
30 |
31 | mFilterContentView.setOnClickListener(this);
32 | }
33 |
34 | private void initFilterDropDownView() {
35 | String[] titleList = new String[] { "第一个", "第二个", "第三个", "第四个" };
36 | dropDownMenu.setMenuAdapter(new DropMenuAdapter(this, titleList, this));
37 | }
38 |
39 | @Override public void onFilterDone(int position, String positionTitle, String urlValue) {
40 | if (position != 3) {
41 | dropDownMenu.setPositionIndicatorText(FilterUrl.instance().position, FilterUrl.instance().positionTitle);
42 | }
43 |
44 | dropDownMenu.close();
45 | mFilterContentView.setText(FilterUrl.instance()
46 | .toString());
47 | }
48 |
49 | @Override protected void onDestroy() {
50 | super.onDestroy();
51 | FilterUrl.instance()
52 | .clear();
53 | }
54 |
55 | @Override public void onClick(View view) {
56 | startActivity(new Intent(this, FilterActivity.class));
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/entity/FilterType.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * author: baiiu
7 | * date: on 16/2/19 18:09
8 | * description:
9 | */
10 | public class FilterType {
11 | public String desc;
12 | public List child;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/entity/FilterUrl.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.entity;
2 |
3 | import android.text.TextUtils;
4 |
5 | /**
6 | * 描述:
7 | */
8 | public class FilterUrl {
9 | private volatile static FilterUrl filterUrl;
10 |
11 | private FilterUrl() {
12 | }
13 |
14 | public static FilterUrl instance() {
15 | if (filterUrl == null) {
16 | synchronized (FilterUrl.class) {
17 | if (filterUrl == null) {
18 | filterUrl = new FilterUrl();
19 | }
20 | }
21 | }
22 | return filterUrl;
23 | }
24 |
25 | public String singleListPosition;
26 | public String doubleListLeft;
27 | public String doubleListRight;
28 | public String singleGridPosition;
29 | public String doubleGridTop;
30 | public String doubleGridBottom;
31 |
32 | public int position;
33 | public String positionTitle;
34 |
35 | @Override
36 | public String toString() {
37 | StringBuilder buffer = new StringBuilder();
38 |
39 | if (!TextUtils.isEmpty(singleListPosition)) {
40 | buffer.append("singleListPosition=");
41 | buffer.append(singleListPosition);
42 | buffer.append("\n");
43 | }
44 |
45 |
46 | if (!TextUtils.isEmpty(doubleListLeft)) {
47 | buffer.append("doubleListLeft=");
48 | buffer.append(doubleListLeft);
49 | buffer.append("\n");
50 | }
51 |
52 | if (!TextUtils.isEmpty(doubleListRight)) {
53 | buffer.append("doubleListRight=");
54 | buffer.append(doubleListRight);
55 | buffer.append("\n");
56 | }
57 |
58 | if (!TextUtils.isEmpty(singleGridPosition)) {
59 | buffer.append("singleGridPosition=");
60 | buffer.append(singleGridPosition);
61 | buffer.append("\n");
62 | }
63 |
64 | if (!TextUtils.isEmpty(doubleGridTop)) {
65 | buffer.append("doubleGridTop=");
66 | buffer.append(doubleGridTop);
67 | buffer.append("\n");
68 | }
69 |
70 | if (!TextUtils.isEmpty(doubleGridBottom)) {
71 | buffer.append("doubleGridBottom=");
72 | buffer.append(doubleGridBottom);
73 | buffer.append("\n");
74 | }
75 |
76 | return buffer.toString();
77 | }
78 |
79 | public void clear() {
80 | filterUrl = null;
81 | }
82 |
83 |
84 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/fragmentSample/FilterActivity.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.fragmentSample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | /**
8 | * author: baiiu
9 | * date: on 18/1/8 11:56
10 | * description:
11 | */
12 | public class FilterActivity extends AppCompatActivity {
13 |
14 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | getSupportFragmentManager().beginTransaction()
18 | .replace(android.R.id.content, new FilterFragment(), FilterFragment.class.getCanonicalName())
19 | .commitAllowingStateLoss();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/fragmentSample/FilterFragment.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.fragmentSample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 | import butterknife.BindView;
12 | import butterknife.ButterKnife;
13 | import com.baiiu.dropdownmenu.DropMenuAdapter;
14 | import com.baiiu.dropdownmenu.R;
15 | import com.baiiu.dropdownmenu.entity.FilterUrl;
16 | import com.baiiu.filter.DropDownMenu;
17 | import com.baiiu.filter.interfaces.OnFilterDoneListener;
18 |
19 | /**
20 | * author: baiiu
21 | * date: on 18/1/8 11:52
22 | * description:
23 | */
24 | public class FilterFragment extends Fragment implements OnFilterDoneListener {
25 |
26 | @BindView(R.id.dropDownMenu) DropDownMenu dropDownMenu;
27 | @BindView(R.id.mFilterContentView) TextView mFilterContentView;
28 | @BindView(R.id.toolbar) Toolbar mToolbar;
29 |
30 | @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
31 | @Nullable Bundle savedInstanceState) {
32 |
33 | View view = inflater.inflate(R.layout.activity_main, container, false);
34 | ButterKnife.bind(this, view);
35 |
36 | mToolbar.setTitle(R.string.app_name);
37 |
38 | return view;
39 | }
40 |
41 | @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {
42 | super.onActivityCreated(savedInstanceState);
43 | initFilterDropDownView();
44 | }
45 |
46 | private void initFilterDropDownView() {
47 | String[] titleList = new String[] { "第一个", "第二个", "第三个", "第四个" };
48 | dropDownMenu.setMenuAdapter(new DropMenuAdapter(getContext(), titleList, this));
49 | }
50 |
51 | @Override public void onFilterDone(int position, String positionTitle, String urlValue) {
52 | if (position != 3) {
53 | dropDownMenu.setPositionIndicatorText(FilterUrl.instance().position, FilterUrl.instance().positionTitle);
54 | }
55 |
56 | dropDownMenu.close();
57 | mFilterContentView.setText(FilterUrl.instance()
58 | .toString());
59 | }
60 |
61 | @Override public void onDestroy() {
62 | super.onDestroy();
63 | FilterUrl.instance()
64 | .clear();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/betterDoubleGrid/BetterDoubleGridView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.betterDoubleGrid;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.support.v7.widget.GridLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 | import butterknife.BindView;
14 | import butterknife.ButterKnife;
15 | import butterknife.OnClick;
16 | import com.baiiu.dropdownmenu.R;
17 | import com.baiiu.dropdownmenu.entity.FilterUrl;
18 | import com.baiiu.filter.interfaces.OnFilterDoneListener;
19 | import java.util.List;
20 |
21 | /**
22 | * auther: baiiu
23 | * time: 16/6/5 05 23:03
24 | * description:
25 | */
26 | public class BetterDoubleGridView extends LinearLayout implements View.OnClickListener {
27 |
28 | @BindView(R.id.recyclerView) RecyclerView recyclerView;
29 |
30 | private List mTopGridData;
31 | private List mBottomGridList;
32 | private OnFilterDoneListener mOnFilterDoneListener;
33 |
34 |
35 | public BetterDoubleGridView(Context context) {
36 | this(context, null);
37 | }
38 |
39 | public BetterDoubleGridView(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | init(context);
42 | }
43 |
44 | public BetterDoubleGridView(Context context, AttributeSet attrs, int defStyleAttr) {
45 | super(context, attrs, defStyleAttr);
46 | init(context);
47 | }
48 |
49 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
50 | public BetterDoubleGridView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
51 | super(context, attrs, defStyleAttr, defStyleRes);
52 | init(context);
53 | }
54 |
55 | private void init(Context context) {
56 | setBackgroundColor(Color.WHITE);
57 | inflate(context, R.layout.merge_filter_double_grid, this);
58 | ButterKnife.bind(this, this);
59 | }
60 |
61 |
62 | public BetterDoubleGridView setmTopGridData(List mTopGridData) {
63 | this.mTopGridData = mTopGridData;
64 | return this;
65 | }
66 |
67 | public BetterDoubleGridView setmBottomGridList(List mBottomGridList) {
68 | this.mBottomGridList = mBottomGridList;
69 | return this;
70 | }
71 |
72 | public BetterDoubleGridView build() {
73 |
74 | GridLayoutManager gridLayoutManager = new GridLayoutManager(this.getContext(), 4);
75 | gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
76 | @Override public int getSpanSize(int position) {
77 | if (position == 0 || position == mTopGridData.size() + 1) {
78 | return 4;
79 | }
80 | return 1;
81 | }
82 | });
83 | recyclerView.setLayoutManager(gridLayoutManager);
84 | recyclerView.setAdapter(new DoubleGridAdapter(getContext(), mTopGridData, mBottomGridList, this));
85 |
86 | return this;
87 | }
88 |
89 | private TextView mTopSelectedTextView;
90 | private TextView mBottomSelectedTextView;
91 |
92 | @Override public void onClick(View v) {
93 |
94 | TextView textView = (TextView) v;
95 | String text = (String) textView.getTag();
96 |
97 | if (textView == mTopSelectedTextView) {
98 | mTopSelectedTextView = null;
99 | textView.setSelected(false);
100 | } else if (textView == mBottomSelectedTextView) {
101 | mBottomSelectedTextView = null;
102 | textView.setSelected(false);
103 | } else if (mTopGridData.contains(text)) {
104 | if (mTopSelectedTextView != null) {
105 | mTopSelectedTextView.setSelected(false);
106 | }
107 | mTopSelectedTextView = textView;
108 | textView.setSelected(true);
109 | } else {
110 | if (mBottomSelectedTextView != null) {
111 | mBottomSelectedTextView.setSelected(false);
112 | }
113 | mBottomSelectedTextView = textView;
114 | textView.setSelected(true);
115 | }
116 | }
117 |
118 |
119 | public BetterDoubleGridView setOnFilterDoneListener(OnFilterDoneListener listener) {
120 | mOnFilterDoneListener = listener;
121 | return this;
122 | }
123 |
124 | @OnClick(R.id.bt_confirm) public void clickDone() {
125 |
126 | FilterUrl.instance().doubleGridTop = mTopSelectedTextView == null ? "" : (String) mTopSelectedTextView.getTag();
127 | FilterUrl.instance().doubleGridBottom =
128 | mBottomSelectedTextView == null ? "" : (String) mBottomSelectedTextView.getTag();
129 |
130 | if (mOnFilterDoneListener != null) {
131 | mOnFilterDoneListener.onFilterDone(3, "", "");
132 | }
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/betterDoubleGrid/DoubleGridAdapter.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.betterDoubleGrid;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.baiiu.dropdownmenu.view.betterDoubleGrid.holder.ItemViewHolder;
9 | import com.baiiu.dropdownmenu.view.betterDoubleGrid.holder.TitleViewHolder;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * auther: baiiu
15 | * time: 16/6/5 05 23:28
16 | * description:
17 | */
18 | public class DoubleGridAdapter extends RecyclerView.Adapter {
19 | private static final int TYPE_TITLE = 0;
20 | private static final int TYPE_ITEM = 1;
21 |
22 | private Context mContext;
23 | private List topGridData;
24 | private List bottomGridData;
25 | private View.OnClickListener mListener;
26 |
27 | public DoubleGridAdapter(Context context, List topGridData, List bottomGridList, View.OnClickListener listener) {
28 | this.mContext = context;
29 | this.topGridData = topGridData;
30 | this.bottomGridData = bottomGridList;
31 | this.mListener = listener;
32 | }
33 |
34 | @Override
35 | public int getItemViewType(int position) {
36 | if (position == 0 || position == topGridData.size() + 1) {
37 | return TYPE_TITLE;
38 | }
39 |
40 | return TYPE_ITEM;
41 | }
42 |
43 | @Override
44 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
45 | RecyclerView.ViewHolder holder = null;
46 |
47 | switch (viewType) {
48 | case TYPE_TITLE:
49 | holder = new TitleViewHolder(mContext, parent);
50 | break;
51 | case TYPE_ITEM:
52 | holder = new ItemViewHolder(mContext, parent, mListener);
53 | break;
54 | }
55 |
56 |
57 | return holder;
58 | }
59 |
60 | @Override
61 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
62 | int itemViewType = getItemViewType(position);
63 | switch (itemViewType) {
64 | case TYPE_TITLE:
65 | TitleViewHolder titleViewHolder = (TitleViewHolder) holder;
66 | if (position == 0) {
67 | titleViewHolder.bind("Top");
68 | } else {
69 | titleViewHolder.bind("Bottom");
70 | }
71 | break;
72 | case TYPE_ITEM:
73 | ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
74 | if (position < topGridData.size() + 1) {
75 | itemViewHolder.bind(topGridData.get(position - 1));
76 | } else {
77 | itemViewHolder.bind(bottomGridData.get(position - topGridData.size() - 2));
78 | }
79 | break;
80 | }
81 | }
82 |
83 | @Override
84 | public int getItemCount() {
85 | return topGridData.size() + bottomGridData.size() + 2;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/betterDoubleGrid/holder/ItemViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.betterDoubleGrid.holder;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.baiiu.dropdownmenu.R;
9 | import com.baiiu.filter.util.UIUtil;
10 | import com.baiiu.filter.view.FilterCheckedTextView;
11 |
12 | import butterknife.ButterKnife;
13 |
14 | /**
15 | * auther: baiiu
16 | * time: 16/6/5 05 23:35
17 | * description:
18 | */
19 | public class ItemViewHolder extends RecyclerView.ViewHolder {
20 |
21 | private final FilterCheckedTextView textView;
22 | private View.OnClickListener mListener;
23 |
24 | public ItemViewHolder(Context mContext, ViewGroup parent, View.OnClickListener mListener) {
25 | super(UIUtil.infalte(mContext, R.layout.holder_item, parent));
26 | textView = ButterKnife.findById(itemView, R.id.tv_item);
27 | this.mListener = mListener;
28 | }
29 |
30 |
31 | public void bind(String s) {
32 | textView.setText(s);
33 | textView.setTag(s);
34 | textView.setOnClickListener(mListener);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/betterDoubleGrid/holder/TitleViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.betterDoubleGrid.holder;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.ViewGroup;
6 | import android.widget.TextView;
7 |
8 | import com.baiiu.dropdownmenu.R;
9 | import com.baiiu.filter.util.UIUtil;
10 |
11 | /**
12 | * auther: baiiu
13 | * time: 16/6/5 05 23:30
14 | * description:
15 | */
16 | public class TitleViewHolder extends RecyclerView.ViewHolder {
17 |
18 | public TitleViewHolder(Context mContext, ViewGroup parent) {
19 | super(UIUtil.infalte(mContext, R.layout.holder_title, parent));
20 | }
21 |
22 |
23 | public void bind(String s) {
24 | ((TextView) itemView).setText(s);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/doubleGrid/DoubleGridView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.doubleGrid;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.Gravity;
6 | import android.view.View;
7 | import android.widget.AbsListView;
8 | import android.widget.AdapterView;
9 | import android.widget.Button;
10 | import android.widget.ScrollView;
11 | import butterknife.BindView;
12 | import butterknife.ButterKnife;
13 | import com.baiiu.dropdownmenu.R;
14 | import com.baiiu.dropdownmenu.entity.FilterUrl;
15 | import com.baiiu.filter.adapter.SimpleTextAdapter;
16 | import com.baiiu.filter.interfaces.OnFilterDoneListener;
17 | import com.baiiu.filter.util.CommonUtil;
18 | import com.baiiu.filter.util.UIUtil;
19 | import com.baiiu.filter.view.FilterCheckedTextView;
20 | import java.util.List;
21 |
22 | /**
23 | * Created by baiiu on 15/12/22.
24 | * 筛选器GridView
25 | */
26 | public class DoubleGridView extends ScrollView implements View.OnClickListener {
27 |
28 | @BindView(R.id.grid_top) GridViewInScrollView mTopGrid;
29 | @BindView(R.id.grid_bottom) GridViewInScrollView mBottomGrid;
30 | @BindView(R.id.bt_confirm) Button bt_confirm;
31 |
32 | private SimpleTextAdapter mTopAdapter;
33 | private SimpleTextAdapter mBottomAdapter;
34 |
35 | private OnFilterDoneListener onFilterDoneListener;
36 |
37 | public DoubleGridView(Context context) {
38 | this(context, null);
39 | }
40 |
41 | public DoubleGridView(Context context, AttributeSet attrs) {
42 | super(context, attrs);
43 | init(context);
44 | }
45 |
46 | private void init(Context context) {
47 | inflate(context, R.layout.merge_filter_third, this);
48 | setBackgroundResource(android.R.color.white);
49 |
50 | ButterKnife.bind(this, this);
51 |
52 | bt_confirm.setOnClickListener(this);
53 |
54 | initAdapter(context);
55 |
56 | mTopGrid.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
57 | mBottomGrid.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
58 |
59 | mTopGrid.setAdapter(mTopAdapter);
60 | mBottomGrid.setAdapter(mBottomAdapter);
61 | }
62 |
63 | private void initAdapter(Context context) {
64 |
65 | mTopAdapter = new SimpleTextAdapter(null, context) {
66 | @Override public String provideText(String phase) {
67 | return phase;
68 | }
69 |
70 | @Override protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
71 | checkedTextView.setPadding(0, UIUtil.dp(context, 3), 0, UIUtil.dp(context, 3));
72 | checkedTextView.setGravity(Gravity.CENTER);
73 | checkedTextView.setBackgroundResource(R.drawable.selector_filter_grid);
74 | }
75 | };
76 |
77 | mBottomAdapter = new SimpleTextAdapter(null, context) {
78 | @Override public String provideText(String area) {
79 | return area;
80 | }
81 |
82 | @Override protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
83 | checkedTextView.setPadding(0, UIUtil.dp(context, 3), 0, UIUtil.dp(context, 3));
84 | checkedTextView.setBackgroundResource(R.drawable.selector_filter_grid);
85 | checkedTextView.setGravity(Gravity.CENTER);
86 | }
87 | };
88 |
89 | mTopGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
90 | @Override public void onItemClick(AdapterView> parent, View view, int position, long id) {
91 | }
92 | });
93 | }
94 |
95 | public void setTopGridData(List list) {
96 | if (CommonUtil.isEmpty(list)) {
97 | return;
98 | }
99 |
100 | mTopAdapter.setList(list);
101 | }
102 |
103 | public void setBottomGridList(List list) {
104 | if (CommonUtil.isEmpty(list)) {
105 | return;
106 | }
107 |
108 | mBottomAdapter.setList(list);
109 | }
110 |
111 | @Override public void onClick(View v) {
112 | int topPosition = mTopGrid.getCheckedItemPosition();
113 | topPosition = topPosition == -1 ? 0 : topPosition;
114 |
115 | int bottomPosition = mBottomGrid.getCheckedItemPosition();
116 | bottomPosition = bottomPosition == -1 ? 0 : bottomPosition;
117 |
118 | String financePhase = mTopAdapter.getItem(topPosition);
119 | String area = mBottomAdapter.getItem(bottomPosition);
120 |
121 | FilterUrl.instance().doubleGridTop = financePhase;
122 | FilterUrl.instance().doubleGridBottom = area;
123 |
124 | if (onFilterDoneListener != null) {
125 | onFilterDoneListener.onFilterDone(3, "", "");
126 | }
127 | }
128 |
129 | public void setOnFilterDoneListener(OnFilterDoneListener listener) {
130 | onFilterDoneListener = listener;
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/app/src/main/java/com/baiiu/dropdownmenu/view/doubleGrid/GridViewInScrollView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.dropdownmenu.view.doubleGrid;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.GridView;
6 |
7 | /**
8 | * 描述:嵌套在ScrollView中的GridView,使得数据完全展示
9 | */
10 | public class GridViewInScrollView extends GridView {
11 |
12 | public GridViewInScrollView(Context context) {
13 | super(context);
14 | }
15 |
16 | public GridViewInScrollView(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public GridViewInScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | }
23 |
24 | @Override
25 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
26 | if (isInEditMode()) {
27 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
28 | return;
29 | }
30 |
31 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
32 | super.onMeasure(widthMeasureSpec, expandSpec);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/news_article_icon_gray_line_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rect_blue_stroke.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rect_grey_stroke.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_double_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_filter_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
21 |
22 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/holder_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/holder_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/merge_filter_double_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
15 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/merge_filter_third.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
13 |
14 |
15 |
21 |
22 |
23 |
35 |
36 |
37 |
44 |
45 |
46 |
58 |
59 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #cccccc
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FilterDropDownMenu
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.0.1'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | google()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/filter-lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/filter-lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 |
6 | defaultConfig {
7 | minSdkVersion 15
8 | targetSdkVersion 25
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | }
19 |
20 | dependencies {
21 | implementation fileTree(dir: 'libs', include: ['*.jar'])
22 | testImplementation 'junit:junit:4.12'
23 | implementation 'com.android.support:appcompat-v7:25.4.0'
24 | }
25 |
--------------------------------------------------------------------------------
/filter-lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/baiiu/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/filter-lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/DropDownMenu.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.view.animation.Animation;
8 | import android.view.animation.AnimationUtils;
9 | import android.widget.FrameLayout;
10 | import android.widget.RelativeLayout;
11 |
12 | import com.baiiu.filter.adapter.MenuAdapter;
13 | import com.baiiu.filter.util.SimpleAnimationListener;
14 | import com.baiiu.filter.util.UIUtil;
15 | import com.baiiu.filter.view.FixedTabIndicator;
16 |
17 |
18 | /**
19 | * Created by baiiu.
20 | * 筛选器
21 | */
22 | public class DropDownMenu extends RelativeLayout implements View.OnClickListener, FixedTabIndicator.OnItemClickListener {
23 |
24 | private FixedTabIndicator fixedTabIndicator;
25 | private FrameLayout frameLayoutContainer;
26 |
27 | private View currentView;
28 |
29 | private Animation dismissAnimation;
30 | private Animation occurAnimation;
31 | private Animation alphaDismissAnimation;
32 | private Animation alphaOccurAnimation;
33 |
34 | private MenuAdapter mMenuAdapter;
35 |
36 | public DropDownMenu(Context context) {
37 | this(context, null);
38 | }
39 |
40 | public DropDownMenu(Context context, AttributeSet attrs) {
41 | super(context, attrs);
42 | init(context);
43 | }
44 |
45 | public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
46 | super(context, attrs, defStyleAttr);
47 | init(context);
48 | }
49 |
50 | private void init(Context context) {
51 | setBackgroundColor(Color.WHITE);
52 | }
53 |
54 | @Override
55 | protected void onFinishInflate() {
56 | super.onFinishInflate();
57 | setContentView(findViewById(R.id.mFilterContentView));
58 | }
59 |
60 | public void setContentView(View contentView) {
61 | removeAllViews();
62 |
63 | /*
64 | * 1.顶部筛选条
65 | */
66 | fixedTabIndicator = new FixedTabIndicator(getContext());
67 | fixedTabIndicator.setId(R.id.fixedTabIndicator);
68 | addView(fixedTabIndicator, -1, UIUtil.dp(getContext(), 50));
69 |
70 | LayoutParams params = new LayoutParams(-1, -1);
71 | params.addRule(BELOW, R.id.fixedTabIndicator);
72 |
73 | /*
74 | * 2.添加contentView,内容界面
75 | */
76 | addView(contentView, params);
77 |
78 | /*
79 | * 3.添加展开页面,装载筛选器list
80 | */
81 | frameLayoutContainer = new FrameLayout(getContext());
82 | frameLayoutContainer.setBackgroundColor(getResources().getColor(R.color.black_p50));
83 | addView(frameLayoutContainer, params);
84 |
85 | frameLayoutContainer.setVisibility(GONE);
86 |
87 | initListener();
88 | initAnimation();
89 | }
90 |
91 | public void setMenuAdapter(MenuAdapter adapter) {
92 | verifyContainer();
93 |
94 | mMenuAdapter = adapter;
95 | verifyMenuAdapter();
96 |
97 | //1.设置title
98 | fixedTabIndicator.setTitles(mMenuAdapter);
99 |
100 | //2.添加view
101 | setPositionView();
102 | }
103 |
104 | /**
105 | * 可以提供两种方式:
106 | * 1.缓存所有view,
107 | * 2.只保存当前view
108 | *
109 | * 此处选择第二种
110 | */
111 | public void setPositionView() {
112 | int count = mMenuAdapter.getMenuCount();
113 | for (int position = 0; position < count; ++position) {
114 | setPositionView(position, findViewAtPosition(position), mMenuAdapter.getBottomMargin(position));
115 | }
116 | }
117 |
118 | public View findViewAtPosition(int position) {
119 | verifyContainer();
120 |
121 | View view = frameLayoutContainer.getChildAt(position);
122 | if (view == null) {
123 | view = mMenuAdapter.getView(position, frameLayoutContainer);
124 | }
125 |
126 | return view;
127 | }
128 |
129 | private void setPositionView(int position, View view, int bottomMargin) {
130 | verifyContainer();
131 | if (view == null || position > mMenuAdapter.getMenuCount() || position < 0) {
132 | throw new IllegalStateException("the view at " + position + " cannot be null");
133 | }
134 |
135 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-1, -2);
136 | params.bottomMargin = bottomMargin;//添加距离底部高度
137 | frameLayoutContainer.addView(view, position, params);
138 | view.setVisibility(GONE);
139 | }
140 |
141 |
142 | public boolean isShowing() {
143 | verifyContainer();
144 | return frameLayoutContainer.isShown();
145 | }
146 |
147 | public boolean isClosed() {
148 | return !isShowing();
149 | }
150 |
151 | public void close() {
152 | if (isClosed()) {
153 | return;
154 | }
155 |
156 | frameLayoutContainer.startAnimation(alphaDismissAnimation);
157 | fixedTabIndicator.resetCurrentPos();
158 |
159 | if (currentView != null) {
160 | currentView.startAnimation(dismissAnimation);
161 | }
162 | }
163 |
164 |
165 | public void setPositionIndicatorText(int position, String text) {
166 | verifyContainer();
167 | fixedTabIndicator.setPositionText(position, text);
168 | }
169 |
170 | public void setCurrentIndicatorText(String text) {
171 | verifyContainer();
172 | fixedTabIndicator.setCurrentText(text);
173 | }
174 |
175 | //=======================之上对外暴漏方法=======================================
176 | private void initListener() {
177 | frameLayoutContainer.setOnClickListener(this);
178 | fixedTabIndicator.setOnItemClickListener(this);
179 | }
180 |
181 | @Override
182 | public void onClick(View v) {
183 | if (isShowing()) {
184 | close();
185 | }
186 | }
187 |
188 | @Override
189 | public void onItemClick(View v, int position, boolean open) {
190 | if (open) {
191 | close();
192 | } else {
193 |
194 |
195 | currentView = frameLayoutContainer.getChildAt(position);
196 |
197 | if (currentView == null) {
198 | return;
199 | }
200 |
201 |
202 | frameLayoutContainer.getChildAt(fixedTabIndicator.getLastIndicatorPosition()).setVisibility(View.GONE);
203 | frameLayoutContainer.getChildAt(position).setVisibility(View.VISIBLE);
204 |
205 |
206 | if (isClosed()) {
207 | frameLayoutContainer.setVisibility(VISIBLE);
208 | frameLayoutContainer.startAnimation(alphaOccurAnimation);
209 |
210 | //可移出去,进行每次展出
211 | currentView.startAnimation(occurAnimation);
212 | }
213 |
214 |
215 | }
216 | }
217 |
218 |
219 | private void initAnimation() {
220 | occurAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.top_in);
221 |
222 | SimpleAnimationListener listener = new SimpleAnimationListener() {
223 | @Override
224 | public void onAnimationEnd(Animation animation) {
225 | frameLayoutContainer.setVisibility(GONE);
226 | }
227 | };
228 |
229 | dismissAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.top_out);
230 | dismissAnimation.setAnimationListener(listener);
231 |
232 |
233 | alphaDismissAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.alpha_to_zero);
234 | alphaDismissAnimation.setDuration(300);
235 | alphaDismissAnimation.setAnimationListener(listener);
236 |
237 | alphaOccurAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.alpha_to_one);
238 | alphaOccurAnimation.setDuration(300);
239 | }
240 |
241 | private void verifyMenuAdapter() {
242 | if (mMenuAdapter == null) {
243 | throw new IllegalStateException("the menuAdapter is null");
244 | }
245 | }
246 |
247 | private void verifyContainer() {
248 | if (frameLayoutContainer == null) {
249 | throw new IllegalStateException("you must initiation setContentView() before");
250 | }
251 | }
252 |
253 |
254 | }
255 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/adapter/BaseBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public abstract class BaseBaseAdapter extends BaseAdapter {
12 |
13 | public List list;
14 |
15 | protected Context context;
16 |
17 | public BaseBaseAdapter(List list, Context context) {
18 | super();
19 | setList(list);
20 | this.context = context;
21 | }
22 |
23 | /**
24 | * 设置数据。
25 | * 会清空原集合所有数据,后添加。
26 | *
27 | * @param list
28 | */
29 | public void setList(List list) {
30 |
31 | if (list == null) {
32 | list = new ArrayList(0);
33 | }
34 |
35 | this.list = list;
36 |
37 | notifyDataSetChanged();
38 | }
39 |
40 | public List getList() {
41 | return list;
42 | }
43 |
44 | /**
45 | * 添加集合数据到原集合首位,下拉刷新时使用
46 | *
47 | * @param list
48 | */
49 | public void addToFirst(List list) {
50 | if (list == null)
51 | return;
52 | this.list.addAll(0, list);
53 | notifyDataSetChanged();
54 | }
55 |
56 | public void addToFirst(T t) {
57 | if (t == null)
58 | return;
59 | this.list.add(0, t);
60 | notifyDataSetChanged();
61 | }
62 |
63 | /**
64 | * 添加数据到末尾,用于上拉加载等情况。
65 | * 不清楚原集合,添加到末尾。
66 | *
67 | * @param list
68 | */
69 | public void addToLast(List list) {
70 | if (list == null)
71 | return;
72 | this.list.addAll(list);
73 | notifyDataSetChanged();
74 | }
75 |
76 | /**
77 | * 添加元素到集合末尾
78 | *
79 | * @param t
80 | */
81 | public void addToLast(T t) {
82 | if (t == null)
83 | return;
84 | this.list.add(t);
85 | notifyDataSetChanged();
86 | }
87 |
88 | @Override
89 | public int getCount() {
90 | return list.size();
91 | }
92 |
93 | @Override
94 | public T getItem(int position) {
95 | return list.get(position);
96 | }
97 |
98 | @Override
99 | public long getItemId(int position) {
100 | return position;
101 | }
102 |
103 | @Override
104 | public abstract View getView(int position, View convertView,
105 | ViewGroup parent);
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/adapter/MenuAdapter.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.adapter;
2 |
3 | import android.view.View;
4 | import android.widget.FrameLayout;
5 |
6 | /**
7 | * author: baiiu
8 | * date: on 16/1/17 21:03
9 | * description:
10 | */
11 | public interface MenuAdapter {
12 |
13 | /**
14 | * 设置筛选条目个数
15 | */
16 | int getMenuCount();
17 |
18 | /**
19 | * 设置每个筛选器默认Title
20 | */
21 | String getMenuTitle(int position);
22 |
23 | /**
24 | * 设置每个筛选条目距离底部距离
25 | */
26 | int getBottomMargin(int position);
27 |
28 |
29 | /**
30 | * 设置每个筛选条目的View
31 | */
32 | View getView(int position, FrameLayout parentContainer);
33 | }
34 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/adapter/SimpleTextAdapter.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.baiiu.filter.R;
9 | import com.baiiu.filter.util.UIUtil;
10 | import com.baiiu.filter.view.FilterCheckedTextView;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * Created by baiiu on 15/12/23.
16 | * 菜单条目适配器
17 | */
18 | public abstract class SimpleTextAdapter extends BaseBaseAdapter {
19 |
20 | private final LayoutInflater inflater;
21 |
22 | public SimpleTextAdapter(List list, Context context) {
23 | super(list, context);
24 | inflater = LayoutInflater.from(context);
25 | }
26 |
27 | public static class FilterItemHolder {
28 | FilterCheckedTextView checkedTextView;
29 | }
30 |
31 | @Override
32 | public View getView(int position, View convertView, ViewGroup parent) {
33 | FilterItemHolder holder;
34 |
35 | if (convertView == null) {
36 | convertView = inflater.inflate(R.layout.lv_item_filter, parent, false);
37 |
38 | holder = new FilterItemHolder();
39 | holder.checkedTextView = (FilterCheckedTextView) convertView;
40 | holder.checkedTextView.setPadding(0, UIUtil.dp(context, 15), 0, UIUtil.dp(context, 15));
41 | initCheckedTextView(holder.checkedTextView);
42 |
43 | convertView.setTag(holder);
44 | } else {
45 | holder = (FilterItemHolder) convertView.getTag();
46 | }
47 |
48 | T t = list.get(position);
49 | holder.checkedTextView.setText(provideText(t));
50 |
51 | return convertView;
52 | }
53 |
54 | public abstract String provideText(T t);
55 |
56 | protected void initCheckedTextView(FilterCheckedTextView checkedTextView) {
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/interfaces/OnFilterDoneListener.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.interfaces;
2 |
3 | /**
4 | * author: baiiu
5 | * date: on 16/1/21 23:30
6 | * description:
7 | */
8 | public interface OnFilterDoneListener {
9 | void onFilterDone(int position, String positionTitle, String urlValue);
10 | }
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/interfaces/OnFilterItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.interfaces;
2 |
3 | /**
4 | * author: baiiu
5 | * date: on 16/2/16 15:49
6 | * description:
7 | */
8 | public interface OnFilterItemClickListener {
9 | void onItemClick(DATA item);
10 | }
11 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/typeview/DoubleListView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.typeview;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.AdapterView;
7 | import android.widget.LinearLayout;
8 | import android.widget.ListView;
9 |
10 | import com.baiiu.filter.R;
11 | import com.baiiu.filter.adapter.BaseBaseAdapter;
12 | import com.baiiu.filter.adapter.SimpleTextAdapter;
13 | import com.baiiu.filter.util.CommonUtil;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * Created by baiiu on 15/12/17.
19 | * 双列ListView
20 | */
21 | public class DoubleListView extends LinearLayout implements AdapterView.OnItemClickListener {
22 |
23 | private BaseBaseAdapter mLeftAdapter;
24 | private BaseBaseAdapter mRightAdapter;
25 | private ListView lv_left;
26 | private ListView lv_right;
27 |
28 | public DoubleListView(Context context) {
29 | this(context, null);
30 | }
31 |
32 | public DoubleListView(Context context, AttributeSet attrs) {
33 | super(context, attrs);
34 | init(context);
35 | }
36 |
37 | public DoubleListView(Context context, AttributeSet attrs, int defStyleAttr) {
38 | super(context, attrs, defStyleAttr);
39 | init(context);
40 | }
41 |
42 | private void init(Context context) {
43 | setOrientation(VERTICAL);
44 | inflate(context, R.layout.merge_filter_list, this);
45 |
46 | lv_left = (ListView) findViewById(R.id.lv_left);
47 | lv_right = (ListView) findViewById(R.id.lv_right);
48 | lv_left.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
49 | lv_right.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
50 |
51 | lv_left.setOnItemClickListener(this);
52 | lv_right.setOnItemClickListener(this);
53 | }
54 |
55 |
56 | public DoubleListView leftAdapter(SimpleTextAdapter leftAdapter) {
57 | mLeftAdapter = leftAdapter;
58 | lv_left.setAdapter(leftAdapter);
59 | return this;
60 | }
61 |
62 | public DoubleListView rightAdapter(SimpleTextAdapter rightAdapter) {
63 | mRightAdapter = rightAdapter;
64 | lv_right.setAdapter(rightAdapter);
65 | return this;
66 | }
67 |
68 | public void setLeftList(List list, int checkedPosition) {
69 | mLeftAdapter.setList(list);
70 |
71 | if (checkedPosition != -1) {
72 | // lv_left.performItemClick(mLeftAdapter.getView(checkedPositoin, null, null), checkedPositoin, mLeftAdapter.getItemId(checkedPositoin));//调用此方法相当于点击.第一次进来时会触发重复加载.
73 | lv_left.setItemChecked(checkedPosition, true);
74 | }
75 | }
76 |
77 | public void setRightList(List list, int checkedPosition) {
78 | mRightAdapter.setList(list);
79 | if (checkedPosition != -1) {
80 | lv_right.setItemChecked(checkedPosition, true);
81 | }
82 | }
83 |
84 | private OnLeftItemClickListener mOnLeftItemClickListener;
85 | private OnRightItemClickListener mOnRightItemClickListener;
86 |
87 | public interface OnLeftItemClickListener {
88 | List provideRightList(LEFTD leftAdapter, int position);
89 | }
90 |
91 | public interface OnRightItemClickListener {
92 | void onRightItemClick(LEFTD item, RIGHTD childItem);
93 | }
94 |
95 | public DoubleListView onLeftItemClickListener(OnLeftItemClickListener onLeftItemClickListener) {
96 | this.mOnLeftItemClickListener = onLeftItemClickListener;
97 | return this;
98 | }
99 |
100 | public DoubleListView onRightItemClickListener(OnRightItemClickListener onRightItemClickListener) {
101 | this.mOnRightItemClickListener = onRightItemClickListener;
102 | return this;
103 | }
104 |
105 | public ListView getLeftListView() {
106 | return lv_left;
107 | }
108 |
109 | public ListView getRightListView() {
110 | return lv_right;
111 | }
112 |
113 | //========================点击事件===================================
114 | private int mRightLastChecked;
115 | private int mLeftLastPosition;
116 | private int mLeftLastCheckedPosition;
117 |
118 | @Override
119 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
120 | if (CommonUtil.isFastDoubleClick()) {
121 | return;
122 | }
123 |
124 | if (mLeftAdapter == null || mRightAdapter == null) {
125 | return;
126 | }
127 |
128 | if (parent == lv_left) {
129 | mLeftLastPosition = position;
130 |
131 | if (mOnLeftItemClickListener != null) {
132 | LEFTD item = mLeftAdapter.getItem(position);
133 |
134 | List rightds = mOnLeftItemClickListener.provideRightList(item, position);
135 | mRightAdapter.setList(rightds);
136 |
137 | if (CommonUtil.isEmpty(rightds)) {
138 | //当前点的就是这个条目
139 | mLeftLastCheckedPosition = -1;
140 | }
141 | }
142 |
143 | lv_right.setItemChecked(mRightLastChecked, mLeftLastCheckedPosition == position);
144 | } else {
145 | mLeftLastCheckedPosition = mLeftLastPosition;
146 | mRightLastChecked = position;
147 |
148 | if (mOnRightItemClickListener != null) {
149 | mOnRightItemClickListener.onRightItemClick(mLeftAdapter.getItem(mLeftLastCheckedPosition), mRightAdapter.getItem(mRightLastChecked));
150 | }
151 | }
152 | }
153 |
154 |
155 | }
156 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/typeview/SingleGridView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.typeview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.GridView;
10 | import android.widget.ListView;
11 |
12 | import com.baiiu.filter.adapter.BaseBaseAdapter;
13 | import com.baiiu.filter.interfaces.OnFilterItemClickListener;
14 | import com.baiiu.filter.util.CommonUtil;
15 | import com.baiiu.filter.util.UIUtil;
16 |
17 | import java.util.List;
18 |
19 | /**
20 | * author: baiiu
21 | * date: on 16/2/16 15:46
22 | * description:
23 | */
24 | public class SingleGridView extends GridView implements AdapterView.OnItemClickListener {
25 |
26 | private BaseBaseAdapter mAdapter;
27 | private OnFilterItemClickListener mOnItemClickListener;
28 |
29 | public SingleGridView(Context context) {
30 | this(context, null);
31 | }
32 |
33 | public SingleGridView(Context context, AttributeSet attrs) {
34 | super(context, attrs);
35 | init(context);
36 | }
37 |
38 | public SingleGridView(Context context, AttributeSet attrs, int defStyleAttr) {
39 | super(context, attrs, defStyleAttr);
40 | init(context);
41 | }
42 |
43 | private void init(Context context) {
44 | setChoiceMode(ListView.CHOICE_MODE_SINGLE);
45 | setSelector(new ColorDrawable(Color.TRANSPARENT));
46 | setNumColumns(3);
47 | setBackgroundColor(Color.WHITE);
48 | setSmoothScrollbarEnabled(false);
49 |
50 |
51 | int dp = UIUtil.dp(context, 15);
52 |
53 | setVerticalSpacing(dp);
54 | setHorizontalSpacing(dp);
55 | setPadding(dp, dp, dp, dp);
56 |
57 | setOnItemClickListener(this);
58 | }
59 |
60 | public SingleGridView adapter(BaseBaseAdapter adapter) {
61 | this.mAdapter = adapter;
62 | setAdapter(adapter);
63 | return this;
64 | }
65 |
66 | public SingleGridView onItemClick(OnFilterItemClickListener onItemClickListener) {
67 | this.mOnItemClickListener = onItemClickListener;
68 | return this;
69 | }
70 |
71 |
72 | public void setList(List list, int checkedPositoin) {
73 | mAdapter.setList(list);
74 |
75 | if (checkedPositoin != -1) {
76 | setItemChecked(checkedPositoin, true);
77 | }
78 | }
79 |
80 | @Override
81 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
82 | if (CommonUtil.isFastDoubleClick()) {
83 | return;
84 | }
85 |
86 | DATA item = mAdapter.getItem(position);
87 |
88 | if (mOnItemClickListener != null) {
89 | mOnItemClickListener.onItemClick(item);
90 | }
91 | }
92 |
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/typeview/SingleListView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.typeview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.drawable.ColorDrawable;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 | import android.widget.ListView;
10 |
11 | import com.baiiu.filter.adapter.BaseBaseAdapter;
12 | import com.baiiu.filter.interfaces.OnFilterItemClickListener;
13 | import com.baiiu.filter.util.CommonUtil;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * Created by baiiu on 15/12/17.
19 | * 双列ListView
20 | */
21 | public class SingleListView extends ListView implements AdapterView.OnItemClickListener {
22 |
23 | private BaseBaseAdapter mAdapter;
24 | private OnFilterItemClickListener mOnItemClickListener;
25 |
26 | public SingleListView(Context context) {
27 | this(context, null);
28 | }
29 |
30 | public SingleListView(Context context, AttributeSet attrs) {
31 | super(context, attrs);
32 | init(context);
33 | }
34 |
35 | public SingleListView(Context context, AttributeSet attrs, int defStyleAttr) {
36 | super(context, attrs, defStyleAttr);
37 | init(context);
38 | }
39 |
40 | private void init(Context context) {
41 | setChoiceMode(ListView.CHOICE_MODE_SINGLE);
42 | setDivider(null);
43 | setDividerHeight(0);
44 | setSelector(new ColorDrawable(Color.TRANSPARENT));
45 |
46 | setOnItemClickListener(this);
47 | }
48 |
49 |
50 | public SingleListView adapter(BaseBaseAdapter adapter) {
51 | this.mAdapter = adapter;
52 | setAdapter(adapter);
53 | return this;
54 | }
55 |
56 | public SingleListView onItemClick(OnFilterItemClickListener onItemClickListener) {
57 | this.mOnItemClickListener = onItemClickListener;
58 | return this;
59 | }
60 |
61 | public void setList(List list, int checkedPositoin) {
62 | mAdapter.setList(list);
63 |
64 | if (checkedPositoin != -1) {
65 | setItemChecked(checkedPositoin, true);
66 | }
67 | }
68 |
69 |
70 | @Override
71 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
72 | if (CommonUtil.isFastDoubleClick()) {
73 | return;
74 | }
75 |
76 | DATA item = mAdapter.getItem(position);
77 | if (mOnItemClickListener != null) {
78 | mOnItemClickListener.onItemClick(item);
79 | }
80 | }
81 |
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/util/CommonUtil.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.util;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by baiiu on 15/11/25.
10 | * 简单的通用util
11 | */
12 | public class CommonUtil {
13 |
14 | public static boolean isEmpty(List list) {
15 | return list == null || list.isEmpty();
16 | }
17 |
18 | public static boolean notEmpty(List list) {
19 | return !isEmpty(list);
20 | }
21 |
22 | //全部为空
23 | public static boolean isAllEmpty(List... lists) {
24 | List booleans = new ArrayList<>();
25 |
26 | for (List list : lists) {
27 | if (isEmpty(list)) {
28 | booleans.add(Boolean.TRUE);
29 | }
30 | }
31 |
32 | return notEmpty(booleans) && booleans.contains(Boolean.FALSE);
33 | }
34 |
35 | //只有一个为空
36 | public static boolean isOneEmpty(List... lists) {
37 | for (List list : lists) {
38 | if (isEmpty(list)) {
39 | return true;
40 | }
41 | }
42 |
43 | return false;
44 | }
45 |
46 |
47 | //====================================================================
48 | //====================================================================
49 |
50 | public static boolean isEmpty(String s) {
51 | return s == null || TextUtils.isEmpty(s);
52 | }
53 |
54 | public static boolean notEmpty(String s) {
55 | return s != null && !TextUtils.isEmpty(s.trim());
56 | }
57 |
58 | public static boolean isAllEmpty(String... strings) {
59 | List booleans = new ArrayList<>();
60 |
61 | for (String s : strings) {
62 | booleans.add(CommonUtil.isEmpty(s));
63 | }
64 |
65 | return notEmpty(booleans) && booleans.contains(Boolean.FALSE);
66 | }
67 |
68 | //只有一个为空
69 | public static boolean isOneEmpty(String... strings) {
70 | for (String s : strings) {
71 | if (isEmpty(s)) {
72 | return true;
73 | }
74 | }
75 |
76 | return false;
77 | }
78 |
79 | public static long mLastClickTime;
80 |
81 | public static boolean isFastDoubleClick() {
82 | long time = System.currentTimeMillis();
83 | long timeD = time - mLastClickTime;
84 | if (0 < timeD && timeD < 500) {
85 | return true;
86 | }
87 | mLastClickTime = time;
88 | return false;
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/util/SimpleAnimationListener.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.util;
2 |
3 | import android.view.animation.Animation;
4 |
5 | /**
6 | * author: baiiu
7 | * date: on 15/12/17 13:48
8 | * description:
9 | */
10 | public class SimpleAnimationListener implements Animation.AnimationListener {
11 | @Override
12 | public void onAnimationStart(Animation animation) {
13 |
14 | }
15 |
16 | @Override
17 | public void onAnimationEnd(Animation animation) {
18 |
19 | }
20 |
21 | @Override
22 | public void onAnimationRepeat(Animation animation) {
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/util/UIUtil.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.util;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.LayoutRes;
5 | import android.util.TypedValue;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | /**
11 | * author: baiiu
12 | * date: on 16/2/16 13:55
13 | * description:
14 | */
15 | public class UIUtil {
16 |
17 | public static int dp(Context context, int dp) {
18 | return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
19 | dp, context.getResources().getDisplayMetrics()) + 0.5F);
20 | }
21 |
22 |
23 | public static View infalte(Context context, @LayoutRes int layoutId, ViewGroup parent) {
24 | return LayoutInflater.from(context).inflate(layoutId, parent, false);
25 |
26 | }
27 |
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/view/FilterCheckedTextView.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.Checkable;
6 | import android.widget.TextView;
7 |
8 | /**
9 | * author: baiiu
10 | * date: on 16/1/17 21:04
11 | * description:
12 | */
13 |
14 | public class FilterCheckedTextView extends TextView implements Checkable {
15 | private boolean mChecked;
16 |
17 | public FilterCheckedTextView(Context context) {
18 | this(context, null);
19 | }
20 |
21 | public FilterCheckedTextView(Context context, AttributeSet attrs) {
22 | this(context, attrs, 0);
23 | }
24 |
25 | public FilterCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
26 | super(context, attrs, defStyleAttr);
27 | }
28 |
29 | @Override
30 | public void setChecked(boolean checked) {
31 | if (checked != mChecked) {
32 | mChecked = checked;
33 | refreshDrawableState();
34 | }
35 | }
36 |
37 | @Override
38 | public boolean isChecked() {
39 | return mChecked;
40 | }
41 |
42 | @Override
43 | public void toggle() {
44 | setChecked(!mChecked);
45 | }
46 |
47 | private static final int[] CHECKED_STATE_SET = {
48 | android.R.attr.state_checked
49 | };
50 |
51 | @Override
52 | protected int[] onCreateDrawableState(int extraSpace) {
53 | final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
54 | if (isChecked()) {
55 | mergeDrawableStates(drawableState, CHECKED_STATE_SET);
56 | }
57 | return drawableState;
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/filter-lib/src/main/java/com/baiiu/filter/view/FixedTabIndicator.java:
--------------------------------------------------------------------------------
1 | package com.baiiu.filter.view;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.drawable.Drawable;
8 | import android.text.TextUtils;
9 | import android.util.AttributeSet;
10 | import android.util.TypedValue;
11 | import android.view.Gravity;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.LinearLayout;
15 | import android.widget.RelativeLayout;
16 | import android.widget.TextView;
17 |
18 | import com.baiiu.filter.R;
19 | import com.baiiu.filter.adapter.MenuAdapter;
20 | import com.baiiu.filter.util.UIUtil;
21 |
22 | import java.util.Arrays;
23 | import java.util.List;
24 |
25 | public class FixedTabIndicator extends LinearLayout {
26 |
27 | private Context context;
28 | private int mTabVisibleCount = 4;// tab数量
29 |
30 | /*
31 | * 分割线
32 | */
33 | private Paint mDividerPaint;
34 | private int mDividerColor = 0xFFdddddd;// 分割线颜色
35 | private int mDividerPadding = 13;// 分割线距离上下padding
36 |
37 | /*
38 | * 上下两条线
39 | */
40 | private Paint mLinePaint;
41 | private float mLineHeight = 1;
42 | private int mLineColor = 0xFFeeeeee;
43 |
44 |
45 | private int mTabTextSize = 13;// 指针文字的大小,sp
46 | private int mTabDefaultColor = 0xFF666666;// 未选中默认颜色
47 | private int mTabSelectedColor = 0xFF008DF2;// 指针选中颜色
48 | private int drawableRight = 10;
49 |
50 | private int measureHeight;
51 | private int measuredWidth;
52 |
53 | private int mTabCount;// 设置的条目数量
54 | private int mCurrentIndicatorPosition;// 上一个指针选中条目
55 | private int mLastIndicatorPosition;// 上一个指针选中条目
56 | private OnItemClickListener mOnItemClickListener;
57 |
58 |
59 | public FixedTabIndicator(Context context) {
60 | this(context, null);
61 | }
62 |
63 | public FixedTabIndicator(Context context, AttributeSet attrs) {
64 | super(context, attrs);
65 | init(context);
66 | }
67 |
68 | public FixedTabIndicator(Context context, AttributeSet attrs, int defStyle) {
69 | super(context, attrs, defStyle);
70 | init(context);
71 | }
72 |
73 |
74 | /**
75 | * 条目点击事件
76 | */
77 | public interface OnItemClickListener {
78 | /**
79 | * 回调方法
80 | *
81 | * @param v 当前点击的view
82 | * @param position 当前点击的position
83 | * @param open 当前的状态,蓝色为open,筛选器为打开状态
84 | */
85 | void onItemClick(View v, int position, boolean open);
86 | }
87 |
88 | public void setOnItemClickListener(OnItemClickListener itemClickListenner) {
89 | this.mOnItemClickListener = itemClickListenner;
90 | }
91 |
92 | private void init(Context context) {
93 | this.context = context;
94 | setOrientation(LinearLayout.HORIZONTAL);
95 | setBackgroundColor(Color.WHITE);
96 | setWillNotDraw(false);
97 |
98 | mDividerPaint = new Paint();
99 | mDividerPaint.setAntiAlias(true);
100 | mDividerPaint.setColor(mDividerColor);
101 |
102 | mLinePaint = new Paint();
103 | mLinePaint.setColor(mLineColor);
104 |
105 | mDividerPadding = UIUtil.dp(context, mDividerPadding);
106 | drawableRight = UIUtil.dp(context, drawableRight);
107 | }
108 |
109 |
110 | @Override
111 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
112 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
113 | measureHeight = getMeasuredHeight();
114 | measuredWidth = getMeasuredWidth();
115 | }
116 |
117 | @Override
118 | protected void onDraw(Canvas canvas) {
119 | super.onDraw(canvas);
120 |
121 | for (int i = 0; i < mTabCount - 1; ++i) {// 分割线的个数比tab的个数少一个
122 | final View child = getChildAt(i);
123 | if (child == null || child.getVisibility() == View.GONE) {
124 | continue;
125 | }
126 |
127 | canvas.drawLine(child.getRight(), mDividerPadding, child.getRight(), measureHeight - mDividerPadding, mDividerPaint);
128 | }
129 |
130 |
131 | //上边黑线
132 | canvas.drawRect(0, 0, measuredWidth, mLineHeight, mLinePaint);
133 |
134 | //下边黑线
135 | canvas.drawRect(0, measureHeight - mLineHeight, measuredWidth, measureHeight, mLinePaint);
136 | }
137 |
138 | /**
139 | * 添加相应的布局进此容器
140 | */
141 | public void setTitles(List list) {
142 | if (list == null || list.isEmpty()) {
143 | throw new IllegalStateException("条目数量位空");
144 | }
145 | this.removeAllViews();
146 |
147 | mTabCount = list.size();
148 | for (int pos = 0; pos < mTabCount; ++pos) {
149 | addView(generateTextView(list.get(pos), pos));
150 | }
151 |
152 | postInvalidate();
153 | }
154 |
155 | public void setTitles(String[] list) {
156 | setTitles(Arrays.asList(list));
157 | }
158 |
159 | public void setTitles(MenuAdapter menuAdapter) {
160 | if (menuAdapter == null) {
161 | return;
162 | }
163 | this.removeAllViews();
164 |
165 | mTabCount = menuAdapter.getMenuCount();
166 | for (int pos = 0; pos < mTabCount; ++pos) {
167 | addView(generateTextView(menuAdapter.getMenuTitle(pos), pos));
168 | }
169 | postInvalidate();
170 | }
171 |
172 |
173 | private void switchTab(int pos) {
174 | TextView tv = getChildAtCurPos(pos);
175 |
176 | Drawable drawable = tv.getCompoundDrawables()[2];
177 | int level = drawable.getLevel();
178 |
179 | if (mOnItemClickListener != null) {
180 | mOnItemClickListener.onItemClick(tv, pos, level == 1);
181 | }
182 |
183 | if (mLastIndicatorPosition == pos) {
184 | // 点击同一个条目时
185 | tv.setTextColor(level == 0 ? mTabSelectedColor : mTabDefaultColor);
186 | drawable.setLevel(1 - level);
187 |
188 | return;
189 | }
190 |
191 | mCurrentIndicatorPosition = pos;
192 | resetPos(mLastIndicatorPosition);
193 |
194 | //highLightPos(pos);
195 | tv.setTextColor(mTabSelectedColor);
196 | tv.getCompoundDrawables()[2].setLevel(1);
197 |
198 | mLastIndicatorPosition = pos;
199 | }
200 |
201 | /**
202 | * 重置字体颜色
203 | */
204 | public void resetPos(int pos) {
205 | TextView tv = getChildAtCurPos(pos);
206 | tv.setTextColor(mTabDefaultColor);
207 | tv.getCompoundDrawables()[2].setLevel(0);
208 | }
209 |
210 | /**
211 | * 重置当前字体颜色
212 | */
213 | public void resetCurrentPos() {
214 | resetPos(mCurrentIndicatorPosition);
215 | }
216 |
217 | /**
218 | * 获取当前pos内的TextView
219 | */
220 | public TextView getChildAtCurPos(int pos) {
221 | return (TextView) ((ViewGroup) getChildAt(pos)).getChildAt(0);
222 | }
223 |
224 | /**
225 | * 直接用TextView使用weight不能控制图片,需要用用父控件包裹
226 | */
227 | private View generateTextView(String title, int pos) {
228 | // 子空间TextView
229 | TextView tv = new TextView(context);
230 | tv.setGravity(Gravity.CENTER);
231 | tv.setText(title);
232 | tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabTextSize);
233 | tv.setTextColor(mTabDefaultColor);
234 | tv.setSingleLine();
235 | tv.setEllipsize(TextUtils.TruncateAt.END);
236 | tv.setMaxEms(6);//限制4个字符
237 | Drawable drawable = getResources().getDrawable(R.drawable.level_filter);
238 | tv.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
239 | tv.setCompoundDrawablePadding(drawableRight);
240 |
241 | // 将TextView添加到父控件RelativeLayout
242 | RelativeLayout rl = new RelativeLayout(context);
243 | RelativeLayout.LayoutParams rlParams = new RelativeLayout.LayoutParams(-2, -2);
244 | rlParams.addRule(RelativeLayout.CENTER_IN_PARENT);
245 | rl.addView(tv, rlParams);
246 | rl.setId(pos);
247 |
248 | // 再将RelativeLayout添加到LinearLayout中
249 | LayoutParams params = new LayoutParams(-1, -1);
250 | params.weight = 1;
251 | params.gravity = Gravity.CENTER;
252 | rl.setLayoutParams(params);
253 |
254 | rl.setOnClickListener(new OnClickListener() {
255 | @Override
256 | public void onClick(View v) {
257 | // 设置点击事件
258 | switchTab(v.getId());
259 | }
260 | });
261 |
262 | return rl;
263 | }
264 |
265 | /**
266 | * 高亮字体颜色
267 | */
268 | public void highLightPos(int pos) {
269 | TextView tv = getChildAtCurPos(pos);
270 | tv.setTextColor(mTabSelectedColor);
271 | tv.getCompoundDrawables()[2].setLevel(1);
272 | }
273 |
274 | public int getCurrentIndicatorPosition() {
275 | return mCurrentIndicatorPosition;
276 | }
277 |
278 | public void setCurrentText(String text) {
279 | setPositionText(mCurrentIndicatorPosition, text);
280 | }
281 |
282 | public void setPositionText(int position, String text) {
283 | if (position < 0 || position > mTabCount - 1) {
284 | throw new IllegalArgumentException("position 越界");
285 | }
286 | TextView tv = getChildAtCurPos(position);
287 | tv.setTextColor(mTabDefaultColor);
288 | tv.setText(text);
289 | tv.getCompoundDrawables()[2].setLevel(0);
290 | }
291 |
292 | public int getLastIndicatorPosition() {
293 | return mLastIndicatorPosition;
294 | }
295 | }
296 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/anim/alpha_to_one.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/anim/alpha_to_zero.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/anim/top_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/anim/top_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable-xxhdpi/common_filter_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/filter-lib/src/main/res/drawable-xxhdpi/common_filter_arrow_down.png
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable-xxhdpi/common_filter_arrow_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/filter-lib/src/main/res/drawable-xxhdpi/common_filter_arrow_up.png
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable/layer_filter_checked.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable/layer_filter_unchecked.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable/level_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable/selector_filter_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/drawable/selector_tv_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/layout/lv_item_filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/layout/merge_filter_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #7f000000
5 | #e7e7e7
6 | #fafafa
7 | #4285f4
8 | #5a626d
9 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/filter-lib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Filter
3 |
4 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jan 08 11:44:34 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/images/dropDownMenu.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baiiu/DropDownMenu/445a23adbe0b190e13c06c2a2c799ad9a82636ac/images/dropDownMenu.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':filter-lib'
2 |
--------------------------------------------------------------------------------