Fixed two NPE's, also eek what happened to repeats.

pull/14/head
Tim Su 17 years ago
parent c0cbd60444
commit a6ce373866

@ -30,6 +30,7 @@ import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.Log;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@ -151,16 +152,20 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
/** Toggle the expanded state of this task */
public void toggleExpanded(View view, TaskModelForList task) {
if(CACHE_TRUE.equals(task.getCachedLabel(KEY_EXPANDED))) {
task.putCachedLabel(KEY_EXPANDED, null);
hooks.setSelectedItem(null);
} else {
task.putCachedLabel(KEY_EXPANDED, CACHE_TRUE);
hooks.setSelectedItem(task.getTaskIdentifier());
}
try {
if(CACHE_TRUE.equals(task.getCachedLabel(KEY_EXPANDED))) {
task.putCachedLabel(KEY_EXPANDED, null);
hooks.setSelectedItem(null);
} else {
task.putCachedLabel(KEY_EXPANDED, CACHE_TRUE);
hooks.setSelectedItem(task.getTaskIdentifier());
}
setFieldContentsAndVisibility(view, task);
((ListView)view.getParent()).setSelection(objects.indexOf(task));
setFieldContentsAndVisibility(view, task);
((ListView)view.getParent()).setSelection(objects.indexOf(task));
} catch (Exception e) {
Log.e("astrid", "Error in toggleExpanded", e);
}
}
// ----------------------------------------------------------------------
@ -514,7 +519,7 @@ public class TaskListAdapter extends ArrayAdapter<TaskModelForList> {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
View parent = (View)buttonView.getParent();
View parent = (View)buttonView.getParent().getParent();
TaskModelForList task = (TaskModelForList)parent.getTag();
int newProgressPercentage;

@ -34,6 +34,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import com.timsu.astrid.data.AbstractController;
import com.timsu.astrid.data.sync.SyncDataController;
import com.timsu.astrid.data.task.AbstractTaskModel.RepeatInfo;
import com.timsu.astrid.data.task.AbstractTaskModel.TaskModelDatabaseHelper;
import com.timsu.astrid.utilities.Notifications;
@ -239,7 +240,7 @@ public class TaskController extends AbstractController {
/**
* Called when the task is saved. Perform some processing on the task.
*
*
* @param task
* @param values
*/
@ -250,21 +251,21 @@ public class TaskController extends AbstractController {
== AbstractTaskModel.COMPLETE_PERCENTAGE) {
onTaskSetCompleted(task, values);
}
// task timer was updated
if(values.containsKey(AbstractTaskModel.TIMER_START)) {
// show notification bar if timer was started
if(values.get(AbstractTaskModel.TIMER_START) != null) {
Notifications.showTimingNotification(context,
Notifications.showTimingNotification(context,
task.getTaskIdentifier(), task.getName());
} else {
Notifications.clearAllNotifications(context, task.getTaskIdentifier());
}
}
}
/**
/**
* Called when this task is set to completed.
*
* @param task task to process
@ -273,7 +274,14 @@ public class TaskController extends AbstractController {
private void onTaskSetCompleted(AbstractTaskModel task, ContentValues values) {
values.put(AbstractTaskModel.COMPLETION_DATE, System.currentTimeMillis());
// handle repeat
Cursor cursor = fetchTaskCursor(task.getTaskIdentifier(),
TaskModelForRepeat.FIELD_LIST);
TaskModelForRepeat repeatModel = new TaskModelForRepeat(cursor, values);
RepeatInfo repeatInfo = repeatModel.getRepeat();
if(repeatInfo != null)
repeatModel.repeatTaskBy(context, this, repeatInfo);
cursor.close();
}
/** Set last notification date */

Loading…
Cancel
Save