Adding nullchecks in strategic locations

pull/14/head
Tim Su 14 years ago
parent fa0177c76d
commit 293fbbb489

@ -96,7 +96,8 @@ abstract public class SubActivity {
}
public void startManagingCursor(Cursor c) {
parent.startManagingCursor(c);
if(c != null)
parent.startManagingCursor(c);
}
public void setTitle(CharSequence title) {

@ -190,6 +190,7 @@ public class SyncDataController extends AbstractController {
/** Closes database resource */
@Override
public void close() {
syncDatabase.close();
if(syncDatabase != null)
syncDatabase.close();
}
}

@ -437,6 +437,8 @@ public class TaskController extends AbstractController {
public TaskModelForEdit fetchTaskForEdit(Activity activity, TaskIdentifier
taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForEdit.FIELD_LIST);
if(cursor == null)
return null;
activity.startManagingCursor(cursor);
TaskModelForEdit model = new TaskModelForEdit(taskId, cursor);
return model;
@ -445,6 +447,8 @@ public class TaskController extends AbstractController {
/** Returns a TaskModelForList corresponding to the given TaskIdentifier */
public TaskModelForList fetchTaskForList(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForList.FIELD_LIST);
if(cursor == null)
return null;
TaskModelForList model = new TaskModelForList(cursor);
cursor.close();
return model;
@ -453,6 +457,8 @@ public class TaskController extends AbstractController {
/** Returns a TaskModelForXml corresponding to the given TaskIdentifier */
public TaskModelForXml fetchTaskForXml(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForXml.FIELD_LIST);
if(cursor == null)
return null;
TaskModelForXml model = new TaskModelForXml(cursor);
cursor.close();
return model;

Loading…
Cancel
Save