本文整理汇总了Java中com.google.cloud.backend.android.CloudQuery.Scope类的典型用法代码示例。如果您正苦于以下问题:Java Scope类的具体用法?Java Scope怎么用?Java Scope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scope类属于com.google.cloud.backend.android.CloudQuery包,在下文中一共展示了Scope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
@Override
public void run() {
CloudCallbackHandler<List<CloudEntity>> userStateHandler = new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
if (results == null) {
return; // nothing we can do (could change state to unknown again?)
}
mUserState = results.size() > 0 ? UserState.BANNED : UserState.ALLOWED;
showBannedMessage();
}
@Override
public void onError(IOException exception) {
// nothing we can do (could change state to unknown again?)
}
};
CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_BANS);
cloudQuery.setFilter(F.eq(QRCloudUtils.DATABASE_PROP_USER, getPreferencesAccountName()));
cloudQuery.setLimit(1);
cloudQuery.setScope(Scope.PAST);
getCloudBackend().list(cloudQuery, userStateHandler);
}
示例2: listAllPosts
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
private void listAllPosts() {
// create a response handler that will receive the query result or an error
CloudCallbackHandler<List<CloudEntity>> handler = new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
posts = results;
updateGuestbookUI();
}
@Override
public void onError(IOException exception) {
handleEndpointException(exception);
}
};
// execute the query with the handler
getCloudBackend().listByKind("Guestbook", CloudEntity.PROP_CREATED_AT, Order.DESC, 50,
Scope.FUTURE_AND_PAST, handler);
}
示例3: listAllPosts
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
private void listAllPosts() {
// create a response handler that will receive the query result or an
// error
CloudCallbackHandler<List<CloudEntity>> handler = new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
posts = results;
updateGuestbookUI();
}
@Override
public void onError(IOException exception) {
handleEndpointException(exception);
}
};
// execute the query with the handler
getCloudBackend().listByKind("Guestbook", CloudEntity.PROP_CREATED_AT, Order.DESC, 50, Scope.FUTURE_AND_PAST,
handler);
}
示例4: cacheInBackground
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
@Override
public boolean cacheInBackground() throws Exception {
if (!QRCloudUtils.internetAvailable(getActivity())) {
return false;
}
mRefreshTime = System.currentTimeMillis(); // update the last refreshed time
mItemOffset += QRCloudUtils.ITEMS_TO_LOAD; // load another set of items if possible //TODO: fix when loaded
// Log.d(LOG_TAG, CloudEntityListFragment.this.getTag() + " " + "loading items");
// execute the cloud query with the handler
CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_MESSAGES);
cloudQuery.setSort(mSortType == null ? CloudEntity.PROP_CREATED_AT : mSortType, Order.DESC); // default date
if (mGeoHashEnabled) {
// filter by a geohash/geocell hack: http://stackoverflow.com/a/1096744/1993220
String geoHash = mCallback.getLocationHash(); // calculated to query precision
if (geoHash == null) {
// Log.d(LOG_TAG, CloudEntityListFragment.this.getTag() + " " + "no geo");
return false; // no point doing anything - no geohash available
} else if (QRCloudUtils.GEOCELL_LOADING_MAGIC_VALUE.equals(geoHash)) {
// Log.d(LOG_TAG, CloudEntityListFragment.this.getTag() + " " + "magic geo");
return true; // we're getting a location - wait for another refresh callback
} else {
// Log.d(LOG_TAG, CloudEntityListFragment.this.getTag() + " " + "real geo");
String maxGeoHash = new String(geoHash + "\ufffd");
mExtraFilter = F.and(F.ge(QRCloudUtils.DATABASE_PROP_GEOCELL, geoHash),
F.le(QRCloudUtils.DATABASE_PROP_GEOCELL, maxGeoHash));
}
} else {
// Log.d(LOG_TAG, CloudEntityListFragment.this.getTag() + " " + "geo disabled");
}
cloudQuery.setLimit(mItemOffset);
cloudQuery.setScope(Scope.FUTURE_AND_PAST);
mQueryId = mCallback.loadItems(cloudQuery, mExtraFilter, mQueryHandler, mQueryId);
return true;
}
示例5: createQueryForCloudMessage
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
private CloudQuery createQueryForCloudMessage(String topicId, int maxOfflineMessages) {
// whether the query should include past messages since the last message
boolean includeOfflineMessages = maxOfflineMessages > 0;
long lastTime = (new Date()).getTime();
if (includeOfflineMessages) {
lastTime = getSharedPreferences().getLong(getPrefKeyForTopicId(topicId), lastTime);
}
// create query
CloudQuery cq = new CloudQuery(KIND_NAME_CLOUD_MESSAGES);
cq.setFilter(F.and(F.eq(PROP_TOPIC_ID, topicId),
F.gt(CloudEntity.PROP_CREATED_AT, new DateTime(lastTime))));
cq.setSort(CloudEntity.PROP_CREATED_AT, Order.DESC);
cq.setSubscriptionDurationSec(SUBSCRIPTION_DURATION_FOR_PUSH_MESSAGE);
if (includeOfflineMessages) {
cq.setLimit(maxOfflineMessages);
cq.setScope(Scope.FUTURE_AND_PAST);
} else {
cq.setLimit(DEFAULT_MAX_MESSAGES_TO_RECEIVE);
cq.setScope(Scope.FUTURE);
}
// set topicId as a queryId. Any queries on the same topic will
// be treated as just one query.
cq.setQueryId(topicId);
return cq;
}
示例6: list
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a query with specified {@link CloudQuery}.
*
* @param query
* {@link CloudQuery} to execute.
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void list(CloudQuery query, CloudCallbackHandler<List<CloudEntity>> handler) {
// register the query as continuous query
if (query.isContinuous()) {
CloudQuery ncq = new CloudQuery(query);
ncq.setScope(Scope.PAST);
ContinuousQueryHandler cqh = new ContinuousQueryHandler(handler, ncq, getCredential());
continuousQueries.put(query.getQueryId(), cqh);
}
// execute the query
_list(query, handler, new Handler());
}
示例7: createQueryForCloudMessage
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
private CloudQuery createQueryForCloudMessage(String topicId, int maxOfflineMessages) {
// whether the query should include past messages since the last message
boolean includeOfflineMessages = maxOfflineMessages > 0;
long lastTime = (new Date()).getTime();
if (includeOfflineMessages) {
lastTime = getSharedPreferences().getLong(getPrefKeyForTopicId(topicId), lastTime);
}
// create query
CloudQuery cq = new CloudQuery(KIND_NAME_CLOUD_MESSAGES);
cq.setFilter(F.and(F.eq(PROP_TOPIC_ID, topicId), F.gt(CloudEntity.PROP_CREATED_AT, new DateTime(lastTime))));
cq.setSort(CloudEntity.PROP_CREATED_AT, Order.DESC);
cq.setSubscriptionDurationSec(SUBSCRIPTION_DURATION_FOR_PUSH_MESSAGE);
if (includeOfflineMessages) {
cq.setLimit(maxOfflineMessages);
cq.setScope(Scope.FUTURE_AND_PAST);
} else {
cq.setLimit(DEFAULT_MAX_MESSAGES_TO_RECEIVE);
cq.setScope(Scope.FUTURE);
}
// set topicId as a queryId. Any queries on the same topic will
// be treated as just one query.
cq.setQueryId(topicId);
return cq;
}
示例8: list
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a query with specified {@link CloudQuery}.
*
* @param query
* {@link CloudQuery} to execute.
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void list(CloudQuery query, CloudCallbackHandler<List<CloudEntity>> handler) {
// register the query as continuous query
if (query.isContinuous()) {
CloudQuery ncq = new CloudQuery(query);
ncq.setScope(Scope.PAST);
ContinuousQueryHandler cqh = new ContinuousQueryHandler(handler, ncq, getCredential());
continuousQueries.put(query.getQueryId(), cqh);
}
// execute the query
_list(query, handler, new Handler());
}
示例9: updateCode
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
private void updateCode(final String codeHash, final String codeContents, final BarcodeFormat barcodeFormat,
final ParsedResultType barcodeType) {
// delay so we let the UI queries load first
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
CloudCallbackHandler<List<CloudEntity>> handler = new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
if (results.size() <= 0) {
// no record for this code exists - create a CloudEntity with the new code
CloudEntity newCode = new CloudEntity(QRCloudUtils.DATABASE_KIND_CODES);
newCode.put(QRCloudUtils.DATABASE_PROP_HASH, codeHash);
newCode.put(QRCloudUtils.DATABASE_PROP_CONTENTS, codeContents);
newCode.put(QRCloudUtils.DATABASE_PROP_FORMAT, barcodeFormat.name());
newCode.put(QRCloudUtils.DATABASE_PROP_TYPE, barcodeType.name());
newCode.put(QRCloudUtils.DATABASE_PROP_SCANS, 1); // this is the initial scan
newCode.put(QRCloudUtils.DATABASE_PROP_SOURCE, ContentProviderAuthority.DB_SOURCE);
// execute the insertion; nothing we can do on error, so ignore the result
getCloudBackend().insert(newCode, null);
} else {
CloudEntity existingEntity = results.get(0);
if (existingEntity != null) {
Object currentScanCount = existingEntity.get(QRCloudUtils.DATABASE_PROP_SCANS);
if (currentScanCount != null) {
// update to increase the scan count; nothing to do on error, so no result handler
existingEntity.put(QRCloudUtils.DATABASE_PROP_SCANS,
Integer.valueOf(currentScanCount.toString()) + 1);
getCloudBackend().update(existingEntity, null);
}
}
}
}
@Override
public void onError(IOException exception) {
// nothing else we can do
}
};
// now search for an existing record of this code
CloudQuery cloudQuery = new CloudQuery(QRCloudUtils.DATABASE_KIND_CODES);
cloudQuery.setFilter(F.eq(QRCloudUtils.DATABASE_PROP_HASH, codeHash));
cloudQuery.setLimit(1);
cloudQuery.setScope(Scope.PAST);
getCloudBackend().list(cloudQuery, handler);
}
}, NON_URGENT_QUERY_DELAY);
}
示例10: listByProperty
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} with specified single property condition.
*
* @param kindName
* a name of Kind to query
* @param propertyName
* property name for filtering
* @param operator
* operator that will be applied to the filtering
* @param propertyValue
* value that will be used in the filtering
* @param order
* {@link Order} of sorting on the specified property (ignored when
* inequality filter is not used as the operator)
* @param limit
* number of maximum entities to be returned
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void listByProperty(String kindName, String propertyName, F.Op operator,
Object propertyValue, CloudQuery.Order order, int limit, Scope scope,
CloudCallbackHandler<List<CloudEntity>> handler) {
CloudQuery cq = new CloudQuery(kindName);
cq.setFilter(F.createFilter(operator.name(), propertyName, propertyValue));
cq.setSort(propertyName, order);
cq.setLimit(limit);
cq.setScope(scope);
this.list(cq, handler);
}
示例11: listByKind
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} that retrieves all entities in the specified
* kind.
*
* @param kindName
* a name of Kind to query
* @param sortPropertyName
* property name for sorting
* @param order
* {@link Order} of sorting on the specified property
* @param limit
* number of maximum entities to be returned
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void listByKind(String kindName, String sortPropertyName, CloudQuery.Order order,
int limit, Scope scope, CloudCallbackHandler<List<CloudEntity>> handler) {
CloudQuery cq = new CloudQuery(kindName);
cq.setSort(sortPropertyName, order);
cq.setLimit(limit);
cq.setScope(scope);
this.list(cq, handler);
}
示例12: listByProperty
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} with specified single property condition.
*
* @param kindName
* a name of Kind to query
* @param propertyName
* property name for filtering
* @param operator
* operator that will be applied to the filtering
* @param propertyValue
* value that will be used in the filtering
* @param order
* {@link Order} of sorting on the specified property (ignored
* when inequality filter is not used as the operator)
* @param limit
* number of maximum entities to be returned
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void listByProperty(String kindName, String propertyName, F.Op operator, Object propertyValue,
CloudQuery.Order order, int limit, Scope scope, CloudCallbackHandler<List<CloudEntity>> handler) {
CloudQuery cq = new CloudQuery(kindName);
cq.setFilter(F.createFilter(operator.name(), propertyName, propertyValue));
cq.setSort(propertyName, order);
cq.setLimit(limit);
cq.setScope(scope);
this.list(cq, handler);
}
示例13: listByKind
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} that retrieves all entities in the
* specified kind.
*
* @param kindName
* a name of Kind to query
* @param sortPropertyName
* property name for sorting
* @param order
* {@link Order} of sorting on the specified property
* @param limit
* number of maximum entities to be returned
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void listByKind(String kindName, String sortPropertyName, CloudQuery.Order order, int limit, Scope scope,
CloudCallbackHandler<List<CloudEntity>> handler) {
CloudQuery cq = new CloudQuery(kindName);
cq.setSort(sortPropertyName, order);
cq.setLimit(limit);
cq.setScope(scope);
this.list(cq, handler);
}
示例14: getLastEntityOfKind
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} that retrieves the last one entity in the
* specified kind.
*
* @param kindName
* a name of Kind to query
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void getLastEntityOfKind(String kindName, Scope scope,
CloudCallbackHandler<List<CloudEntity>> handler) {
this.listByKind(kindName, CloudEntity.PROP_CREATED_AT, Order.DESC, 1, scope, handler);
}
示例15: getLastEntityOfKind
import com.google.cloud.backend.android.CloudQuery.Scope; //导入依赖的package包/类
/**
* Executes a {@link CloudQuery} that retrieves the last one entity in the
* specified kind.
*
* @param kindName
* a name of Kind to query
* @param scope
* {@link Scope} of this query
* @param handler
* {@link CloudCallbackHandler} that handles the response.
*/
public void getLastEntityOfKind(String kindName, Scope scope, CloudCallbackHandler<List<CloudEntity>> handler) {
this.listByKind(kindName, CloudEntity.PROP_CREATED_AT, Order.DESC, 1, scope, handler);
}