android.util.SparseArray#removeAt ( )源码实例Demo

下面列出了android.util.SparseArray#removeAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: AlarmManagerService.java
@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);
        }
    }
}
 
源代码2 项目: AndroidAnimationExercise   文件: Recycler.java
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;
}
 
源代码3 项目: UltimateAndroid   文件: Recycler.java
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;
}
 
源代码4 项目: UltimateAndroid   文件: Recycler.java
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;
}
 
源代码5 项目: android-FlipView   文件: Recycler.java
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;
}
 
源代码6 项目: android_9.0.0_r45   文件: AppErrors.java
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);
        }
    }
}
 
源代码7 项目: AndroidUSBCamera   文件: USBMonitor.java
/**
 * 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--;
}
 
源代码9 项目: libcommon   文件: USBMonitor.java
/**
 * インターフェースを閉じる
 * @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);
}
 
源代码10 项目: DeviceConnect-Android   文件: USBMonitor.java
/**
 * 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);
}