I am writing an app in which i am fetching List of Facebook friends with their profile picture, name and dob
but some of my friends have not given their Birthday Dates, so in place of Birthday i am getting null by default, but now in place of null i want to show: Birthday Not Mentioned.
see below screen shot of my existing app:
Like: Vikas Rana has given DOB on facebook and AJay November has not given DOB on Facebook
> VikY
January 1
> AJamber
Null
Here, in place Null i want to show : Birthday Not Mentioned
FriendsList.java:
public View getView(int position, View convertView, ViewGroup parent) {
JSONObject jsonObject = null;
try {
jsonObject = jsonArray.getJSONObject(position);
} catch (JSONException e) {
}
FriendItem friendItem;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listfb_friends, null);
friendItem = new FriendItem();
convertView.setTag(friendItem);
} else {
friendItem = (FriendItem) convertView.getTag();
}
friendItem.friendPicture = (ImageView) convertView
.findViewById(R.id.picture);
friendItem.friendName = (TextView) convertView
.findViewById(R.id.name);
friendItem.friendDob = (TextView) convertView
.findViewById(R.id.dob);
friendItem.friendLayout = (RelativeLayout) convertView
.findViewById(R.id.friend_item);
try {
String uid = jsonObject.getString("uid");
String url = jsonObject.getString("pic_square");
friendItem.friendPicture.setImageBitmap(picturesGatherer
.getPicture(uid, url));
} catch (JSONException e) {
friendItem.friendName.setText("");
friendItem.friendDob.setText("");
}
try {
friendItem.friendName.setText(jsonObject.getString("name"));
if(!friendItem.friendDob.equals(""))
{
friendItem.friendDob.setText(jsonObject.getString("birthday"));
}
else
{
friendItem.friendDob.setText("Birthday Not Mentioned");
}
} catch (JSONException e) {
friendItem.friendName.setText("");
friendItem.friendDob.setText("");
}
listofshit.put(position, friendItem);
return convertView;
}
and if i am writing code something like this:
try {
friendItem.friendName.setText(jsonObject.getString("name"));
friendItem.friendDob.setText(jsonObject.getString("birthday"));
} catch (JSONException e) {
friendItem.friendName.setText("");
friendItem.friendDob.setText("");
}
finally
{
friendItem.friendDob.setText("Birthday Not Mentioned");
}
so i am getting Birthday Not Mentioned for all facebook friends Birthdays, even for them also those have mentioned.