All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.robobinding.widget.abslistview.ListViewUtils Maven / Gradle / Ivy

package org.robobinding.widget.abslistview;

import android.util.SparseBooleanArray;
import android.widget.AbsListView;

/**
 * 
 * @since 1.0
 * @version $Revision: 1.0 $
 * @author Cheng Wei
 */
public class ListViewUtils {
    private ListViewUtils() {
    }

    /**
     * TODO:Will be replaced by listView.clearChoices(). Requires a change to
     * ShadowListView in Robolectric.
     */
    public static void clearSelections(AbsListView view) {
	AbsListViewBackCompatible viewBackCompatible = new AbsListViewBackCompatible(view);
	SparseBooleanArray array = viewBackCompatible.getCheckedItemPositions();

	if (array == null) {
	    return;
	}

	for (int i = 0; i < array.size(); i++) {
	    int position = array.keyAt(i);
	    boolean checked = array.valueAt(i);
	    if (checked) {
		viewBackCompatible.setItemChecked(position, false);
	    }
	}
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy