Commits

Juha Kuitunen  committed aa1d9c4

improved layout of single issue

  • Participants
  • Parent commits d16ad77

Comments (0)

Files changed (3)

File res/layout/issue.xml

         <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_layout" android:orientation="vertical">
             <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_title" android:textSize="18dip" android:text="@string/nothing"></TextView>
             <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_status" android:text="@string/nothing" android:paddingTop="4dip"></TextView>
-            <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_content" android:text="@string/nothing" android:textSize="18dip" android:paddingTop="4dip"></TextView>
-            <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_comments_count" android:text="@string/nothing" android:paddingTop="4dip"></TextView>
         </LinearLayout>
     </ScrollView>
     <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/issue_comments_list" android:layout_margin="4dip"></ListView>

File res/layout/listitem_issue_header.xml

+<?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" >
+
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/issue_content"
+        android:textSize="18dip" >
+    </TextView>
+
+    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/issue_comments_count"
+        android:paddingTop="4dip"
+        android:textStyle="bold" >
+    </TextView>
+
+</LinearLayout>

File src/com/saibotd/bitbeaker/IssueActivity.java

 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.ViewGroup;
+import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.TextView;
 
 	private String owner;
 	private String title;
 	private int id;
+	private ListView listView;//issue's content and comments
 
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		owner = b.getString("owner");
 		title = b.getString("title");
 		id = b.getInt("id");
+		listView = (ListView) findViewById(R.id.issue_comments_list);
 		((TextView) findViewById(R.id.issue_title)).setText(title);
+
 		progressDialog = ProgressDialog.show(this, "", "Loading ...", true);
 		AsyncLoader asyncLoader = new AsyncLoader();
 		asyncLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id);
 		super.AsyncLoaderDone(result);
 		JSONObject jsonObject;
 		TextView info = (TextView) findViewById(R.id.issue_status);
-		TextView content = (TextView) findViewById(R.id.issue_content);
-		TextView comments_count = (TextView) findViewById(R.id.issue_comments_count);
-		comments_count.setOnClickListener(loadCommentsListener);
 		try {
 			jsonObject = new JSONObject(result);
 
 			infotext = infotext + "\nPriority:\t" + jsonObject.getString("priority");
 			info.setText(infotext);
 
-			content.setText(jsonObject.getString("content"));
-			comments_count.setText("Comments: " + jsonObject.getString("comment_count") + " (click to open)");
+			LinearLayout header = (LinearLayout) getLayoutInflater().inflate(R.layout.listitem_issue_header, null);
+			TextView issue_content = (TextView) header.findViewById(R.id.issue_content);
+			TextView comments_count = (TextView) header.findViewById(R.id.issue_comments_count);
+			issue_content.setText(jsonObject.getString("content"));
+			comments_count.setText("Comments: " + jsonObject.getString("comment_count"));
+			listView.addHeaderView(header);
 			Log.d("TEST", jsonObject.toString());
 		} catch (JSONException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
+
+		progressDialog = ProgressDialog.show(IssueActivity.this, "", "Loading comments...", true);
+		AsyncCommentsLoader asyncCommentsLoader = new AsyncCommentsLoader();
+		asyncCommentsLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id + "/comments/");
 	}
 
-	private OnClickListener loadCommentsListener = new OnClickListener() {
-		public void onClick(View v) {
-			progressDialog = ProgressDialog.show(IssueActivity.this, "", "Loading comments...", true);
-			AsyncCommentsLoader asyncCommentsLoader = new AsyncCommentsLoader();
-			asyncCommentsLoader.execute("https://api.bitbucket.org/1.0/repositories/"+ owner +"/"+ slug +"/issues/" + id + "/comments/");
-		}
-	};
-
 	protected class AsyncCommentsLoader extends AsyncLoader {
 		@Override
 		protected void onPostExecute(String result) {
 	protected void AsyncCommentsLoaderDone(String result) {
 		super.AsyncLoaderDone(result);
 
-		ListView listView = (ListView) findViewById(R.id.issue_comments_list);
 		JSONArray jsonArray;
 		try {
 			jsonArray = new JSONArray(result);