<commit_before>/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package ti.modules.titanium.ui;

import java.util.ArrayList;

import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

import android.app.Activity;
// clang-format off
@Kroll.proxy(creatableInModule = UIModule.class,
	propertyAccessors = {
		TiC.PROPERTY_HEADER_TITLE,
		TiC.PROPERTY_HEADER_VIEW,
		TiC.PROPERTY_FOOTER_TITLE,
		TiC.PROPERTY_FOOTER_VIEW
})
// clang-format on
public class TableViewSectionProxy extends TiViewProxy
{
	private static final String TAG = "TableViewSectionProxy";
	protected ArrayList<TableViewRowProxy> rows = new ArrayList<TableViewRowProxy>();

	public TableViewSectionProxy()
	{
		super();
		rows = new ArrayList<TableViewRowProxy>();
	}

	@Override
	public TiUIView createView(Activity activity)
	{
		return null;
	}

	@Override
	public void setActivity(Activity activity)
	{
		super.setActivity(activity);
		if (rows != null) {
			for (TableViewRowProxy row : rows) {
				row.setActivity(activity);
			}
		}
	}

	// clang-format off
	@Kroll.method
	@Kroll.getProperty
	public TableViewRowProxy[] getRows()
	// clang-format on
	{
		return rows.toArray(new TableViewRowProxy[rows.size()]);
	}

	// clang-format off
	@Kroll.method
	@Kroll.getProperty
	public double getRowCount()
	// clang-format on
	{
		return rows.size();
	}

	@Kroll.method
	public void add(TableViewRowProxy rowProxy)
	{
		if (rowProxy != null) {
			rows.add(rowProxy);
			rowProxy.setParent(this);
		}
	}

	@Kroll.method
	public void remove(TableViewRowProxy rowProxy)
	{
		if (rowProxy != null) {
			rows.remove(rowProxy);
			if (rowProxy.getParent() == this) {
				rowProxy.setParent(null);
			}
		}
	}

	@Kroll.method
	public TableViewRowProxy rowAtIndex(int index)
	{
		TableViewRowProxy result = null;
		if (index > -1 && index < rows.size()) {
			result = rows.get(index);
		}

		return result;
	}

	@Kroll.method
	public void insertRowAt(int index, TableViewRowProxy row)
	{
		if (index > -1 && index <= rows.size()) {
			rows.add(index, row);
			row.setParent(this);
		} else {
			Log.e(TAG, "Index out of range. Unable to insert row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Kroll.method
	public void removeRowAt(int index)
	{
		if (index > -1 && index < rows.size()) {
			TableViewRowProxy rowProxy = rows.get(index);
			rows.remove(index);
			if (rowProxy.getParent() == this) {
				rowProxy.setParent(null);
			}
		} else {
			Log.e(TAG, "Index out of range. Unable to remove row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Kroll.method
	public void updateRowAt(int index, TableViewRowProxy row)
	{
		TableViewRowProxy oldRow = rows.get(index);
		if (row == oldRow) {
			return;
		}
		if (index > -1 && index < rows.size()) {
			rows.set(index, row);
			row.setParent(this);
			if (oldRow.getParent() == this) {
				oldRow.setParent(null);
			}
		} else {
			Log.e(TAG, "Index out of range. Unable to update row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Override
	public String toString()
	{
		return "[object TableViewSectionProxy]";
	}

	@Override
	public void releaseViews()
	{
		super.releaseViews();

		if (rows != null) {
			for (TableViewRowProxy row : rows) {
				row.releaseViews();
			}
		}
	}

	@Override
	public String getApiName()<commit_msg>Do not remove parent for items still in the dataset. (#10124)<commit_after>/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package ti.modules.titanium.ui;

import java.util.ArrayList;

import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;

import android.app.Activity;
// clang-format off
@Kroll.proxy(creatableInModule = UIModule.class,
	propertyAccessors = {
		TiC.PROPERTY_HEADER_TITLE,
		TiC.PROPERTY_HEADER_VIEW,
		TiC.PROPERTY_FOOTER_TITLE,
		TiC.PROPERTY_FOOTER_VIEW
})
// clang-format on
public class TableViewSectionProxy extends TiViewProxy
{
	private static final String TAG = "TableViewSectionProxy";
	protected ArrayList<TableViewRowProxy> rows = new ArrayList<TableViewRowProxy>();

	public TableViewSectionProxy()
	{
		super();
		rows = new ArrayList<TableViewRowProxy>();
	}

	@Override
	public TiUIView createView(Activity activity)
	{
		return null;
	}

	@Override
	public void setActivity(Activity activity)
	{
		super.setActivity(activity);
		if (rows != null) {
			for (TableViewRowProxy row : rows) {
				row.setActivity(activity);
			}
		}
	}

	// clang-format off
	@Kroll.method
	@Kroll.getProperty
	public TableViewRowProxy[] getRows()
	// clang-format on
	{
		return rows.toArray(new TableViewRowProxy[rows.size()]);
	}

	// clang-format off
	@Kroll.method
	@Kroll.getProperty
	public double getRowCount()
	// clang-format on
	{
		return rows.size();
	}

	@Kroll.method
	public void add(TableViewRowProxy rowProxy)
	{
		if (rowProxy != null) {
			rows.add(rowProxy);
			rowProxy.setParent(this);
		}
	}

	@Kroll.method
	public void remove(TableViewRowProxy rowProxy)
	{
		if (rowProxy != null) {
			rows.remove(rowProxy);
			if (rowProxy.getParent() == this) {
				rowProxy.setParent(null);
			}
		}
	}

	@Kroll.method
	public TableViewRowProxy rowAtIndex(int index)
	{
		TableViewRowProxy result = null;
		if (index > -1 && index < rows.size()) {
			result = rows.get(index);
		}

		return result;
	}

	@Kroll.method
	public void insertRowAt(int index, TableViewRowProxy row)
	{
		if (index > -1 && index <= rows.size()) {
			rows.add(index, row);
			row.setParent(this);
		} else {
			Log.e(TAG, "Index out of range. Unable to insert row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Kroll.method
	public void removeRowAt(int index)
	{
		if (index > -1 && index < rows.size()) {
			TableViewRowProxy rowProxy = rows.get(index);
			rows.remove(index);
			if (rowProxy.getParent() == this) {
				rowProxy.setParent(null);
			}
		} else {
			Log.e(TAG, "Index out of range. Unable to remove row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Kroll.method
	public void updateRowAt(int index, TableViewRowProxy row)
	{
		TableViewRowProxy oldRow = rows.get(index);
		if (row == oldRow) {
			return;
		}
		if (index > -1 && index < rows.size()) {
			rows.set(index, row);
			row.setParent(this);
			if (oldRow.getParent() == this && !rows.contains(oldRow)) {
				oldRow.setParent(null);
			}
		} else {
			Log.e(TAG, "Index out of range. Unable to update row at index " + index, Log.DEBUG_MODE);
		}
	}

	@Override
	public String toString()
	{
		return "[object TableViewSectionProxy]";
	}

	@Override
	public void releaseViews()
	{
		super.releaseViews();

		if (rows != null) {
			for (TableViewRowProxy row : rows) {
				row.releaseViews();
			}
		}
	}

	@Override
	public String getApiName()
{'fraction_non_alphanumeric': 0.12424574876577071, 'fraction_numerical': 0.0039769610532089964, 'mean_word_length': 3.7697841726618706, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '142192', 'n_tokens_mistral': 2807, 'n_tokens_neox': 2545, 'n_words': 590}