Cleaned up posts list items

I also created header.xml, a reusable resource for displaying an avatar,
title, user name, and time stamp.

I also renamed some view id's to be more developer friendly

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-10-21 00:19:38 -04:00
parent 415b6f24fa
commit b2f00849a2
9 changed files with 92 additions and 105 deletions

View File

@@ -1,5 +1,5 @@
<manifest package="org.RickBarrette.osj.forum"
android:versionCode="1349"
android:versionCode="1362"
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-sdk

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<QuickContactBadge
android:id="@+id/quickContactBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:gravity="right" >
<TextView
android:id="@+id/textView_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/user"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textView_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/date"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<TextView
android:id="@+id/textView_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/quickContactBadge"
android:paddingLeft="5dip"
android:text="@string/title"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<View
android:id="@+id/firstDivider"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#0099CC"
android:padding="10dip" />
</LinearLayout>

View File

@@ -1,46 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dip"
>
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip" >
<include layout="@layout/header" />
<TextView
android:id="@+id/textView1"
android:id="@+id/textView_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/quickContactBadge1"
android:gravity="center_horizontal"
android:text="@string/title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<QuickContactBadge
android:id="@+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/quickContactBadge1"
android:layout_marginTop="15dp"
android:text="@string/post" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView3"
android:layout_alignLeft="@+id/textView1"
android:text="@string/user"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</LinearLayout>

View File

@@ -5,73 +5,25 @@
android:orientation="vertical"
android:padding="5dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip" >
<QuickContactBadge
android:id="@+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<TextView
android:id="@+id/textView1"
android:paddingLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/quickContactBadge1"
android:text="@string/title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView5"
android:layout_below="@id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/date"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView5"
android:text="@string/user"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<View
android:id="@+id/firstDivider"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#0099CC"
android:padding="10dip" />
<include layout="@layout/header" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:id="@+id/textView_latestPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/firstDivider"
android:text="@string/latest_post"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView4"
android:id="@+id/textView_newPosts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView2"
android:layout_below="@+id/textView_latestPost"
android:text="@string/new_posts"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />

View File

@@ -178,7 +178,7 @@ public class ForumDetailFragment extends PullToRefreshListFragment implements Da
public void run() {
TopicContent.getTopics((String) mItem.content.get("forum_id"), mDb);
setListAdapter(new ThumbnailAdapter(getActivity(), new TopicAdapter(getActivity()), new SimpleWebImageCache<ThumbnailBus, ThumbnailMessage>(null, null,
101, new ThumbnailBus()), new int[] { R.id.quickContactBadge1 }));
101, new ThumbnailBus()), new int[] { R.id.quickContactBadge }));
getPullToRefreshListView().onRefreshComplete();
}
});

View File

@@ -178,7 +178,7 @@ public class TopicDetailFragment extends PullToRefreshListFragment implements Da
public void run() {
ThreadContent.getThread((String) mItem.content.get("topic_id"), mDb);
setListAdapter(new ThumbnailAdapter(getActivity(), new ThreadAdapter(getActivity()), new SimpleWebImageCache<ThumbnailBus, ThumbnailMessage>(null, null,
101, new ThumbnailBus()), new int[] { R.id.quickContactBadge1 }));
101, new ThumbnailBus()), new int[] { R.id.quickContactBadge }));
getPullToRefreshListView().onRefreshComplete();
}
});

View File

@@ -67,7 +67,7 @@ public class TopicListFragment extends ListFragment {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ThumbnailAdapter(getActivity(), new TopicAdapter(getActivity()), new SimpleWebImageCache<ThumbnailBus, ThumbnailMessage>(null, null, 101,
new ThumbnailBus()), new int[] { R.id.quickContactBadge1 }));
new ThumbnailBus()), new int[] { R.id.quickContactBadge }));
}
@Override

View File

@@ -43,6 +43,7 @@ public class ThreadAdapter extends BaseAdapter {
TextView user;
TextView post;
QuickContactBadge badage;
TextView date;
}
private final LayoutInflater mInflater;
@@ -110,10 +111,11 @@ public class ThreadAdapter extends BaseAdapter {
// views
// we want to bind data to.
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.textView1);
holder.user = (TextView) convertView.findViewById(R.id.textView2);
holder.post = (TextView) convertView.findViewById(R.id.textView3);
holder.badage = (QuickContactBadge) convertView.findViewById(R.id.quickContactBadge1);
holder.title = (TextView) convertView.findViewById(R.id.textView_title);
holder.user = (TextView) convertView.findViewById(R.id.textView_user);
holder.post = (TextView) convertView.findViewById(R.id.textView_post);
holder.date = (TextView) convertView.findViewById(R.id.textView_date);
holder.badage = (QuickContactBadge) convertView.findViewById(R.id.quickContactBadge);
convertView.setTag(holder);
} else
@@ -129,6 +131,7 @@ public class ThreadAdapter extends BaseAdapter {
holder.title.setText((String) getItem(position).get("post_title"));
holder.user.setText((String) getItem(position).get("post_author_name"));
holder.post.setText((String) getItem(position).get("post_content"));
holder.date.setText((String) getItem(position).get("post_time"));
holder.badage.setImageResource(R.drawable.ic_launcher);
holder.badage.setTag("http://www.gravatar.com/avatar/9b4f3d34ca3ce31198efac149c3a1ca2?s=300&d=identicon&r=PG");

View File

@@ -111,12 +111,12 @@ public class TopicAdapter extends BaseAdapter {
// views
// we want to bind data to.
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.textView1);
holder.lastestPost = (TextView) convertView.findViewById(R.id.textView2);
holder.user = (TextView) convertView.findViewById(R.id.textView3);
holder.newPosts = (TextView) convertView.findViewById(R.id.textView4);
holder.badage = (QuickContactBadge) convertView.findViewById(R.id.quickContactBadge1);
holder.date = (TextView) convertView.findViewById(R.id.textView5);
holder.title = (TextView) convertView.findViewById(R.id.textView_title);
holder.lastestPost = (TextView) convertView.findViewById(R.id.textView_latestPost);
holder.user = (TextView) convertView.findViewById(R.id.textView_user);
holder.newPosts = (TextView) convertView.findViewById(R.id.textView_newPosts);
holder.badage = (QuickContactBadge) convertView.findViewById(R.id.quickContactBadge);
holder.date = (TextView) convertView.findViewById(R.id.textView_date);
convertView.setTag(holder);
} else