Java Code Examples for android.util.SparseArray#delete()

The following examples show how to use android.util.SparseArray#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Updates restriction bundle for a given user in a given restriction array. If new bundle is
 * empty, record is removed from the array.
 * @return whether restrictions bundle is different from the old one.
 */
private boolean updateRestrictionsIfNeededLR(int userId, @Nullable Bundle restrictions,
        SparseArray<Bundle> restrictionsArray) {
    final boolean changed =
            !UserRestrictionsUtils.areEqual(restrictionsArray.get(userId), restrictions);
    if (changed) {
        if (!UserRestrictionsUtils.isEmpty(restrictions)) {
            restrictionsArray.put(userId, restrictions);
        } else {
            restrictionsArray.delete(userId);
        }
    }
    return changed;
}
 
Example 2
Source File: InstantAppRegistry.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void removeAppLPw(@UserIdInt int userId, int targetAppId) {
    // remove from the installed list
    if (mInstantGrants == null) {
        return; // no grants on the system
    }
    final SparseArray<SparseBooleanArray> targetAppList = mInstantGrants.get(userId);
    if (targetAppList == null) {
        return; // no grants for this user
    }
    targetAppList.delete(targetAppId);
}
 
Example 3
Source File: GasTransactionResponse.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
/**
 * Prune duplicate prices off the edges of the range and create sorted minimal array of prices
 */
public void truncatePriceRange()
{
    arrayResult = new SparseArray<>();
    SparseArray<Float> priceSet = new SparseArray<>();
    for (String price : result.keySet())
    {
        priceSet.put(Integer.valueOf(price), result.get(price));
    }

    for (int index = priceSet.size() - 1; index > 0; index--)
    {
        int thisPrice = priceSet.keyAt(index);
        int nextPrice = priceSet.keyAt(index-1);
        float thisWaitTime = priceSet.valueAt(index);
        float nextWaitTime = priceSet.valueAt(index-1);
        if (thisWaitTime == nextWaitTime)
        {
            priceSet.delete(Math.max(thisPrice, nextPrice));
        }
    }

    for (int index = 0; index < priceSet.size(); index++)
    {
        if (priceSet.valueAt(index) != null)
        {
            arrayResult.put(priceSet.keyAt(index), priceSet.valueAt(index));
        }
    }
}