本文整理汇总了Java中com.box.androidsdk.content.BoxFutureTask类的典型用法代码示例。如果您正苦于以下问题:Java BoxFutureTask类的具体用法?Java BoxFutureTask怎么用?Java BoxFutureTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoxFutureTask类属于com.box.androidsdk.content包,在下文中一共展示了BoxFutureTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mController.getSupportedFeatures().addOnCompletedListener(new BoxFutureTask.OnCompletedListener<BoxFeatures>() {
@Override
public void onCompleted(BoxResponse<BoxFeatures> response) {
if (response.isSuccess()) {
mPasswordProtectedLinksSupported = response.getResult().hasPasswordProtectForSharedLinks();
} else {
mPasswordProtectedLinksSupported = true;
//Defaulting to true - if they aren't indeed supported, this will fail later when attempting to set password.
}
if (mPasswordProtectedLinksSupported && getView() != null && checkIfHasRequiredFields(mShareItem)) {
updateUi();
}
}
});
}
示例2: fetchItemInfo
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Gets information about given box item
*
* @param boxItem Box item object passed by the caller (eg. file, folder and bookmark)
* @return an instance of BoxFutureTask that asynchronously executes a request to obtain
* info about a box item
*/
@Override
public BoxFutureTask<BoxItem> fetchItemInfo(BoxItem boxItem) {
BoxRequest request = null;
if (boxItem instanceof BoxFile) {
request = mFileApi.getInfoRequest(boxItem.getId()).setFields(mFileShareFields);
} else if (boxItem instanceof BoxFolder) {
request = mFolderApi.getInfoRequest(boxItem.getId()).setFields(mFolderShareFields);
} else if (boxItem instanceof BoxBookmark) {
request = mBookmarkApi.getInfoRequest(boxItem.getId()).setFields(mBookmarkShareFields);
}
BoxFutureTask<BoxItem> task = new BoxFutureTask<BoxItem>(BoxItem.class, request);
getApiExecutor().submit(task);
return task;
}
示例3: fetchCollaborations
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Gets the collaborations on a box item
*
* @param boxCollaborationItem Box item for which collaborations need to be fetched
* @return instance of BoxFutureTask that asynchronously executes a request to fetch
* collaborations on box folder
*/
@Override
public BoxFutureTask<BoxIteratorCollaborations> fetchCollaborations(BoxCollaborationItem boxCollaborationItem) {
BoxFutureTask<BoxIteratorCollaborations> task = null;
if (boxCollaborationItem instanceof BoxFolder) {
task = mFolderApi
.getCollaborationsRequest(boxCollaborationItem.getId()).toTask();
} else if (boxCollaborationItem instanceof BoxFile){
task = mFileApi.getCollaborationsRequest(boxCollaborationItem.getId()).toTask();
}
if (task == null){
BoxLogUtils.nonFatalE("BoxShareConteroller","unhandled type " + boxCollaborationItem, new RuntimeException("bad argument"));
return null;
}
getApiExecutor().submit(task);
return task;
}
示例4: fetchRoles
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Gets a list of roles allowed for item collaboration invitees
*
* @param boxCollaborationItem Box item for which roles need to be fetched
* @return instance of BoxFutureTask that asynchronously executes a request to fetch roles
* of invitees for folder collaboration
*/
@Override
public BoxFutureTask<BoxCollaborationItem> fetchRoles(BoxCollaborationItem boxCollaborationItem) {
BoxRequest request = null;
if (boxCollaborationItem instanceof BoxFile) {
request = mFileApi.getInfoRequest(boxCollaborationItem.getId()).setFields(BoxFolder.FIELD_ALLOWED_INVITEE_ROLES);
}
if (boxCollaborationItem instanceof BoxFolder){
request = mFolderApi.getInfoRequest(boxCollaborationItem.getId()).setFields(BoxFolder.FIELD_ALLOWED_INVITEE_ROLES);
}
if (request == null){
BoxLogUtils.nonFatalE("BoxShareConteroller","unhandled type " + boxCollaborationItem, new RuntimeException("bad argument"));
return null;
}
BoxFutureTask<BoxCollaborationItem> task = new BoxFutureTask<BoxCollaborationItem>(BoxCollaborationItem.class, request);
getApiExecutor().submit(task);
return task;
}
示例5: refresh
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Refresh authentication information associated with this session.
*
* @return a task that can be used to block until the information associated with this session has been refreshed.
*/
public BoxFutureTask<BoxSession> refresh() {
if (mRefreshTask != null && mRefreshTask.get() != null){
BoxFutureTask<BoxSession> lastRefreshTask = mRefreshTask.get();
if (!(lastRefreshTask.isCancelled() || lastRefreshTask.isDone())){
return lastRefreshTask;
}
}
final BoxFutureTask<BoxSession> task = (new BoxSessionRefreshRequest(this)).toTask();
new Thread(){
@Override
public void run() {
task.run();
}
}.start();
mRefreshTask = new WeakReference<BoxFutureTask<BoxSession>>(task);
return task;
}
示例6: doUserRefresh
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
private BoxFutureTask<BoxUser> doUserRefresh(final Context context, final BoxAuthenticationInfo info){
BoxSession tempSession = new BoxSession(context, info.accessToken(), null);
BoxApiUser apiUser = new BoxApiUser(tempSession);
BoxFutureTask<BoxUser> task = apiUser.getCurrentUserInfoRequest().setFields(MINIMUM_USER_FIELDS).toTask();
task.addOnCompletedListener(new BoxFutureTask.OnCompletedListener<BoxUser>() {
@Override
public void onCompleted(BoxResponse<BoxUser> response) {
if (response.isSuccess()) {
info.setUser(response.getResult());
BoxAuthentication.getInstance().onAuthenticated(info, context);
} else {
BoxAuthentication.getInstance().onAuthenticationFailure(info, response.getException());
}
}
});
AUTH_EXECUTOR.execute(task);
return task;
}
示例7: disableShareLink
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Disables share link for a box item
*
* @param boxItem Box item object passed by the caller (eg. file, folder and bookmark)
* @return instance of BoxFutureTask that asynchronously executes a request to disable
* the shared link
*/
@Override
public BoxFutureTask<BoxItem> disableShareLink(BoxItem boxItem) {
BoxRequest request = null;
if (boxItem instanceof BoxFile) {
request = mFileApi.getDisableSharedLinkRequest(boxItem.getId()).setFields(mFileShareFields);
} else if (boxItem instanceof BoxFolder) {
request = mFolderApi.getDisableSharedLinkRequest(boxItem.getId()).setFields(mFolderShareFields);
} else if (boxItem instanceof BoxBookmark) {
request = mBookmarkApi.getDisableSharedLinkRequest(boxItem.getId()).setFields(mBookmarkShareFields);
}
return executeRequest(BoxItem.class, request);
}
示例8: addCollaborations
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Adds a list of users as collaborators to a folder by using their emails
*
* @param boxCollaborationItem Box Folder to be collaborated upon
* @param selectedRole Role for folder collaboration
* @param emails Emails of collaborators
* @return instance of BoxFutureTask that asynchronously executes a batch request to add
* collaborators on a given folder
*/
@Override
public BoxFutureTask<BoxResponseBatch> addCollaborations(BoxCollaborationItem boxCollaborationItem, BoxCollaboration.Role selectedRole, String[] emails) {
BoxRequestBatch batchRequest = new BoxRequestBatch();
for (String email: emails) {
String trimmedEmail = email.trim();
if (!SdkUtils.isBlank(trimmedEmail)) {
batchRequest.addRequest(mCollabApi.getAddRequest(boxCollaborationItem, selectedRole, trimmedEmail));
}
}
BoxFutureTask<BoxResponseBatch> task = batchRequest.toTask();
getApiExecutor().submit(task);
return task;
}
示例9: getSupportedFeatures
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Get a list of supported features for the user
*
* @return instance of BoxFutureTask that asynchronously executes a request to fetch the supported features
*/
@Override
public BoxFutureTask<BoxFeatures> getSupportedFeatures() {
BoxFutureTask<BoxFeatures> task = mFeaturesApi.getSupportedFeatures().toTask();
getApiExecutor().submit(task);
return task;
}
示例10: logout
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Logout the currently authenticated user.
*
* @return a task that can be used to block until the user associated with this session has been logged out.
*/
public BoxFutureTask<BoxSession> logout() {
final BoxFutureTask<BoxSession> task = (new BoxSessionLogoutRequest(this)).toTask();
new Thread(){
@Override
public void run() {
task.run();
}
}.start();
return task;
}
示例11: handleToTaskForCachedResult
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
/**
* Default implementation for getting a task to execute the request.
* @param <R> A BoxRequest that implements BoxCaceableRequest
* @return The task used to get data from cache implementation.
* @throws BoxException thrown if there is no cache implementation set in BoxConfig.
*/
protected <R extends BoxRequest & BoxCacheableRequest> BoxFutureTask<T> handleToTaskForCachedResult() throws BoxException {
BoxCache cache = BoxConfig.getCache();
if (cache == null) {
throw new BoxException.CacheImplementationNotFound();
}
return new BoxCacheFutureTask<T, R>(mClazz, (R) getCacheableRequest(), cache);
}
示例12: execute
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
@Override
public void execute(BoxRequest request) {
if (request == null) {
return;
}
if (BoxConfig.getCache() != null && request instanceof BoxCacheableRequest){
try {
BoxFutureTask cacheTask = ((BoxCacheableRequest) request).toTaskForCachedResult();
if (mListener != null){
cacheTask.addOnCompletedListener(mListener);
}
getApiExecutor().execute(cacheTask);
} catch (BoxException e){
BoxLogUtils.e("cache task error ", e);
}
}
BoxFutureTask task = request.toTask();
if (mListener != null) {
task.addOnCompletedListener(mListener);
}
// Thumbnail request should be executed in their own executor pool
ThreadPoolExecutor executor = request instanceof BoxRequestsFile.DownloadThumbnail ?
getThumbnailExecutor() :
getApiExecutor();
executor.submit(task);
}
示例13: toTaskForCachedResult
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
@Override
public BoxFutureTask<BoxIteratorInvitees> toTaskForCachedResult() throws BoxException {
return handleToTaskForCachedResult();
}
示例14: executeAvatarDownloadRequest
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
@Override
public BoxFutureTask<BoxDownload> executeAvatarDownloadRequest(String userId, BoxAvatarView avatarView) {
return null;
}
示例15: executeTask
import com.box.androidsdk.content.BoxFutureTask; //导入依赖的package包/类
protected void executeTask(final BoxFutureTask task){
if (mExecutor == null){
mExecutor = SdkUtils.createDefaultThreadPoolExecutor(2, 2, 3600, TimeUnit.SECONDS);
}
mExecutor.execute(task);
}