[Android] PlaylistActivity: Fix playlist being fully loaded
Geoffrey Métais
git at videolan.org
Fri Jan 18 18:23:50 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 18 18:22:22 2019 +0100| [352623817f93f91ba16089d2248c788082a4c77a] | committer: Geoffrey Métais
PlaylistActivity: Fix playlist being fully loaded
> https://code.videolan.org/videolan/vlc-android/commit/352623817f93f91ba16089d2248c788082a4c77a
---
vlc-android/res/layout/playlist_activity.xml | 33 +++++++-----------
.../src/org/videolan/vlc/gui/PlaylistActivity.java | 40 ++++++++++++----------
2 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/vlc-android/res/layout/playlist_activity.xml b/vlc-android/res/layout/playlist_activity.xml
index 0cde47417..f2fd0d14f 100644
--- a/vlc-android/res/layout/playlist_activity.xml
+++ b/vlc-android/res/layout/playlist_activity.xml
@@ -13,7 +13,8 @@
xmlns:vlc="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator"
android:layout_width="match_parent"
- android:layout_height="match_parent" >
+ android:layout_height="match_parent"
+ android:background="?attr/background_default" >
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
@@ -53,32 +54,24 @@
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
- <androidx.core.widget.NestedScrollView
- android:layout_width="match_parent"
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/songs"
+ android:layout_width="@dimen/default_content_width"
android:layout_height="match_parent"
- vlc:layout_behavior="@string/appbar_scrolling_view_behavior"
- android:keyboardNavigationCluster="true"
- tools:targetApi="o" >
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/songs"
- android:layout_width="@dimen/default_content_width"
- android:layout_height="match_parent"
- android:fastScrollEnabled="true"
- android:layout_gravity="center_horizontal"
- android:paddingTop="16dp"
- android:paddingBottom="@dimen/listview_bottom_padding"
- android:paddingLeft="10dp"
- android:paddingRight="10dp"
- style="@style/Theme.VLC.List"
- android:background="?attr/background_default" />
- </androidx.core.widget.NestedScrollView>
+ android:fastScrollEnabled="true"
+ android:layout_gravity="center_horizontal"
+ android:paddingTop="@dimen/listview_bottom_padding"
+ android:paddingBottom="@dimen/listview_bottom_padding"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ style="@style/Theme.VLC.List"
+ vlc:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
vlc:rippleColor="@color/orange50"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginRight="25dp"
android:layout_marginEnd="25dp"
vlc:layout_anchor="@+id/appbar"
vlc:layout_anchorGravity="bottom|right|end"
diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index 9fc197503..90d00a862 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -24,23 +24,12 @@
package org.videolan.vlc.gui;
import android.annotation.TargetApi;
-import androidx.lifecycle.Observer;
-import androidx.lifecycle.ViewModelProviders;
-import androidx.paging.PagedList;
import android.content.Intent;
-import androidx.databinding.DataBindingUtil;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.Nullable;
-import com.google.android.material.bottomsheet.BottomSheetBehavior;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.core.view.ViewCompat;
-import androidx.appcompat.view.ActionMode;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.Menu;
@@ -48,6 +37,8 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
+
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
@@ -78,6 +69,16 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import androidx.annotation.Nullable;
+import androidx.appcompat.view.ActionMode;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.databinding.DataBindingUtil;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.paging.PagedList;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
public class PlaylistActivity extends AudioPlayerContainerActivity implements IEventsHandler, ActionMode.Callback, View.OnClickListener, CtxActionReceiver {
public final static String TAG = "VLC/PlaylistActivity";
@@ -92,7 +93,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
private PagedTracksModel tracksModel;
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.playlist_activity);
@@ -121,7 +122,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
}
}
});
- final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
+ final boolean fabVisibility = savedInstanceState != null && savedInstanceState.getBoolean(TAG_FAB_VISIBILITY);
if (!TextUtils.isEmpty(mPlaylist.getArtworkMrl())) {
WorkersKt.runIO(new Runnable() {
@@ -134,8 +135,10 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
@Override
public void run() {
mBinding.appbar.setExpanded(true, true);
- if (fabVisibility != -1)
- mBinding.fab.setVisibility(fabVisibility);
+ if (savedInstanceState != null) {
+ if (fabVisibility) mBinding.fab.show();
+ else mBinding.fab.hide();
+ }
}
});
} else WorkersKt.runOnMainThread(new Runnable() {
@@ -152,14 +155,13 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
private void fabFallback() {
mBinding.appbar.setExpanded(false);
- ViewCompat.setNestedScrollingEnabled(mBinding.songs, false);
final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mBinding.fab.getLayoutParams();
lp.setAnchorId(R.id.songs);
- lp.anchorGravity = Gravity.BOTTOM|Gravity.RIGHT|Gravity.END;
+ lp.anchorGravity = Gravity.BOTTOM|Gravity.END;
lp.bottomMargin = getResources().getDimensionPixelSize(R.dimen.default_margin);
lp.setBehavior(new FloatingActionButtonBehavior(PlaylistActivity.this, null));
mBinding.fab.setLayoutParams(lp);
- mBinding.fab.setVisibility(View.VISIBLE);
+ mBinding.fab.show();
}
@Override
@@ -171,7 +173,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());
+ outState.putBoolean(TAG_FAB_VISIBILITY, mBinding.fab.getVisibility() == View.VISIBLE);
super.onSaveInstanceState(outState);
}
More information about the Android
mailing list