├── .gitignore ├── LICENSE ├── README.md ├── StupidAdapter.ExpandAdapter ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── proguard-project.txt ├── project.properties └── src │ └── com │ └── stupid │ └── method │ └── adapter │ └── expand │ ├── OnXItemClickListener.java │ ├── XExpadnAdapter.java │ ├── XExpadnViewHolder.java │ └── package-info.java ├── StupidAdapter.RecyclerViewAdapter ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── libs │ └── android-support-v7-recyclerview.jar ├── proguard-project.txt ├── project.properties └── src │ └── com │ └── stupid │ └── method │ └── adapter │ ├── IPauseOnScrollRecycler.java │ ├── XRecyclerViewHolder.java │ └── XRecylerAdapter.java ├── StupidAdapter ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── ic_launcher-web.png ├── proguard-project.txt ├── project.properties └── src │ └── com │ └── stupid │ └── method │ └── adapter │ ├── IPauseOnScroll.java │ ├── IXAdapter.java │ ├── IXDataListener.java │ ├── IXOnItemClickListener.java │ ├── IXOnItemLongClickListener.java │ ├── IXViewHolder.java │ ├── OnClickItemListener.java │ ├── OnLongClickItemListener.java │ ├── XAdapter.java │ ├── XAdapter2.java │ └── XViewHolder.java └── StupidDemo ├── .classpath ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── assets └── stupidadapter.jar ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar ├── android-support-v7-recyclerview.jar ├── androidquery.jar ├── fastjson-1.1.45.android.jar ├── stupidadapter.expandadapter.jar ├── stupidadapter.jar ├── stupidadapter.recyclerviewadapter.jar └── stupidxhttp.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ ├── ic_launcher.png │ ├── tx_receive_foused.9.png │ ├── tx_receive_normal.9.png │ ├── tx_sender_foused.9.png │ ├── tx_sender_normal.9.png │ └── yb.9.png ├── drawable │ ├── bg_tx_receive.xml │ └── bg_tx_sender.xml ├── layout │ ├── activity_grid_demo.xml │ ├── activity_list_demo.xml │ ├── activity_main.xml │ ├── activity_recyler.xml │ ├── expand_list_view_activity.xml │ ├── joke_view_holder.xml │ ├── list_activity.xml │ ├── msg_view_hodler.xml │ ├── msg_view_hodler_sender.xml │ ├── msg_view_holder_receive.xml │ ├── vlist_view_holder.xml │ └── vlist_view_holder2.xml ├── menu │ ├── expand_list_view.xml │ ├── list.xml │ ├── list_demo.xml │ ├── main.xml │ └── recyler.xml ├── values-sw600dp │ └── dimens.xml ├── values-sw720dp-land │ └── dimens.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml ├── values-w820dp │ └── dimens.xml └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── src └── com └── stupid └── method └── demo ├── activity ├── BaseActivity.java ├── ExpandListViewActivity.java ├── ListActivity.java ├── ListDemoActivity.java ├── MainActivity.java └── RecylerActivity.java ├── bean ├── Data.java ├── IqiyiRoot.java ├── Joke.java ├── MsgModel.java └── Vlist.java ├── holder ├── ExpandChild.java ├── ExpandParent.java ├── JokeViewHolder.java ├── MsgViewHodler.java ├── MsgViewHodlerMap.java └── VlistViewHolder.java └── util └── JsonUtils.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /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 {2015} {name of copyright owner comcp}//这里写啥? 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 | 203 | ----------------------------------------------------------------------- 204 | 这上面说的啥,我也看不懂; 205 | 反正你得带上我名我就谢谢你了. 206 | https://github.com/comcp/android-Stupid-Adapter/ 207 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-Stupid-Adapter 2 | 一个比较蠢的adapter,一切只是为了少写两行代码, 3 | 支持listview,gridView, recyclerview, 的adapter, 4 | 开发者只需要关注 item View 和 数据的关系,业务逻辑.剩下的一切交给我 5 | 6 | 将viewholder,与 adapter分开,每个absListview 不需要创建一个对应的adapter 类, 7 | 只需要创建一个xAdapter 对象, 和一个viewHolder类 继承 xViewHolder 然后实现里面的方法 8 | 9 | XAdapter 继承自baseadapter.还有一些功能还没实现.平时开发也没用上,就没深究 10 | 11 | 12 | wiki 已经写好..... 13 | 14 | 欢迎大家挑bug......如果有人用的话. 15 | 16 | 未来打算多创建几个XViewHolder 用来实现像,item侧滑动删除拉,什么的..... 17 | 18 | #wiki 19 | 20 | 21 | 1.XAdapter2 22 | 23 | 1.1.实例化 24 | 1.1.1 解释 XAdapter2 adapter //存放在adapter里的数据格式,也可以指定object 25 | 例子 XAdapter2 adapter; 26 | 27 | 1.1.2 解释 adapter = new XAdapter2(Content对象, 初始化数据,可以传null , 每条item的View Holder); 28 | 例子 adapter = new XAdapter2(this, null, JokeViewHolder.class); 29 | 1.1.3 为listview设置adapter 30 | listView.setAdapter(adapter); 31 | 1.2.事件 32 | 1.2.1 点击事件 33 | adapter.setClickItemListener(this);// 设置item的点击事件; 34 | 回调 35 | public void onClickItem(View v, int p); //v 当前点击的控件,p 当前点击的元素位置, 36 | 1.2.2 长按事件 37 | adapter.setLongClickItemListener(this);// 设置item的长按事件; 38 | 回调 39 | public boolean onLongClickItem(View v, int p) //v 当前点击的控件,p 当前点击的元素位置, 40 | 41 | 2. IXViewHolder 42 | 43 | viewholder 主要实现 IXViewHolder 方法,并按照 IXViewHolder 的要求实现, 44 | 只要继承了IXViewHolder的类就可以传递给adapter构造 45 | 46 | 2.1 IXViewHolder 执行顺序 47 | 48 | 1)void onCreat(XAdapter adapter, Context context); 49 | 50 | 2)void setOnClickItemListener(OnClickItemListener itemListener); 51 | 52 | 3)void setOnLongClickItemListener(OnLongClickItemListener longClickItemListener); 53 | 54 | 4)View getView(Object data, int position); 55 | 56 | 5)View getView(); 57 | 58 | 6)View setInflater(LayoutInflater inflater); 59 | 60 | 7)void onDestory(int nextPosition, int count); 61 | 2.2 执行顺序 62 | 63 | 当adapter开始 getView 时 64 | 判断IXViewHolder是否创建, 65 | 66 | if 未创建 67 | 68 | 开始创建IXViewHolder, 69 | 1.实例化IXViewHolder 70 | 2.(只执行一次)调用 (6) setInflater(inflater); 71 | 3.(只执行一次)调用 (1) onCreat(adapter, context); 72 | 4.(只执行一次)调用 (2) setOnClickItemListener 73 | 5.(只执行一次)调用 (3) setOnLongClickItemListener 74 | 75 | else 已创建(循环执行) 76 | 77 | 1.(7) onDestory(position, getCount()); 78 | 2.(5) getView(object, position); 79 | 80 | 81 | 82 | ---------分割线----大清早起来写代码--2015-08-26 7:54-------没写完,明天再说吧!------------- 83 | 84 | 85 | --------2016-03-25------ 86 | 这个"明天再写"一拖就是半年, 也没继续写. 87 | 88 | 额,今天终于办理离职了,虽说是离职了,但是还得给公司做兼职.
89 | 未来要去哪里,我也没太想好,
90 | 大连这个小地方,也不知道哪里适合我.
91 | 虽然手里有两个offer,
92 | 但总觉得不是我的菜.
93 | 94 | ---------------------准备增加混淆--------------------
95 | 等我研究明白的 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | StupidAdapter.ExpandAdapter 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | android.library=true 16 | android.library.reference.1=../StupidAdapter 17 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/OnXItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter.expand; 2 | 3 | import com.stupid.method.adapter.OnClickItemListener; 4 | 5 | import android.view.View; 6 | 7 | public interface OnXItemClickListener extends OnClickItemListener { 8 | 9 | public void onClickChild(View view, int parentId, int childPosition); 10 | 11 | } -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnAdapter.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter.expand; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | import android.content.Context; 9 | import android.util.Log; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.BaseExpandableListAdapter; 13 | 14 | import com.stupid.method.adapter.OnClickItemListener; 15 | import com.stupid.method.adapter.XAdapter2; 16 | 17 | public class XExpadnAdapter extends 18 | BaseExpandableListAdapter { 19 | 20 | private OnXItemClickListener onItemClickListener; 21 | 22 | final Map> mMap; 23 | final XAdapter2 parentAdapter; 24 | 25 | final Class> parentViewClass; 26 | final Class> childViewClass; 27 | final Context mContext; 28 | 29 | private class OnClickItemListenerImpl implements OnClickItemListener { 30 | private int parentId; 31 | 32 | @Override 33 | public void onClickItem(View view, int childPosition) { 34 | if (onItemClickListener != null) { 35 | onItemClickListener.onClickChild(view, getParentId(), 36 | childPosition); 37 | } 38 | } 39 | 40 | public OnClickItemListenerImpl(int pid) { 41 | this.parentId = pid; 42 | } 43 | 44 | public int getParentId() { 45 | return parentId; 46 | } 47 | 48 | } 49 | 50 | public XExpadnAdapter(Context context, 51 | Class> parentViewClass, 52 | Class> childViewClass) { 53 | this(context, parentViewClass, childViewClass, null); 54 | } 55 | 56 | public XExpadnAdapter(Context context, 57 | Class> parentViewClass, 58 | Class> childViewClass, 59 | Map> data) { 60 | mContext = context; 61 | this.parentViewClass = parentViewClass; 62 | this.childViewClass = childViewClass; 63 | mMap = new HashMap>(); 64 | parentAdapter = new XAdapter2(context, parentViewClass); 65 | addAll(data); 66 | } 67 | 68 | public void addAll(Map> data) { 69 | 70 | if (data == null) { 71 | return; 72 | } 73 | Set set = data.keySet(); 74 | int i = 0; 75 | for (ParentModel p : set) { 76 | parentAdapter.add(p); 77 | XAdapter2 childaAdapter = mMap.get(p); 78 | if (childaAdapter == null) { 79 | childaAdapter = new XAdapter2(mContext, 80 | data.get(p), childViewClass); 81 | mMap.put(p, childaAdapter); 82 | 83 | } else { 84 | childaAdapter.setData(data.get(p)); 85 | } 86 | // childaAdapter.setClickItemListener(clickItemListener); 87 | i++; 88 | } 89 | } 90 | 91 | @Override 92 | public Object getChild(int groupPosition, int childPosition) { 93 | 94 | return mMap.get(parentAdapter.get(groupPosition)).get(childPosition); 95 | } 96 | 97 | @Override 98 | public long getChildId(int groupPosition, int childPosition) { 99 | Log.d("XAdapter3", "getChildId:" + groupPosition); 100 | 101 | return mMap.get(parentAdapter.get(groupPosition)).hashCode(); 102 | } 103 | 104 | @Override 105 | public int getChildrenCount(int groupPosition) { 106 | Log.d("XAdapter3", "getChildrenCount:" + groupPosition); 107 | return mMap == null ? 0 : (parentAdapter == null ? 0 : parentAdapter 108 | .get(groupPosition) == null ? 0 : mMap.get(parentAdapter 109 | .get(groupPosition)) == null ? 0 : mMap.get( 110 | parentAdapter.get(groupPosition)).size()); 111 | } 112 | 113 | @Override 114 | public View getChildView(int groupPosition, int childPosition, 115 | boolean isLastChild, View convertView, ViewGroup parent) { 116 | if (convertView == null) { 117 | convertView = mMap.get(parentAdapter.get(groupPosition)).getView( 118 | childPosition, convertView, parent); 119 | } 120 | if (convertView.getTag() instanceof XExpadnViewHolder) { 121 | XExpadnViewHolder holder = (XExpadnViewHolder) convertView 122 | .getTag(); 123 | holder.onNodeIsChild(isLastChild, groupPosition); 124 | holder.setParentId(groupPosition); 125 | holder.setOnClickItemListener(new OnClickItemListenerImpl( 126 | groupPosition)); 127 | convertView = holder.getView( 128 | mMap.get(parentAdapter.get(groupPosition)).getItem( 129 | childPosition), childPosition, false); 130 | } 131 | return convertView; 132 | } 133 | 134 | @Override 135 | public Object getGroup(int groupPosition) { 136 | 137 | return parentAdapter == null ? null : parentAdapter.get(groupPosition); 138 | } 139 | 140 | @Override 141 | public int getGroupCount() { 142 | return parentAdapter == null ? 0 : parentAdapter.size(); 143 | } 144 | 145 | @Override 146 | public long getGroupId(int groupPosition) { 147 | return parentAdapter.get(groupPosition).hashCode(); 148 | } 149 | 150 | @Override 151 | public View getGroupView(int groupPosition, boolean isExpanded, 152 | View convertView, ViewGroup parent) { 153 | convertView = parentAdapter.getView(groupPosition, convertView, parent); 154 | if (convertView.getTag() instanceof XExpadnViewHolder) { 155 | XExpadnViewHolder holder = (XExpadnViewHolder) convertView.getTag(); 156 | holder.onNodeIsParent(isExpanded, 157 | mMap.get(parentAdapter.get(groupPosition)).size()); 158 | } 159 | return convertView; 160 | } 161 | 162 | @Override 163 | public boolean hasStableIds() { 164 | return false; 165 | } 166 | 167 | @Override 168 | public boolean isChildSelectable(int groupPosition, int childPosition) { 169 | return true; 170 | } 171 | 172 | public OnXItemClickListener getClickItemListener() { 173 | return onItemClickListener; 174 | } 175 | 176 | public void setClickItemListener(OnXItemClickListener onItemClickListener) { 177 | this.onItemClickListener = onItemClickListener; 178 | parentAdapter.setClickItemListener(onItemClickListener); 179 | } 180 | 181 | public void clear() { 182 | 183 | mMap.clear(); 184 | parentAdapter.clear(); 185 | 186 | } 187 | 188 | public ParentModel getItem(int position) { 189 | 190 | return parentAdapter == null ? null : parentAdapter.getItem(position); 191 | } 192 | 193 | public int size() { 194 | return getGroupCount(); 195 | } 196 | 197 | } -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/XExpadnViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter.expand; 2 | 3 | import com.stupid.method.adapter.XViewHolder; 4 | 5 | /** 6 | * @author wangx 7 | * 8 | * @param 9 | */ 10 | public abstract class XExpadnViewHolder extends XViewHolder { 11 | 12 | /** 13 | * run in {@link XViewHolder#getView(Object, int, boolean)} after; 14 | * 15 | * @param isLastChild 16 | * 当前节点是否是最后一个节点 17 | * @param parentPosition 18 | * 父节点id 19 | */ 20 | protected abstract void onNodeIsChild(boolean isLastChild, 21 | int parentPosition); 22 | 23 | OnXItemClickListener onItemClickListener; 24 | private int parentId; 25 | 26 | /** 27 | * run in {@link XViewHolder#getView(Object, int, boolean)} after; 28 | * 29 | * @param isExpanded 30 | * 当前节点是否展开 31 | * @param childCount 32 | * 子节点数量 33 | */ 34 | protected abstract void onNodeIsParent(boolean isExpanded, int childCount); 35 | 36 | public int getParentId() { 37 | return parentId; 38 | } 39 | 40 | public void setParentId(int parentId) { 41 | this.parentId = parentId; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /StupidAdapter.ExpandAdapter/src/com/stupid/method/adapter/expand/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author wangx 6 | * 7 | */ 8 | package com.stupid.method.adapter.expand; -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | StupidAdapter.RecyclerViewAdapter 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/libs/android-support-v7-recyclerview.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidAdapter.RecyclerViewAdapter/libs/android-support-v7-recyclerview.jar -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | android.library.reference.1=../StupidAdapter 16 | android.library=true 17 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/src/com/stupid/method/adapter/IPauseOnScrollRecycler.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import com.stupid.method.adapter.IPauseOnScroll.IXPauseListener; 4 | 5 | import android.support.v7.widget.RecyclerView; 6 | import android.support.v7.widget.RecyclerView.OnScrollListener; 7 | 8 | public class IPauseOnScrollRecycler extends OnScrollListener { 9 | private OnScrollListener listener2; 10 | IXPauseListener adapter; 11 | 12 | public IPauseOnScrollRecycler(IXPauseListener adapter, 13 | OnScrollListener listener) { 14 | this.adapter = adapter; 15 | this.listener2 = listener; 16 | } 17 | 18 | @Override 19 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 20 | 21 | super.onScrolled(recyclerView, dx, dy); 22 | if (listener2 != null) 23 | listener2.onScrolled(recyclerView, dx, dy); 24 | } 25 | 26 | @Override 27 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 28 | super.onScrollStateChanged(recyclerView, newState); 29 | switch (newState) { 30 | case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE: 31 | adapter.onResume(); 32 | break; 33 | case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: 34 | // adapter.pause(); 35 | adapter.onResume(); 36 | break; 37 | case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_FLING: 38 | adapter.onPause(); 39 | break; 40 | } 41 | if (listener2 != null) 42 | listener2.onScrollStateChanged(recyclerView, newState); 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/src/com/stupid/method/adapter/XRecyclerViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView.ViewHolder; 4 | 5 | abstract public class XRecyclerViewHolder extends XViewHolder { 6 | ViewHolder v7viewHolder; 7 | 8 | public ViewHolder getViewHolder() { 9 | setTag(this); 10 | if (v7viewHolder == null) 11 | v7viewHolder = new ViewHolder(getView()) { 12 | }; 13 | return v7viewHolder; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /StupidAdapter.RecyclerViewAdapter/src/com/stupid/method/adapter/XRecylerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.ListIterator; 8 | 9 | import android.support.v7.widget.RecyclerView.Adapter; 10 | import android.support.v7.widget.RecyclerView.AdapterDataObserver; 11 | import android.support.v7.widget.RecyclerView.OnScrollListener; 12 | import android.support.v7.widget.RecyclerView.ViewHolder; 13 | import android.util.Log; 14 | import android.view.LayoutInflater; 15 | import android.view.ViewGroup; 16 | 17 | import com.stupid.method.adapter.IPauseOnScroll.IXPauseListener; 18 | 19 | public class XRecylerAdapter extends Adapter implements 20 | Collection, IXPauseListener { 21 | private static final String tag = "XRecylerAdapter"; 22 | private List mData; 23 | Class> cls; 24 | private OnClickItemListener clickItemListener; 25 | private boolean onScrolling = false; 26 | private IXDataListener onDataChang; 27 | 28 | public IXDataListener getOnDataChang() { 29 | return onDataChang; 30 | } 31 | 32 | { 33 | registerAdapterDataObserver(new AdapterDataObserver() { 34 | @Override 35 | public void onChanged() { 36 | super.onChanged(); 37 | onDataChange(); 38 | } 39 | }); 40 | } 41 | 42 | private void onDataChange() { 43 | if (getOnDataChang() != null) 44 | if (getItemCount() == 0) 45 | getOnDataChang().onDataEmpty(); 46 | else 47 | getOnDataChang().onDataChange(); 48 | } 49 | 50 | public void add(int location, T object) { 51 | mData.add(location, object); 52 | } 53 | 54 | public boolean add(T object) { 55 | return mData.add(object); 56 | } 57 | 58 | public boolean addAll(int location, Collection collection) { 59 | return mData.addAll(location, collection); 60 | } 61 | 62 | public boolean addAll(Collection collection) { 63 | return mData.addAll(collection); 64 | } 65 | 66 | public void clear() { 67 | mData.clear(); 68 | } 69 | 70 | public boolean contains(Object object) { 71 | return mData.contains(object); 72 | } 73 | 74 | public boolean containsAll(Collection collection) { 75 | return mData.containsAll(collection); 76 | } 77 | 78 | public boolean equals(Object object) { 79 | return mData.equals(object); 80 | } 81 | 82 | public T get(int location) { 83 | return mData.get(location); 84 | } 85 | 86 | public int hashCode() { 87 | return mData.hashCode(); 88 | } 89 | 90 | public int indexOf(Object object) { 91 | return mData.indexOf(object); 92 | } 93 | 94 | public boolean isEmpty() { 95 | return mData.isEmpty(); 96 | } 97 | 98 | public Iterator iterator() { 99 | return mData.iterator(); 100 | } 101 | 102 | public int lastIndexOf(Object object) { 103 | return mData.lastIndexOf(object); 104 | } 105 | 106 | public ListIterator listIterator() { 107 | return mData.listIterator(); 108 | } 109 | 110 | public ListIterator listIterator(int location) { 111 | return mData.listIterator(location); 112 | } 113 | 114 | public T remove(int location) { 115 | return mData.remove(location); 116 | } 117 | 118 | public boolean remove(Object object) { 119 | return mData.remove(object); 120 | } 121 | 122 | public boolean removeAll(Collection collection) { 123 | return mData.removeAll(collection); 124 | } 125 | 126 | public boolean retainAll(Collection collection) { 127 | return mData.retainAll(collection); 128 | } 129 | 130 | public T set(int location, T object) { 131 | return mData.set(location, object); 132 | } 133 | 134 | public int size() { 135 | return mData.size(); 136 | } 137 | 138 | public List subList(int start, int end) { 139 | return mData.subList(start, end); 140 | } 141 | 142 | public Object[] toArray() { 143 | return mData.toArray(); 144 | } 145 | 146 | public T[] toArray(T[] array) { 147 | return mData.toArray(array); 148 | } 149 | 150 | private OnLongClickItemListener longClickItemListener; 151 | 152 | public XRecylerAdapter(Class> clz, 153 | List datas) { 154 | cls = clz; 155 | this.mData = datas; 156 | if (this.mData == null) { 157 | this.mData = new ArrayList(0); 158 | } 159 | 160 | } 161 | 162 | @Override 163 | public int getItemCount() { 164 | 165 | return mData == null ? 0 : mData.size(); 166 | } 167 | 168 | @Override 169 | public void onBindViewHolder(ViewHolder vh, int position) { 170 | XRecyclerViewHolder holder = null; 171 | if (vh.itemView.getTag() instanceof XRecyclerViewHolder) { 172 | holder = (XRecyclerViewHolder) vh.itemView.getTag(); 173 | holder.onDestory(position, getItemCount()); 174 | holder.setView(vh.itemView).getView(mData.get(position), position, 175 | isOnScrolling()); 176 | } 177 | 178 | } 179 | 180 | @Override 181 | public ViewHolder onCreateViewHolder(ViewGroup v, int p) { 182 | 183 | return creatViewHolder(v); 184 | 185 | } 186 | 187 | public IPauseOnScrollRecycler getOnScrollListener(OnScrollListener l) { 188 | return new IPauseOnScrollRecycler(this, l); 189 | } 190 | 191 | ViewHolder creatViewHolder(ViewGroup v) { 192 | XRecyclerViewHolder holder = null; 193 | 194 | if (cls != null) { 195 | 196 | try { 197 | holder = (XRecyclerViewHolder) cls.newInstance(); 198 | holder.setInflater(LayoutInflater.from(v.getContext()), v); 199 | holder.onCreate(v.getContext()); 200 | holder.setOnClickItemListener(getClickItemListener()); 201 | holder.setOnLongClickItemListener(getLongClickItemListener()); 202 | } catch (InstantiationException e) { 203 | e.printStackTrace(); 204 | } catch (IllegalAccessException e) { 205 | e.printStackTrace(); 206 | } 207 | if (holder != null) 208 | return holder.getViewHolder(); 209 | 210 | } else { 211 | Log.e(tag, "没有设置 IXRecyclerViewHolder "); 212 | } 213 | return null; 214 | 215 | } 216 | 217 | public OnLongClickItemListener getLongClickItemListener() { 218 | return longClickItemListener; 219 | } 220 | 221 | public void setLongClickItemListener( 222 | OnLongClickItemListener longClickItemListener) { 223 | this.longClickItemListener = longClickItemListener; 224 | } 225 | 226 | public OnClickItemListener getClickItemListener() { 227 | return clickItemListener; 228 | } 229 | 230 | public void setClickItemListener(OnClickItemListener clickItemListener) { 231 | this.clickItemListener = clickItemListener; 232 | } 233 | 234 | public void onPause() { 235 | setOnScrolling(true); 236 | } 237 | 238 | public void onResume() { 239 | if (isOnScrolling()) {// 如果已经滚动停止,就别刷新列表了 240 | setOnScrolling(false); 241 | notifyDataSetChanged(); 242 | 243 | } 244 | 245 | } 246 | 247 | public boolean isOnScrolling() { 248 | return onScrolling; 249 | } 250 | 251 | public void setOnScrolling(boolean onScrolling) { 252 | this.onScrolling = onScrolling; 253 | } 254 | 255 | public void setOnDataChang(IXDataListener onDataChang) { 256 | this.onDataChang = onDataChang; 257 | } 258 | 259 | } 260 | -------------------------------------------------------------------------------- /StupidAdapter/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /StupidAdapter/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | StupidAdapter 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /StupidAdapter/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /StupidAdapter/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /StupidAdapter/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /StupidAdapter/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidAdapter/ic_launcher-web.png -------------------------------------------------------------------------------- /StupidAdapter/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /StupidAdapter/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-12 15 | android.library=true 16 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IPauseOnScroll.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import android.widget.AbsListView; 4 | import android.widget.AbsListView.OnScrollListener; 5 | 6 | /** 7 | * 8 | * @说明: 9 | * 10 | * 当absListview滚动时向IXViewholder发送滚动事件 11 | * 12 | * @author: comcp@126.com 13 | * 14 | * @version: v1 15 | * 16 | * @创建时间:2015-9-11 17 | * **/ 18 | class IPauseOnScroll 19 | // extends android.support.v7.widget.RecyclerView.OnScrollListener 20 | implements OnScrollListener { 21 | interface IXPauseListener { 22 | void onResume(); 23 | 24 | void onPause(); 25 | } 26 | 27 | IXPauseListener adapter; 28 | OnScrollListener listener; 29 | 30 | // private android.support.v7.widget.RecyclerView.OnScrollListener 31 | // listener2; 32 | 33 | public IPauseOnScroll(IXPauseListener adapter, OnScrollListener listener) { 34 | this.adapter = adapter; 35 | this.listener = listener; 36 | } 37 | 38 | // public IPauseOnScroll(IXPauseListener adapter, 39 | // android.support.v7.widget.RecyclerView.OnScrollListener listener) { 40 | // this.adapter = adapter; 41 | // this.listener2 = listener; 42 | // } 43 | 44 | // @Override 45 | // public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 46 | // 47 | // super.onScrolled(recyclerView, dx, dy); 48 | // if (listener2 != null) 49 | // listener2.onScrolled(recyclerView, dx, dy); 50 | // } 51 | 52 | // @Override 53 | // public void onScrollStateChanged(RecyclerView recyclerView, int newState) 54 | // { 55 | // super.onScrollStateChanged(recyclerView, newState); 56 | // switch (newState) { 57 | // case OnScrollListener.SCROLL_STATE_IDLE: 58 | // adapter.onResume(); 59 | // break; 60 | // case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: 61 | // // adapter.pause(); 62 | // adapter.onResume(); 63 | // break; 64 | // case OnScrollListener.SCROLL_STATE_FLING: 65 | // adapter.onPause(); 66 | // break; 67 | // } 68 | // if (listener2 != null) 69 | // listener2.onScrollStateChanged(recyclerView, newState); 70 | // 71 | // } 72 | 73 | @Override 74 | public void onScroll(AbsListView view, int firstVisibleItem, 75 | int visibleItemCount, int totalItemCount) { 76 | if (listener != null) 77 | listener.onScroll(view, firstVisibleItem, visibleItemCount, 78 | totalItemCount); 79 | 80 | } 81 | 82 | @Override 83 | public void onScrollStateChanged(AbsListView view, int scrollState) { 84 | switch (scrollState) { 85 | case OnScrollListener.SCROLL_STATE_IDLE: 86 | adapter.onResume(); 87 | break; 88 | case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: 89 | // adapter.pause(); 90 | adapter.onResume(); 91 | break; 92 | case OnScrollListener.SCROLL_STATE_FLING: 93 | adapter.onPause(); 94 | break; 95 | } 96 | if (listener != null) 97 | listener.onScrollStateChanged(view, scrollState); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IXAdapter.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import java.util.List; 4 | 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | public interface IXAdapter { 10 | public View convertView(int position, View convertView, ViewGroup parent, 11 | List mData, LayoutInflater inflater); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IXDataListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | /** 当数据改变时调用 **/ 4 | public interface IXDataListener { 5 | 6 | void onDataChange(); 7 | 8 | void onDataEmpty(); 9 | 10 | } -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IXOnItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | public interface IXOnItemClickListener extends OnClickItemListener { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IXOnItemLongClickListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | public interface IXOnItemLongClickListener extends OnLongClickItemListener { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/IXViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | /** 9 | * * @调用顺序
10 | * 11 | * 1. {@link #setInflater(LayoutInflater)}
12 | * 2. {@link #getLayoutId()}
13 | * 3. {@link #onCreate(XAdapter, android.content.Context)}
14 | * 4. 如果已实例化该类,会先调用onDestiny();
15 | * 5. {@link #getView(Object, int)}
16 | * -----------
17 | * 6. {@link #onResetView(Object, int)}
18 | * [1,2,3] 只执行一遍
19 | * [4,5,6]会重复执行 20 | * 21 | * **/ 22 | public interface IXViewHolder { 23 | int getLayoutId(); 24 | 25 | /** 26 | * @return 27 | */ 28 | View getView(); 29 | 30 | /** 31 | * @param data 32 | * @param position 33 | * @param onScrolling 34 | * @return 35 | */ 36 | View getView(T data, int position, boolean onScrolling); 37 | 38 | /** 39 | * @param context 40 | */ 41 | void onCreate(Context context); 42 | 43 | /** 44 | * @param nextPosition 45 | * @param count 46 | */ 47 | void onDestory(int nextPosition, int count); 48 | 49 | /** 50 | * 当前容器的数据长度 51 | * 52 | * @param size 53 | */ 54 | void setListSize(int size); 55 | 56 | /** 57 | * @param inflater 58 | * @param parent 59 | * @return 60 | */ 61 | View setInflater(LayoutInflater inflater, ViewGroup parent); 62 | 63 | /** 64 | * @param itemListener 65 | */ 66 | void setOnClickItemListener(OnClickItemListener itemListener); 67 | 68 | /** 69 | * @param longClickItemListener 70 | */ 71 | void setOnLongClickItemListener( 72 | OnLongClickItemListener longClickItemListener); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/OnClickItemListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import android.view.View; 4 | 5 | /*** 6 | * item内元素的onClick 7 | * 8 | * OnClickItemListener.java 9 | * 10 | * @author :@C 11 | * @version:2015-1-7下午10:24:41 12 | * 13 | */ 14 | public interface OnClickItemListener { 15 | public void onClickItem(View v, int position); 16 | 17 | } -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/OnLongClickItemListener.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * OnLongClickItemListener.java 7 | * 8 | * @author :@C 9 | * @version:2015-1-7下午10:24:41 10 | * 11 | */ 12 | public interface OnLongClickItemListener { 13 | public boolean onLongClickItem(View v, int position); 14 | } 15 | -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/XAdapter.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.ListIterator; 8 | 9 | import android.content.Context; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.AbsListView.OnScrollListener; 14 | import android.widget.BaseAdapter; 15 | import android.widget.TextView; 16 | 17 | import com.stupid.method.adapter.IPauseOnScroll.IXPauseListener; 18 | 19 | /** 20 | * @说明 懒惰使人进步 21 | * 22 | * @author comcp@126.com 23 | * 24 | * @version v1.3 25 | * 26 | * @创建时间:2014-12-3上午11:21:31 27 | * 28 | */ 29 | public abstract class XAdapter extends BaseAdapter implements Collection, 30 | IXPauseListener { 31 | protected IXAdapter adapter; 32 | protected Context context; 33 | protected LayoutInflater inflater; 34 | protected List mData; 35 | private IXDataListener onDataChang; 36 | 37 | private boolean onScrolling = false; 38 | 39 | public XAdapter(Context context, List mData, 40 | IXAdapter adapterInterface) { 41 | if (context == null) 42 | throw new NullPointerException("XAdapter 构造函数的 Context 不能为空"); 43 | this.mData = mData; 44 | if (this.mData == null) { 45 | this.mData = new ArrayList(); 46 | } 47 | this.adapter = adapterInterface; 48 | this.context = context; 49 | inflater = LayoutInflater.from(context); 50 | 51 | } 52 | 53 | public XAdapter add(int location, T object) { 54 | mData.add(location, object); 55 | return this; 56 | 57 | } 58 | 59 | public boolean add(T object) { 60 | if (mData != null) 61 | return mData.add(object); 62 | else 63 | return false; 64 | } 65 | 66 | public boolean addAll(Collection collection) { 67 | if (mData != null) 68 | return mData.addAll(collection); 69 | else 70 | return false; 71 | } 72 | 73 | public boolean addAll(int location, Collection collection) { 74 | return mData.addAll(location, collection); 75 | } 76 | 77 | public void clear() { 78 | mData.clear(); 79 | } 80 | 81 | public boolean contains(Object object) { 82 | return mData.contains(object); 83 | } 84 | 85 | public boolean containsAll(Collection collection) { 86 | return mData.containsAll(collection); 87 | } 88 | 89 | public boolean equals(Object object) { 90 | return mData.equals(object); 91 | } 92 | 93 | public T get(int location) { 94 | return mData.get(location); 95 | } 96 | 97 | public IXAdapter getAdapterInterface() { 98 | return adapter; 99 | } 100 | 101 | @Override 102 | public int getCount() { 103 | 104 | return mData == null ? 0 : mData.size(); 105 | } 106 | 107 | @Override 108 | public T getItem(int position) { 109 | 110 | return position > -1 ? mData == null ? null : mData.get(position) 111 | : null; 112 | } 113 | 114 | @Override 115 | public long getItemId(int position) { 116 | 117 | return position; 118 | } 119 | 120 | public List getData() { 121 | return mData; 122 | } 123 | 124 | public IXDataListener getOnDataChang() { 125 | return onDataChang; 126 | } 127 | 128 | public IPauseOnScroll getOnScrollListener(OnScrollListener l) { 129 | return new IPauseOnScroll(this, l); 130 | } 131 | 132 | @Override 133 | public View getView(int position, View convertView, ViewGroup parent) { 134 | if (adapter != null) 135 | return adapter.convertView(position, convertView, parent, mData, 136 | inflater); 137 | else { 138 | TextView tv = new TextView(context); 139 | tv.setPadding(10, 10, 10, 10); 140 | tv.setText("没有设置 ISuperAdapter"); 141 | return tv; 142 | } 143 | } 144 | 145 | public int hashCode() { 146 | return mData.hashCode(); 147 | } 148 | 149 | public int indexOf(Object object) { 150 | return mData.indexOf(object); 151 | } 152 | 153 | public boolean isEmpty() { 154 | return mData.isEmpty(); 155 | } 156 | 157 | /** 158 | * @return the onScrolling 159 | */ 160 | public boolean isOnScrolling() { 161 | return onScrolling; 162 | } 163 | 164 | public Iterator iterator() { 165 | return mData.iterator(); 166 | } 167 | 168 | public int lastIndexOf(Object object) { 169 | return mData.lastIndexOf(object); 170 | } 171 | 172 | public ListIterator listIterator() { 173 | return mData.listIterator(); 174 | } 175 | 176 | public ListIterator listIterator(int location) { 177 | return mData.listIterator(location); 178 | } 179 | 180 | @Override 181 | public void notifyDataSetChanged() { 182 | super.notifyDataSetChanged(); 183 | onDataChange(); 184 | } 185 | 186 | @Override 187 | public void notifyDataSetInvalidated() { 188 | super.notifyDataSetInvalidated(); 189 | onDataChange(); 190 | } 191 | 192 | private void onDataChange() { 193 | if (onDataChang != null) 194 | if (getCount() == 0) 195 | onDataChang.onDataEmpty(); 196 | else 197 | onDataChang.onDataChange(); 198 | } 199 | 200 | public void onPause() { 201 | setOnScrolling(true); 202 | } 203 | 204 | public T remove(int location) { 205 | if (mData != null) 206 | return mData.remove(location); 207 | else 208 | return null; 209 | } 210 | 211 | public boolean remove(Object object) { 212 | if (mData != null) 213 | return mData.remove(object); 214 | else 215 | return false; 216 | } 217 | 218 | public boolean removeAll(Collection collection) { 219 | if (mData != null) 220 | return mData.removeAll(collection); 221 | else 222 | return false; 223 | } 224 | 225 | public void onResume() { 226 | if (isOnScrolling()) {// 如果已经滚动停止,就别刷新列表了 227 | setOnScrolling(false); 228 | notifyDataSetChanged(); 229 | } 230 | 231 | } 232 | 233 | public boolean retainAll(Collection collection) { 234 | return mData.retainAll(collection); 235 | } 236 | 237 | public T set(int location, T object) { 238 | return mData.set(location, object); 239 | } 240 | 241 | public void setAdapterInterface(IXAdapter adapterInterface) { 242 | this.adapter = adapterInterface; 243 | } 244 | 245 | public void setData(List mData) { 246 | this.mData = mData; 247 | this.notifyDataSetChanged(); 248 | } 249 | 250 | public void setOnDataChang(IXDataListener onDataChang) { 251 | this.onDataChang = onDataChang; 252 | onDataChange(); 253 | } 254 | 255 | /** 256 | * @param onScrolling 257 | * the onScrolling to set 258 | */ 259 | public void setOnScrolling(boolean onScrolling) { 260 | this.onScrolling = onScrolling; 261 | } 262 | 263 | public int size() { 264 | return mData.size(); 265 | } 266 | 267 | public List subList(int start, int end) { 268 | return mData.subList(start, end); 269 | } 270 | 271 | public Object[] toArray() { 272 | return mData.toArray(); 273 | } 274 | 275 | public T[] toArray(T[] array) { 276 | return mData.toArray(array); 277 | } 278 | 279 | /*** 280 | * 更新整个列表
281 | * 先删除列表内数据,再更新 282 | * */ 283 | public void upData(List mData) { 284 | if (mData == null) { 285 | this.mData = mData; 286 | } else { 287 | this.mData.clear(); 288 | this.mData.addAll(mData); 289 | 290 | } 291 | 292 | this.notifyDataSetChanged(); 293 | 294 | } 295 | 296 | } -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/XAdapter2.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import android.content.Context; 7 | import android.util.Log; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | /** 13 | * 14 | * @说明 懒惰使人更进一步 15 | * 16 | * 使用反射做adapter
17 | * 使用的时候只需要写一个ViewHolder 继承自{@link XViewHolder}
18 | * 当@link 19 | * {@link XAdapter2#convertView(int, View, ViewGroup, ArrayList, LayoutInflater)} 20 | * 时对viewholder进行实例化. 初始化view 21 | * 22 | * @author comcp@126.com 23 | * 24 | * @version v1.6 25 | * 26 | * @创建时间:2015-2-3 27 | * **/ 28 | public class XAdapter2 extends XAdapter implements IXAdapter { 29 | private static final String tag = "XAdapter2"; 30 | private OnClickItemListener clickItemListener; 31 | private OnLongClickItemListener longClickItemListener; 32 | private Class> viewBean; 33 | 34 | public XAdapter2(Context context, List mData, 35 | Class> xViewHolder) { 36 | super(context, mData, null); 37 | super.setAdapterInterface(this); 38 | if (xViewHolder == null) 39 | throw new NullPointerException( 40 | "XAdapter2(context,List,Class) :最后一个参数 class 不能为空"); 41 | this.viewBean = xViewHolder; 42 | 43 | } 44 | 45 | public XAdapter2(Context context, 46 | Class> xViewHolder) { 47 | this(context, null, xViewHolder); 48 | } 49 | 50 | /** 51 | * 增加String 载入class, 52 | * 53 | * 可以通过 配置文件动态载入不同viewHolder 54 | * 55 | * 好像是没什么卵用. 56 | * 57 | * **/ 58 | @SuppressWarnings("unchecked") 59 | public XAdapter2(Context context, String className) 60 | throws ClassNotFoundException { 61 | this(context, null, (Class>) Class 62 | .forName(className)); 63 | } 64 | 65 | @Override 66 | public View convertView(int position, View convertView, ViewGroup parent, 67 | List mData, LayoutInflater inflater) { 68 | IXViewHolder holder = null; 69 | 70 | if (convertView == null 71 | || !(convertView.getTag() instanceof IXViewHolder)) { 72 | 73 | if (viewBean != null) { 74 | 75 | try { 76 | holder = (IXViewHolder) viewBean.newInstance(); 77 | holder.setInflater(inflater, parent); 78 | holder.onCreate(context); 79 | holder.setOnClickItemListener(this.clickItemListener); 80 | holder.setOnLongClickItemListener(longClickItemListener); 81 | } catch (InstantiationException e) { 82 | e.printStackTrace(); 83 | } catch (IllegalAccessException e) { 84 | e.printStackTrace(); 85 | } 86 | 87 | } else { 88 | Log.e(tag, "没有设置 IXViewHolder "); 89 | return super.getView(position, convertView, parent); 90 | } 91 | 92 | } else { 93 | holder = (IXViewHolder) convertView.getTag(); 94 | holder.onDestory(position, getCount()); 95 | } 96 | if (holder != null) { 97 | holder.setListSize(getCount()); 98 | return holder.getView(mData.get(position), position, 99 | isOnScrolling()); 100 | } else 101 | return super.getView(position, convertView, parent); 102 | } 103 | 104 | public OnClickItemListener getClickItemListener() { 105 | return clickItemListener; 106 | } 107 | 108 | public OnLongClickItemListener getLongClickItemListener() { 109 | return longClickItemListener; 110 | } 111 | 112 | public void setClickItemListener(OnClickItemListener clickItemListener) { 113 | this.clickItemListener = clickItemListener; 114 | } 115 | 116 | public void setLongClickItemListener( 117 | OnLongClickItemListener longClickItemListener) { 118 | this.longClickItemListener = longClickItemListener; 119 | } 120 | } -------------------------------------------------------------------------------- /StupidAdapter/src/com/stupid/method/adapter/XViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.stupid.method.adapter; 2 | 3 | import java.lang.reflect.ParameterizedType; 4 | import java.lang.reflect.Type; 5 | 6 | import android.content.Context; 7 | import android.content.res.Resources; 8 | import android.graphics.drawable.Drawable; 9 | import android.util.Log; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.View.OnClickListener; 13 | import android.view.View.OnKeyListener; 14 | import android.view.View.OnLongClickListener; 15 | import android.view.View.OnTouchListener; 16 | import android.view.ViewGroup; 17 | 18 | /** 19 | * @说明: 执行顺序 {@link XViewHolder#getLayoutId()} 20 | * {@link XViewHolder#onCreate(XAdapter, android.content.Context)} 21 | * {@link XViewHolder#onDestory(int)} 22 | * {@link XViewHolder#onResetView(Object, int)} 23 | * 24 | * @警告 请不要手动调用 {@link IXViewHolder #getView(Object, int)} 25 | * 26 | * 27 | * @author comcp@126.com
28 | * github: https://github.com/comcp/android-StupidMethod 29 | * @version v1.7 30 | * 31 | * @创建时间:2014-12-3上午11:21:31 32 | * 33 | * 34 | * 增加异常抛出,不再拦截异常 35 | * 36 | */ 37 | abstract public class XViewHolder implements IXViewHolder, 38 | OnClickListener, OnLongClickListener { 39 | 40 | protected Context context; 41 | 42 | protected LayoutInflater inflater; 43 | 44 | private OnClickItemListener itemListener; 45 | 46 | private OnLongClickItemListener longClickItemListener; 47 | protected Type entityClass; 48 | 49 | protected T mData; 50 | 51 | protected View mRoot; 52 | private boolean onScrolling; 53 | 54 | private int position; 55 | public String tag = this.getClass().getSimpleName(); 56 | 57 | protected View findViewById(int id) { 58 | if (mRoot != null) 59 | return mRoot.findViewById(id); 60 | else 61 | return null; 62 | } 63 | 64 | @Override 65 | public abstract int getLayoutId(); 66 | 67 | public int getPosition() { 68 | return position; 69 | } 70 | 71 | public Resources getResources() { 72 | return mRoot.getResources(); 73 | } 74 | 75 | /** 76 | * 如果用户要用代码创建View,重写getView(); 77 | * 78 | *
 79 | 	 * @Override
 80 | 	 * public View getView() {
 81 | 	 * 
 82 | 	 * 	if (super.getView() == null) {
 83 | 	 * 		mRoot = new View(context);
 84 | 	 * 	}
 85 | 	 * 
 86 | 	 * 	return super.getView();
 87 | 	 * }
 88 | 	 * 
 89 | 	 * 
90 | **/ 91 | @Override 92 | public View getView() { 93 | return mRoot; 94 | } 95 | 96 | @Override 97 | public View getView(T data, int position, boolean onScrolling) { 98 | this.setOnScrolling(onScrolling); 99 | this.setPosition(position); 100 | mRoot.setTag(this); 101 | try { 102 | // 会出现强制类型转换问题 103 | onResetView(data, position); 104 | } catch (NullPointerException e) { 105 | Log.e(tag, String.format("在[%s]发生空指针异常,数据[%s],position[%d]", tag, 106 | data == null ? "null" : data.toString(), position)); 107 | throw e; 108 | } catch (ClassCastException e) { 109 | Log.e(tag, String.format("在[%s] 发生类型转换异常->数据类型[%s] 无法转换成 泛型类型[%s]", 110 | tag, data == null ? "null" : data.getClass(), 111 | getEntityClass())); 112 | throw e; 113 | } 114 | return mRoot; 115 | } 116 | 117 | public boolean isOnScrolling() { 118 | return onScrolling; 119 | } 120 | 121 | @Override 122 | public void onClick(View v) { 123 | if (itemListener != null) { 124 | itemListener.onClickItem(v, getPosition()); 125 | } 126 | 127 | } 128 | 129 | @Override 130 | public void onDestory(int nextPosition, int count) { 131 | 132 | } 133 | 134 | @Override 135 | public boolean onLongClick(View v) { 136 | if (longClickItemListener != null) { 137 | return longClickItemListener.onLongClickItem(v, getPosition()); 138 | } else 139 | return false; 140 | } 141 | 142 | public final XViewHolder setView(View v) { 143 | mRoot = v; 144 | return this; 145 | } 146 | 147 | public abstract void onResetView(T data, int position); 148 | 149 | public boolean post(Runnable action) { 150 | return mRoot.post(action); 151 | } 152 | 153 | public void setBackgroundColor(int color) { 154 | mRoot.setBackgroundColor(color); 155 | } 156 | 157 | public void setBackgroundDrawable(Drawable d) { 158 | mRoot.setBackgroundDrawable(d); 159 | } 160 | 161 | public void setBackgroundResource(int resid) { 162 | mRoot.setBackgroundResource(resid); 163 | } 164 | 165 | protected void setData(T data) { 166 | 167 | mData = data; 168 | 169 | } 170 | 171 | @Override 172 | public View setInflater(LayoutInflater inflater, ViewGroup parent) { 173 | this.inflater = inflater; 174 | this.context = inflater.getContext(); 175 | 176 | if (mRoot == null) 177 | mRoot = getView();// 如果返回不为null,则使用该view 178 | if (mRoot == null) { 179 | mRoot = inflater.inflate(getLayoutId(), parent, false); 180 | if (mRoot == null) { 181 | Log.e(tag, 182 | String.format( 183 | "[%s]类未实现getLayoutId(),或者传递进来的layout id 是错误的,当前获得到的layoutId为[%d]", 184 | getClass(), getLayoutId())); 185 | throw new NullPointerException( 186 | "通过 getLayoutId() 无法 inflate layout"); 187 | } 188 | } 189 | return mRoot; 190 | } 191 | 192 | public void setLongClickable(boolean longClickable) { 193 | mRoot.setLongClickable(longClickable); 194 | } 195 | 196 | @Override 197 | public void setOnClickItemListener(OnClickItemListener itemListener) { 198 | this.itemListener = itemListener; 199 | } 200 | 201 | public void setOnClickListener(OnClickListener l) { 202 | if (mRoot != null) 203 | mRoot.setOnClickListener(l); 204 | } 205 | 206 | public void setOnKeyListener(OnKeyListener l) { 207 | mRoot.setOnKeyListener(l); 208 | 209 | } 210 | 211 | @Override 212 | public void setOnLongClickItemListener( 213 | OnLongClickItemListener longClickItemListener) { 214 | this.longClickItemListener = longClickItemListener; 215 | 216 | } 217 | 218 | public void setOnLongClickListener(OnLongClickListener l) { 219 | if (mRoot != null) 220 | mRoot.setOnLongClickListener(l); 221 | } 222 | 223 | public void setOnScrolling(boolean onScrolling) { 224 | this.onScrolling = onScrolling; 225 | } 226 | 227 | public void setOnTouchListener(OnTouchListener l) { 228 | mRoot.setOnTouchListener(l); 229 | } 230 | 231 | public void setPosition(int position) { 232 | this.position = position; 233 | } 234 | 235 | public void setTag(int key, Object tag) { 236 | mRoot.setTag(key, tag); 237 | } 238 | 239 | public void setTag(Object tag) { 240 | mRoot.setTag(tag); 241 | } 242 | 243 | protected Type getEntityClass() { 244 | if (entityClass == null) { 245 | ParameterizedType type = (ParameterizedType) getClass() 246 | .getGenericSuperclass(); 247 | 248 | Type[] t = type.getActualTypeArguments(); 249 | if (t.length > 0) 250 | entityClass = t[0]; 251 | else 252 | Log.w(tag, "无法获得泛型类型"); 253 | } 254 | return entityClass; 255 | } 256 | 257 | @Override 258 | public String toString() { 259 | 260 | return String.format("%s<%s>->hashCode:%d", getClass().toString(), 261 | hashCode()); 262 | } 263 | 264 | @Override 265 | public void setListSize(int size) { 266 | 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /StupidDemo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /StupidDemo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | StupidDemo 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /StupidDemo/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /StupidDemo/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 34 | 35 | 38 | 39 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /StupidDemo/assets/stupidadapter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/assets/stupidadapter.jar -------------------------------------------------------------------------------- /StupidDemo/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/ic_launcher-web.png -------------------------------------------------------------------------------- /StupidDemo/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/android-support-v4.jar -------------------------------------------------------------------------------- /StupidDemo/libs/android-support-v7-recyclerview.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/android-support-v7-recyclerview.jar -------------------------------------------------------------------------------- /StupidDemo/libs/androidquery.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/androidquery.jar -------------------------------------------------------------------------------- /StupidDemo/libs/fastjson-1.1.45.android.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/fastjson-1.1.45.android.jar -------------------------------------------------------------------------------- /StupidDemo/libs/stupidadapter.expandadapter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/stupidadapter.expandadapter.jar -------------------------------------------------------------------------------- /StupidDemo/libs/stupidadapter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/stupidadapter.jar -------------------------------------------------------------------------------- /StupidDemo/libs/stupidadapter.recyclerviewadapter.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/stupidadapter.recyclerviewadapter.jar -------------------------------------------------------------------------------- /StupidDemo/libs/stupidxhttp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/libs/stupidxhttp.jar -------------------------------------------------------------------------------- /StupidDemo/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /StupidDemo/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | -------------------------------------------------------------------------------- /StupidDemo/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/tx_receive_foused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/tx_receive_foused.9.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/tx_receive_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/tx_receive_normal.9.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/tx_sender_foused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/tx_sender_foused.9.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/tx_sender_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/tx_sender_normal.9.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable-xxhdpi/yb.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcp/android-Stupid-Adapter/6571bd9d4431bb69a874540abfd0bb5c1862264c/StupidDemo/res/drawable-xxhdpi/yb.9.png -------------------------------------------------------------------------------- /StupidDemo/res/drawable/bg_tx_receive.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /StupidDemo/res/drawable/bg_tx_sender.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /StupidDemo/res/layout/activity_grid_demo.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /StupidDemo/res/layout/activity_list_demo.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /StupidDemo/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 |