Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add flag to ListView to ignore recycling #13884

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ListItemProxy extends TiViewProxy
private boolean placeholder = false;
private boolean hasAddedItemEvents = false;
private boolean selected = false;
private boolean preventRecycling = false;

public ListItemProxy()
{
Expand Down Expand Up @@ -543,6 +544,9 @@ public ListViewHolder getHolder()
public void setHolder(ListViewHolder holder)
{
this.holder = holder;
if (preventRecycling) {
preventRecycling();
}
}

/**
Expand Down Expand Up @@ -841,6 +845,10 @@ private void processProperty(String name, Object value)
if (name.equals(TiC.PROPERTY_CAN_MOVE)) {
invalidate();
}

if (name.equals("preventRecycling")) {
preventRecycling = TiConvert.toBoolean(value, false);
}
}

private void loadTemplate()
Expand Down Expand Up @@ -911,4 +919,16 @@ protected boolean canApplyTouchFeedback(@NonNull KrollDict props)
return false;
}
}

/**
* Set isRecyclable for item.
*
* @param value Boolean value
*/
private void preventRecycling()
{
if (this.holder != null) {
this.holder.setIsRecyclable(false);
}
}
}
9 changes: 9 additions & 0 deletions apidoc/Titanium/UI/ListItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ properties:
type: String
accessors: false

- name: preventRecycling
description: |
If set to `true` the ListItems will keep the values. Use this only if needed e.g. when you have TextFields
or Switches in your ItemTemplate.
type: Boolean
default: false
platforms: [android]
since: "12.2.0"

- name: title
summary: Title to set in the text area of the item.
description: |
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/ListView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ events:
summary: Fired when a list row has started moving.
description: |
This event can be used to change the UI once a new drag-and-drop interaction starts.
The event properties are available in Titanium SDK 12.0.0+
The event properties are available in Titanium SDK 12.0.0+
since: "11.1.0"
platforms: [android, iphone, ipad, macos]
properties:
Expand Down
Loading