0% found this document useful (0 votes)
19 views13 pages

Log Book 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views13 pages

Log Book 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

COMP1786 Logbook Upload Template

Table of Contents
1. Basic Information..........................................................................................................................1
2. Exercise answer.............................................................................................................................1
2.1 Screen shots demonstrating what you achieved..................................................................1
2.2 Code that you wrote.............................................................................................................4

Figure 1: Main View...............................................................................................................................2


Figure 2: Delete Funciton.......................................................................................................................3
Figure 3: Edit Function...........................................................................................................................4
Figure 4: Main Activity Class (1).............................................................................................................5
Figure 5: Main Activity class (2).............................................................................................................6
Figure 6: Main Activity class (3).............................................................................................................7
Figure 7: Task Database Helper..............................................................................................................8
Figure 8: Task Manager (1).....................................................................................................................9
Figure 9: Task Manager (2).....................................................................................................................9
Figure 10: Task Manager (3)...................................................................................................................9
Figure 11: TaskDialogManager (1).......................................................................................................10
Figure 12: Task Dialog Manager (2)......................................................................................................11
Figure 13: xml Activity Main................................................................................................................12
Figure 14: xml task_item......................................................................................................................13

1. Basic Information
1.1 Student name NGUYEN HAI VIET

1.2 Who did you work with? Note that for Just work alone
logbook exercises you are allowed to work with
one other person as long as you give their
name and login id and both contribute to the
work.

1.3 Which Exercise is this? Tick as  Exercise 1


appropriate.
 Exercise 2

 Exercise 3

1.4 How well did you complete the  I tried but couldn't complete it
exercise? Tick as appropriate.
 I did it but I feel I should have done
better

 I did everything that was asked

 I did more than was asked for


1.5 Briefly explain your answer to question 1.4 I have completed all the tasks in logbook 3. In
my application, the features like adding,
Without any explanation/justification, your
editing, and deleting tasks. I use Sqlite to be
scores will be deducted.
able to save tasks so that I can edit and delete
tasks in the Sqlite as well as show the tasks in
the Sqlite as a list view.

2. Exercise answer
2.1 Screen shots demonstrating what you achieved
Paste screen shots in here. Add explanation of what each screen shot demonstrates

Figure 1: Main View

This is the main screen of ListActivityMain. This page will display the tasks in the list using list
view as the name next to it will have 2 buttons in the form of images: edit and button. This page also
has a field for users to enter and a button to add to the list.
Figure 2: Delete Funciton

This is the screen when clicking on the trash can image, a dialog will be displayed to confirm
whether the user wants to delete or not.
Figure 3: Edit Function

This is the screen when clicking on the pen image, a dialog will appear. In this dialog, the
name of the task will be displayed and then if the user changes the field and clicks confirm, the new
name for the task will be saved.

2.2 Code that you wrote


Copy and paste relevant code here. Actual code please, not screen shots.

You need to add brief explanation.

a. Main activity
Figure 4: Main Activity Class (1)

In this image there is the onCreate function. This function is called when the xml of this class is
called. This function sets up the interface and user interaction events with the tasks. It will initialize
the arraylist to store the lists, create an ArrayAdapter<Task> to display the list of tasks in the ListView.
Then comes the getView, this function is used to call the ArrayAdapter to be able to reuse the display
views for each task in the list. It will get the tasks in the list and then get the position of each task to
display in order.
Figure 5: Main Activity class (2)

In this image there will be 2 buttons edit and delete. When clicking on these 2 buttons, it will call
2 functions in the TaskDialogManager class. There is also an add button and when the text field is not
empty, it will add to the list, making the text field empty and displaying a message.
Figure 6: Main Activity class (3)

There is also an add button in here and when the text field is not empty, it will be added to
the list, making the text field empty and displaying a notification. Besides, there is also a loadtask
function to ensure that when tasks are updated, a notification will be displayed as well as the
listview will be reloaded.

b. TaskDatabaseHelper
Figure 7: Task Database Helper

This is a class used to manage the creation and upgrade of SQLite databases for the
application by inheriting SQLiteOpenHelper. This class helps the communication between the
application and Sqlite become more logical. Starting with the initialization function here will
receive the name of the database and the version of that database. Then continue with the
onCreate function, this function will be called when the database is created for the first time, it
will create a table with 2 columns id and name. Then comes the upgrade function to be able to
upgrade the database if there is a change in the tables in it.

c. TaskManager
Figure 8: Task Manager (1)

Figure 9: Task Manager (2)

Figure 10: Task Manager (3)

The TaskManager class in the code above is a class that manages operations with the SQLite
database for the to-do list application. This class uses TaskDatabaseHelper to connect to the
database and provides functions such as: loading the task list from the tasks table (loadTasks),
adding a new task (addTask), updating the task name (updateTask), deleting a task by ID
(deleteTask), and getting the ID of a task based on the name (getTaskId). In addition, the class
also provides functions to check the completion status of a task (isTaskCompleted) and toggle the
completion status (toggleTaskCompletion). All operations are performed through SQLite
communication methods, making task data management easy and efficient.

d. TaskDialogManager

This is the class used to set up dialogs so that when used, the sepup dialog will appear.

Figure 11: TaskDialogManager (1)

This is the editDialog function. In this code, there will be a title as well as receiving 2 values: the
location and name of the task. This dialog can also be a button. When clicking on the button, the
onClick function will be called, this function will get the text field and then call the updateTask
function in the MainActivity class to update the new text for the task.
Figure 12: Task Dialog Manager (2)

This is the DeleteDialog function. In this code, there will also be a title and a button, and this
function only needs to get the position of the task and call the delete function in ListTaskActivity to
delete it. Besides, there will also be an interface to get the functions from there to use.

e. Acitivity_Main
Figure 13: xml Activity Main

This is the xml of MainActivity. In here there will be a button to add class, there will be a field
to enter the class name as well as a list view to show the tasks.

f. Task_item
Figure 14: xml task_item

This is the xml of each item, there will be 1 checkbox, textview shows the name of the task,
there will be 2 buttons in the form of images: edit and delete.

You might also like