Commit 3c139f42 authored by Geoffrey Métais's avatar Geoffrey Métais

Persist FAB visibility on rotation

parent 87f817e3
......@@ -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() {
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment