Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void getlikecommentsofpost(final ViewHolder holder, String page_post_id) {
- GraphRequest request = GraphRequest.newGraphPathRequest(
- accessToken,
- "/" + page_post_id,
- new GraphRequest.Callback() {
- @Override
- public void onCompleted(GraphResponse response) {
- Log.e("Response", response.getJSONObject() + "");
- JSONObject jsonObject = response.getJSONObject();
- try {
- JSONObject likes = jsonObject.getJSONObject("likes");
- JSONArray data = likes.getJSONArray("data");
- int page_post_likes = data.length();
- if (page_post_likes == 0) {
- holder.page_post_like_count_text_view.setText("0 Likes");
- } else {
- holder.page_post_like_count_text_view.setText(page_post_likes + " Likes");
- }
- try {
- for (int i = 0; i < data.length(); i++) {
- JSONObject object = data.getJSONObject(i);
- String page_post_liked_user_id = object.getString("id");
- }
- } catch (JSONException e) {
- Log.e("JSONException", e.toString());
- }
- } catch (JSONException e) {
- Log.e("JSONException", e.toString());
- holder.page_post_like_count_text_view.setText("0 Likes");
- }
- try {
- JSONObject comments = jsonObject.getJSONObject("comments");
- JSONArray data = comments.getJSONArray("data");
- int comment_count = data.length();
- if (comment_count == 0) {
- holder.page_post_comment_count_text_view.setText("0 Comments");
- } else {
- holder.page_post_comment_count_text_view.setText(comment_count + " Comments");
- }
- try {
- for (int i = 0; i < data.length(); i++) {
- JSONObject object = data.getJSONObject(i);
- String message = object.getString("message");
- String created_time = object.getString("created_time");
- String commented_id = object.getString("id");
- JSONObject comment_from = object.getJSONObject("from");
- String comment_user_name = comment_from.getString("name");
- String comment_userid = comment_from.getString("id");
- }
- } catch (JSONException e) {
- Log.e("JSONException", e.toString());
- }
- } catch (JSONException e) {
- Log.e("JSONException", e.toString());
- holder.page_post_comment_count_text_view.setText("0 Comments");
- }
- try {
- JSONObject share = jsonObject.getJSONObject("shares");
- int page_post_share_count = share.getInt("count");
- if (page_post_share_count == 0) {
- holder.page_post_share_count_text_view.setText("0 Shares");
- } else {
- holder.page_post_share_count_text_view.setText(page_post_share_count + " Shares");
- }
- } catch (JSONException e) {
- Log.e("JSONException", e.toString());
- holder.page_post_share_count_text_view.setText("0 Shares");
- }
- }
- });
- Bundle parameters = new Bundle();
- parameters.putString("fields", "likes.summary(true),comments.summary(true),shares");
- request.setParameters(parameters);
- request.executeAsync();
- }
Add Comment
Please, Sign In to add comment