1. German Larrain
  2. bitbeaker

Commits

Juha Kuitunen  committed f65e4a2

rough version of showing issue comments

  • Participants
  • Parent commits 23590bc
  • Branches default

Comments (0)

Files changed (1)

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

View file
  • Ignore whitespace
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 public class IssueActivity extends MyActivity {
 	public void AsyncLoaderDone(String result) {
 		super.AsyncLoaderDone(result);
 		JSONObject jsonObject;
-		TextView status = (TextView) findViewById(R.id.issue_status);
+		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);
-			status.setText("Status: " + jsonObject.getString("status"));
+
+			String infotext = "Status:\t" + jsonObject.getString("status");
+			infotext = infotext + "\nType:\t\t" + jsonObject.getJSONObject("metadata").getString("kind");
+			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)");
 			Log.d("TEST", jsonObject.toString());
 		try {
 			jsonArray = new JSONArray(result);
 			Log.d("ISSUE_COMMENTS", jsonArray.toString());
+
+			LinearLayout issue_layout = (LinearLayout) findViewById(R.id.issue_layout);
+			for (int i = 0; i < jsonArray.length(); i++) {
+
+				// TODO: Use something smarter for creating layout. :)
+
+				TextView tv = new TextView(this);
+				JSONObject row = jsonArray.getJSONObject(i);
+				String content = row.getString("content")=="null" ? "Updated content. Further info not available via API" : row.getString("content");
+				tv.setPadding(0, 15, 0, 0);
+				tv.setText(
+						"Author:\t" + row.getJSONObject("author_info").getString("username") + "\n" +
+						"Posted (UTC):\t" + row.getString("utc_created_on") + "\n" +
+						"\n" +
+						content
+				);
+				issue_layout.addView(tv);
+			}
+
 		} catch (JSONException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();