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

ListView Android performance refactor #3235

Open
wants to merge 16 commits into
base: ucr
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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
17 changes: 17 additions & 0 deletions appinventor/components-ios/src/ListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ open class ListView: ViewComponent, AbstractMethodsForViewComponent,
_view.reloadData()
}
}

// This property is not supported in iOS
@objc open var BounceEdgeEffect: Bool {
get {
return false;
}
set(addEffect) {
}
}

//ListData
@objc open var ListData: String {
Expand Down Expand Up @@ -346,6 +355,14 @@ open class ListView: ViewComponent, AbstractMethodsForViewComponent,

// MARK: Methods

@objc open func AddItem(_ mainText: String, _ detailText: String, _ imageName: String) {
_listData.append(["Text1": mainText, "Text2": detailText, "Image": imageName])
}

@objc open func AddItemAtIndex(_ addIndex: Int32, _ mainText: String, _ detailText: String, _ imageName: String) {
_listData.insert(["Text1": mainText, "Text2": detailText, "Image": imageName], at: Int(addIndex - 1))
}

@objc open func CreateElement(_ mainText: String, _ detailText: String, _ imageName: String) -> YailDictionary {
return [
"Text1": mainText,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2023 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.components.common;

import java.util.HashMap;
import java.util.Map;

/**
* Defines a parameter of ListViewLayout used by the ListView component.
*/
public enum LayoutType implements OptionList<Integer> {
@Default
MainText(0),
MainText_DetailText_Vertical(1),
MainText_DetailText_Horizontal(2),
Image_MainText(3),
Image_MainText_DetailText_Vertical(4);

private final int layout;

LayoutType(int value) {
SusanRatiLane marked this conversation as resolved.
Show resolved Hide resolved
this.layout = value;
}

public Integer toUnderlyingValue() {
return layout;
}

private static final Map<Integer, LayoutType> lookup = new HashMap<>();

static {
for(LayoutType value : LayoutType.values()) {
lookup.put(value.toUnderlyingValue(), value);
}
}

public static LayoutType fromUnderlyingValue(Integer value) {
return lookup.get(value);
}
}
SusanRatiLane marked this conversation as resolved.
Show resolved Hide resolved
ewpatton marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2024 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.components.common;

import java.util.HashMap;
import java.util.Map;

/**
* Defines a parameter of ListOrientation used by the ListView component.
*/
public enum ListOrientation implements OptionList<Integer> {
@Default
Vertical(0),
Horizontal(1);

private final int orientation;

ListOrientation(int value) {
SusanRatiLane marked this conversation as resolved.
Show resolved Hide resolved
this.orientation = value;
}

public Integer toUnderlyingValue() {
return orientation;
}

private static final Map<Integer, ListOrientation> lookup = new HashMap<>();

static {
for(ListOrientation value : ListOrientation.values()) {
lookup.put(value.toUnderlyingValue(), value);
}
}

public static ListOrientation fromUnderlyingValue(Integer value) {
return lookup.get(value);
}

public static ListOrientation fromUnderlyingValue(String value) {
return fromUnderlyingValue(Integer.parseInt(value));
}
}
SusanRatiLane marked this conversation as resolved.
Show resolved Hide resolved
Loading