Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Relating Users in Parse.com Adding Checkmarks When the List is Loaded

Vrezh Gulyan
Vrezh Gulyan
11,161 Points

What is the most efficient way to check mark the friends?

I plan on using similar code to this in an app I am currently making thanks to this website! From taking multiple computer science classes I immediately saw the red flag in the idea of looping through every single potential list item and doing a relationship check and then checking each item. I plan on having a popular app and should write my code accordingly otherwise whats the point really?

One idea I had is that this could be done whenever the user initially choses to add a friend.

Click to add a friend ->> Set list item as click ->> save in background ->> (Eventually) Update Friends list

I haven't tried it yet but just logically it seems like it would work just fine.. I would love your input on this Ben.. or anyone who has written an app that uses a list view and had to deal with a similar problem.

1 Answer

Dhruv Gupta
Dhruv Gupta
4,320 Points

I'm no expert but that sounds fine, but I don't think this would be ideal in a popular app.

You wouldn't just put everyone on the list for you to edit friends.

You could make suggestions based on some algorithm, but putting everyone randomly sounds like a bad idea.

I would only utilize a search field in finding friends, which would then send that individual a request. If that individuals accepts, then he/she/zhe shows up in your edit friends.

The editfriends list would then only consist of your current friends, and a search field. You could quite easily make a list of your current friends, but simply getting all the users from your ParseRelation.

Vrezh Gulyan
Vrezh Gulyan
11,161 Points

I assumed the approval process for friends was a given but I should have mentioned it. I was more asking about if it would be better to do it right away rather then iterate through and entire list of friends later.

Good idea on your end though a search field would solve the problem also. You could also display a list of "People you may know" based on your friends mutual connections.