Frederik Hahne avatar Frederik Hahne committed b459875

Fixed issue #73.

Updating issues now works as expected. The first changed parameter was always ignored.

Comments (0)

Files changed (2)

src/com/saibotd/bitbeaker/Helper.java

 	}
 	
 	/**
+	 * Converts a map of key-value pairs into a string of parameters that
+	 * can be used as post/put params for the REST api.
+	 * 
+	 * For example, if the input is a map like
+	 * "[foo : bar, baz : zok]", then the output is "foo=bar&baz=zok".
+	 * 
+	 * Notice the small difference compared to {@link #convertMapToUrlParams(Map)} the missing preceding '?'.
+	 * 
+	 * @see #convertMapToUrlParams(Map)
+	 * @param postParams
+	 * @return
+	 */
+	public static String convertMapToPostParams(Map<String, String> postParams) {
+		if (postParams == null || postParams.isEmpty()) {
+			return "";
+		}
+		
+		StringBuilder result = new StringBuilder();
+		for (Map.Entry<String,String> param : postParams.entrySet()) {
+			result.append(param.getKey()).append("=").append(param.getValue()).append("&");			
+		}
+		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.

src/com/saibotd/bitbeaker/activities/UpdateIssueActivity.java

 
 			JSONObject issueJson = new JSONObject(result);
 
+			// Issue title
+			initialTitle = issueJson.getString("title");
 			titleEditor = (EditText) findViewById(R.id.new_issue_title);
-			titleEditor.setText(issue_title);
+			titleEditor.setText(initialTitle);
 
 			// Issue content.
 			initialContent = issueJson.getString("content");
 			}
 			
 			bitbeaker.delKV(updateURI);
-			executeAsyncLoader(updateURI, Helper.convertMapToUrlParams(postParams), null, "PUT");
+			executeAsyncLoader(updateURI, Helper.convertMapToPostParams(postParams), null, "PUT");
 			return true;
 
 		}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.