当前位置: 首页>>代码示例>>Java>>正文


Java FacebookException类代码示例

本文整理汇总了Java中com.facebook.FacebookException的典型用法代码示例。如果您正苦于以下问题:Java FacebookException类的具体用法?Java FacebookException怎么用?Java FacebookException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FacebookException类属于com.facebook包,在下文中一共展示了FacebookException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import com.facebook.FacebookException; //导入依赖的package包/类
private static void validate(ShareContent content, Validator validator)
        throws FacebookException {
    if (content == null) {
        throw new FacebookException("Must provide non-null content to share");
    }

    if (content instanceof ShareLinkContent) {
        validator.validate((ShareLinkContent) content);
    } else if (content instanceof SharePhotoContent) {
        validator.validate((SharePhotoContent) content);
    } else if (content instanceof ShareVideoContent) {
        validator.validate((ShareVideoContent) content);
    } else if (content instanceof ShareOpenGraphContent) {
        validator.validate((ShareOpenGraphContent) content);
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:17,代码来源:ShareContentValidation.java

示例2: validatePhotoContent

import com.facebook.FacebookException; //导入依赖的package包/类
private static void validatePhotoContent(
        SharePhotoContent photoContent, Validator validator) {
    List<SharePhoto> photos = photoContent.getPhotos();
    if (photos == null || photos.isEmpty()) {
        throw new FacebookException("Must specify at least one Photo in SharePhotoContent.");
    }
    if (photos.size() > ShareConstants.MAXIMUM_PHOTO_COUNT) {
        throw new FacebookException(
                String.format(
                        Locale.ROOT,
                        "Cannot add more than %d photos.",
                        ShareConstants.MAXIMUM_PHOTO_COUNT));
    }

    for (SharePhoto photo : photos) {
        validator.validate(photo);
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:19,代码来源:ShareContentValidation.java

示例3: validatePhotoForApi

import com.facebook.FacebookException; //导入依赖的package包/类
private static void validatePhotoForApi(SharePhoto photo, Validator validator) {
    if (photo == null) {
        throw new FacebookException("Cannot share a null SharePhoto");
    }

    Bitmap photoBitmap = photo.getBitmap();
    Uri photoUri = photo.getImageUrl();

    if (photoBitmap == null) {
        if (photoUri == null) {
            throw new FacebookException(
                    "SharePhoto does not have a Bitmap or ImageUrl specified");
        }

        if (Utility.isWebUri(photoUri) && !validator.isOpenGraphContent()) {
            throw new FacebookException(
                    "Cannot set the ImageUrl of a SharePhoto to the Uri of an image on the " +
                            "web when sharing SharePhotoContent");
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:22,代码来源:ShareContentValidation.java

示例4: validateOpenGraphContent

import com.facebook.FacebookException; //导入依赖的package包/类
private static void validateOpenGraphContent(
        ShareOpenGraphContent openGraphContent, Validator validator) {
    validator.validate(openGraphContent.getAction());

    String previewPropertyName = openGraphContent.getPreviewPropertyName();
    if (Utility.isNullOrEmpty(previewPropertyName)) {
        throw new FacebookException("Must specify a previewPropertyName.");
    }

    if (openGraphContent.getAction().get(previewPropertyName) == null) {
        throw new FacebookException(
                "Property \"" + previewPropertyName + "\" was not found on the action. " +
                        "The name of the preview property must match the name of an " +
                        "action property.");
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:17,代码来源:ShareContentValidation.java

示例5: getExceptionFromErrorData

import com.facebook.FacebookException; //导入依赖的package包/类
public static FacebookException getExceptionFromErrorData(Bundle errorData) {
    if (errorData == null) {
        return null;
    }
    String type = errorData.getString(BRIDGE_ARG_ERROR_TYPE);
    if (type == null) {
        type = errorData.getString(STATUS_ERROR_TYPE);
    }
    String description = errorData.getString(BRIDGE_ARG_ERROR_DESCRIPTION);
    if (description == null) {
        description = errorData.getString(STATUS_ERROR_DESCRIPTION);
    }
    if (type == null || !type.equalsIgnoreCase(ERROR_USER_CANCELED)) {
        return new FacebookException(description);
    }
    return new FacebookOperationCanceledException(description);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:NativeProtocol.java

示例6: initializeFacebookLogin

import com.facebook.FacebookException; //导入依赖的package包/类
void initializeFacebookLogin() {
    // Initialize Facebook Login button
    mCallbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = (LoginButton) findViewById(R.id.button_facebook_login);
    loginButton.setReadPermissions("email", "public_profile", "user_posts", "user_photos");
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d(TAG, "facebook:onSuccess:" + loginResult);
            handleFacebookAccessToken(loginResult.getAccessToken());
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "facebook:onCancel");
            // ...
        }

        @Override
        public void onError(FacebookException error) {
            Log.w(TAG, "facebook:onError", error);
        }
    });
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:25,代码来源:LoginActivity.java

示例7: validateOpenGraphValueContainer

import com.facebook.FacebookException; //导入依赖的package包/类
private static void validateOpenGraphValueContainer(
        ShareOpenGraphValueContainer valueContainer,
        Validator validator,
        boolean requireNamespace) {
    Set<String> keySet = valueContainer.keySet();
    for (String key : keySet) {
        validateOpenGraphKey(key, requireNamespace);
        Object o = valueContainer.get(key);
        if (o instanceof List) {
            List list = (List) o;
            for (Object objectInList : list) {
                if (objectInList == null) {
                    throw new FacebookException(
                            "Cannot put null objects in Lists in " +
                                    "ShareOpenGraphObjects and ShareOpenGraphActions");
                }
                validateOpenGraphValueContainerObject(objectInList, validator);
            }
        } else {
            validateOpenGraphValueContainerObject(o, validator);
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:24,代码来源:ShareContentValidation.java

示例8: registerSharerCallback

import com.facebook.FacebookException; //导入依赖的package包/类
public static void registerSharerCallback(
        final int requestCode,
        final CallbackManager callbackManager,
        final FacebookCallback<Sharer.Result> callback) {
    if (!(callbackManager instanceof CallbackManagerImpl)) {
        throw new FacebookException("Unexpected CallbackManager, " +
                "please use the provided Factory.");
    }

    ((CallbackManagerImpl) callbackManager).registerCallback(
            requestCode,
            new CallbackManagerImpl.Callback() {
                @Override
                public boolean onActivityResult(int resultCode, Intent data) {
                    return handleActivityResult(
                            requestCode,
                            resultCode,
                            data,
                            getShareResultProcessor(callback));
                }
            });
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:23,代码来源:ShareInternalUtility.java

示例9: toJSONObjectForWeb

import com.facebook.FacebookException; //导入依赖的package包/类
public static JSONObject toJSONObjectForWeb(
        final ShareOpenGraphContent shareOpenGraphContent)
        throws JSONException {
    ShareOpenGraphAction action = shareOpenGraphContent.getAction();

    return OpenGraphJSONUtility.toJSONObject(
            action,
            new OpenGraphJSONUtility.PhotoJSONProcessor() {
                @Override
                public JSONObject toJSONObject(SharePhoto photo) {
                    Uri photoUri = photo.getImageUrl();
                    JSONObject photoJSONObject = new JSONObject();
                    try {
                        photoJSONObject.put(
                                NativeProtocol.IMAGE_URL_KEY, photoUri.toString());
                    } catch (JSONException e) {
                        throw new FacebookException("Unable to attach images", e);
                    }
                    return photoJSONObject;
                }
            });
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:23,代码来源:ShareInternalUtility.java

示例10: issueResponse

import com.facebook.FacebookException; //导入依赖的package包/类
private static void issueResponse(
        final UploadContext uploadContext,
        final FacebookException error,
        final String videoId) {
    // Remove the UploadContext synchronously
    // Once the UploadContext is removed, this is the only reference to it.
    removePendingUpload(uploadContext);

    Utility.closeQuietly(uploadContext.videoStream);

    if (uploadContext.callback != null) {
        if (error != null) {
            ShareInternalUtility.invokeOnErrorCallback(uploadContext.callback, error);
        } else if (uploadContext.isCanceled) {
            ShareInternalUtility.invokeOnCancelCallback(uploadContext.callback);
        } else {
            ShareInternalUtility.invokeOnSuccessCallback(uploadContext.callback, videoId);
        }
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:21,代码来源:VideoUploader.java

示例11: initialize

import com.facebook.FacebookException; //导入依赖的package包/类
private void initialize()
        throws FileNotFoundException {
    ParcelFileDescriptor fileDescriptor = null;
    try {
        if (Utility.isFileUri(videoUri)) {
            fileDescriptor = ParcelFileDescriptor.open(
                    new File(videoUri.getPath()),
                    ParcelFileDescriptor.MODE_READ_ONLY);
            videoSize = fileDescriptor.getStatSize();
            videoStream = new ParcelFileDescriptor.AutoCloseInputStream(fileDescriptor);
        } else if (Utility.isContentUri(videoUri)) {
            videoSize = Utility.getContentSize(videoUri);
            videoStream = FacebookSdk
                    .getApplicationContext()
                    .getContentResolver()
                    .openInputStream(videoUri);
        } else {
            throw new FacebookException("Uri must be a content:// or file:// uri");
        }
    } catch (FileNotFoundException e) {
        Utility.closeQuietly(videoStream);

        throw e;
    }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:26,代码来源:VideoUploader.java

示例12: getParameters

import com.facebook.FacebookException; //导入依赖的package包/类
@Override
public Bundle getParameters()
        throws IOException {
    Bundle parameters = new Bundle();
    parameters.putString(PARAM_UPLOAD_PHASE, PARAM_VALUE_UPLOAD_TRANSFER_PHASE);
    parameters.putString(PARAM_SESSION_ID, uploadContext.sessionId);
    parameters.putString(PARAM_START_OFFSET, chunkStart);

    byte[] chunk = getChunk(uploadContext, chunkStart, chunkEnd);
    if (chunk != null) {
        parameters.putByteArray(PARAM_VIDEO_FILE_CHUNK, chunk);
    } else {
        throw new FacebookException("Error reading video");
    }

    return parameters;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:18,代码来源:VideoUploader.java

示例13: registerCallBackManager

import com.facebook.FacebookException; //导入依赖的package包/类
/**
 * Register call back manager to Google log in button.
 *
 * @param activity    the activity
 * @param loginButton the login button
 */
private void registerCallBackManager(final Activity activity, LoginButton loginButton) {
    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            mLoginResult = loginResult;
            getUserProfile(activity);
        }

        @Override
        public void onCancel() {
            mFacebookLoginResultCallBack.onFacebookLoginCancel();
        }

        @Override
        public void onError(FacebookException error) {
            mFacebookLoginResultCallBack.onFacebookLoginError(error);
        }
    });
}
 
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:26,代码来源:FacebookHelper.java

示例14: LoginFacebook

import com.facebook.FacebookException; //导入依赖的package包/类
public LoginFacebook(LoginButton login, Activity context, PreferencesShared pref, final Intent intent) {
    callbackManager = CallbackManager.Factory.create();
    this.context = context;
    preferencesShared = pref;
    login.setReadPermissions(Arrays.asList("public_profile", "user_friends"));
    login.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            //Log.d("facebook", "succes" + loginResult.getAccessToken().getToken() + "id" + loginResult.getAccessToken().getExpires() + "data" + loginResult.getAccessToken().getUserId());
            conectedwithFacebook(loginResult.getAccessToken().getToken(),intent);
        }

        @Override
        public void onCancel() {
            Log.d("intra","facebook");
        }

        @Override
        public void onError(FacebookException error) {
            Log.d("facebook", "error" + error.toString());
        }

    });
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:25,代码来源:LoginFacebook.java

示例15: authorize

import com.facebook.FacebookException; //导入依赖的package包/类
void authorize(Request request) {
    if (request == null) {
        return;
    }

    if (pendingRequest != null) {
        throw new FacebookException("Attempted to authorize while a request is pending.");
    }

    if (AccessToken.getCurrentAccessToken() != null && !checkInternetPermission()) {
        // We're going to need INTERNET permission later and don't have it, so fail early.
        return;
    }
    pendingRequest = request;
    handlersToTry = getHandlersToTry(request);
    tryNextHandler();
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:18,代码来源:LoginClient.java


注:本文中的com.facebook.FacebookException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。