├── .gitignore
├── LICENSE
├── README.md
├── layout.png
├── layout2.png
├── menu.png
├── method分析.txt
└── recyclerView4Tv
├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── lp
│ │ └── recyclerview4tv
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── lp
│ │ │ └── recyclerview4tv
│ │ │ ├── MainActivity.java
│ │ │ ├── data
│ │ │ └── Datas.java
│ │ │ └── example
│ │ │ ├── BaseExampleActivity.java
│ │ │ ├── GridLayoutActivity.java
│ │ │ ├── LinearLayoutActivity.java
│ │ │ └── StaggeredGridActivity.java
│ └── res
│ │ ├── drawable
│ │ └── select_border.9.png
│ │ ├── layout
│ │ ├── activity_grid_layout.xml
│ │ ├── activity_main.xml
│ │ ├── activity_staggered_grid.xml
│ │ ├── activity_staggered_layout.xml
│ │ ├── item_example.xml
│ │ ├── item_linear_h.xml
│ │ └── item_main_example.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── loaderror.png
│ │ └── loading.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── lp
│ └── recyclerview4tv
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── recyclerview4tvlibrary
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── lp
│ │ └── recyclerview4tvlibrary
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── lp
│ │ │ └── recyclerview4tvlibrary
│ │ │ ├── effect
│ │ │ ├── BaseEffect.java
│ │ │ └── RecyclerViewEffect.java
│ │ │ ├── utils
│ │ │ ├── OperationManager.java
│ │ │ └── ViewUtils.java
│ │ │ └── view
│ │ │ ├── FocusFrameView.java
│ │ │ ├── MenuDialogView.java
│ │ │ ├── OperateView.java
│ │ │ └── TvRecyclerView.java
│ └── res
│ │ ├── drawable
│ │ ├── menu_btn_bg.xml
│ │ ├── shape_selected.xml
│ │ └── shape_unselected.xml
│ │ ├── layout
│ │ ├── layout_menu_dialog.xml
│ │ ├── layout_operateview.xml
│ │ └── layout_place_holder.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── lp
│ └── recyclerview4tvlibrary
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
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 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/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.md:
--------------------------------------------------------------------------------
1 | # recyclerView4Tv
2 | 在Tv端使用的RecyclerView,修复了由于数据更新,导致的布局错乱,焦点乱跑.
3 | 
4 |
5 | 
6 |
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/layout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/littleloulou/TvRecyclerView/5dbe5f3c92f67c64200387950c8418b00f7cf903/layout.png
--------------------------------------------------------------------------------
/layout2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/littleloulou/TvRecyclerView/5dbe5f3c92f67c64200387950c8418b00f7cf903/layout2.png
--------------------------------------------------------------------------------
/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/littleloulou/TvRecyclerView/5dbe5f3c92f67c64200387950c8418b00f7cf903/menu.png
--------------------------------------------------------------------------------
/method分析.txt:
--------------------------------------------------------------------------------
1 |
2 | //当前选中的第一个条目时候
3 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: child:=========>android.support.v7.widget.AppCompatTextView{41e4b9d0 VFED..CL .F....I. 20,20-520,100 #7f0b0058 app:id/tv_example}
4 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: rect:==========>Rect(0, 0 - 500, 80)
5 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: ********************************
6 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: parentLeft:======>10
7 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: parentTop:======>10
8 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: parentRight:======>530
9 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: parentBottom:======>610
10 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: ********************************
11 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: childLeft:======>20
12 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: childTop:======>20
13 | 11-18 10:15:37.236 8451-8451/com.lp.recyclerview4tv I/System.out: childRight:======>520
14 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: childBottom:======>100
15 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: ********************************
16 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: offScreenLeft:======>0
17 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: offScreenTop:======>0
18 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: offScreenRight:======>0
19 | 11-18 10:15:37.246 8451-8451/com.lp.recyclerview4tv I/System.out: offScreenBottom:======>0
20 | ...
21 | ...
22 | ...
--------------------------------------------------------------------------------
/recyclerView4Tv/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/.name:
--------------------------------------------------------------------------------
1 | recyclerView4Tv
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
25 |
--------------------------------------------------------------------------------
/recyclerView4Tv/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/recyclerView4Tv/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction, and
10 | distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright
13 | owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all other entities
16 | that control, are controlled by, or are under common control with that entity.
17 | For the purposes of this definition, "control" means (i) the power, direct or
18 | indirect, to cause the direction or management of such entity, whether by
19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20 | outstanding shares, or (iii) beneficial ownership of such entity.
21 |
22 | "You" (or "Your") shall mean an individual or Legal Entity exercising
23 | permissions granted by this License.
24 |
25 | "Source" form shall mean the preferred form for making modifications, including
26 | but not limited to software source code, documentation source, and configuration
27 | files.
28 |
29 | "Object" form shall mean any form resulting from mechanical transformation or
30 | translation of a Source form, including but not limited to compiled object code,
31 | generated documentation, and conversions to other media types.
32 |
33 | "Work" shall mean the work of authorship, whether in Source or Object form, made
34 | available under the License, as indicated by a copyright notice that is included
35 | in or attached to the work (an example is provided in the Appendix below).
36 |
37 | "Derivative Works" shall mean any work, whether in Source or Object form, that
38 | is based on (or derived from) the Work and for which the editorial revisions,
39 | annotations, elaborations, or other modifications represent, as a whole, an
40 | original work of authorship. For the purposes of this License, Derivative Works
41 | shall not include works that remain separable from, or merely link (or bind by
42 | name) to the interfaces of, the Work and Derivative Works thereof.
43 |
44 | "Contribution" shall mean any work of authorship, including the original version
45 | of the Work and any modifications or additions to that Work or Derivative Works
46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work
47 | by the copyright owner or by an individual or Legal Entity authorized to submit
48 | on behalf of the copyright owner. For the purposes of this definition,
49 | "submitted" means any form of electronic, verbal, or written communication sent
50 | to the Licensor or its representatives, including but not limited to
51 | communication on electronic mailing lists, source code control systems, and
52 | issue tracking systems that are managed by, or on behalf of, the Licensor for
53 | the purpose of discussing and improving the Work, but excluding communication
54 | that is conspicuously marked or otherwise designated in writing by the copyright
55 | owner as "Not a Contribution."
56 |
57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58 | of whom a Contribution has been received by Licensor and subsequently
59 | incorporated within the Work.
60 |
61 | 2. Grant of Copyright License.
62 |
63 | Subject to the terms and conditions of this License, each Contributor hereby
64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65 | irrevocable copyright license to reproduce, prepare Derivative Works of,
66 | publicly display, publicly perform, sublicense, and distribute the Work and such
67 | Derivative Works in Source or Object form.
68 |
69 | 3. Grant of Patent License.
70 |
71 | Subject to the terms and conditions of this License, each Contributor hereby
72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73 | irrevocable (except as stated in this section) patent license to make, have
74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75 | such license applies only to those patent claims licensable by such Contributor
76 | that are necessarily infringed by their Contribution(s) alone or by combination
77 | of their Contribution(s) with the Work to which such Contribution(s) was
78 | submitted. If You institute patent litigation against any entity (including a
79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80 | Contribution incorporated within the Work constitutes direct or contributory
81 | patent infringement, then any patent licenses granted to You under this License
82 | for that Work shall terminate as of the date such litigation is filed.
83 |
84 | 4. Redistribution.
85 |
86 | You may reproduce and distribute copies of the Work or Derivative Works thereof
87 | in any medium, with or without modifications, and in Source or Object form,
88 | provided that You meet the following conditions:
89 |
90 | You must give any other recipients of the Work or Derivative Works a copy of
91 | this License; and
92 | You must cause any modified files to carry prominent notices stating that You
93 | changed the files; and
94 | You must retain, in the Source form of any Derivative Works that You distribute,
95 | all copyright, patent, trademark, and attribution notices from the Source form
96 | of the Work, excluding those notices that do not pertain to any part of the
97 | Derivative Works; and
98 | If the Work includes a "NOTICE" text file as part of its distribution, then any
99 | Derivative Works that You distribute must include a readable copy of the
100 | attribution notices contained within such NOTICE file, excluding those notices
101 | that do not pertain to any part of the Derivative Works, in at least one of the
102 | following places: within a NOTICE text file distributed as part of the
103 | Derivative Works; within the Source form or documentation, if provided along
104 | with the Derivative Works; or, within a display generated by the Derivative
105 | Works, if and wherever such third-party notices normally appear. The contents of
106 | the NOTICE file are for informational purposes only and do not modify the
107 | License. You may add Your own attribution notices within Derivative Works that
108 | You distribute, alongside or as an addendum to the NOTICE text from the Work,
109 | provided that such additional attribution notices cannot be construed as
110 | modifying the License.
111 | You may add Your own copyright statement to Your modifications and may provide
112 | additional or different license terms and conditions for use, reproduction, or
113 | distribution of Your modifications, or for any such Derivative Works as a whole,
114 | provided Your use, reproduction, and distribution of the Work otherwise complies
115 | with the conditions stated in this License.
116 |
117 | 5. Submission of Contributions.
118 |
119 | Unless You explicitly state otherwise, any Contribution intentionally submitted
120 | for inclusion in the Work by You to the Licensor shall be under the terms and
121 | conditions of this License, without any additional terms or conditions.
122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of
123 | any separate license agreement you may have executed with Licensor regarding
124 | such Contributions.
125 |
126 | 6. Trademarks.
127 |
128 | This License does not grant permission to use the trade names, trademarks,
129 | service marks, or product names of the Licensor, except as required for
130 | reasonable and customary use in describing the origin of the Work and
131 | reproducing the content of the NOTICE file.
132 |
133 | 7. Disclaimer of Warranty.
134 |
135 | Unless required by applicable law or agreed to in writing, Licensor provides the
136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138 | including, without limitation, any warranties or conditions of TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140 | solely responsible for determining the appropriateness of using or
141 | redistributing the Work and assume any risks associated with Your exercise of
142 | permissions under this License.
143 |
144 | 8. Limitation of Liability.
145 |
146 | In no event and under no legal theory, whether in tort (including negligence),
147 | contract, or otherwise, unless required by applicable law (such as deliberate
148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be
149 | liable to You for damages, including any direct, indirect, special, incidental,
150 | or consequential damages of any character arising as a result of this License or
151 | out of the use or inability to use the Work (including but not limited to
152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153 | any and all other commercial damages or losses), even if such Contributor has
154 | been advised of the possibility of such damages.
155 |
156 | 9. Accepting Warranty or Additional Liability.
157 |
158 | While redistributing the Work or Derivative Works thereof, You may choose to
159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160 | other liability obligations and/or rights consistent with this License. However,
161 | in accepting such obligations, You may act only on Your own behalf and on Your
162 | sole responsibility, not on behalf of any other Contributor, and only if You
163 | agree to indemnify, defend, and hold each Contributor harmless for any liability
164 | incurred by, or claims asserted against, such Contributor by reason of your
165 | accepting any such warranty or additional liability.
166 |
167 | END OF TERMS AND CONDITIONS
168 |
169 | APPENDIX: How to apply the Apache License to your work
170 |
171 | To apply the Apache License to your work, attach the following boilerplate
172 | notice, with the fields enclosed by brackets "{}" replaced with your own
173 | identifying information. (Don't include the brackets!) The text should be
174 | enclosed in the appropriate comment syntax for the file format. We also
175 | recommend that a file or class name and description of purpose be included on
176 | the same "printed page" as the copyright notice for easier identification within
177 | third-party archives.
178 |
179 | Copyright 2016 lph_xiaoloulou
180 |
181 | Licensed under the Apache License, Version 2.0 (the "License");
182 | you may not use this file except in compliance with the License.
183 | You may obtain a copy of the License at
184 |
185 | http://www.apache.org/licenses/LICENSE-2.0
186 |
187 | Unless required by applicable law or agreed to in writing, software
188 | distributed under the License is distributed on an "AS IS" BASIS,
189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 | See the License for the specific language governing permissions and
191 | limitations under the License.
192 |
--------------------------------------------------------------------------------
/recyclerView4Tv/README.md:
--------------------------------------------------------------------------------
1 | #recyclerView4Tv
2 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '23.0.3'
6 |
7 | defaultConfig {
8 | applicationId "com.lp.recyclerview4tv"
9 | minSdkVersion 16
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:24.2.1'
26 | compile project(':recyclerview4tvlibrary')
27 | compile 'com.github.bumptech.glide:glide:3.7.0'
28 | }
29 |
--------------------------------------------------------------------------------
/recyclerView4Tv/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 D:\dev\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 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/src/androidTest/java/com/lp/recyclerview4tv/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.lp.recyclerview4tv;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/recyclerView4Tv/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/src/main/java/com/lp/recyclerview4tv/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.lp.recyclerview4tv;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import com.lp.recyclerview4tv.example.GridLayoutActivity;
13 | import com.lp.recyclerview4tv.example.LinearLayoutActivity;
14 | import com.lp.recyclerview4tv.example.StaggeredGridActivity;
15 | import com.lp.recyclerview4tvlibrary.view.FocusFrameView;
16 | import com.lp.recyclerview4tvlibrary.view.TvRecyclerView;
17 |
18 | public class MainActivity extends AppCompatActivity {
19 |
20 | private TvRecyclerView mTvList;
21 | private FocusFrameView mFocusFrame;
22 | private LinearLayoutManager mManager;
23 |
24 | private static final String[] mDatas = {
25 | "LinearLayout--->HORIZONTAL",
26 | "LinearLayout--->VERTICAL",
27 | "GridLayout--->HORIZONTAL",
28 | "GridLayout--->VERTICAL",
29 | "StaggeredGridLayout--->HORIZONTAL",
30 | "StaggeredGridLayout--->VERTICAL",
31 | };
32 | private MenuAdapter mAdapter;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 | initView();
39 | }
40 |
41 |
42 | private void initView() {
43 | mTvList = ((TvRecyclerView) findViewById(R.id.trv));
44 | mFocusFrame = ((FocusFrameView) findViewById(R.id.frame));
45 | mTvList.initFrame(mFocusFrame, R.drawable.select_border, -2);
46 | mManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
47 | mTvList.setLayoutManager(mManager);
48 | mTvList.setOnItemListener(new TvRecyclerView.OnItemListener() {
49 | @Override
50 | public boolean onItemPreSelected(TvRecyclerView parent, View itemView, int position) {
51 | return false;
52 | }
53 |
54 | @Override
55 | public boolean onItemSelected(TvRecyclerView parent, View itemView, int position) {
56 | return false;
57 | }
58 |
59 | @Override
60 | public boolean onReviseFocusFollow(TvRecyclerView parent, View itemView, int position) {
61 | return false;
62 | }
63 |
64 | @Override
65 | public void onItemClick(TvRecyclerView parent, View itemView, int position) {
66 | switch (position) {
67 | case 0:
68 | Intent intent = new Intent(MainActivity.this, LinearLayoutActivity.class);
69 | intent.putExtra("isVertical", "0");
70 | startActivity(intent);
71 | break;
72 | case 1:
73 | Intent intent1 = new Intent(MainActivity.this, LinearLayoutActivity.class);
74 | intent1.putExtra("isVertical", "1");
75 | startActivity(intent1);
76 | break;
77 | case 2:
78 | Intent intent2 = new Intent(MainActivity.this, GridLayoutActivity.class);
79 | intent2.putExtra("isVertical", "0");
80 | startActivity(intent2);
81 | break;
82 | case 3:
83 | Intent intent3 = new Intent(MainActivity.this, GridLayoutActivity.class);
84 | intent3.putExtra("isVertical", "1");
85 | startActivity(intent3);
86 | break;
87 | case 4:
88 | Intent intent4 = new Intent(MainActivity.this, StaggeredGridActivity.class);
89 | intent4.putExtra("isVertical", "0");
90 | startActivity(intent4);
91 | break;
92 | case 5:
93 | Intent intent5 = new Intent(MainActivity.this, StaggeredGridActivity.class);
94 | intent5.putExtra("isVertical", "1");
95 | startActivity(intent5);
96 | break;
97 | }
98 | }
99 |
100 | @Override
101 | public boolean onItemLongClick(TvRecyclerView parent, View itemView, int position) {
102 | return false;
103 | }
104 | });
105 | mAdapter = new MenuAdapter();
106 | mTvList.setAdapter(mAdapter);
107 | }
108 |
109 | class MenuAdapter extends TvRecyclerView.TvAdapter {
110 | @Override
111 | public TvRecyclerView.TvViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
112 | return new MenuHolder(LayoutInflater.from(MainActivity.this).inflate(R.layout.item_main_example, parent, false));
113 | }
114 |
115 | @Override
116 | public void onBindViewHolder(TvRecyclerView.TvViewHolder holder, int position) {
117 | ((TextView) holder.itemView).setText(mDatas[position]);
118 | }
119 |
120 | @Override
121 | public int getItemCount() {
122 | return mDatas.length;
123 | }
124 |
125 | @Override
126 | protected Object getData(int start) {
127 | return null;
128 | }
129 | }
130 |
131 | class MenuHolder extends TvRecyclerView.TvViewHolder {
132 | public MenuHolder(View itemView) {
133 | super(itemView);
134 | }
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/src/main/java/com/lp/recyclerview4tv/data/Datas.java:
--------------------------------------------------------------------------------
1 | package com.lp.recyclerview4tv.data;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by lph on 2016/11/3.
10 | * 模拟数据,如果想扩展可以使用RxJava 和 Retrofit 从网络获取资源
11 | */
12 | public class Datas {
13 | private static List dataLists = new ArrayList<>();
14 |
15 | //这样写会item条目越来越多,这种效果
16 | public static List getDatas() {
17 | String[] datas = {
18 | "http://img4.imgtn.bdimg.com/it/u=2263564587,3827516789&fm=11&gp=0.jpg",
19 | "http://img4.imgtn.bdimg.com/it/u=2001849689,2934143493&fm=11&gp=0.jpg",
20 | "http://img1.imgtn.bdimg.com/it/u=3757412355,3884139848&fm=21&gp=0.jpg",
21 | "http://img3.imgtn.bdimg.com/it/u=419977589,4263339770&fm=11&gp=0.jpg",
22 | "http://img4.imgtn.bdimg.com/it/u=3059488398,1048400338&fm=21&gp=0.jpg",
23 | "http://img3.imgtn.bdimg.com/it/u=1560600784,4035223257&fm=21&gp=0.jpg",
24 | "http://img3.imgtn.bdimg.com/it/u=2497352402,3816602579&fm=21&gp=0.jpg",
25 | "http://d.ifengimg.com/w155_h107_q80/p0.ifengimg.com/a/2016_45/293f360c3994b17_size66_w206_h142.jpg",
26 | "http://d.ifengimg.com/w512_h288_q80/p3.ifengimg.com/cmpp/2016/11/03/502bdc446946330749bd670e73252746_size298_w640_h360.jpg",
27 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/a/2016_45/be27daf8bd89165_size64_w554_h361.jpg",
28 | "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=412147864,1332891885&fm=80&w=179&h=119&img.jpg",
29 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/ifengimcp/pic/20161103/199466c84c143bc76a61_size9_w168_h120.jpg",
30 | "http://img1.imgtn.bdimg.com/it/u=1207158778,2343027651&fm=11&gp=0.jpg",
31 | "http://d.hiphotos.baidu.com/image/h%3D360/sign=856d60650933874483c5297a610fd937/55e736d12f2eb938e81944c7d0628535e5dd6f8a.jpg",
32 | "http://d.ifengimg.com/w166_h120/p0.ifengimg.com/ifengiclient/ipic/2016052821/swoole_location_0b913b85734fa084386466b74facd719_size96_w533_h768.jpg",
33 | "http://img4.imgtn.bdimg.com/it/u=2263564587,3827516789&fm=11&gp=0.jpg",
34 | "http://img4.imgtn.bdimg.com/it/u=2001849689,2934143493&fm=11&gp=0.jpg",
35 | "http://img1.imgtn.bdimg.com/it/u=3757412355,3884139848&fm=21&gp=0.jpg",
36 | "http://img3.imgtn.bdimg.com/it/u=419977589,4263339770&fm=11&gp=0.jpg",
37 | "http://img4.imgtn.bdimg.com/it/u=3059488398,1048400338&fm=21&gp=0.jpg",
38 | "http://img3.imgtn.bdimg.com/it/u=1560600784,4035223257&fm=21&gp=0.jpg",
39 | "http://img3.imgtn.bdimg.com/it/u=2497352402,3816602579&fm=21&gp=0.jpg",
40 | "http://d.ifengimg.com/w155_h107_q80/p0.ifengimg.com/a/2016_45/293f360c3994b17_size66_w206_h142.jpg",
41 | "http://d.ifengimg.com/w512_h288_q80/p3.ifengimg.com/cmpp/2016/11/03/502bdc446946330749bd670e73252746_size298_w640_h360.jpg",
42 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/a/2016_45/be27daf8bd89165_size64_w554_h361.jpg",
43 | "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=412147864,1332891885&fm=80&w=179&h=119&img.jpg",
44 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/ifengimcp/pic/20161103/199466c84c143bc76a61_size9_w168_h120.jpg",
45 | "http://img1.imgtn.bdimg.com/it/u=1207158778,2343027651&fm=11&gp=0.jpg",
46 | "http://d.hiphotos.baidu.com/image/h%3D360/sign=856d60650933874483c5297a610fd937/55e736d12f2eb938e81944c7d0628535e5dd6f8a.jpg",
47 | "http://d.ifengimg.com/w166_h120/p0.ifengimg.com/ifengiclient/ipic/2016052821/swoole_location_0b913b85734fa084386466b74facd719_size96_w533_h768.jpg",
48 | "http://img4.imgtn.bdimg.com/it/u=2263564587,3827516789&fm=11&gp=0.jpg",
49 | "http://img4.imgtn.bdimg.com/it/u=2001849689,2934143493&fm=11&gp=0.jpg",
50 | "http://img1.imgtn.bdimg.com/it/u=3757412355,3884139848&fm=21&gp=0.jpg",
51 | "http://img3.imgtn.bdimg.com/it/u=419977589,4263339770&fm=11&gp=0.jpg",
52 | "http://img4.imgtn.bdimg.com/it/u=3059488398,1048400338&fm=21&gp=0.jpg",
53 | "http://img3.imgtn.bdimg.com/it/u=1560600784,4035223257&fm=21&gp=0.jpg",
54 | "http://img3.imgtn.bdimg.com/it/u=2497352402,3816602579&fm=21&gp=0.jpg",
55 | "http://d.ifengimg.com/w155_h107_q80/p0.ifengimg.com/a/2016_45/293f360c3994b17_size66_w206_h142.jpg",
56 | "http://d.ifengimg.com/w512_h288_q80/p3.ifengimg.com/cmpp/2016/11/03/502bdc446946330749bd670e73252746_size298_w640_h360.jpg",
57 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/a/2016_45/be27daf8bd89165_size64_w554_h361.jpg",
58 | "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=412147864,1332891885&fm=80&w=179&h=119&img.jpg",
59 | "http://d.ifengimg.com/w132_h94_q80/p0.ifengimg.com/ifengimcp/pic/20161103/199466c84c143bc76a61_size9_w168_h120.jpg",
60 | "http://img1.imgtn.bdimg.com/it/u=1207158778,2343027651&fm=11&gp=0.jpg",
61 | "http://d.hiphotos.baidu.com/image/h%3D360/sign=856d60650933874483c5297a610fd937/55e736d12f2eb938e81944c7d0628535e5dd6f8a.jpg",
62 | "http://d.ifengimg.com/w166_h120/p0.ifengimg.com/ifengiclient/ipic/2016052821/swoole_location_0b913b85734fa084386466b74facd719_size96_w533_h768.jpg"
63 | };
64 | if (dataLists.size() > 0) {
65 | return dataLists;
66 | }
67 | dataLists.addAll(Arrays.asList(datas));
68 | // 下面这样写会抛出异常的,原因是因为Arrays.asList返回的ArrayList 并不是java.utils包下的ArrayList,而是java.utils.arrays.ArrayList
69 | //他们都实现了List接口
70 | //改ArrayList 不支持add 和 addAll操作,想想也毕竟是通过数组转换而来的,而数组的长度是不可以动态增加的
71 | // List list1 = Arrays.asList(datas);
72 | // List list2 = Arrays.asList(datas2);
73 | // list2.addAll(list1);
74 | return dataLists;
75 | }
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/recyclerView4Tv/app/src/main/java/com/lp/recyclerview4tv/example/BaseExampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.lp.recyclerview4tv.example;
2 |
3 | import android.graphics.Rect;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.KeyEvent;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 | import android.widget.Toast;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.lp.recyclerview4tv.R;
17 | import com.lp.recyclerview4tv.data.Datas;
18 | import com.lp.recyclerview4tvlibrary.utils.OperationManager;
19 | import com.lp.recyclerview4tvlibrary.utils.ViewUtils;
20 | import com.lp.recyclerview4tvlibrary.view.FocusFrameView;
21 | import com.lp.recyclerview4tvlibrary.view.MenuDialogView;
22 | import com.lp.recyclerview4tvlibrary.view.OperateView;
23 | import com.lp.recyclerview4tvlibrary.view.TvRecyclerView;
24 |
25 | import java.util.ArrayList;
26 | import java.util.Collections;
27 | import java.util.List;
28 |
29 | /**
30 | * Created by lph on 2016/11/3.
31 | */
32 | public abstract class BaseExampleActivity extends AppCompatActivity {
33 |
34 | private List mDatas = new ArrayList<>();
35 | protected TvRecyclerView mTvRecyclerView;
36 | protected FocusFrameView mFocusFrame;
37 | protected DefaultAdapter mAdapter;
38 | protected String mIsVertical;
39 | private MenuDialogView mMenuDialog;
40 | private int mCurrentFocus;
41 | private OperationManager.OperateParameter mParameter;
42 | private OperationManager mManager;
43 | private List mOperateData;
44 | private View mCrurrentItemView;
45 |
46 | @Override
47 | protected void onCreate(@Nullable Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(getContentResource());
50 | mIsVertical = getIntent().getStringExtra("isVertical");
51 | initData();
52 | initView();
53 | }
54 |
55 | protected void initView() {
56 | mTvRecyclerView = ((TvRecyclerView) findViewById(R.id.trv));
57 | mFocusFrame = ((FocusFrameView) findViewById(R.id.frame));
58 | mTvRecyclerView.initFrame(mFocusFrame, R.drawable.select_border, getFramePadding());
59 | mTvRecyclerView.setOnItemListener(getItemListener());
60 | mTvRecyclerView.setLayoutManager(getLayoutManager());
61 | mTvRecyclerView.setItemScale(1.1f);
62 | mAdapter = new DefaultAdapter();
63 | mTvRecyclerView.setAdapter(mAdapter);
64 | }
65 |
66 | protected abstract RecyclerView.LayoutManager getLayoutManager();
67 |
68 | protected TvRecyclerView.OnItemListener getItemListener() {
69 | return new TvRecyclerView.OnItemListener() {
70 | @Override
71 | public boolean onItemPreSelected(TvRecyclerView parent, View itemView, int position) {
72 | return false;
73 | }
74 |
75 | @Override
76 | public boolean onItemSelected(TvRecyclerView parent, View itemView, int position) {
77 | mCrurrentItemView = itemView;
78 | mCurrentFocus = position;
79 | return false;
80 | }
81 |
82 | @Override
83 | public boolean onReviseFocusFollow(TvRecyclerView parent, View itemView, int position) {
84 | return false;
85 | }
86 |
87 | @Override
88 | public void onItemClick(TvRecyclerView parent, View itemView, int position) {
89 | Toast.makeText(BaseExampleActivity.this, "按菜单键对item进行操作", Toast.LENGTH_LONG).show();
90 | }
91 |
92 | @Override
93 | public boolean onItemLongClick(TvRecyclerView parent, View itemView, int position) {
94 | Toast.makeText(BaseExampleActivity.this, "onItemLongClick------>:" + position, Toast.LENGTH_SHORT).show();
95 | return true;
96 | }
97 | };
98 | }
99 |
100 | protected abstract int getFramePadding();
101 |
102 |
103 | protected void initData() {
104 | /* for (int i = 0; i < 20; i++) {
105 | if (i < Datas.getDatas().size()) {
106 | mDatas.add(Datas.getDatas().get(i));
107 | } else {
108 | mDatas.add(i + "");
109 | }
110 | }*/
111 | mDatas.clear();
112 | for (String data : Datas.getDatas()) {
113 | mDatas.add(data);
114 | }
115 | }
116 |
117 | protected int getContentResource() {
118 | return R.layout.activity_main;
119 | }
120 |
121 | class DefaultAdapter extends TvRecyclerView.TvAdapter {
122 | @Override
123 | public TvRecyclerView.TvViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
124 | return getViewHolder(parent, viewType);
125 | }
126 |
127 | @Override
128 | public void onBindViewHolder(TvRecyclerView.TvViewHolder holder, int position) {
129 | changeSize(holder.itemView, position);
130 | holder.setData(mDatas.get(position));
131 | }
132 |
133 | @Override
134 | public int getItemCount() {
135 | return mDatas.size();
136 | }
137 |
138 | @Override
139 | public void onBindViewHolder(TvRecyclerView.TvViewHolder holder, int position, List