[Android] Prevent NPE in browsers on device rotation

Romain Vimont rom at rom1v.com
Mon Nov 13 21:00:15 CET 2017



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


More information about the Android mailing list