Java 类com.facebook.share.widget.LikeView 实例源码

项目:kognitivo    文件:LikeActionController.java   
/**
 * Called by the LikeView when an object-id is set on it.
 *
 * @param objectId Object Id
 * @param callback Callback to be invoked when the LikeActionController has been created.
 */
public static void getControllerForObjectId(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    if (!isInitialized) {
        performFirstInitialize();
    }

    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
    } else {
        diskIOWorkQueue.addActiveWorkItem(
                new CreateLikeActionControllerWorkItem(objectId, objectType, callback));
    }
}
项目:kognitivo    文件:LikeActionController.java   
private static void verifyControllerAndInvokeCallback(
        LikeActionController likeActionController,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    LikeView.ObjectType bestObjectType = ShareInternalUtility.getMostSpecificObjectType(
            objectType,
            likeActionController.objectType);
    FacebookException error = null;
    if (bestObjectType == null) {
        // Looks like the existing controller has an object_type for this object_id that is
        // not compatible with the requested object type.
        error = new FacebookException(
                "Object with id:\"%s\" is already marked as type:\"%s\". " +
                        "Cannot change the type to:\"%s\"",
                likeActionController.objectId,
                likeActionController.objectType.toString(),
                objectType.toString());
        likeActionController = null;
    } else {
        likeActionController.objectType = bestObjectType;
    }

    invokeCallbackWithController(callback, likeActionController, error);
}
项目:kognitivo    文件:LikeActionController.java   
/**
 * Indicates whether the LikeView should enable itself.
 *
 * @return Indication of whether the LikeView should enable itself.
 */
public boolean shouldEnableView() {
    if (LikeDialog.canShowNativeDialog() || LikeDialog.canShowWebFallback()) {
        return true;
    }
    if (objectIsPage || (objectType == LikeView.ObjectType.PAGE)) {
        // If we can't use the dialogs, then we can't like Pages.
        // Before any requests are made to the server, we have to rely on the object type set
        // by the app. If we have permissions to make requests, we will know the real type after
        // the first request.
        return false;
    }

    // See if we have publish permissions.
    // NOTE: This will NOT be accurate if the app has the type set as UNKNOWN, and the
    // underlying object is a page.
    AccessToken token = AccessToken.getCurrentAccessToken();
    return token != null
            && token.getPermissions() != null
            && token.getPermissions().contains("publish_actions");
}
项目:kognitivo    文件:LikeActionController.java   
GetEngagementRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle requestParams = new Bundle();
    requestParams.putString(
            "fields",
            "engagement.fields(" +
                    "count_string_with_like," +
                    "count_string_without_like," +
                    "social_sentence_with_like," +
                    "social_sentence_without_like)");

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            objectId,
            requestParams,
            HttpMethod.GET));
}
项目:kognitivo    文件:ShareInternalUtility.java   
@Nullable
public static LikeView.ObjectType getMostSpecificObjectType(
        LikeView.ObjectType objectType1,
        LikeView.ObjectType objectType2) {
    if (objectType1 == objectType2) {
        return objectType1;
    }

    if (objectType1 == LikeView.ObjectType.UNKNOWN) {
        return objectType2;
    } else if (objectType2 == LikeView.ObjectType.UNKNOWN) {
        return objectType1;
    } else {
        // We can't have a PAGE and an OPEN_GRAPH type be compatible.
        return null;
    }
}
项目:MovieManiac    文件:SupportDeveloperActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_support_developer);

    FacebookSdk.sdkInitialize(getApplicationContext());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_action_navigation_arrow_back_inverted);
    toolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
    setTitle(R.string.support_developers_string);

    LikeView likeView = (LikeView) findViewById(R.id.facebookLikeView);
    if (likeView != null) {
        likeView.setObjectIdAndType(NetworkConstants.FACEBOOK_PAGE_URL, LikeView.ObjectType.PAGE);
        likeView.setLikeViewStyle(LikeView.Style.BOX_COUNT);
    }

    findViewById(R.id.buttonReportBugs).setOnClickListener(this);
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
/**
 * Called by the LikeView when an object-id is set on it.
 *
 * @param objectId Object Id
 * @param callback Callback to be invoked when the LikeActionController has been created.
 */
public static void getControllerForObjectId(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    if (!isInitialized) {
        performFirstInitialize();
    }

    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
    } else {
        diskIOWorkQueue.addActiveWorkItem(
                new CreateLikeActionControllerWorkItem(objectId, objectType, callback));
    }
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
private static boolean canLike(LikeView.ObjectType objectType) {
    if (LikeDialog.canShowNativeDialog() || LikeDialog.canShowWebFallback()) {
        return true;
    }
    if (objectType == LikeView.ObjectType.PAGE) {
        // If we can't use the dialogs, then we can't like Pages.
        return false;
    }

    // See if we have publish permissions.
    // NOTE: This will NOT be accurate if the app has the type set as UNKNOWN, and the
    // underlying object is a page.
    AccessToken token = AccessToken.getCurrentAccessToken();
    return token != null
            && token.getPermissions() != null
            && token.getPermissions().contains("publish_actions");
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
private static void verifyControllerAndInvokeCallback(
        LikeActionController likeActionController,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    LikeView.ObjectType bestObjectType = ShareInternalUtility.getMostSpecificObjectType(
            objectType,
            likeActionController.objectType);
    FacebookException error = null;
    if (bestObjectType == null) {
        // Looks like the existing controller has an object_type for this object_id that is
        // not compatible with the requested object type.
        error = new FacebookException(
                "Object with id:\"%s\" is already marked as type:\"%s\". " +
                        "Cannot change the type to:\"%s\"",
                likeActionController.objectId,
                likeActionController.objectType.toString(),
                objectType.toString());
        likeActionController = null;
    } else {
        likeActionController.objectType = bestObjectType;
    }

    invokeCallbackWithController(callback, likeActionController, error);
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
GetPageIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle pageIdRequestParams = new Bundle();
    pageIdRequestParams.putString("fields", "id");
    pageIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            pageIdRequestParams,
            HttpMethod.GET));
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
GetEngagementRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle requestParams = new Bundle();
    requestParams.putString(
            "fields",
            "engagement.fields(" +
                    "count_string_with_like," +
                    "count_string_without_like," +
                    "social_sentence_with_like," +
                    "social_sentence_without_like)");

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            objectId,
            requestParams,
            HttpMethod.GET));
}
项目:Move-Alarm_ORCA    文件:ShareInternalUtility.java   
@Nullable
public static LikeView.ObjectType getMostSpecificObjectType(
        LikeView.ObjectType objectType1,
        LikeView.ObjectType objectType2) {
    if (objectType1 == objectType2) {
        return objectType1;
    }

    if (objectType1 == LikeView.ObjectType.UNKNOWN) {
        return objectType2;
    } else if (objectType2 == LikeView.ObjectType.UNKNOWN) {
        return objectType1;
    } else {
        // We can't have a PAGE and an OPEN_GRAPH type be compatible.
        return null;
    }
}
项目:SocioBlood    文件:LikeActionController.java   
/**
 * Called by the LikeView when an object-id is set on it.
 *
 * @param objectId Object Id
 * @param callback Callback to be invoked when the LikeActionController has been created.
 */
public static void getControllerForObjectId(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    if (!isInitialized) {
        performFirstInitialize();
    }

    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
    } else {
        diskIOWorkQueue.addActiveWorkItem(
                new CreateLikeActionControllerWorkItem(objectId, objectType, callback));
    }
}
项目:SocioBlood    文件:LikeActionController.java   
private static void verifyControllerAndInvokeCallback(
        LikeActionController likeActionController,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    LikeView.ObjectType bestObjectType = ShareInternalUtility.getMostSpecificObjectType(
            objectType,
            likeActionController.objectType);
    FacebookException error = null;
    if (bestObjectType == null) {
        // Looks like the existing controller has an object_type for this object_id that is
        // not compatible with the requested object type.
        error = new FacebookException(
                "Object with id:\"%s\" is already marked as type:\"%s\". " +
                        "Cannot change the type to:\"%s\"",
                likeActionController.objectId,
                likeActionController.objectType.toString(),
                objectType.toString());
        likeActionController = null;
    } else {
        likeActionController.objectType = bestObjectType;
    }

    invokeCallbackWithController(callback, likeActionController, error);
}
项目:SocioBlood    文件:LikeActionController.java   
/**
 * Indicates whether the LikeView should enable itself.
 *
 * @return Indication of whether the LikeView should enable itself.
 */
public boolean shouldEnableView() {
    if (LikeDialog.canShowNativeDialog() || LikeDialog.canShowWebFallback()) {
        return true;
    }
    if (objectIsPage || (objectType == LikeView.ObjectType.PAGE)) {
        // If we can't use the dialogs, then we can't like Pages.
        // Before any requests are made to the server, we have to rely on the object type set
        // by the app. If we have permissions to make requests, we will know the real type after
        // the first request.
        return false;
    }

    // See if we have publish permissions.
    // NOTE: This will NOT be accurate if the app has the type set as UNKNOWN, and the
    // underlying object is a page.
    AccessToken token = AccessToken.getCurrentAccessToken();
    return token != null
            && token.getPermissions() != null
            && token.getPermissions().contains("publish_actions");
}
项目:SocioBlood    文件:LikeActionController.java   
GetEngagementRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle requestParams = new Bundle();
    requestParams.putString(
            "fields",
            "engagement.fields(" +
                    "count_string_with_like," +
                    "count_string_without_like," +
                    "social_sentence_with_like," +
                    "social_sentence_without_like)");

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            objectId,
            requestParams,
            HttpMethod.GET));
}
项目:SocioBlood    文件:ShareInternalUtility.java   
@Nullable
public static LikeView.ObjectType getMostSpecificObjectType(
        LikeView.ObjectType objectType1,
        LikeView.ObjectType objectType2) {
    if (objectType1 == objectType2) {
        return objectType1;
    }

    if (objectType1 == LikeView.ObjectType.UNKNOWN) {
        return objectType2;
    } else if (objectType2 == LikeView.ObjectType.UNKNOWN) {
        return objectType1;
    } else {
        // We can't have a PAGE and an OPEN_GRAPH type be compatible.
        return null;
    }
}
项目:kognitivo    文件:LikeActionController.java   
/**
 * NOTE: This MUST be called ONLY via the CreateLikeActionControllerWorkItem class to ensure
 * that it happens on the right thread, at the right time.
 */
private static void createControllerForObjectIdAndType(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    // Check again to see if the controller was created before attempting to deserialize/create
    // one. Need to check this in the case where multiple LikeViews are looking for a controller
    // for the same object and all got queued up to create one. We only want the first one to go
    // through with the creation, and the rest should get the same instance from the
    // object-cache.
    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
        return;
    }

    // Try deserialize from disk
    controllerForObject = deserializeFromDiskSynchronously(objectId);

    if (controllerForObject == null) {
        controllerForObject = new LikeActionController(objectId, objectType);
        serializeToDiskAsync(controllerForObject);
    }

    // Update object-cache.
    putControllerInMemoryCache(objectId, controllerForObject);

    // Refresh the controller on the Main thread.
    final LikeActionController controllerToRefresh = controllerForObject;
    handler.post(new Runnable() {
        @Override
        public void run() {
            controllerToRefresh.refreshStatusAsync();
        }
    });

    invokeCallbackWithController(callback, controllerToRefresh, null);
}
项目:kognitivo    文件:LikeActionController.java   
GetOGObjectIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle objectIdRequestParams = new Bundle();
    objectIdRequestParams.putString("fields", "og_object.fields(id)");
    objectIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            objectIdRequestParams,
            HttpMethod.GET));
}
项目:kognitivo    文件:LikeActionController.java   
GetPageIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle pageIdRequestParams = new Bundle();
    pageIdRequestParams.putString("fields", "id");
    pageIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            pageIdRequestParams,
            HttpMethod.GET));
}
项目:kognitivo    文件:LikeActionController.java   
PublishLikeRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle likeRequestParams = new Bundle();
    likeRequestParams.putString("object", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            likeRequestParams,
            HttpMethod.POST));
}
项目:kognitivo    文件:LikeActionController.java   
GetPageLikesRequestWrapper(String pageId) {
    super(pageId, LikeView.ObjectType.PAGE);
    this.pageId = pageId;

    Bundle requestParams = new Bundle();
    requestParams.putString("fields", "id");

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/likes/" + pageId,
            requestParams,
            HttpMethod.GET));
}
项目:kognitivo    文件:LikeActionController.java   
GetOGObjectLikesRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);
    this.objectId = objectId;
    this.objectType = objectType;

    Bundle requestParams = new Bundle();
    requestParams.putString("fields", "id,application");
    requestParams.putString("object", this.objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            requestParams,
            HttpMethod.GET));
}
项目:kognitivo    文件:LikeActionController.java   
CreateLikeActionControllerWorkItem(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    this.objectId = objectId;
    this.objectType = objectType;
    this.callback = callback;
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
/**
 * NOTE: This MUST be called ONLY via the CreateLikeActionControllerWorkItem class to ensure
 * that it happens on the right thread, at the right time.
 */
private static void createControllerForObjectIdAndType(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    // Check again to see if the controller was created before attempting to deserialize/create
    // one. Need to check this in the case where multiple LikeViews are looking for a controller
    // for the same object and all got queued up to create one. We only want the first one to go
    // through with the creation, and the rest should get the same instance from the
    // object-cache.
    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
        return;
    }

    // Try deserialize from disk
    controllerForObject = deserializeFromDiskSynchronously(objectId);

    if (controllerForObject == null) {
        controllerForObject = new LikeActionController(objectId, objectType);
        serializeToDiskAsync(controllerForObject);
    }

    // Update object-cache.
    putControllerInMemoryCache(objectId, controllerForObject);

    // Refresh the controller on the Main thread.
    final LikeActionController controllerToRefresh = controllerForObject;
    handler.post(new Runnable() {
        @Override
        public void run() {
            controllerToRefresh.refreshStatusAsync();
        }
    });

    invokeCallbackWithController(callback, controllerToRefresh, null);
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
GetOGObjectIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle objectIdRequestParams = new Bundle();
    objectIdRequestParams.putString("fields", "og_object.fields(id)");
    objectIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            objectIdRequestParams,
            HttpMethod.GET));
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
PublishLikeRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle likeRequestParams = new Bundle();
    likeRequestParams.putString("object", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            likeRequestParams,
            HttpMethod.POST));
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
GetOGObjectLikesRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle requestParams = new Bundle();
    requestParams.putString("fields", "id,application");
    requestParams.putString("object", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            requestParams,
            HttpMethod.GET));
}
项目:Move-Alarm_ORCA    文件:LikeActionController.java   
CreateLikeActionControllerWorkItem(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    this.objectId = objectId;
    this.objectType = objectType;
    this.callback = callback;
}
项目:SocioBlood    文件:LikeActionController.java   
/**
 * NOTE: This MUST be called ONLY via the CreateLikeActionControllerWorkItem class to ensure
 * that it happens on the right thread, at the right time.
 */
private static void createControllerForObjectIdAndType(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    // Check again to see if the controller was created before attempting to deserialize/create
    // one. Need to check this in the case where multiple LikeViews are looking for a controller
    // for the same object and all got queued up to create one. We only want the first one to go
    // through with the creation, and the rest should get the same instance from the
    // object-cache.
    LikeActionController controllerForObject = getControllerFromInMemoryCache(objectId);
    if (controllerForObject != null) {
        // Direct object-cache hit
        verifyControllerAndInvokeCallback(controllerForObject, objectType, callback);
        return;
    }

    // Try deserialize from disk
    controllerForObject = deserializeFromDiskSynchronously(objectId);

    if (controllerForObject == null) {
        controllerForObject = new LikeActionController(objectId, objectType);
        serializeToDiskAsync(controllerForObject);
    }

    // Update object-cache.
    putControllerInMemoryCache(objectId, controllerForObject);

    // Refresh the controller on the Main thread.
    final LikeActionController controllerToRefresh = controllerForObject;
    handler.post(new Runnable() {
        @Override
        public void run() {
            controllerToRefresh.refreshStatusAsync();
        }
    });

    invokeCallbackWithController(callback, controllerToRefresh, null);
}
项目:SocioBlood    文件:LikeActionController.java   
GetOGObjectIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle objectIdRequestParams = new Bundle();
    objectIdRequestParams.putString("fields", "og_object.fields(id)");
    objectIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            objectIdRequestParams,
            HttpMethod.GET));
}
项目:SocioBlood    文件:LikeActionController.java   
GetPageIdRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle pageIdRequestParams = new Bundle();
    pageIdRequestParams.putString("fields", "id");
    pageIdRequestParams.putString("ids", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "",
            pageIdRequestParams,
            HttpMethod.GET));
}
项目:SocioBlood    文件:LikeActionController.java   
PublishLikeRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle likeRequestParams = new Bundle();
    likeRequestParams.putString("object", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            likeRequestParams,
            HttpMethod.POST));
}
项目:SocioBlood    文件:LikeActionController.java   
GetOGObjectLikesRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    super(objectId, objectType);

    Bundle requestParams = new Bundle();
    requestParams.putString("fields", "id,application");
    requestParams.putString("object", objectId);

    setRequest(new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            "me/og.likes",
            requestParams,
            HttpMethod.GET));
}
项目:SocioBlood    文件:LikeActionController.java   
CreateLikeActionControllerWorkItem(
        String objectId,
        LikeView.ObjectType objectType,
        CreationCallback callback) {
    this.objectId = objectId;
    this.objectType = objectType;
    this.callback = callback;
}
项目:kognitivo    文件:LikeActionController.java   
/**
 * Called from CallbackManager to process any pending likes that had resulted in the Like
 * dialog being displayed
 *
 * @param requestCode From the originating call to onActivityResult
 * @param resultCode  From the originating call to onActivityResult
 * @param data        From the originating call to onActivityResult
 * @return Indication of whether the Intent was handled
 */
public static boolean handleOnActivityResult(final int requestCode,
                                             final int resultCode,
                                             final Intent data) {
    // See if we were waiting on a Like dialog completion.
    if (Utility.isNullOrEmpty(objectIdForPendingController)) {
        Context appContext = FacebookSdk.getApplicationContext();
        SharedPreferences sharedPreferences = appContext.getSharedPreferences(
                LIKE_ACTION_CONTROLLER_STORE,
                Context.MODE_PRIVATE);

        objectIdForPendingController = sharedPreferences.getString(
                LIKE_ACTION_CONTROLLER_STORE_PENDING_OBJECT_ID_KEY,
                null);
    }

    if (Utility.isNullOrEmpty(objectIdForPendingController)) {
        // Doesn't look like we were waiting on a Like dialog completion
        return false;
    }

    getControllerForObjectId(
            objectIdForPendingController,
            LikeView.ObjectType.UNKNOWN,
            new CreationCallback() {
                @Override
                public void onComplete(
                        LikeActionController likeActionController,
                        FacebookException error) {
                    if (error == null) {
                        likeActionController.onActivityResult(
                                requestCode,
                                resultCode,
                                data);
                    } else {
                        Utility.logd(TAG, error);
                    }
                }
            });

    return true;
}
项目:kognitivo    文件:LikeActionController.java   
private static LikeActionController deserializeFromJson(String controllerJsonString) {
    LikeActionController controller;

    try {
        JSONObject controllerJson = new JSONObject(controllerJsonString);
        int version = controllerJson.optInt(JSON_INT_VERSION_KEY, -1);
        if (version != LIKE_ACTION_CONTROLLER_VERSION) {
            // Don't attempt to deserialize a controller that might be serialized differently
            // than expected.
            return null;
        }

        String objectId = controllerJson.getString(JSON_STRING_OBJECT_ID_KEY);
        int objectTypeInt = controllerJson.optInt(
                JSON_INT_OBJECT_TYPE_KEY,
                LikeView.ObjectType.UNKNOWN.getValue());

        controller = new LikeActionController(
                objectId,
                LikeView.ObjectType.fromInt(objectTypeInt));

        // Make sure to default to null and not empty string, to keep the logic elsewhere
        // functioning properly.
        controller.likeCountStringWithLike =
                controllerJson.optString(JSON_STRING_LIKE_COUNT_WITH_LIKE_KEY, null);
        controller.likeCountStringWithoutLike =
                controllerJson.optString(JSON_STRING_LIKE_COUNT_WITHOUT_LIKE_KEY, null);
        controller.socialSentenceWithLike =
                controllerJson.optString(JSON_STRING_SOCIAL_SENTENCE_WITH_LIKE_KEY, null);
        controller.socialSentenceWithoutLike =
                controllerJson.optString(JSON_STRING_SOCIAL_SENTENCE_WITHOUT_LIKE_KEY, null);
        controller.isObjectLiked = controllerJson.optBoolean(JSON_BOOL_IS_OBJECT_LIKED_KEY);
        controller.unlikeToken = controllerJson.optString(JSON_STRING_UNLIKE_TOKEN_KEY, null);

        JSONObject analyticsJSON = controllerJson.optJSONObject(
                JSON_BUNDLE_FACEBOOK_DIALOG_ANALYTICS_BUNDLE);
        if (analyticsJSON != null) {
            controller.facebookDialogAnalyticsBundle =
                    BundleJSONConverter.convertToBundle(analyticsJSON);
        }
    } catch (JSONException e) {
        Log.e(TAG, "Unable to deserialize controller from JSON", e);
        controller = null;
    }

    return controller;
}
项目:kognitivo    文件:LikeActionController.java   
/**
 * Constructor
 */
private LikeActionController(String objectId, LikeView.ObjectType objectType) {
    this.objectId = objectId;
    this.objectType = objectType;
}
项目:kognitivo    文件:LikeActionController.java   
private void presentLikeDialog(
        final Activity activity,
        final Fragment fragment,
        final Bundle analyticsParameters) {
    String analyticsEvent = null;

    if (LikeDialog.canShowNativeDialog()) {
        analyticsEvent = AnalyticsEvents.EVENT_LIKE_VIEW_DID_PRESENT_DIALOG;
    } else if (LikeDialog.canShowWebFallback()) {
        analyticsEvent = AnalyticsEvents.EVENT_LIKE_VIEW_DID_PRESENT_FALLBACK;
    } else {
        // We will get here if the user tapped the button when dialogs cannot be shown.
        logAppEventForError("present_dialog", analyticsParameters);
        Utility.logd(TAG, "Cannot show the Like Dialog on this device.");

        // If we got to this point, we should ask the views to check if they should now
        // be disabled.
        broadcastAction(null, ACTION_LIKE_ACTION_CONTROLLER_UPDATED);
    }

    // Using the value of analyticsEvent to see if we can show any version of the dialog.
    // Written this way just to prevent extra lines of code.
    if (analyticsEvent != null) {
        String objectTypeString = (this.objectType != null)
                ? this.objectType.toString()
                : LikeView.ObjectType.UNKNOWN.toString();
        LikeContent likeContent = new LikeContent.Builder()
                .setObjectId(this.objectId)
                .setObjectType(objectTypeString)
                .build();

        if (fragment != null) {
            new LikeDialog(fragment).show(likeContent);
        } else {
            new LikeDialog(activity).show(likeContent);
        }

        saveState(analyticsParameters);

        getAppEventsLogger().logSdkEvent(
                AnalyticsEvents.EVENT_LIKE_VIEW_DID_PRESENT_DIALOG,
                null,
                analyticsParameters);
    }
}
项目:kognitivo    文件:LikeActionController.java   
protected AbstractRequestWrapper(String objectId, LikeView.ObjectType objectType) {
    this.objectId = objectId;
    this.objectType = objectType;
}