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 --> dates. c.f. Java's SimpleDateFormat -->
<string name="daysVertical">T\na\ng\ne</string> <!-- vertical labels <string name="daysVertical">T\na\ng\ne</string> <!-- vertical labels
are used in the number dialogs --> 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"> <plurals name="Ndays">
<item quantity="one">1 Tag</item> <item quantity="one">1 Tag</item>
<item quantity="other">%d Tage</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.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.DefaultConnectionReuseStrategy; import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.DefaultHttpClientConnection;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHeader;
import org.apache.http.params.BasicHttpParams; import org.apache.http.params.BasicHttpParams;
@ -115,8 +114,6 @@ public class Invoker {
private HttpClient httpClient; private HttpClient httpClient;
private DefaultHttpClientConnection connection;
public Invoker(String serverHostName, int serverPortNumber, String serviceRelativeUri, ApplicationInfo applicationInfo) public Invoker(String serverHostName, int serverPortNumber, String serviceRelativeUri, ApplicationInfo applicationInfo)
throws ServiceInternalException throws ServiceInternalException
{ {
@ -315,18 +312,7 @@ public class Invoker {
// } // }
finally finally
{ {
if (connection != null && (response == null || connectionStrategy.keepAlive(response, context) == false)) httpClient.getConnectionManager().closeExpiredConnections();
{
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);
}
}
} }
lastInvocation = System.currentTimeMillis(); lastInvocation = System.currentTimeMillis();

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

@ -57,7 +57,7 @@ public class RtmTaskNote
Text innerText = (Text) element.getChildNodes().item(i); Text innerText = (Text) element.getChildNodes().item(i);
if (text == null) text = ""; 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 { SIZE {
@Override @Override
int compareTo(TagListSubActivity self, TagModelForView arg0, TagModelForView arg1) { 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() { handler.post(new Runnable() {
public void run() { public void run() {
// set up our adapter synchronized(TagListSubActivity.this) {
final TagListAdapter tagAdapter = new TagListAdapter(getParent(), // set up our adapter
android.R.layout.simple_list_item_1, tagArray, final TagListAdapter tagAdapter = new TagListAdapter(getParent(),
tagToTaskCount); android.R.layout.simple_list_item_1, tagArray,
tagToTaskCount);
// set up ui components // set up ui components
setUpListUI(tagAdapter); setUpListUI(tagAdapter);
}
loadingText.setVisibility(View.GONE); loadingText.setVisibility(View.GONE);
} }
}); });

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

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

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

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

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

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

Loading…
Cancel
Save