本文将介绍com.facebook.presto.sql.parser.ParsingException的实例源码的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时
本文将介绍com.facebook.presto.sql.parser.ParsingException的实例源码的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于com.facebook.crypto.exception.KeyChainException的实例源码、com.facebook.FacebookAuthorizationException的实例源码、com.facebook.FacebookDialogException的实例源码、com.facebook.FacebookException的实例源码的知识。
本文目录一览:- com.facebook.presto.sql.parser.ParsingException的实例源码
- com.facebook.crypto.exception.KeyChainException的实例源码
- com.facebook.FacebookAuthorizationException的实例源码
- com.facebook.FacebookDialogException的实例源码
- com.facebook.FacebookException的实例源码
com.facebook.presto.sql.parser.ParsingException的实例源码
private String getFormattedsql(CreateView statement) { Query query = statement.getQuery(); String sql = formatsql(query); // verify round-trip Statement parsed; try { parsed = sqlParser.createStatement(sql); } catch (ParsingException e) { throw new PrestoException(INTERNAL_ERROR,"Formatted query does not parse: " + query); } if (!query.equals(parsed)) { throw new PrestoException(INTERNAL_ERROR,"Query does not round-trip: " + query); } return sql; }
@Nullable private static ErrorCode toErrorCode(@Nullable Throwable throwable) { if (throwable == null) { return null; } if (throwable instanceof PrestoException) { return ((PrestoException) throwable).getErrorCode(); } if (throwable instanceof Failure && ((Failure) throwable).getErrorCode() != null) { return ((Failure) throwable).getErrorCode(); } if (throwable instanceof ParsingException || throwable instanceof SemanticException) { return Syntax_ERROR.toErrorCode(); } if (throwable.getCause() != null) { return toErrorCode(throwable.getCause()); } return INTERNAL_ERROR.toErrorCode(); }
private Query parseView(String view,QualifiedobjectName name,Table node) { try { Statement statement = sqlParser.createStatement(view); return checkType(statement,Query.class,"parsed view"); } catch (ParsingException e) { throw new SemanticException(VIEW_PARSE_ERROR,node,"Failed parsing stored view '%s': %s",name,e.getMessage()); } }
private static Optional<Object> getParsedStatement(String statement) { try { return Optional.of((Object) sql_PARSER.createStatement(statement)); } catch (ParsingException e) { return Optional.empty(); } }
public BinaryLiteral(Optional<NodeLocation> location,String value) { super(location); requireNonNull(value,"value is null"); String hexString = WHITESPACE_PATTERN.matcher(value).replaceAll("").toupperCase(); if (NOT_HEX_DIGIT_PATTERN.matcher(hexString).matches()) { throw new ParsingException("Binary literal can only contain hexadecimal digits",location.get()); } if (hexString.length() % 2 != 0) { throw new ParsingException("Binary literal must contain an even number of digits",location.get()); } this.value = Slices.wrappedBuffer(BaseEncoding.base16().decode(hexString)); }
private LongLiteral(Optional<NodeLocation> location,"value is null"); try { this.value = Long.parseLong(value); } catch (NumberFormatException e) { throw new ParsingException("Invalid numeric literal: " + value); } }
private GenericLiteral(Optional<NodeLocation> location,String type,String value) { super(location); requireNonNull(type,"type is null"); requireNonNull(value,"value is null"); if (type.equalsIgnoreCase("X")) { // we explicitly disallow "X" as type name,so if the user arrived here,// it must be because that he intended to give a binaryLiteral instead,but // added whitespace between the X and quote throw new ParsingException("Spaces are not allowed between 'X' and the starting quote of a binary literal",location.get()); } this.type = type; this.value = value; }
private static Statement parseFormatted(sqlParser sqlParser,String sql,Node tree) { try { return sqlParser.createStatement(sql); } catch (ParsingException e) { throw new AssertionError(format( "Failed to parse formatted sql: %s\nerror: %s\ntree: %s",sql,e.getMessage(),tree)); } }
@Override public QueryInfo createquery(Session session,String query) { requireNonNull(query,"query is null"); checkArgument(!query.isEmpty(),"query must not be empty string"); QueryId queryId = session.getQueryId(); QueryExecution queryExecution; try { Statement statement = sqlParser.createStatement(query); QueryExecutionFactory<?> queryExecutionFactory = executionFactories.get(statement.getClass()); if (queryExecutionFactory == null) { throw new PrestoException(NOT_SUPPORTED,"Unsupported statement type: " + statement.getClass().getSimpleName()); } queryExecution = queryExecutionFactory.createqueryExecution(queryId,query,session,statement); } catch (ParsingException | PrestoException e) { // This is intentionally not a method,since after the state change listener is registered // it's not safe to do any of this,and we had bugs before where people reused this code in a method URI self = locationFactory.createqueryLocation(queryId); QueryExecution execution = new FailedQueryExecution(queryId,self,transactionManager,queryExecutor,e); queries.put(queryId,execution); queryMonitor.createdEvent(execution.getQueryInfo()); queryMonitor.completionEvent(execution.getQueryInfo()); stats.queryFinished(execution.getQueryInfo()); expirationQueue.add(execution); return execution.getQueryInfo(); } queryMonitor.createdEvent(queryExecution.getQueryInfo()); queryExecution.addStatechangelistener(newValue -> { if (newValue.isDone()) { QueryInfo info = queryExecution.getQueryInfo(); stats.queryFinished(info); queryMonitor.completionEvent(info); expirationQueue.add(queryExecution); } }); queries.put(queryId,queryExecution); // start the query in the background if (!queueManager.submit(queryExecution,stats)) { queryExecution.fail(new PrestoException(QUERY_QUEUE_FULL,"Too many queued queries!")); } return queryExecution.getQueryInfo(); }
com.facebook.crypto.exception.KeyChainException的实例源码
@Override public void set(final Set<String> value) { final Set<String> encryptedSet = new HashSet<>(value.size()); for (final String s : value) { try { encryptedSet.add(Base64.encodetoString( crypto.encrypt( s.getBytes(Charset.defaultCharset()),entity ),Base64.NO_WRAP )); } catch (KeyChainException | CryptoInitializationException | IOException e) { Log.e(TAG,e.getMessage()); encryptedSet.add(null); } } preferences.edit().putStringSet(key,encryptedSet).apply(); }
@Override public void set(final String value) { try { if (value != null) { super.set(Base64.encodetoString( crypto.encrypt( value.getBytes(Charset.defaultCharset()),Base64.NO_WRAP )); } else { delete(); } } catch (KeyChainException | CryptoInitializationException | IOException e) { Log.e(TAG,e.getMessage()); } }
@Override public synchronized byte[] getCipherKey() throws KeyChainException { if (!setCipherKey) { PasswordBasedKeyDerivation derivation = new PasswordBasedKeyDerivation(secureRandom,nativeCryptoLibrary); derivation.setPassword(password); derivation.setSalt(password.getBytes()); derivation.setIterations(IteraTION_COUNT); derivation.setKeyLengthInBytes(cryptoConfig.keyLength); try { cipherKey = derivation.generate(); } catch (CryptoInitializationException e) { return null; } } setCipherKey = true; return cipherKey; }
private String encrypt(final String plainText) { if (TextUtils.isEmpty(plainText)) { return plainText; } byte[] cipherText = null; if (!crypto.isAvailable()) { log(Log.WARN,"encrypt: crypto not available"); return null; } try { cipherText = crypto.encrypt(plainText.getBytes(),entity); } catch (KeyChainException | CryptoInitializationException | IOException e) { log(Log.ERROR,"encrypt: " + e); } return cipherText != null ? Base64.encodetoString(cipherText,Base64.DEFAULT) : null; }
private String decrypt(final String encryptedText) { if (TextUtils.isEmpty(encryptedText)) { return encryptedText; } byte[] plainText = null; if (!crypto.isAvailable()) { log(Log.WARN,"decrypt: crypto not available"); return null; } try { plainText = crypto.decrypt(Base64.decode(encryptedText,Base64.DEFAULT),"decrypt: " + e); } return plainText != null ? new String(plainText) : null; }
private byte[] maybeGenerateKey(String key,int length) throws KeyChainException,JAQException { byte[] data; String salt = mSharedPreferences.getString(CommonCrypto.hashPrefKey(key),""); if (!TextUtils.isEmpty(salt)) { try { data = BeeCrypto.get().decrypt(salt.getBytes(CharsetsSupport.UTF_8)); data = Base64.decode(data,Base64.NO_WRAP); } catch (Exception e) { Timber.w(e,"get key from preferences failure"); data = generateKeyAndSave(key,length); } } else { data = generateKeyAndSave(key,length); } return data; }
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}) public File obscureFile(File file,boolean deleteOldFile){ if (enableCrypto) { try { boolean isImage = FileUtils.isFileForImage(file); File mEncryptedFile = new File(makeDirectory()+DEFAULT_PREFIX_FILENAME+file.getName()); OutputStream fileStream = new bufferedoutputstream(new FileOutputStream(mEncryptedFile)); OutputStream outputStream = crypto.getCipherOutputStream(fileStream,mEntityPassword); int read; byte[] buffer = new byte[1024]; BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); while ((read = bis.read(buffer)) != -1) { outputStream.write(buffer,read); } outputStream.close(); bis.close(); if (deleteOldFile) file.delete(); File pathDir = new File(isImage?makeImagesDirectory():makeFileDirectory()); return FileUtils.moveFile(mEncryptedFile,pathDir); } catch (KeyChainException | CryptoInitializationException | IOException e) { e.printstacktrace(); return null; } } else { return file; } }
@Override public byte[] getMacKey() throws KeyChainException { if (!setMacKey) { macKey = new byte[NativeMac.KEY_LENGTH]; secureRandom.nextBytes(macKey); } setMacKey = true; return macKey; }
@Override public byte[] getCipherKey() throws KeyChainException { if (mCipherKey == null) { try { mCipherKey = maybeGenerateKey(CIPHER_KEY,mCryptoConfig.keyLength); } catch (JAQException e) { Timber.w(e,"generate cipher key failure"); throw new KeyChainException(e.getMessage(),e); } } return mCipherKey; }
@Override public byte[] getMacKey() throws KeyChainException { if (mMacKey == null) { try { mMacKey = maybeGenerateKey(MAC_KEY,64); } catch (JAQException e) { throw new KeyChainException(e.getMessage(),e); } } return mMacKey; }
private void put(String key,String hashKey,String value) throws KeyChainException,CryptoInitializationException,IOException { Entity entity = Entity.create(key); // original key byte[] data = mCrypto.encrypt(value.getBytes(CharsetsSupport.UTF_8),entity); mPreference.edit().putString(hashKey,Base64.encodetoString(data,Base64.NO_WRAP)).apply(); }
public Bitmap decryptPhoto(String filename) throws IOException,KeyChainException { FileInputStream fileStream = new FileInputStream(path + filename); InputStream inputStream = crypto.getCipherInputStream(fileStream,entity); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); inputStream.close(); return bitmap; }
/** * Encrypts the unencrypted file. Can throw a lot of errors * * @param encrypted * @param unencrypted * @param entityName * @throws IOException * @throws CryptoInitializationException * @throws KeyChainException */ @Override public void encrypt(File encrypted,File unencrypted,String entityName) throws IOException,KeyChainException { doFileChecks(unencrypted,encrypted); FileInputStream from = new FileInputStream(unencrypted); // Stream to read from source OutputStream to = crypto.getCipherOutputStream(new FileOutputStream(encrypted),new Entity(entityName)); // Stream to write to destination copyStreams(from,to); }
/** * Decrypts the encrypted file. Can also throw a lot of errors * * @param encrypted * @param unencrypted * @param entityName * @throws IOException * @throws CryptoInitializationException * @throws KeyChainException */ @Override public void decrypt(File encrypted,KeyChainException { doFileChecks(encrypted,unencrypted); InputStream from = crypto.getCipherInputStream(new FileInputStream(encrypted),new Entity(entityName)); FileOutputStream to = new FileOutputStream(unencrypted); copyStreams(from,to); }
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}) public File deObscureFile(File file,boolean deleteOldFile){ if (enableCrypto) { try { if (file.getName().contains(DEFAULT_PREFIX_FILENAME)) { boolean isImage = FileUtils.isFileForImage(file); File mDecryptedFile = new File(makeDirectory() + file.getName().replace(DEFAULT_PREFIX_FILENAME,"")); InputStream inputStream = crypto.getCipherInputStream(new FileInputStream(file),mEntityPassword); ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputStream outputStream = new FileOutputStream(mDecryptedFile); BufferedInputStream bis = new BufferedInputStream(inputStream); int mRead; byte[] mBuffer = new byte[1024]; while ((mRead = bis.read(mBuffer)) != -1) { outputStream.write(mBuffer,mRead); } bis.close(); out.writeto(outputStream); inputStream.close(); outputStream.close(); out.close(); if (deleteOldFile) file.delete(); File pathDir = new File(isImage?makeImagesDirectory():makeFileDirectory()); return FileUtils.moveFile(mDecryptedFile,pathDir); } return null; } catch (KeyChainException | CryptoInitializationException | IOException e) { e.printstacktrace(); return null; } } return file; }
@Override public byte[] getNewIV() throws KeyChainException { byte[] iv = new byte[cryptoConfig.ivLength]; secureRandom.nextBytes(iv); return iv; }
public static String encrypt(Crypto crypto,String alias,String plainText) throws IOException,KeyChainException,CryptoInitializationException { final byte[] bytes = crypto.encrypt(plainText.getBytes(ENCODING),Entity.create(alias)); return Base64.encodetoString(bytes,BASE64_FLAG); }
public static String decrypt(Crypto crypto,String encryptedText) throws IOException,CryptoInitializationException { final byte[] bytes = crypto.decrypt(Base64.decode(encryptedText,BASE64_FLAG),Entity.create(alias)); return new String(bytes,ENCODING); }
@Override public byte[] getNewIV() throws KeyChainException { byte[] iv = new byte[mCryptoConfig.ivLength]; mSecureRandom.nextBytes(iv); return iv; }
public void savePhotoEncrypted(Bitmap imageBitmap,String filename) throws KeyChainException,IOException { FileOutputStream fileStream = new FileOutputStream(path + filename); OutputStream outputStream = crypto.getCipherOutputStream(fileStream,entity); imageBitmap.compress(Bitmap.CompressFormat.JPEG,100,outputStream); outputStream.close(); }
/** * Encrypts a file input stream to the given file * @param encrypted file to be written to. Cannot be a directory * @param unencrypted the original file to be encrypted * @exception java.io.IOException thrown when the operation fails,either because the encrypted * file already exists,or something Failed during encryption */ public void encrypt(File encrypted,KeyChainException;
public void decrypt(File encrypted,KeyChainException;
com.facebook.FacebookAuthorizationException的实例源码
private void registerFacebookCallback() { final PublishSubject<String> fbAccesstoken = this.facebookAccesstoken; final BehaviorSubject<FacebookException> fbAuthError = this.facebookAuthorizationError; this.callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(this.callbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(final @NonNull LoginResult result) { fbAccesstoken.onNext(result.getAccesstoken().getToken()); } @Override public void onCancel() { // continue } @Override public void onError(final @NonNull FacebookException error) { if (error instanceof FacebookAuthorizationException) { fbAuthError.onNext(error); } } }); }
protected void execute() { if (sessionManager.isLoggedIn()) { Accesstoken accesstoken = sessionManager.getAccesstoken(); Bundle bundle = updateAppSecretProof(); GraphRequest request = new GraphRequest(accesstoken,getGraPHPath(),bundle,HttpMethod.GET); request.setVersion(configuration.getGraphVersion()); runRequest(request); } else { String reason = Errors.getError(Errors.ErrorMsg.LOGIN); Logger.logError(getClass(),reason,null); if (mSingleEmitter != null) { mSingleEmitter.onError(new FacebookAuthorizationException(reason)); } } }
public void fbLogin(final FBLoginInterface fbLoginInterface,final Activity activity) { List<String> permissionNeeds = Arrays.asList("email"); LoginManager.getInstance().logInWithReadPermissions(activity,permissionNeeds); LoginManager.getInstance().registerCallback(callbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccesstoken(),new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object,GraphResponse response) { Bundle facebookBundle = getFacebookData(object); fbLoginInterface.doTaskAfterLogin(facebookBundle); } }); Bundle parameters = new Bundle(); parameters.putString("fields","id,first_name,last_name,email,gender,birthday,location"); // Parámetros que pedimos a facebook request.setParameters(parameters); request.executeAsync(); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { if (error instanceof FacebookAuthorizationException) { if (Accesstoken.getCurrentAccesstoken() != null) { LoginManager.getInstance().logout(); fbLogin(fbLoginInterface,activity); } } } }); }
private void onSessionCallback(Session paramSession,SessionState paramSessionState,Exception paramException,DialogListener paramDialogListener) { Bundle localBundle = paramSession.getAuthorizationBundle(); if (paramSessionState == SessionState.OPENED) { Session localSession2; synchronized (this.lock) { Session localSession1 = this.session; localSession2 = null; if (paramSession != localSession1) { localSession2 = this.session; this.session = paramSession; this.sessionInvalidated = false; } } if (localSession2 != null) localSession2.close(); paramDialogListener.onComplete(localBundle); return; } if (paramException != null) { if ((paramException instanceof FacebookOperationCanceledException)) { paramDialogListener.onCancel(); return; } if (((paramException instanceof FacebookAuthorizationException)) && (localBundle != null) && (localBundle.containsKey("com.facebook.sdk.WebViewErrorCode")) && (localBundle.containsKey("com.facebook.sdk.FailingUrl"))) { paramDialogListener.onError(new DialogError(paramException.getMessage(),localBundle.getInt("com.facebook.sdk.WebViewErrorCode"),localBundle.getString("com.facebook.sdk.FailingUrl"))); return; } paramDialogListener.onFacebookError(new FacebookError(paramException.getMessage())); } }
com.facebook.FacebookDialogException的实例源码
private void callDialogListener(Bundle values,FacebookException error) { if (mListener == null) { return; } if (values != null) { mListener.onComplete(values); } else { if (error instanceof FacebookDialogException) { FacebookDialogException facebookDialogException = (FacebookDialogException) error; DialogError dialogError = new DialogError(facebookDialogException.getMessage(),facebookDialogException.getErrorCode(),facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle paramBundle,FacebookException paramFacebookException) { if (this.mListener == null) return; if (paramBundle != null) { this.mListener.onComplete(paramBundle); return; } if ((paramFacebookException instanceof FacebookDialogException)) { FacebookDialogException localFacebookDialogException = (FacebookDialogException)paramFacebookException; DialogError localDialogError = new DialogError(localFacebookDialogException.getMessage(),localFacebookDialogException.getErrorCode(),localFacebookDialogException.getFailingUrl()); this.mListener.onError(localDialogError); return; } if ((paramFacebookException instanceof FacebookOperationCanceledException)) { this.mListener.onCancel(); return; } FacebookError localFacebookError = new FacebookError(paramFacebookException.getMessage()); this.mListener.onFacebookError(localFacebookError); }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
private void callDialogListener(Bundle values,facebookDialogException.getFailingUrl()); mListener.onError(dialogError); } else if (error instanceof FacebookOperationCanceledException) { mListener.onCancel(); } else { FacebookError facebookError = new FacebookError(error.getMessage()); mListener.onFacebookError(facebookError); } } }
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl) { super.onReceivedError(view,errorCode,description,failingUrl); sendErrorToListener(new FacebookDialogException(description,failingUrl)); WebDialog.this.dismiss(); }
@Override public void onReceivedSslError(WebView view,SslErrorHandler handler,SslError error) { if (disABLE_SSL_CHECK_FOR_TESTING) { handler.proceed(); } else { super.onReceivedSslError(view,handler,error); sendErrorToListener(new FacebookDialogException(null,ERROR_Failed_SSL_HANDSHAKE,null)); handler.cancel(); WebDialog.this.dismiss(); } }
public void onReceivedSslError(WebView paramWebView,SslErrorHandler paramSslErrorHandler,SslError paramSslError) { super.onReceivedSslError(paramWebView,paramSslErrorHandler,paramSslError); WebDialog.this.sendErrorToListener(new FacebookDialogException(null,-11,null)); paramSslErrorHandler.cancel(); WebDialog.this.dismiss(); }
@Override public void onReceivedError(WebView view,failingUrl)); WebDialog.this.dismiss(); }
@Override public void onReceivedSslError(WebView view,null)); handler.cancel(); WebDialog.this.dismiss(); } }
public void onReceivedError(WebView paramWebView,int paramInt,String paramString1,String paramString2) { super.onReceivedError(paramWebView,paramInt,paramString1,paramString2); WebDialog.this.sendErrorToListener(new FacebookDialogException(paramString1,paramString2)); WebDialog.this.dismiss(); }
com.facebook.FacebookException的实例源码
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); } }
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); } }
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"); } } }
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."); } }
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); }
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); } }); }
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); } } }
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)); } }); }
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; } }); }
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); } } }
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; } }
@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; }
/** * 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); } }); }
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()); } }); }
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(); }
private void processResponse(ImageResponse response) { // First check if the response is for the right request. We may have: // 1. Sent a new request,thus super-ceding this one. // 2. Detached this view,in which case the response should be discarded. if (response.getRequest() == lastRequest) { lastRequest = null; Bitmap responseImage = response.getBitmap(); Exception error = response.getError(); if (error != null) { OnErrorListener listener = onErrorListener; if (listener != null) { listener.onError(new FacebookException( "Error in downloading profile picture for profileId: " + getProfileId(),error)); } else { Logger.log(LoggingBehavior.REQUESTS,Log.ERROR,TAG,error.toString()); } } else if (responseImage != null) { setimageBitmap(responseImage); if (response.isCachedRedirect()) { sendImageRequest(false); } } } }
@Override public void setCallbackToLoginFacebookButton() { callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Bundle param = new Bundle(); param.putString("fields","id,email"); facebookLink(loginResult); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { Logger.logExceptionToFabric(error); } }); }
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 FacebookOperationCanceledException(description); } /* Todo parse error values and create appropriate exception class */ return new FacebookException(description); }
private void processResponse(ImageResponse response) { // First check if the response is for the right request. We may have: // 1. Sent a new request,in which case the response should be discarded. if (response.getRequest() == lastRequest) { lastRequest = null; Bitmap responseImage = response.getBitmap(); Exception error = response.getError(); if (error != null) { OnErrorListener listener = onErrorListener; if (listener != null) { listener.onError(new FacebookException( "Error in downloading profile picture for profileId: " + getProfileId(),error.toString()); } } else if (responseImage != null) { setimageBitmap(responseImage); if (response.isCachedRedirect()) { sendImageRequest(false); } } } }
public FacebookHelper(@NonNull FacebookListener facebookListener) { mListener = facebookListener; mCallBackManager = CallbackManager.Factory.create(); FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { mListener.onFbSignInSuccess(loginResult.getAccesstoken().getToken(),loginResult.getAccesstoken().getUserId()); } @Override public void onCancel() { mListener.onFbSignInFail("User cancelled operation"); } @Override public void onError(FacebookException e) { mListener.onFbSignInFail(e.getMessage()); } }; LoginManager.getInstance().registerCallback(mCallBackManager,mCallBack); }
@OnClick(R.id.fb_login) public void setUpFacebookLoginButton() { LoginManager.getInstance().logInWithReadPermissions(this,Arrays.asList("email","public_profile")); LoginManager.getInstance().registerCallback(callbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { handleFacebookAccesstoken(loginResult.getAccesstoken()); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { if(!isNetworkConnected()){ Snackbar.make(findViewById(android.R.id.content),"please check internet connection",Snackbar.LENGTH_SHORT).show(); }else{ Snackbar.make(findViewById(android.R.id.content),"unexpected error,please try again later",Snackbar.LENGTH_SHORT).show(); } } }); }
protected void registerFacebookCallback() { LoginManager.getInstance().registerCallback(facebookCallbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code Log.d(TAG,"Login Success"); handleFacebookAccesstoken(loginResult.getAccesstoken()); } @Override public void onCancel() { // App code Log.d(TAG,"Login canceled"); } @Override public void onError(FacebookException exception) { // App code Log.d(TAG,"Login error"); } }); }
private void processResponse(ImageResponse response) { // First check if the response is for the right request. We may have: // 1. Sent a new request,error.toString()); } } else if (responseImage != null) { setimageBitmap(responseImage); if (response.isCachedRedirect()) { sendImageRequest(false); } } } }
private void facebookLogIn(View view) { LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button); loginButton.setReadPermissions("email"); // If using in a fragment loginButton.setFragment(this); // Other app specific specialization loginButton.performClick(); // Callback registration loginButton.registerCallback(callbackManager,new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code Toast.makeText(getContext(),"Logged In Successfully",Toast.LENGTH_SHORT).show(); setSessionManagement(); startActivity(new Intent(getApplicationContext(),MapsActivity.class)); } @Override public void onCancel() { // App code Toast.makeText(getContext(),"LogIn Failed",Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException exception) { // App code Toast.makeText(getContext(),Toast.LENGTH_SHORT).show(); } }); }
public static Bundle create( UUID callId,ShareContent shareContent,boolean shouldFailOnDataError) { Validate.notNull(shareContent,"shareContent"); Validate.notNull(callId,"callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent) shareContent; nativeParams = create(linkContent,shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent) shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent,callId); nativeParams = create(photoContent,photoUrls,shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent) shareContent; String videoUrl = ShareInternalUtility.getVideoUrl(videoContent,callId); nativeParams = create(videoContent,videoUrl,shouldFailOnDataError); } else if (shareContent instanceof ShareOpenGraphContent) { final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent; try { JSONObject openGraphActionjsON = ShareInternalUtility.toJSONObjectForCall( callId,openGraphContent); openGraphActionjsON = ShareInternalUtility.removeNamespacesFromogJsonObject( openGraphActionjsON,false); nativeParams = create(openGraphContent,openGraphActionjsON,shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
private static void validateLinkContent( ShareLinkContent linkContent,Validator validator) { Uri imageUrl = linkContent.getimageUrl(); if (imageUrl != null && !Utility.isWebUri(imageUrl)) { throw new FacebookException("Image Url must be an http:// or https:// url"); } }
private static void validatePhotoForWebDialog(SharePhoto photo,Validator validator) { if (photo == null) { throw new FacebookException("Cannot share a null SharePhoto"); } Uri imageUri = photo.getimageUrl(); if (imageUri == null || !Utility.isWebUri(imageUri)) { throw new FacebookException( "SharePhoto must have a non-null imageUrl set to the Uri of an image " + "on the web"); } }
private static void validateVideo(ShareVideo video,Validator validator) { if (video == null) { throw new FacebookException("Cannot share a null ShareVideo"); } Uri localUri = video.getLocalUrl(); if (localUri == null) { throw new FacebookException("ShareVideo does not have a LocalUrl specified"); } if (!Utility.isContentUri(localUri) && !Utility.isFileUri(localUri)) { throw new FacebookException("ShareVideo must reference a video that is on the device"); } }
public static void invokeCallbackWithException( FacebookCallback<Sharer.Result> callback,final Exception exception) { if (exception instanceof FacebookException) { invokeOnErrorCallback(callback,(FacebookException) exception); return; } invokeCallbackWithError( callback,"Error preparing share content: " + exception.getLocalizedMessage()); }
public static boolean handleActivityResult( int requestCode,int resultCode,Intent data,ResultProcessor resultProcessor) { AppCall appCall = getAppCallFromActivityResult(requestCode,data); if (appCall == null) { return false; } NativeAppCallAttachmentStore.cleanupAttachmentsForCall(appCall.getCallId()); if (resultProcessor == null) { return true; } FacebookException exception = NativeProtocol.getExceptionFromErrorData( NativeProtocol.getErrorDataFromresultIntent(data)); if (exception != null) { if (exception instanceof FacebookOperationCanceledException) { resultProcessor.onCancel(appCall); } else { resultProcessor.onError(appCall,exception); } } else { // If here,we did not find an error in the result. Bundle results = NativeProtocol.getSuccessResultsFromIntent(data); resultProcessor.onSuccess(appCall,results); } return true; }
static void invokeOnErrorCallback( FacebookCallback<Sharer.Result> callback,String message) { logShareResult(AnalyticsEvents.ParaMETER_SHARE_OUTCOME_ERROR,message); if (callback != null) { callback.onError(new FacebookException(message)); } }
static void invokeOnErrorCallback( FacebookCallback<Sharer.Result> callback,FacebookException ex) { logShareResult(AnalyticsEvents.ParaMETER_SHARE_OUTCOME_ERROR,ex.getMessage()); if (callback != null) { callback.onError(ex); } }
/** * Creates a new Request configured to upload an image to create a staging resource. Staging * resources allow you to post binary data such as images,in preparation for a post of an Open * Graph object or action which references the image. The URI returned when uploading a staging * resource may be passed as the image property for an Open Graph object or action. * * @param accesstoken the access token to use,or null * @param imageUri the file:// or content:// Uri pointing to the image to upload * @param callback a callback that will be called when the request is completed to handle * success or error conditions * @return a Request that is ready to execute * @throws FileNotFoundException */ public static GraphRequest newUploadStagingResourceWithImageRequest( Accesstoken accesstoken,Uri imageUri,Callback callback ) throws FileNotFoundException { if (Utility.isFileUri(imageUri)) { return newUploadStagingResourceWithImageRequest( accesstoken,new File(imageUri.getPath()),callback); } else if (!Utility.isContentUri(imageUri)) { throw new FacebookException("The image Uri must be either a file:// or content:// Uri"); } GraphRequest.ParcelableResourceWithMimeType<Uri> resourceWithMimeType = new GraphRequest.ParcelableResourceWithMimeType<>(imageUri,"image/png"); Bundle parameters = new Bundle(1); parameters.putParcelable(STAGING_ParaM,resourceWithMimeType); return new GraphRequest( accesstoken,MY_STAGING_RESOURCES,parameters,HttpMethod.POST,callback); }
public static Bundle create( UUID callId,"callId"); Bundle nativeParams = null; if (shareContent instanceof ShareLinkContent) { final ShareLinkContent linkContent = (ShareLinkContent)shareContent; nativeParams = create(linkContent,shouldFailOnDataError); } else if (shareContent instanceof SharePhotoContent) { final SharePhotoContent photoContent = (SharePhotoContent)shareContent; List<String> photoUrls = ShareInternalUtility.getPhotoUrls( photoContent,shouldFailOnDataError); } else if (shareContent instanceof ShareVideoContent) { final ShareVideoContent videoContent = (ShareVideoContent)shareContent; nativeParams = create(videoContent,openGraphContent); nativeParams = create(openGraphContent,shouldFailOnDataError); } catch (final JSONException e) { throw new FacebookException( "Unable to create a JSON Object from the provided ShareOpenGraphContent: " + e.getMessage()); } } return nativeParams; }
@Override protected void handleSuccess(JSONObject jsonObject) throws JSONException { if (jsonObject.getBoolean("success")) { issueResponSEOnMainThread(null,uploadContext.videoId); } else { handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE)); } }
@Override public void run() { if (!uploadContext.isCanceled) { try { executeGraphRequestSynchronously(getParameters()); } catch (FacebookException fe) { endUploadWithFailure(fe); } catch (Exception e) { endUploadWithFailure(new FacebookException(ERROR_UPLOAD,e)); } } else { // No specific failure here. endUploadWithFailure(null); } }
protected void executeGraphRequestSynchronously(Bundle parameters) { GraphRequest request = new GraphRequest( uploadContext.accesstoken,String.format(Locale.ROOT,"%s/videos",uploadContext.graphNode),null); GraphResponse response = request.executeAndWait(); if (response != null) { FacebookRequestError error = response.getError(); JSONObject responseJSON = response.getJSONObject(); if (error != null) { if (!attemptRetry(error.getSubErrorCode())) { handleError(new FacebookGraphResponseException(response,ERROR_UPLOAD)); } } else if (responseJSON != null) { try { handleSuccess(responseJSON); } catch (JSONException e) { endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE,e)); } } else { handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE)); } } else { handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE)); } }
protected void issueResponSEOnMainThread( final FacebookException error,final String videoId) { getHandler().post(new Runnable() { @Override public void run() { issueResponse(uploadContext,error,videoId); } }); }
/** * Share the content. * * @param callback the callback to call once the share is complete. */ public void share(FacebookCallback<Sharer.Result> callback) { if (!this.canShare()) { ShareInternalUtility.invokeCallbackWithError( callback,"Insufficient permissions for sharing content via Api."); return; } final ShareContent shareContent = this.getShareContent(); // Validate the share content try { ShareContentValidation.validateForApiShare(shareContent); } catch (FacebookException ex) { ShareInternalUtility.invokeCallbackWithException(callback,ex); return; } if (shareContent instanceof ShareLinkContent) { this.shareLinkContent((ShareLinkContent) shareContent,callback); } else if (shareContent instanceof SharePhotoContent) { this.sharePhotoContent((SharePhotoContent) shareContent,callback); } else if (shareContent instanceof ShareVideoContent) { this.shareVideoContent((ShareVideoContent) shareContent,callback); } else if (shareContent instanceof ShareOpenGraphContent) { this.shareOpenGraphContent((ShareOpenGraphContent) shareContent,callback); } }
public static Bundle createBundleForException(FacebookException e) { if (e == null) { return null; } Bundle errorBundle = new Bundle(); errorBundle.putString(BRIDGE_ARG_ERROR_DESCRIPTION,e.toString()); if (!(e instanceof FacebookOperationCanceledException)) { return errorBundle; } errorBundle.putString(BRIDGE_ARG_ERROR_TYPE,ERROR_USER_CANCELED); return errorBundle; }
今天的关于com.facebook.presto.sql.parser.ParsingException的实例源码的分享已经结束,谢谢您的关注,如果想了解更多关于com.facebook.crypto.exception.KeyChainException的实例源码、com.facebook.FacebookAuthorizationException的实例源码、com.facebook.FacebookDialogException的实例源码、com.facebook.FacebookException的实例源码的相关知识,请在本站进行查询。
本文标签: