本文整理汇总了Java中org.chromium.base.CollectionUtil类的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtil类的具体用法?Java CollectionUtil怎么用?Java CollectionUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollectionUtil类属于org.chromium.base包,在下文中一共展示了CollectionUtil类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: informRegistrationFailure
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
@Override
public void informRegistrationFailure(
byte[] clientId, ObjectId objectId, boolean isTransient, String errorMessage) {
Log.w(TAG, "Registration failure on " + objectId + " ; transient = " + isTransient
+ ": " + errorMessage);
if (isTransient) {
// Retry immediately on transient failures. The base AndroidListener will handle
// exponential backoff if there are repeated failures.
List<ObjectId> objectIdAsList = CollectionUtil.newArrayList(objectId);
if (readRegistrationsFromPrefs().contains(objectId)) {
register(clientId, objectIdAsList);
} else {
unregister(clientId, objectIdAsList);
}
}
}
示例2: informRegistrationStatus
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
@Override
public void informRegistrationStatus(
byte[] clientId, ObjectId objectId, RegistrationState regState) {
Log.d(TAG, "Registration status for " + objectId + ": " + regState);
List<ObjectId> objectIdAsList = CollectionUtil.newArrayList(objectId);
boolean registrationisDesired = readRegistrationsFromPrefs().contains(objectId);
if (regState == RegistrationState.REGISTERED) {
if (!registrationisDesired) {
Log.i(TAG, "Unregistering for object we're no longer interested in");
unregister(clientId, objectIdAsList);
}
} else {
if (registrationisDesired) {
Log.i(TAG, "Registering for an object");
register(clientId, objectIdAsList);
}
}
}
示例3: createRegisterIntent
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
/**
* Create an Intent that will start the invalidation listener service and
* register for the specified types.
*/
public static Intent createRegisterIntent(Account account,
boolean allTypes, Set<ModelType> types) {
Intent registerIntent = new Intent(ACTION_REGISTER);
String[] selectedTypesArray;
if (allTypes) {
selectedTypesArray = new String[]{ModelType.ALL_TYPES_TYPE};
} else {
selectedTypesArray = new String[types.size()];
int pos = 0;
for (ModelType type : types) {
selectedTypesArray[pos++] = type.name();
}
}
registerIntent.putStringArrayListExtra(EXTRA_REGISTERED_TYPES,
CollectionUtil.newArrayList(selectedTypesArray));
registerIntent.putExtra(EXTRA_ACCOUNT, account);
return registerIntent;
}
示例4: informRegistrationFailure
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
@Override
public void informRegistrationFailure(
byte[] clientId, ObjectId objectId, boolean isTransient, String errorMessage) {
Log.w(TAG, "Registration failure on " + objectId + " ; transient = " + isTransient
+ ": " + errorMessage);
if (isTransient) {
// Retry immediately on transient failures. The base AndroidListener will handle
// exponential backoff if there are repeated failures.
List<ObjectId> objectIdAsList = CollectionUtil.newArrayList(objectId);
if (readRegistrationsFromPrefs().contains(objectId)) {
register(clientId, objectIdAsList);
} else {
unregister(clientId, objectIdAsList);
}
}
}
示例5: informRegistrationStatus
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
@Override
public void informRegistrationStatus(
byte[] clientId, ObjectId objectId, RegistrationState regState) {
Log.d(TAG, "Registration status for " + objectId + ": " + regState);
List<ObjectId> objectIdAsList = CollectionUtil.newArrayList(objectId);
boolean registrationisDesired = readRegistrationsFromPrefs().contains(objectId);
if (regState == RegistrationState.REGISTERED) {
if (!registrationisDesired) {
Log.i(TAG, "Unregistering for object we're no longer interested in");
unregister(clientId, objectIdAsList);
}
} else {
if (registrationisDesired) {
Log.i(TAG, "Registering for an object");
register(clientId, objectIdAsList);
}
}
}
示例6: createRegisterIntent
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
/**
* Create an Intent that will start the invalidation listener service and
* register for the specified types.
*/
public static Intent createRegisterIntent(Account account, Set<Integer> types) {
Intent registerIntent = new Intent(ACTION_REGISTER);
String[] selectedTypesArray = new String[types.size()];
int pos = 0;
for (Integer type : types) {
selectedTypesArray[pos++] = ModelTypeHelper.toNotificationType(type);
}
registerIntent.putStringArrayListExtra(
EXTRA_REGISTERED_TYPES, CollectionUtil.newArrayList(selectedTypesArray));
registerIntent.putExtra(EXTRA_ACCOUNT, account);
return registerIntent;
}
示例7: DeviceSensors
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
protected DeviceSensors() {
mOrientationSensorSets = CollectionUtil.newArrayList(DEVICE_ORIENTATION_SENSORS_A,
DEVICE_ORIENTATION_SENSORS_B, DEVICE_ORIENTATION_SENSORS_C);
}
示例8: trimVisibleNetworks
import org.chromium.base.CollectionUtil; //导入依赖的package包/类
@Nullable
@VisibleForTesting
static VisibleNetworks trimVisibleNetworks(@Nullable VisibleNetworks visibleNetworks) {
if (visibleNetworks == null || visibleNetworks.isEmpty()) {
return null;
}
// Trim visible networks to only include a limited number of visible not-conntected networks
// based on flag.
VisibleCell connectedCell = visibleNetworks.connectedCell();
VisibleWifi connectedWifi = visibleNetworks.connectedWifi();
Set<VisibleCell> visibleCells = visibleNetworks.allVisibleCells();
Set<VisibleWifi> visibleWifis = visibleNetworks.allVisibleWifis();
VisibleCell extraVisibleCell = null;
VisibleWifi extraVisibleWifi = null;
if (shouldExcludeVisibleWifi(connectedWifi)) {
// Trim the connected wifi.
connectedWifi = null;
}
// Select the extra visible cell.
if (visibleCells != null) {
for (VisibleCell candidateCell : visibleCells) {
if (ApiCompatibilityUtils.objectEquals(connectedCell, candidateCell)) {
// Do not include this candidate cell, since its already the connected one.
continue;
}
// Add it and since we only want one, stop iterating over other cells.
extraVisibleCell = candidateCell;
break;
}
}
// Select the extra visible wifi.
if (visibleWifis != null) {
for (VisibleWifi candidateWifi : visibleWifis) {
if (shouldExcludeVisibleWifi(candidateWifi)) {
// Do not include this candidate wifi.
continue;
}
if (ApiCompatibilityUtils.objectEquals(connectedWifi, candidateWifi)) {
// Replace the connected, since the candidate will have level. This is because
// the android APIs exposing connected WIFI do not expose level, while the ones
// exposing visible wifis expose level.
connectedWifi = candidateWifi;
// Do not include this candidate wifi, since its already the connected one.
continue;
}
// Keep the one with stronger level (since it's negative, this is the smaller value)
if (extraVisibleWifi == null || extraVisibleWifi.level() > candidateWifi.level()) {
extraVisibleWifi = candidateWifi;
}
}
}
if (connectedCell == null && connectedWifi == null && extraVisibleCell == null
&& extraVisibleWifi == null) {
return null;
}
return VisibleNetworks.create(connectedWifi, connectedCell,
extraVisibleWifi != null ? CollectionUtil.newHashSet(extraVisibleWifi) : null,
extraVisibleCell != null ? CollectionUtil.newHashSet(extraVisibleCell) : null);
}