[Android] Persist FAB visibility on rotation
Geoffrey Métais
git at videolan.org
Mon Feb 20 17:46:50 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 20 16:39:32 2017 +0100| [3c139f4279d96861b2fc9c804e7fc4d43cb7ccf9] | committer: Geoffrey Métais
Persist FAB visibility on rotation
> https://code.videolan.org/videolan/vlc-android/commit/3c139f4279d96861b2fc9c804e7fc4d43cb7ccf9
---
vlc-android/src/org/videolan/vlc/gui/InfoActivity.java | 6 ++++++
vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java b/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
index b03dcfd..f233da0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
@@ -37,6 +37,7 @@ import java.io.File;
public class InfoActivity extends AudioPlayerContainerActivity implements View.OnClickListener {
public final static String TAG_ITEM = "ML_ITEM";
+ public final static String TAG_FAB_VISIBILITY= "FAB";
private MediaWrapper mItem;
private MediaInfoAdapter mAdapter;
@@ -60,6 +61,8 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
savedInstanceState.getParcelable(TAG_ITEM) :
getIntent().getParcelableExtra(TAG_ITEM));
mBinding.setItem(mItem);
+ final int fabVisibility = savedInstanceState != null
+ ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
mAdapter = new MediaInfoAdapter(this);
mBinding.list.setAdapter(mAdapter);
@@ -76,6 +79,8 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
public void run() {
ViewCompat.setNestedScrollingEnabled(mBinding.container, true);
mBinding.appbar.setExpanded(true, true);
+ if (fabVisibility != -1)
+ mBinding.fab.setVisibility(fabVisibility);
}
});
} else
@@ -102,6 +107,7 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(TAG_ITEM, mItem);
+ outState.putInt(TAG_FAB_VISIBILITY, mBinding.fab.getVisibility());
}
private void noCoverFallback() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index 484c047..5b12a7f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -72,6 +72,7 @@ import java.util.List;
public class PlaylistActivity extends AudioPlayerContainerActivity implements IEventsHandler, ActionMode.Callback, View.OnClickListener {
public final static String TAG = "VLC/PlaylistActivity";
+ public final static String TAG_FAB_VISIBILITY= "FAB";
private AudioBrowserAdapter mAdapter;
private MediaLibraryItem mPlaylist;
@@ -96,6 +97,8 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
mBinding.songs.setLayoutManager(new LinearLayoutManager(this));
mBinding.songs.setAdapter(mAdapter);
+ final int fabVisibility = savedInstanceState != null
+ ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
if (!TextUtils.isEmpty(mPlaylist.getArtworkMrl())) {
VLCApplication.runBackground(new Runnable() {
@@ -108,6 +111,8 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
@Override
public void run() {
mBinding.appbar.setExpanded(true, true);
+ if (fabVisibility != -1)
+ mBinding.fab.setVisibility(fabVisibility);
}
});
} else
@@ -154,6 +159,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable(AudioBrowserFragment.TAG_ITEM, mPlaylist);
+ outState.putInt(TAG_FAB_VISIBILITY, mBinding.fab.getVisibility());
super.onSaveInstanceState(outState);
}
More information about the Android
mailing list