public static void validate(GameRequestContent content) { Validate.notNull(content.getMessage(), "message"); if (content.getObjectId() != null ^ (content.getActionType() == GameRequestContent.ActionType.ASKFOR || content.getActionType() == GameRequestContent.ActionType.SEND)) { throw new IllegalArgumentException( "Object id should be provided if and only if action type is send or askfor"); } // parameters to, filters, suggestions are mutually exclusive int mutex = 0; if (content.getTo() != null) { mutex++; } if (content.getSuggestions() != null) { mutex++; } if (content.getFilters() != null) { mutex++; } if (mutex > 1) { throw new IllegalArgumentException( "Parameters to, filters and suggestions are mutually exclusive"); } }
@Override public AppCall createAppCall(final GameRequestContent content) { GameRequestValidation.validate(content); AppCall appCall = createBaseAppCall(); DialogPresenter.setupAppCallForWebDialog( appCall, GAME_REQUEST_DIALOG, WebDialogParameters.create(content)); return appCall; }
public void showDialogForInvites(String title, String message) { GameRequestContent content = new GameRequestContent.Builder() .setTitle(title) .setMessage(message) .setFilters(GameRequestContent.Filters.APP_NON_USERS) .build(); requestDialog.show(content); }
public void showDialogForRequests (String title, String message) { GameRequestContent content = new GameRequestContent.Builder() .setTitle(title) .setMessage(message) .setFilters(GameRequestContent.Filters.APP_USERS) .build(); requestDialog.show(content); }
public void showDirectRequests (String title, String message, List<String> recip) { GameRequestContent content = new GameRequestContent.Builder() .setTitle(title) .setMessage(message) .setRecipients(recip) .build(); requestDialog.show(content); }
public static Bundle create(GameRequestContent gameRequestContent) { Bundle webParams = new Bundle(); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_MESSAGE, gameRequestContent.getMessage()); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_TO, gameRequestContent.getTo()); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_TITLE, gameRequestContent.getTitle()); Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_DATA, gameRequestContent.getData()); if (gameRequestContent.getActionType() != null) { Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_ACTION_TYPE, gameRequestContent.getActionType().toString().toLowerCase(Locale.ENGLISH)); } Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_OBJECT_ID, gameRequestContent.getObjectId()); if (gameRequestContent.getFilters() != null) { Utility.putNonEmptyString( webParams, ShareConstants.WEB_DIALOG_PARAM_FILTERS, gameRequestContent.getFilters().toString().toLowerCase(Locale.ENGLISH)); } Utility.putCommaSeparatedStringList( webParams, ShareConstants.WEB_DIALOG_PARAM_SUGGESTIONS, gameRequestContent.getSuggestions()); return webParams; }
@Override public boolean canShow(final GameRequestContent content) { return true; }
/** * Shows a {@link GameRequestDialog} to send a request, using * the passed in activity. No callback will be invoked. * * @param activity Activity hosting the dialog. * @param gameRequestContent Content of the request. */ public static void show(final Activity activity, final GameRequestContent gameRequestContent) { new GameRequestDialog(activity).show(gameRequestContent); }
/** * Shows a {@link GameRequestDialog} to send a request, using * the passed in activity. No callback will be invoked. * * @param fragment Fragment hosting the dialog. * @param gameRequestContent Content of the request. */ public static void show(final Fragment fragment, final GameRequestContent gameRequestContent) { new GameRequestDialog(fragment).show(gameRequestContent); }