Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
删除评论的崩溃问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liubaicai committed Aug 22, 2016
1 parent 752dc45 commit 8da966d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "net.liubaicai.android.acfun"
minSdkVersion 15
targetSdkVersion 24
versionCode 4
versionName "1.2.0.1"
versionCode 5
versionName "1.2.0.2"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.liubaicai.android.acfun"
android:versionCode="4"
android:versionName="1.2.0.1">
android:versionCode="5"
android:versionName="1.2.0.2">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,57 +60,64 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (commentIdList == null)
return null;

SimpleDraweeView avatar_image;
TextView name_text;
TextView time_text;
TextView floor_text;
TextViewFixTouchConsume content_text;

if (convertView == null) {
convertView = inflater.inflate(resource, null);
avatar_image = (SimpleDraweeView) convertView.findViewById(R.id.avatar_image);
name_text = (TextView) convertView.findViewById(R.id.name_text);
time_text = (TextView) convertView.findViewById(R.id.time_text);
floor_text = (TextView) convertView.findViewById(R.id.floor_text);
content_text = (TextViewFixTouchConsume) convertView.findViewById(R.id.content_text);

ViewCache cache = new ViewCache();
cache.avatar_image = avatar_image;
cache.name_text = name_text;
cache.time_text = time_text;
cache.floor_text = floor_text;
cache.content_text = content_text;
convertView.setTag(cache);
} else {
ViewCache cache = (ViewCache) convertView.getTag();
avatar_image = cache.avatar_image;
name_text = cache.name_text;
time_text = cache.time_text;
floor_text = cache.floor_text;
content_text = cache.content_text;
}
CommentContent commentListItem = (CommentContent) getItem(position);

if (commentListItem != null) {
avatar_image.setImageURI(Uri.parse(commentListItem.getUserImg()));
name_text.setText(commentListItem.getUserName());
if (commentListItem.getNameRed() == 1)
name_text.setTextColor(context.getResources().getColor(R.color.news_number_color));
else
try{
SimpleDraweeView avatar_image;
TextView name_text;
TextView time_text;
TextView floor_text;
TextViewFixTouchConsume content_text;

if (convertView == null) {
convertView = inflater.inflate(resource, null);
avatar_image = (SimpleDraweeView) convertView.findViewById(R.id.avatar_image);
name_text = (TextView) convertView.findViewById(R.id.name_text);
time_text = (TextView) convertView.findViewById(R.id.time_text);
floor_text = (TextView) convertView.findViewById(R.id.floor_text);
content_text = (TextViewFixTouchConsume) convertView.findViewById(R.id.content_text);

ViewCache cache = new ViewCache();
cache.avatar_image = avatar_image;
cache.name_text = name_text;
cache.time_text = time_text;
cache.floor_text = floor_text;
cache.content_text = content_text;
convertView.setTag(cache);
} else {
ViewCache cache = (ViewCache) convertView.getTag();
avatar_image = cache.avatar_image;
name_text = cache.name_text;
time_text = cache.time_text;
floor_text = cache.floor_text;
content_text = cache.content_text;
}
CommentContent commentListItem = (CommentContent) getItem(position);

if (commentListItem != null) {
if (commentListItem.getUserImg()!=null&&!commentListItem.getUserImg().isEmpty())
avatar_image.setImageURI(Uri.parse(commentListItem.getUserImg()));
else
avatar_image.setImageResource(R.drawable.img_default_avatar);
name_text.setText(commentListItem.getUserName());
if (commentListItem.getNameRed() == 1)
name_text.setTextColor(context.getResources().getColor(R.color.news_number_color));
else
name_text.setTextColor(context.getResources().getColor(R.color.text_gray2_color));
time_text.setText(commentListItem.getPostDate());
floor_text.setText(String.valueOf(commentListItem.getCount()));
//content_text.setText(commentListItem.getContent());
TextViewUtils.setCommentContent(content_text, commentListItem);
} else {
avatar_image.setImageResource(R.drawable.img_default_avatar);
name_text.setText("::该楼层已被删除");
name_text.setTextColor(context.getResources().getColor(R.color.text_gray2_color));
time_text.setText(commentListItem.getPostDate());
floor_text.setText(String.valueOf(commentListItem.getCount()));
//content_text.setText(commentListItem.getContent());
TextViewUtils.setCommentContent(content_text, commentListItem);
} else {
avatar_image.setImageResource(R.drawable.img_default_avatar);
name_text.setText("::该楼层已被删除");
name_text.setTextColor(context.getResources().getColor(R.color.text_gray2_color));
time_text.setText("::该楼层已被删除");
floor_text.setText("0");
content_text.setText("::该楼层已被删除");
time_text.setText("::该楼层已被删除");
floor_text.setText("0");
content_text.setText("::该楼层已被删除");
}
return convertView;
}catch (Exception ex){
return null;
}
return convertView;
}


Expand Down

0 comments on commit 8da966d

Please sign in to comment.