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

The following examples show how to use android.util.SparseArray#removeAt() . 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: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static void findAllUnrestrictedPendingBackgroundAlarmsLockedInner(
        SparseArray<ArrayList<Alarm>> pendingAlarms, ArrayList<Alarm> unrestrictedAlarms,
        Predicate<Alarm> isBackgroundRestricted) {

    for (int uidIndex = pendingAlarms.size() - 1; uidIndex >= 0; uidIndex--) {
        final int uid = pendingAlarms.keyAt(uidIndex);
        final ArrayList<Alarm> alarmsForUid = pendingAlarms.valueAt(uidIndex);

        for (int alarmIndex = alarmsForUid.size() - 1; alarmIndex >= 0; alarmIndex--) {
            final Alarm alarm = alarmsForUid.get(alarmIndex);

            if (isBackgroundRestricted.test(alarm)) {
                continue;
            }

            unrestrictedAlarms.add(alarm);
            alarmsForUid.remove(alarmIndex);
        }

        if (alarmsForUid.size() == 0) {
            pendingAlarms.removeAt(uidIndex);
        }
    }
}
 
Example 2
Source File: Recycler.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example 3
Source File: Recycler.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example 4
Source File: Recycler.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example 5
Source File: Recycler.java    From android-FlipView with Apache License 2.0 6 votes vote down vote up
static Scrap retrieveFromScrap(SparseArray<Scrap> scrapViews, int position) {
	int size = scrapViews.size();
	if (size > 0) {
		// See if we still have a view for this position.
		Scrap result = scrapViews.get(position, null);
		if (result != null) {
			scrapViews.remove(position);
			return result;
		}
		int index = size - 1;
		result = scrapViews.valueAt(index);
		scrapViews.removeAt(index);
		result.valid = false;
		return result;
	}
	return null;
}
 
Example 6
Source File: AppErrors.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
void resetProcessCrashTimeLocked(boolean resetEntireUser, int appId, int userId) {
    final ArrayMap<String, SparseArray<Long>> pmap = mProcessCrashTimes.getMap();
    for (int ip = pmap.size() - 1; ip >= 0; ip--) {
        SparseArray<Long> ba = pmap.valueAt(ip);
        for (int i = ba.size() - 1; i >= 0; i--) {
            boolean remove = false;
            final int entUid = ba.keyAt(i);
            if (!resetEntireUser) {
                if (userId == UserHandle.USER_ALL) {
                    if (UserHandle.getAppId(entUid) == appId) {
                        remove = true;
                    }
                } else {
                    if (entUid == UserHandle.getUid(userId, appId)) {
                        remove = true;
                    }
                }
            } else if (UserHandle.getUserId(entUid) == userId) {
                remove = true;
            }
            if (remove) {
                ba.removeAt(i);
            }
        }
        if (ba.size() == 0) {
            pmap.removeAt(ip);
        }
    }
}
 
Example 7
Source File: USBMonitor.java    From AndroidUSBCamera with Apache License 2.0 5 votes vote down vote up
/**
 * close interface
 * @param intf
 * @throws IllegalStateException
 */
public synchronized void releaseInterface(final UsbInterface intf) throws IllegalStateException {
	checkConnection();
	final SparseArray<UsbInterface> intfs = mInterfaces.get(intf.getId());
	if (intfs != null) {
		final int index = intfs.indexOfValue(intf);
		intfs.removeAt(index);
		if (intfs.size() == 0) {
			mInterfaces.remove(intf.getId());
		}
	}
	mConnection.releaseInterface(intf);
}
 
Example 8
Source File: ClusterMapContributeEditActivity.java    From intra42 with Apache License 2.0 5 votes vote down vote up
private void deleteRow(int y) {
    for (int i = 0; i < cluster.map.size(); i++) {
        SparseArray<Location> col;
        if ((col = cluster.map.get(i)) != null) {
            for (int j = y; j < col.size() - 1; j++) {
                col.setValueAt(j, col.valueAt(j + 1));
            }
            col.removeAt(col.size() - 1);
        }
    }
    cluster.height--;
}
 
Example 9
Source File: USBMonitor.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * インターフェースを閉じる
 * @param intf
 * @throws IllegalStateException
 */
public synchronized void releaseInterface(final UsbInterface intf)
	throws IllegalStateException {

	checkConnection();
	final SparseArray<UsbInterface> intfs = mInterfaces.get(intf.getId());
	if (intfs != null) {
		final int index = intfs.indexOfValue(intf);
		intfs.removeAt(index);
		if (intfs.size() == 0) {
			mInterfaces.remove(intf.getId());
		}
	}
	mConnection.releaseInterface(intf);
}
 
Example 10
Source File: USBMonitor.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
/**
 * close interface
 * @param intf
 * @throws IllegalStateException
 */
public synchronized void releaseInterface(final UsbInterface intf) throws IllegalStateException {
	checkConnection();
	final SparseArray<UsbInterface> intfs = mInterfaces.get(intf.getId());
	if (intfs != null) {
		final int index = intfs.indexOfValue(intf);
		intfs.removeAt(index);
		if (intfs.size() == 0) {
			mInterfaces.remove(intf.getId());
		}
	}
	mConnection.releaseInterface(intf);
}