-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQLite functionality for the task list (using CursorAdapter)
- Loading branch information
Showing
22 changed files
with
217 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+1.89 KB
...uji/todolist/AddNewTodoItemActivity.class → ...uji/todolist/AddNewTodoTaskActivity.class
Binary file not shown.
Binary file removed
BIN
-1.03 KB
TodoListManager/bin/classes/il/ac/huji/todolist/RetainedFragment.class
Binary file not shown.
Binary file removed
BIN
-2.99 KB
TodoListManager/bin/classes/il/ac/huji/todolist/RowWithDateArrayAdapter.class
Binary file not shown.
Binary file modified
BIN
-633 Bytes
(70%)
TodoListManager/bin/classes/il/ac/huji/todolist/TodoListManagerActivity$1.class
Binary file not shown.
Binary file added
BIN
+2.22 KB
TodoListManager/bin/classes/il/ac/huji/todolist/TodoListManagerActivity$2.class
Binary file not shown.
Binary file modified
BIN
-621 Bytes
(89%)
TodoListManager/bin/classes/il/ac/huji/todolist/TodoListManagerActivity.class
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.78 KB
TodoListManager/bin/classes/il/ac/huji/todolist/TodoTaskCursorAdapter.class
Binary file not shown.
Binary file added
BIN
+4.27 KB
TodoListManager/bin/classes/il/ac/huji/todolist/TodoTaskSQLiteHelper.class
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
TodoListManager/src/il/ac/huji/todolist/RetainedFragment.java
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
TodoListManager/src/il/ac/huji/todolist/RowWithDateArrayAdapter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
TodoListManager/src/il/ac/huji/todolist/TodoTaskCursorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package il.ac.huji.todolist; | ||
|
||
import java.util.Date; | ||
|
||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.graphics.Color; | ||
import android.support.v4.widget.CursorAdapter; | ||
import android.text.format.DateFormat; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
public class TodoTaskCursorAdapter extends CursorAdapter { | ||
private int _layout; | ||
|
||
public TodoTaskCursorAdapter(Context context, Cursor c) { | ||
super(context, c, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); | ||
_layout = R.layout.todo_task; | ||
} | ||
|
||
@Override | ||
public void bindView(View view, Context context, Cursor cursor) { | ||
TextView taskTitle = (TextView)view.findViewById(R.id.txtTodoTitle); | ||
taskTitle.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(1)))); | ||
|
||
TextView taskDueDate = (TextView)view.findViewById(R.id.txtTodoDueDate); | ||
|
||
Long today = System.currentTimeMillis(); | ||
Long taskDue = cursor.getLong(cursor.getColumnIndex(cursor.getColumnName(2))); | ||
|
||
if (taskDue == null) { // should not happen | ||
taskDueDate.setText(context.getResources().getString(R.string.no_due_date)); | ||
} | ||
else { | ||
Date date = new Date(); | ||
date.setTime(taskDue); | ||
String dueDate = DateFormat.getDateFormat(context).format(date); | ||
taskDueDate.setText(dueDate); | ||
} | ||
|
||
if (today - taskDue > 0) { // over due | ||
taskTitle.setTextColor(Color.RED); | ||
taskDueDate.setTextColor(Color.RED); | ||
} | ||
else { | ||
taskTitle.setTextColor(Color.BLACK); | ||
taskDueDate.setTextColor(Color.BLACK); | ||
} | ||
} | ||
|
||
@Override | ||
public View newView(Context context, Cursor cursor, ViewGroup parent) { | ||
// when the view will be created for first time, we inflate the row layout | ||
LayoutInflater inflater = LayoutInflater.from(parent.getContext()); | ||
View view = inflater.inflate(_layout, parent, false); | ||
|
||
return view; | ||
} | ||
|
||
} |
Oops, something went wrong.