下面列出了android.util.SparseArray#removeAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
}
}
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;
}
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;
}
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;
}
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;
}
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);
}
}
}
/**
* 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);
}
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--;
}
/**
* インターフェースを閉じる
* @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);
}
/**
* 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);
}