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

[TIMOB-5996] add removeview function #5235

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

@Kroll.proxy(creatableInModule=UIModule.class, propertyAccessors = {
TiC.PROPERTY_CONTENT_HEIGHT, TiC.PROPERTY_CONTENT_WIDTH,
Expand All @@ -38,7 +39,7 @@ public class ScrollViewProxy extends TiViewProxy
private static final int MSG_SCROLL_TO = MSG_FIRST_ID + 100;
private static final int MSG_SCROLL_TO_BOTTOM = MSG_FIRST_ID + 101;
protected static final int MSG_LAST_ID = MSG_FIRST_ID + 999;

public ScrollViewProxy()
{
super();
Expand Down Expand Up @@ -119,6 +120,7 @@ public void handleScrollTo(int x, int y) {
public void handleScrollToBottom() {
getScrollView().scrollToBottom();
}


@Override
public String getApiName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class ScrollableViewProxy extends TiViewProxy
private static final int DEFAULT_PAGING_CONTROL_TIMEOUT = 3000;

protected AtomicBoolean inScroll;

public ScrollableViewProxy()
{
super();
Expand Down Expand Up @@ -127,7 +126,17 @@ public boolean handleMessage(Message msg)
case MSG_REMOVE_VIEW: {
AsyncResult holder = (AsyncResult) msg.obj;
Object view = holder.getArg();
if (view instanceof TiViewProxy) {
if (view instanceof Integer) {
int rowIndex = (Integer) view;
TiViewProxy[] rowArray = this.getChildren();
if (rowArray != null) {
if (rowIndex >= 0 && rowIndex < rowArray.length) {
this.remove((TiViewProxy) rowArray[rowIndex]);
} else {
Log.e(TAG, "Unable to remove child. Index out of range. Non-existent child " + rowIndex);
}
}
} else if (view instanceof TiViewProxy) {
getView().removeView((TiViewProxy) view);
handled = true;
} else if (view != null) {
Expand Down Expand Up @@ -299,7 +308,7 @@ public void setActivity(Activity activity)
proxy.setActivity(activity);
}
}

@Override
public String getApiName()
{
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/ScrollableView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ methods:
- name: removeView
summary: Removes an existing page from this Scrollable View.
description: |
On Android and Mobile Web, does nothing if the page does not exist in
On Mobile Web, does nothing if the page does not exist in
<Titanium.UI.ScrollableView.views>.

On iOS, throws an exception if the page does not exist in <Titanium.UI.ScrollableView.views>
Expand Down