Fixed some findbugs issues, and a bug with tags and lists when synchronizing.

pull/14/head
Tim Su 17 years ago
parent 96e5f46ef9
commit 191846caf8

@ -55,7 +55,7 @@
dates. c.f. Java's SimpleDateFormat -->
<string name="daysVertical">T\na\ng\ne</string> <!-- vertical labels
are used in the number dialogs -->
<string name="hoursVertical">S\nt\nu\nn\nd\ne\nn</string>
<string name="hoursVertical">U\nh\nr</string>
<plurals name="Ndays">
<item quantity="one">1 Tag</item>
<item quantity="other">%d Tage</item>

@ -39,7 +39,6 @@ import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpClientConnection;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.BasicHttpParams;
@ -115,8 +114,6 @@ public class Invoker {
private HttpClient httpClient;
private DefaultHttpClientConnection connection;
public Invoker(String serverHostName, int serverPortNumber, String serviceRelativeUri, ApplicationInfo applicationInfo)
throws ServiceInternalException
{
@ -315,18 +312,7 @@ public class Invoker {
// }
finally
{
if (connection != null && (response == null || connectionStrategy.keepAlive(response, context) == false))
{
try
{
connection.close();
}
catch (IOException exception)
{
Log.w(TAG, new StringBuffer("Could not close properly the socket connection to '").append(connection.getRemoteAddress()).append("' on port ").append(
connection.getRemotePort()).toString(), exception);
}
}
httpClient.getConnectionManager().closeExpiredConnections();
}
lastInvocation = System.currentTimeMillis();

@ -99,7 +99,7 @@ public abstract class RtmData
return result.toString();
}
public static Date parseDate(String s)
public synchronized static Date parseDate(String s)
{
try
{
@ -112,7 +112,7 @@ public abstract class RtmData
}
}
public static String formatDate(Date d)
public synchronized static String formatDate(Date d)
{
return DATE_FORMAT.format(new Date(d.getTime() - TimeZone.getDefault().getOffset(d.getTime()))) + "Z";
}

@ -26,7 +26,7 @@ import org.w3c.dom.Text;
/**
* Represents a single task note.
*
*
* @author Edouard Mercier
* @since 2008.04.22
*/
@ -50,14 +50,14 @@ public class RtmTaskNote
created = parseDate(element.getAttribute("created"));
modified = parseDate(element.getAttribute("modified"));
title = element.getAttribute("title");
// The note text itself might be split across multiple children of the
// note element, so get all of the children.
for (int i=0; i<element.getChildNodes().getLength(); i++) {
Text innerText = (Text) element.getChildNodes().item(i);
if (text == null) text = "";
text = text.concat(innerText.getData().toString());
text = text.concat(innerText.getData());
}
}

@ -117,7 +117,9 @@ public class TagListSubActivity extends SubActivity {
SIZE {
@Override
int compareTo(TagListSubActivity self, TagModelForView arg0, TagModelForView arg1) {
return self.tagToTaskCount.get(arg1) - self.tagToTaskCount.get(arg0);
synchronized(self) {
return self.tagToTaskCount.get(arg1) - self.tagToTaskCount.get(arg0);
}
}
};
@ -169,13 +171,14 @@ public class TagListSubActivity extends SubActivity {
handler.post(new Runnable() {
public void run() {
// set up our adapter
final TagListAdapter tagAdapter = new TagListAdapter(getParent(),
android.R.layout.simple_list_item_1, tagArray,
tagToTaskCount);
// set up ui components
setUpListUI(tagAdapter);
synchronized(TagListSubActivity.this) {
// set up our adapter
final TagListAdapter tagAdapter = new TagListAdapter(getParent(),
android.R.layout.simple_list_item_1, tagArray,
tagToTaskCount);
// set up ui components
setUpListUI(tagAdapter);
}
loadingText.setVisibility(View.GONE);
}
});

@ -296,7 +296,7 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
nameValue = "(" + r.getString(R.string.taskList_hiddenPrefix) + ") " + nameValue;
task.putCachedLabel(KEY_HIDDEN, CACHE_TRUE);
}
cachedResult = nameValue.toString();
cachedResult = nameValue;
task.putCachedLabel(KEY_NAME, cachedResult);
}
name.setText(cachedResult);

@ -137,7 +137,7 @@ public class TaskListSubActivity extends SubActivity {
static boolean syncPreferencesOpened = false;
// other instance variables
class TaskListContext {
static class TaskListContext {
Map<TagIdentifier, TagModelForView> tagMap;
ArrayList<TaskModelForList> taskArray;
HashMap<Long, TaskModelForList> tasksById;

@ -133,7 +133,7 @@ public abstract class AbstractModel {
setValues.put(field, newValue);
}
protected static HashMap<Class<?>, HashMap<String, Integer>>
protected static final HashMap<Class<?>, HashMap<String, Integer>>
columnIndexCache = new HashMap<Class<?>, HashMap<String, Integer>>();
private int getColumnIndex(String field) {
HashMap<String, Integer> classCache;

@ -153,7 +153,7 @@ public class TagController extends AbstractController {
AbstractTagModel.NAME + " = ?", new String[] {name}, null, null, null, null);
try {
if (cursor != null) {
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
TagModelForView model = new TagModelForView(cursor);
return model;

@ -246,8 +246,8 @@ public class RTMSyncProvider extends SynchronizationProvider {
postUpdate(new Runnable() {
public void run() {
DialogUtilities.okDialog(context,
"Sorry, list '" + entry.getValue() +
"' import failed. Try again later!", null);
"Sorry, import of list '" + entry.getValue() +
"' failed. Try again later!", null);
}
});
continue;
@ -263,6 +263,7 @@ public class RTMSyncProvider extends SynchronizationProvider {
Preferences.setSyncRTMLastSync(context, syncTime);
} catch (Exception e) {
Log.e("rtmsync", "Error in synchronization", e);
showError(context, e, null);
} finally {
@ -324,7 +325,7 @@ public class RTMSyncProvider extends SynchronizationProvider {
if(dueDate != remoteTask.dueDate && dueDate != null &&
!dueDate.equals(remoteTask.dueDate))
rtmService.tasks_setDueDate(timeline, id.listId, id.taskSeriesId,
id.taskId, dueDate, dueDate != null);
id.taskId, dueDate, true);
// progress
if(task.progressPercentage != null && !task.progressPercentage.equals(

@ -259,7 +259,7 @@ public abstract class SynchronizationProvider {
// remove it from data structures
data.localChanges.remove(mapping);
data.localIdToSyncMapping.remove(taskId);
data.remoteIdToSyncMapping.remove(mapping);
data.remoteIdToSyncMapping.remove(mapping.getRemoteId());
data.remoteChangeMap.remove(taskId);
// update stats

Loading…
Cancel
Save