Commits

Ville Saalo committed bdda843

Added some Javadoc comments.

Comments (0)

Files changed (6)

src/com/saibotd/bitbeaker/Bitbeaker.java

 public class Bitbeaker extends Application {
 	
 	private SharedPreferences settings;
+	
+	/** A cache of key-value -pairs. */
 	private Map<String,String> kv = new LinkedHashMap<String,String>(); 
+
+	private static final int MAX_CACHE_ITEMS = 100;
 	
 	@Override
 	public void onCreate(){
 	public void setKV(String key, String value){
 		kv.put(key, value);
 		Log.d("KV", kv.toString());
-		while(kv.size() > 100){
+		// Remove the oldest entries from the cache, if there are too
+		// many of them:
+		while(kv.size() > MAX_CACHE_ITEMS){
 			Entry<String,String> entry = kv.entrySet().iterator().next();
 			Log.d("KV DEL", entry.toString());
 			kv.remove(entry.getKey());

src/com/saibotd/bitbeaker/ChangesetActivity.java

 import android.graphics.Color;
 import android.os.Bundle;
 import android.text.method.LinkMovementMethod;
-import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;

src/com/saibotd/bitbeaker/Helper.java

 		return result.substring(0, result.length() - 1);
 	}
 	
+	/**
+	 * Returns the objects in the given JSONArray as a List.
+	 * @param array The JSONArray
+	 * @return A List that contains the objects the given JSONArray contains.
+	 * @throws JSONException
+	 */
 	@SuppressWarnings("unchecked")
 	public static <T> List<T> getJsonArrayAsList(JSONArray array) throws JSONException {
 		List<T> list = new ArrayList<T>();
 		return list;
 	}
 	
+	/**
+	 * Turns a List of objects into a JSONArray.
+	 * @param list A List of objects
+	 * @return A JSONArray that contains the objects that the given list contains
+	 */
 	public static <T> JSONArray getListAsJsonArray(List<T> list) {
 		JSONArray result = new JSONArray();
 		for (int i = 0; i < list.size(); i++) {
 		return result;
 	}
 	
+	/**
+	 * Sorts a JSONArray that consists of JSONObjects. 
+	 * @param array A JSONArray that contains only JSONObjects
+	 * @param parameter The key to the value in the JSONObjects by which to sort
+	 * @param direction Whether to have an ascending (a...z) or descending (z...a) sort
+	 * @return A JSONArray with its contents sorted by the given parameters
+	 */
 	public static JSONArray getSortedJsonObjectArray(JSONArray array, String parameter, Sort direction) {
 		try {
 			List<JSONObject> list = getJsonArrayAsList(array);
 		}
 	}
 	
+	/**
+	 * A class that compares two JSONObjects by the values of the given key.
+	 * To be used with, for example, the 
+	 * {@link java.util.Collections#sort(List, Comparator)} method. 
+	 */
 	private static class JSONObjectComparator implements Comparator<JSONObject> {
 		private final String parameter;
 		private final Sort direction;

src/com/saibotd/bitbeaker/RepositoryActivity.java

         return true;
     }
     
+    private static final int MENU_INDEX_BRANCHES = 0;
+    private static final int MENU_INDEX_ISSUES = 1;
+    private static final int MENU_INDEX_WIKI = 2;
+    
     @Override
     public boolean onPrepareOptionsMenu (Menu menu) {
-    	if (branches.length > 0) menu.getItem(0).setVisible(true);
-        else menu.getItem(0).setVisible(false);
-        if (hasIssues) menu.getItem(1).setVisible(true);
-        else menu.getItem(1).setVisible(false);
-        if (hasWiki) menu.getItem(2).setVisible(true);
-        else menu.getItem(2).setVisible(false);
+    	if (branches.length > 0) menu.getItem(MENU_INDEX_BRANCHES).setVisible(true);
+        else menu.getItem(MENU_INDEX_BRANCHES).setVisible(false);
+        if (hasIssues) menu.getItem(MENU_INDEX_ISSUES).setVisible(true);
+        else menu.getItem(MENU_INDEX_ISSUES).setVisible(false);
+        if (hasWiki) menu.getItem(MENU_INDEX_WIKI).setVisible(true);
+        else menu.getItem(MENU_INDEX_WIKI).setVisible(false);
         return true;
     }
     

src/com/saibotd/bitbeaker/clicklisteners/UserProfileActivityStartingClickListener.java

 import android.view.View;
 import android.view.View.OnClickListener;
 
+/**
+ * This class is an OnClickListener that launches the UserProfileActivity for
+ * the username given in the constructor. This class can thus be used for
+ * making a View clickable by using its 
+ * {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
+ * method, the click leading the user to the profile of the given user. 
+ */
 public class UserProfileActivityStartingClickListener implements OnClickListener {
 
 	private final String username;

src/com/saibotd/bitbeaker/tests/HelperTest.java

 package com.saibotd.bitbeaker.tests;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 		}
 	}
 	
-	public void test_getSortedJsonArray_with_ascending_date() throws Exception {
+	public void test_getSortedJsonObjectArray_with_ascending_date() throws Exception {
 		JSONArray result = Helper.getSortedJsonObjectArray(getTestArray(), "date", Sort.ASCENDING);
 		int i = 0;
 		assertEquals("1917-12-06", result.getJSONObject(i).get("date"));
 		assertEquals("Steve Jobs dies", result.getJSONObject(i++).get("event"));
 	}
 	
-	public void test_getSortedJsonArray_with_descending_text() throws Exception {
+	public void test_getSortedJsonObjectArray_with_descending_text() throws Exception {
 		JSONArray result = Helper.getSortedJsonObjectArray(getTestArray(), "event", Sort.DESCENDING);
 		int i = 0;
 		assertEquals("1991-12-08", result.getJSONObject(i).get("date"));