Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old December 29th, 2012, 05:17 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

Thanks

tjdroid is offline  
Reply With Quote
sponsored links
Old January 3rd, 2013, 09:34 AM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

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.
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
Reply
Tags
androod oop


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:30 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.