Example usage for android.util SparseArray clear

List of usage examples for android.util SparseArray clear

Introduction

In this page you can find the example usage for android.util SparseArray clear.

Prototype

public void clear() 

Source Link

Document

Removes all key-value mappings from this SparseArray.

Usage

From source file:com.svpino.longhorn.artifacts.StockTileProcessor.java

public static void create(Fragment fragment, TableLayout tableLayout, List<Stock> stocks,
        SparseArray<View> tiles, boolean restart) {

    if (restart) {
        tableLayout.removeAllViews();/*w w w.  jav  a2  s .  c  o  m*/
        if (tiles != null) {
            tiles.clear();
        }
    }

    tableLayout.setStretchAllColumns(true);
    tableLayout.setShrinkAllColumns(true);

    int margin = Extensions.dpToPixels(fragment.getResources(), 3);
    int height = Extensions.dpToPixels(fragment.getResources(), 90);

    int index = createFixedHeaderRow(fragment, tableLayout, stocks, tiles, height, margin);

    int row = index == 3 ? 1 : 0;

    while (index < stocks.size()) {
        index = createStandardRow(fragment, tableLayout, stocks, tiles, height, margin, index, row);
        row++;
    }

    while (tableLayout.getChildCount() > row) {
        tableLayout.removeViewAt(tableLayout.getChildCount() - 1);
    }

    if (stocks.size() % 2 != 0) {
        TableRow tableRow = new TableRow(fragment.getActivity());

        View addNewStockTile = createTileForAddingNewStock(fragment);
        tableRow.addView(addNewStockTile, getSpannedLayoutParams(row, margin, height));

        tableLayout.addView(tableRow);
    } else {
        TableRow tableRow = (TableRow) tableLayout.getChildAt(tableLayout.getChildCount() - 1);
        LayoutParams layoutParams = (TableRow.LayoutParams) tableRow.getChildAt(0).getLayoutParams();
        layoutParams.bottomMargin = margin;
        layoutParams.height = height;
    }
}

From source file:com.android.talkback.CollectionState.java

private static void updateTableHeaderInfo(AccessibilityNodeInfoCompat collectionRoot,
        SparseArray<CharSequence> rowHeaders, SparseArray<CharSequence> columnHeaders, boolean computeHeaders) {
    rowHeaders.clear();
    columnHeaders.clear();//from   ww w .jav  a  2s. com

    if (!computeHeaders) {
        return;
    }

    if (collectionRoot == null || collectionRoot.getCollectionInfo() == null) {
        return;
    }

    // Limit search to children and grandchildren of the root node for performance reasons.
    // We want to search grandchildren because web pages put table headers <th> inside table
    // rows <tr> so they are nested two levels down.
    CollectionInfoCompat collectionInfo = collectionRoot.getCollectionInfo();
    int numChildren = collectionRoot.getChildCount();
    for (int i = 0; i < numChildren; ++i) {
        AccessibilityNodeInfoCompat child = collectionRoot.getChild(i);

        if (!updateSingleTableHeader(child, collectionInfo, rowHeaders, columnHeaders)) {
            int numGrandchildren = child.getChildCount();
            for (int j = 0; j < numGrandchildren; ++j) {
                AccessibilityNodeInfoCompat grandchild = child.getChild(j);
                updateSingleTableHeader(grandchild, collectionInfo, rowHeaders, columnHeaders);
                grandchild.recycle();
            }
        }

        child.recycle();
    }
}

From source file:com.fuzz.indicator.CutoutViewIndicator.java

/**
 * Utility method for invalidating the {@link #generator} (so to speak).
 * <p>//from   w ww .j  av  a  2 s.  com
 *     It'll ensure that the child views match both what the current
 *     {@link CutoutCellGenerator} creates AND the params defined by
 *     {@link #defaultChildParams}.
 * </p>
 * Views which have been marked for
 * {@link CutoutViewLayoutParams#preservedDuringRebuild preservation} will
 * not be replaced.
 */
public void rebuildChildViews() {
    SparseArray<CutoutCell> preserved = cells.clone();
    cells.clear();
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (((CutoutViewLayoutParams) child.getLayoutParams()).preservedDuringRebuild) {
            cells.put(i, preserved.get(i));
        }
    }
    preserved.clear();
    removeAllViews();
    dataSetObserver.onChanged();
}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

public static void cancelAllNotifications(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();//from ww w  . j a  v  a2s.  com

    @SuppressWarnings("unchecked")
    SparseArray<NotificationData> notificationMap = (SparseArray<NotificationData>) Reflection.getPrivateField(
            StatusBarNotificationManager.class, StatusBarNotificationManager.getInstance(),
            "notificationDataMap");
    notificationMap.clear();
}