Skip to content

Commit

Permalink
comments: HTC EVO and Dell Mini X10 trying to fix (not fixed) selfpost
Browse files Browse the repository at this point in the history
there seems to be a NullPointerException somewhere so it
does not render the selfpost. problem getting the
spannedSelftext probably
  • Loading branch information
talklittle committed Jan 3, 2011
1 parent d507af7 commit e8373da
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/com/andrewshu/android/reddit/CommentsListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,15 @@ public boolean isEmpty() {

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
View view = convertView;

ThingInfo item = this.getItem(position);

try {
if (position == 0) {
// The OP
if (convertView == null) {
if (view == null) {
view = mInflater.inflate(R.layout.threads_list_item, null);
} else {
view = convertView;
}

ThreadsListActivity.fillThreadsListItemView(view, item, CommentsListActivity.this,
Expand All @@ -407,26 +405,22 @@ public View getView(int position, View convertView, ViewGroup parent) {
String.format(getResources().getString(R.string.thread_time_submitter),
Util.getTimeAgo(item.getCreated_utc()), item.getAuthor()));

if (item.getSelftext() != null
&& !Constants.EMPTY_STRING.equals(item.getSelftext())) {
if (item.getSpannedSelftext() != null
&& !Constants.EMPTY_STRING.equals(item.getSpannedSelftext())) {
selftextView.setVisibility(View.VISIBLE);
selftextView.setText(item.getSpannedSelftext());
} else {
selftextView.setVisibility(View.GONE);
}

} else if (mHiddenComments.contains(position)) {
if (convertView == null) {
if (view == null) {
// Doesn't matter which view we inflate since it's gonna be invisible
view = mInflater.inflate(R.layout.zero_size_layout, null);
} else {
view = convertView;
}
} else if (mHiddenCommentHeads.contains(position)) {
if (convertView == null) {
if (view == null) {
view = mInflater.inflate(R.layout.comments_list_item_hidden, null);
} else {
view = convertView;
}
TextView votesView = (TextView) view.findViewById(R.id.votes);
TextView submitterView = (TextView) view.findViewById(R.id.submitter);
Expand All @@ -449,10 +443,8 @@ public View getView(int position, View convertView, ViewGroup parent) {

} else if (mMorePositions.contains(position)) {
// "load more comments"
if (convertView == null) {
if (view == null) {
view = mInflater.inflate(R.layout.more_comments_view, null);
} else {
view = convertView;
}

// Set colors based on theme
Expand All @@ -470,24 +462,21 @@ public View getView(int position, View convertView, ViewGroup parent) {

} else { // Regular comment
// Here view may be passed in for re-use, or we make a new one.
if (convertView == null) {
if (view == null) {
view = mInflater.inflate(R.layout.comments_list_item, null);
} else {
view = convertView;
}

fillCommentsListItemView(view, item, CommentsListActivity.this, mSettings, commentManager);

}
} catch (NullPointerException e) {
if (Constants.LOGGING) Log.w(TAG, "NPE in getView()", e);
// Probably means that the List is still being built, and OP probably got put in wrong position
if (convertView == null) {
if (view == null) {
if (position == 0)
view = mInflater.inflate(R.layout.threads_list_item, null);
else
view = mInflater.inflate(R.layout.comments_list_item, null);
} else {
view = convertView;
}
}
return view;
Expand Down

0 comments on commit e8373da

Please sign in to comment.