Skip to content

Commit d057eed

Browse files
authored
feat(android): add fixedSize to RecyclerViews (#13138)
* feat(android): add fixedSize to ListView * feat(android): add fixedSize to TableView * docs * docs
1 parent 0d20ec0 commit d057eed

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/TiListView.java

+3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ public boolean inSelectionHotspot(@NonNull MotionEvent e)
267267
finalbooleanallowsMultipleSelection
268268
= properties.optBoolean(TiC.PROPERTY_ALLOWS_MULTIPLE_SELECTION_DURING_EDITING, false);
269269

270+
if (properties.optBoolean(TiC.PROPERTY_FIXED_SIZE, false)) {
271+
this.recyclerView.setHasFixedSize(true);
272+
}
270273
if (editing && allowsSelection) {
271274
if (allowsMultipleSelection) {
272275
this.tracker = trackerBuilder.withSelectionPredicate(SelectionPredicates.createSelectAnything())

android/modules/ui/src/java/ti/modules/titanium/ui/widget/tableview/TiTableView.java

+3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ public boolean inSelectionHotspot(@NonNull MotionEvent e)
244244
finalbooleanallowsMultipleSelection
245245
= properties.optBoolean(TiC.PROPERTY_ALLOWS_MULTIPLE_SELECTION_DURING_EDITING, false);
246246

247+
if (properties.optBoolean(TiC.PROPERTY_FIXED_SIZE, false)) {
248+
this.recyclerView.setHasFixedSize(true);
249+
}
247250
if (editing && allowsSelection) {
248251
if (allowsMultipleSelection) {
249252
this.tracker = trackerBuilder.withSelectionPredicate(SelectionPredicates.createSelectAnything())

android/titanium/src/java/org/appcelerator/titanium/TiC.java

+1
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ public class TiC
832832
publicstaticfinalStringPROPERTY_LASTPHONETIC = "lastPhonetic";
833833
publicstaticfinalStringPROPERTY_JOBTITLE = "jobTitle";
834834
publicstaticfinalStringPROPERTY_DEPARTMENT = "department";
835+
publicstaticfinalStringPROPERTY_FIXED_SIZE = "fixedSize";
835836

836837
publicstaticfinalStringSIZE_AUTO = "auto";
837838
publicstaticfinalStringURL_APP_PREFIX = "app://";

apidoc/Titanium/UI/ListView.yml

+10
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ properties:
685685
since: 7.5.0
686686
platforms: [android]
687687

688+
- name: fixedSize
689+
summary: Sets fixedSize mode on Android ListViews.
690+
description: |
691+
Set it to `true` if all ListItems have the same size to gain some performance.
692+
type: Boolean
693+
default: false
694+
availability: creation
695+
since: 10.2.0
696+
platforms: [android]
697+
688698
- name: allowsSelectionDuringEditing
689699
summary: Determines whether this list view items can be selected while editing the table.
690700
type: Boolean

apidoc/Titanium/UI/TableView.yml

+10
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,16 @@ properties:
11541154
default: true
11551155
platforms: [android, iphone, ipad, macos]
11561156

1157+
- name: fixedSize
1158+
summary: Sets fixedSize mode on Android TableView.
1159+
description: |
1160+
Set it to `true` if all TableView items have the same size to gain some performance.
1161+
type: Boolean
1162+
default: false
1163+
availability: creation
1164+
since: 10.2.0
1165+
platforms: [android]
1166+
11571167
- name: footerDividersEnabled
11581168
summary: When set to false, the ListView will not draw the divider before the footer view.
11591169
type: Boolean

0 commit comments

Comments
 (0)
close