本文整理汇总了Java中com.google.ipc.invalidation.external.client.types.ObjectId类的典型用法代码示例。如果您正苦于以下问题:Java ObjectId类的具体用法?Java ObjectId怎么用?Java ObjectId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectId类属于com.google.ipc.invalidation.external.client.types包,在下文中一共展示了ObjectId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSavedObjectIds
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Returns the saved non-sync object ids, or {@code null} if none exist. */
@Nullable
public Set<ObjectId> getSavedObjectIds() {
SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
Set<String> objectIdStrings = preferences.getStringSet(PrefKeys.TANGO_OBJECT_IDS, null);
if (objectIdStrings == null) {
return null;
}
Set<ObjectId> objectIds = new HashSet<ObjectId>(objectIdStrings.size());
for (String objectIdString : objectIdStrings) {
ObjectId objectId = getObjectId(objectIdString);
if (objectId != null) {
objectIds.add(objectId);
}
}
return objectIds;
}
示例2: getObjectId
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/**
* Converts the given object id string stored in preferences to an object id.
* Returns null if the string does not represent a valid object id.
*/
private ObjectId getObjectId(String objectIdString) {
int separatorPos = objectIdString.indexOf(':');
// Ensure that the separator is surrounded by at least one character on each side.
if (separatorPos < 1 || separatorPos == objectIdString.length() - 1) {
return null;
}
int objectSource;
try {
objectSource = Integer.parseInt(objectIdString.substring(0, separatorPos));
} catch (NumberFormatException e) {
return null;
}
byte[] objectName = objectIdString.substring(separatorPos + 1).getBytes();
return ObjectId.newInstance(objectSource, objectName);
}
示例3: getRegisteredObjectIds
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Returns the object ids for which to register contained in the intent. */
public static Set<ObjectId> getRegisteredObjectIds(Intent intent) {
ArrayList<Integer> objectSources =
intent.getIntegerArrayListExtra(EXTRA_REGISTERED_OBJECT_SOURCES);
ArrayList<String> objectNames =
intent.getStringArrayListExtra(EXTRA_REGISTERED_OBJECT_NAMES);
if (objectSources == null || objectNames == null
|| objectSources.size() != objectNames.size()) {
return null;
}
Set<ObjectId> objectIds = new HashSet<ObjectId>(objectSources.size());
for (int i = 0; i < objectSources.size(); i++) {
objectIds.add(
ObjectId.newInstance(objectSources.get(i), objectNames.get(i).getBytes()));
}
return objectIds;
}
示例4: informRegistrationFailure
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的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 com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的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: AndroidListenerState
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Initializes state from proto. */
AndroidListenerState(int initialMaxDelayMs, int maxDelayFactor,
AndroidListenerProtocol.AndroidListenerState state) {
desiredRegistrations = new HashSet<ObjectId>();
for (ObjectIdP objectIdProto : state.getRegistration()) {
desiredRegistrations.add(ProtoWrapperConverter.convertFromObjectIdProto(objectIdProto));
}
for (RetryRegistrationState retryState : state.getRetryRegistrationState()) {
ObjectIdP objectIdP = retryState.getNullableObjectId();
if (objectIdP == null) {
continue;
}
ObjectId objectId = ProtoWrapperConverter.convertFromObjectIdProto(objectIdP);
delayGenerators.put(objectId, new TiclExponentialBackoffDelayGenerator(random,
initialMaxDelayMs, maxDelayFactor, retryState.getExponentialBackoffState()));
}
for (ScheduledRegistrationRetry registrationRetry : state.getRegistrationRetry()) {
registrationRetries.put(registrationRetry.getExecuteTimeMs(), registrationRetry.getCommand());
}
clientId = state.getClientId();
requestCodeSeqNum = state.getRequestCodeSeqNum();
isDirty = false;
this.initialMaxDelayMs = initialMaxDelayMs;
this.maxDelayFactor = maxDelayFactor;
}
示例7: informRegistrationStatus
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
@Override
public void informRegistrationStatus(byte[] clientId, ObjectId objectId,
RegistrationState regState) {
Log.i(TAG, "informRegistrationStatus");
List<ObjectId> objectIds = new ArrayList<ObjectId>();
objectIds.add(objectId);
if (regState == RegistrationState.REGISTERED) {
if (!interestingObjects.contains(objectId)) {
Log.i(TAG, "Unregistering for object we're no longer interested in");
unregister(clientId, objectIds);
}
} else {
if (interestingObjects.contains(objectId)) {
Log.i(TAG, "Registering for an object");
register(clientId, objectIds);
}
}
}
示例8: informRegistrationFailure
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的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);
}
}
}
示例9: informRegistrationStatus
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的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);
}
}
}
示例10: issueDelayedRegistrationIntent
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Issues a registration retry with delay. */
static void issueDelayedRegistrationIntent(Context context, AndroidClock clock,
ByteString clientId, ObjectId objectId, boolean isRegister, int delayMs, int requestCode) {
RegistrationCommand command = isRegister ?
AndroidListenerProtos.newDelayedRegisterCommand(clientId, objectId) :
AndroidListenerProtos.newDelayedUnregisterCommand(clientId, objectId);
Intent intent = new Intent()
.putExtra(EXTRA_REGISTRATION, command.toByteArray())
.setClass(context, AlarmReceiver.class);
// Create a pending intent that will cause the AlarmManager to fire the above intent.
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, intent,
PendingIntent.FLAG_ONE_SHOT);
// Schedule the pending intent after the appropriate delay.
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long executeMs = clock.nowMs() + delayMs;
alarmManager.set(AlarmManager.RTC, executeMs, pendingIntent);
}
示例11: requestSync
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/**
* Requests that the sync system perform a sync.
*
* @param objectId the object that changed, if known.
* @param version the version of the object that changed, if known.
* @param payload the payload of the change, if known.
*/
private void requestSync(@Nullable ObjectId objectId, @Nullable Long version,
@Nullable String payload) {
// Construct the bundle to supply to the native sync code.
Bundle bundle = new Bundle();
if (objectId == null && version == null && payload == null) {
// Use an empty bundle in this case for compatibility with the v1 implementation.
} else {
if (objectId != null) {
bundle.putInt("objectSource", objectId.getSource());
bundle.putString("objectId", new String(objectId.getName()));
}
// We use "0" as the version if we have an unknown-version invalidation. This is OK
// because the native sync code special-cases zero and always syncs for invalidations at
// that version (Tango defines a special UNKNOWN_VERSION constant with this value).
bundle.putLong("version", (version == null) ? 0 : version);
bundle.putString("payload", (payload == null) ? "" : payload);
}
Account account = ChromeSigninController.get(this).getSignedInUser();
String contractAuthority = SyncStatusHelper.get(this).getContractAuthority();
requestSyncFromContentResolver(bundle, account, contractAuthority);
}
示例12: getSavedObjectIds
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Returns the saved non-sync object ids, or {@code null} if none exist. */
@Nullable
public Set<ObjectId> getSavedObjectIds() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
Set<String> objectIdStrings = preferences.getStringSet(PrefKeys.TANGO_OBJECT_IDS, null);
if (objectIdStrings == null) {
return null;
}
Set<ObjectId> objectIds = new HashSet<ObjectId>(objectIdStrings.size());
for (String objectIdString : objectIdStrings) {
ObjectId objectId = getObjectId(objectIdString);
if (objectId != null) {
objectIds.add(objectId);
}
}
return objectIds;
}
示例13: informRegistrationFailure
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
@Override
public void informRegistrationFailure(byte[] clientId, ObjectId objectId, boolean isTransient,
String errorMessage) {
Log.e(TAG, "Registration failure!");
if (isTransient) {
// Retry immediately on transient failures. The base AndroidListener will handle exponential
// backoff if there are repeated failures.
List<ObjectId> objectIds = new ArrayList<ObjectId>();
objectIds.add(objectId);
if (interestingObjects.contains(objectId)) {
Log.i(TAG, "Retrying registration of " + objectId);
register(clientId, objectIds);
} else {
Log.i(TAG, "Retrying unregistration of " + objectId);
unregister(clientId, objectIds);
}
}
}
示例14: refreshData
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Updates UI with current registration status and object versions. */
private static void refreshData() {
final MainActivity activity = State.currentActivity;
if (null != activity) {
final StringBuilder builder = new StringBuilder();
builder.append("\nLast informed versions status\n");
builder.append("--begin-------------\n");
synchronized (State.lastInformedVersion) {
for (Entry<ObjectId, String> entry : State.lastInformedVersion.entrySet()) {
builder.append(entry.getKey().toString()).append(" -> ").append(entry.getValue())
.append("\n");
}
}
builder.append("--end---------------\n");
activity.info.post(new Runnable() {
@Override
public void run() {
activity.info.setText(builder.toString());
}
});
}
}
示例15: handleIncomingHeader
import com.google.ipc.invalidation.external.client.types.ObjectId; //导入依赖的package包/类
/** Handles a server {@code header}. */
private void handleIncomingHeader(ServerMessageHeader header) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
Preconditions.checkState(nonce == null,
"Cannot process server header with non-null nonce (have %s): %s", nonce, header);
if (header.registrationSummary != null) {
// We've received a summary from the server, so if we were suppressing
// registrations, we should now allow them to go to the registrar.
shouldSendRegistrations = true;
// Pass the registration summary to the registration manager. If we are now in agreement
// with the server and we had any pending operations, we can tell the listener that those
// operations have succeeded.
Set<ProtoWrapper<RegistrationP>> upcalls =
registrationManager.informServerRegistrationSummary(header.registrationSummary);
logger.fine("Receivced new server registration summary (%s); will make %s upcalls",
header.registrationSummary, upcalls.size());
for (ProtoWrapper<RegistrationP> upcall : upcalls) {
RegistrationP registration = upcall.getProto();
ObjectId objectId = ProtoConverter.convertFromObjectIdProto(registration.getObjectId());
RegistrationState regState = convertOpTypeToRegState(registration.getOpType());
listener.informRegistrationStatus(this, objectId, regState);
}
}
}