[Android] Prevent NPE in browsers on device rotation

Geoffrey Métais geoffrey at videolan.org
Tue Nov 14 09:14:47 CET 2017


The general idea was to offload onCreate(…) in order to have the
activities/fragments loaded faster.
I did not suspect onSaveInstanceState() could be called before
onActivityCreated(…)…

Le lun. 13 nov. 2017 à 21:00, Romain Vimont <rom at rom1v.com> a écrit :

>
>
> Le lundi 13 novembre 2017 à 18:45 +0100, Geoffrey Métais a écrit :
> > vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com>
> | Mon Nov 13 18:40:44 2017 +0100|
> [758c200e10ddac5cbad406d4107b431efcdaa2e6] | committer: Geoffrey Métais
> >
> > Prevent NPE in browsers on device rotation
> >
> > (cherry picked from commit 45c45adbd5b2b8972fdc28a450333285fa878190)
> >
> > >
> https://code.videolan.org/videolan/vlc-android/commit/758c200e10ddac5cbad406d4107b431efcdaa2e6
> > ---
> >
> >  vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java |
> 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git
> a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
> b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
> > index 2a1695b12..5aee19028 100644
> > ---
> a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
> > +++
> b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
> > @@ -245,7 +245,8 @@ public abstract class BaseBrowserFragment extends
> SortableFragment<BaseBrowserAd
> >      public void onSaveInstanceState(Bundle outState){
> >          outState.putString(KEY_MRL, mMrl);
> >          outState.putParcelable(KEY_MEDIA, mCurrentMedia);
> > -        VLCApplication.storeData(KEY_MEDIA_LIST+mMrl,
> mAdapter.getAll());
> > +        if (mAdapter != null)
>
> Why not just initializing mAdapter in onCreate(…)?
>
> > +            VLCApplication.storeData(KEY_MEDIA_LIST+mMrl,
> mAdapter.getAll());
> >          VLCApplication.storeData(KEY_CONTENT_LIST+mMrl,
> mFoldersContentLists);
> >          if (mRecyclerView != null)
> >              outState.putInt(KEY_POSITION,
> mLayoutManager.findFirstCompletelyVisibleItemPosition());
> >
> > _______________________________________________
> > Android mailing list
> > Android at videolan.org
> > https://mailman.videolan.org/listinfo/android
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20171114/c13ee905/attachment-0001.html>


More information about the Android mailing list