Thursday, July 4, 2013

[android-developers] Re: Scenario where initLoader() does not call onLoadFinished()

Etienne, your solution is "nearly" correct. This is the working solution

public static <T> void initLoader(final int loaderId, final Bundle args, final LoaderCallbacks<T> callbacks,          final LoaderManager loaderManager) {      final Loader<T> loader = loaderManager.getLoader(loaderId);      if (loader != null && loader.isReset()) {          loaderManager.restartLoader(loaderId, args, callbacks);      } else {          loaderManager.initLoader(loaderId, args, callbacks);      }  }

On Friday, July 27, 2012 12:00:17 AM UTC+2, Etienne wrote:
Actually it should be:

Loader loader = getLoaderManager().getLoader(-1);
   
if (loader != null && !loader.isReset()) {
      getLoaderManager
().restartLoader(-1, null, this);
   
} else {
      getLoaderManager
().initLoader(-1, null, this);
   
}

You should only restart the loader if the loader is NOT reset.  So the second condition in the if condition changes to the negated version.  I got this to work for me.


On Thursday, January 12, 2012 10:47:58 PM UTC-8, David Wu wrote:
Hi there,

I ran into a very similar problem and solved it by replacing the
following line in onActivityCreate()

    getLoaderManager().initLoader(0, getArguments(), this);

to

    Loader loader = getLoaderManager().getLoader(0);
    if ( loader != null && loader.isReset() ) {
        getLoaderManager().restartLoader(0, getArguments(), this);
    } else {
        getLoaderManager().initLoader(0, getArguments(), this);
    }


Not sure if it addresses your problem.  I hope it helps.


On Dec 13 2011, 3:29 pm, kaciula <catalin.moro...@gmail.com> wrote:
> As I said, the initial bugs were fixed by revision 4 of ACL. However, there
> is still a bug present in both the ACL and Android. I've tested it with
> Android version 3.2 and 4.0. Check out the updated project athttps://github.com/kaciula/BugRetain
>
> I think this is a pretty important bug. The scenario is this: From activity
> A, go to activity B, switch once the orientation and go back to activity A.
> As a consequence of this bug, I can't write an app with fragments that use
> setRetainInstance and is available in both orientations. I really need a
> workaround until the Android guys fix the issue. Thoughts?

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate