2014-05-21 171 views
2

我使用Parse作爲後端,即時通訊設法獲取用戶個人資料圖片並顯示它。我不想使用ProfilePictureView,因爲即時通訊使用顯示其他圖像視圖的gridview。你可以看到我也在使用gravater api。使用picasso獲取用戶的facebook個人資料圖片

所以問題是:它不會顯示配置文件圖片,只有佔位符圖片(gravatar工作正常並顯示),我做錯了什麼?

ParseUser user = mUsers.get(position); 
      String email; 
      if (user.getEmail() == null) { // this is how i check if its a facebook 
              // user 

       ParseUser currentUser = user; 
       if (currentUser.get(ParseConstants.KEY_FACEBOOK_DETAILS) != null) { 
        JSONObject userProfile = currentUser 
          .getJSONObject(ParseConstants.KEY_FACEBOOK_DETAILS); 
        try { 
         if (userProfile.getString("facebookId") != null) { 
          String facebookId = userProfile.get("facebookId") 
            .toString(); 
          String facebookName = userProfile.getString("name"); 
          holder.nameLabel.setText(facebookName); 
          // holder.userImageView.setProfileId(facebookId); 
          String facebookProfilePicUrl = "http://graph.facebook.com/" 
            + facebookId + "/picture"; 

          Picasso.with(mContext).load(facebookProfilePicUrl) 
            .placeholder(R.drawable.avatar_empty) 
            .into(holder.userImageView); 
         } 
        } catch (JSONException e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 
        } 

       } 
      } else { 

       email = user.getEmail().toLowerCase(Locale.getDefault()); 
       if (email.equals("")) { 
        holder.userImageView.setImageResource(R.drawable.avatar_empty); 
       } else { 
        String hash = MD5Util.md5Hex(email); 
        String gravatarUrl = "http://www.gravatar.com/avatar/" + hash 
          + "?s=204&d=404"; 
        Picasso.with(mContext).load(gravatarUrl) 
          .placeholder(R.drawable.avatar_empty) 
          .into(holder.userImageView); 
       } 
       holder.nameLabel.setText(user.getUsername()); 
      } 

      GridView gridView = (GridView) parent; 
      if (gridView.isItemChecked(position)) { 
       holder.checkImageView.setVisibility(View.VISIBLE); 
      } else { 
       holder.checkImageView.setVisibility(View.INVISIBLE); 
      } 

      return convertView; 

回答

19

從http更改爲https。解決了它。

+0

這個求解器對我來說也是! – aletede91

相關問題