Apps tjdroid UserPhone Rank: Andryo Posts: 1 Join date: Dec 30, 2012 I need some Android OOP advice


I'm developing an app for my college capstone project. It's an app for building contractors that has three basic functions. It allows them to create a project (project object), create a visit for the project where they can enter notes about the visit (visit object) and take pictures during the visit (picture object). At the conclusion of the visit they can then send an email with the notes and pictures to their boss, client, etc. My design consisted of those three objects: Project, Visit, and Picture.

I originally designed this last March and then another class, Java 6 which required I pass the Java certification test, kicked in. I finally passed the certification and am working on completing the project. Right now I have the following objects:
DbAdapter - parent class for handling the tables
ProjectDbAdapter - child class for handling the Project table
ProjectListActivity - class for displaying the Projects and providing editing and selection of a project
ProjectEditActivity - class for editing the Project fields
ProjectShowActivity - class the displays a project's information and allows options for editing the project and creating a visit

I'm having a problem in that if I click on a project in the ProjectListActivity screen, to open the project in the ProjectShowActivity screen I don't have the information, rowId value, to pass to the ProjectShowActivity to query the database to display the project record.

Based on my design, I should have a Project object that I can pass but I haven't implemented that yet and I don't know if I need to.

So, I'm looking for opinions and advice. Do I need to have a Project object or should the ProjectListActivity serve the same purpose and by the same token, do I need a Picture and Visit object or will the corresponding activities serve the same purpose.



Android Expert
If it were me, I would have a database that would store the information regarding each project. Then, I would have a data access object that would interface with the database, allowing you to grab a particular project handle and create a Project object from its information. In your ProjectListActivity (which I am assuming is a subclass of ListActivity or just a regular Activity with a ListView object), you need to create an ListAdapater for the listview and pass in a list of projects that is obtained from the data access object. You would also need to override the getView method of the ListAdapter which would populate each list item depending on the project referenced by the index parameter.

Each project should be stored in the database with a unique id (which will probably be the primary key of the table), which would be accessible from the Project object that is generated from that table row.

when a user clicks on a particular item in the ListView, the bundle of the Intent that is created to start the next activity would be given the id of the Project that is referenced by the clicked listview item. Then, in the onCreate method of the new Activity, you would use the data access object to query the Project object with the given id.