BoD / android-contentprovider-generator

A tool to generate Android ContentProviders.
GNU General Public License v3.0
619 stars 151 forks source link

Add setCursor to AbstractCursor to prevent extra initialization of model Cursors #82

Closed R4md4c closed 9 years ago

R4md4c commented 9 years ago

Hello,

I have a code that does something like this

cursor.moveToFirst();
do {
      UserCursor userCursor = new UserCursor(cursor);
      if (userCursor.getIsRegistered() != null && !userCursor.getIsRegistered()) {
               // do Something
       }
} while (cursor.moveToNext());

Instead of creating a new UserCursor each time, why don't we add a setCursor method and reuse the object instead of creating new one, I think that would save memory, right ?

sgueniot commented 9 years ago

Hello, Do move to next on userCursor object instead of data.

Le mar. 7 avr. 2015 12:43, Ahmed I. Khalil notifications@github.com a écrit :

Hello,

I have a code something like this

data.moveToFirst(); do { UserCursor userCursor = new UserCursor(data); if (userCursor.getIsRegistered() != null && !userCursor.getIsRegistered()) { // do Something } } while (data.moveToNext());

Instead of creating a new UserCursor each time, why don't we use setCursor and reuse the object instead of creating new one, I think that would be saving memory, right ?

— Reply to this email directly or view it on GitHub https://github.com/BoD/android-contentprovider-generator/issues/82.

R4md4c commented 9 years ago

Hi sgueniot,

Thanks for pointing this out, you are right. It will work this way.

I'll close this issue.