@Override protected void populateOpenGraphAction(ShareOpenGraphAction.Builder actionBuilder) { if (selectedPlace != null) { actionBuilder.putString("place", selectedPlace.optString("id")); } }
@Override protected void populateOpenGraphAction(ShareOpenGraphAction.Builder actionBuilder) { if (foodChoice != null && foodChoice.length() > 0) { if (foodChoiceUrl != null && foodChoiceUrl.length() > 0) { actionBuilder.putString("meal", foodChoiceUrl); } else { ShareOpenGraphObject mealObject = new ShareOpenGraphObject.Builder() .putString("og:type", MEAL_OBJECT_TYPE) .putString("og:title", foodChoice) .build(); actionBuilder.putObject("meal", mealObject); } } }
private ShareOpenGraphAction getThrowAction() { // The OG objects have their own bitmaps we could rely on, but in order to demonstrate // attaching an in-memory bitmap (e.g., a game screencap) we'll send the bitmap explicitly // ourselves. ImageButton view = gestureImages[playerChoice]; BitmapDrawable drawable = (BitmapDrawable) view.getBackground(); final Bitmap bitmap = drawable.getBitmap(); return new ShareOpenGraphAction.Builder() .setActionType(OpenGraphConsts.THROW_ACTION_TYPE) .putString("fb_sample_rps:gesture", getBuiltInGesture(playerChoice)) .putString("fb_sample_rps:opposing_gesture", getBuiltInGesture(computerChoice)) .putPhotoArrayList("og:image", new ArrayList<SharePhoto>() {{ add(new SharePhoto.Builder().setBitmap(bitmap).build()); }}) .build(); }
private ShareOpenGraphAction getAction() { return new ShareOpenGraphAction.Builder() .putString(TYPE_KEY, "myActionType") .putObject( "myObject", new ShareOpenGraphObject.Builder() .putString("myString", "value") .putInt("myInt", 42) .putBoolean("myBoolean", true) .putStringArrayList( "myStringArray", createArrayList( "string1", "string2", "string3") ) .putObject( "myObject", new ShareOpenGraphObject.Builder() .putDouble("myPi", 3.14) .build() ) .build()).build(); }
@Test public void testItAcceptsShareOpenGraphContent() { String actionKey = "foo"; String actionValue = "fooValue"; ShareOpenGraphAction shareOpenGraphAction = new ShareOpenGraphAction.Builder() .putString(actionKey, actionValue) .setActionType(actionKey) .build(); ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder() .setPreviewPropertyName(actionKey) .setAction(shareOpenGraphAction).build(); ShareContentValidation.validateForMessage(shareOpenGraphContent); ShareContentValidation.validateForNativeShare(shareOpenGraphContent); ShareContentValidation.validateForApiShare(shareOpenGraphContent); ShareContentValidation.validateForWebShare(shareOpenGraphContent); }
@Test public void testJsonSerializationOfOpenGraphExistingPlace() { ShareOpenGraphContent content = new ShareOpenGraphContent.Builder() .setAction( new ShareOpenGraphAction.Builder() .putString("place", "1") .build() ).setPlaceId("2") .build(); try { JSONObject object = ShareInternalUtility.toJSONObjectForCall(null, content); assertEquals("1", object.getString("place")); } catch (JSONException ex) { // Fail assertNotNull(ex); return; } }
/** * Sets the type for the action. * * @param actionType The type for the action. * @return The builder. */ public Builder setActionType(final String actionType) { this.putString(ACTION_TYPE_KEY, actionType); return this; }
public static ShareOpenGraphAction.Builder getOpenGraphActionBuilder() { return prepareOpenGraphValueContainerBuilder( new ShareOpenGraphAction.Builder()) .setActionType(OPEN_GRAPH_ACTION_TYPE) .putString( OPEN_GRAPH_CONTENT_PREVIEW_PROPERTY_NAME, OPEN_GRAPH_CONTENT_PREVIEW_PROPERTY_VALUE); }