Skip to content
Snippets Groups Projects
Commit 100a3b55 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Add empty views to Folders and Video groups

(cherry picked from commit dc32f80d)
parent d8616f57
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/folders_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadingEdge="none"
android:fastScrollEnabled="true"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="empty"
type="boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/folders_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadingEdge="none"
android:fastScrollEnabled="true"
android:gravity="center"
android:numColumns="auto_fit"
android:padding="@dimen/half_default_margin"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:stretchMode="none" />
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<TextView
android:id="@+id/textview_nomedia"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_empty"
android:drawablePadding="@dimen/default_margin"
android:gravity="center"
android:numColumns="auto_fit"
android:padding="@dimen/half_default_margin"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:stretchMode="none" />
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<TextView
android:id="@+id/textview_nomedia"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_empty"
android:drawablePadding="@dimen/default_margin"
android:gravity="center"
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<Button
android:id="@+id/button_nomedia"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_medialibrary_preferences"
android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textview_nomedia" />
<TextView
android:id="@+id/loading_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/loading"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/loading_flipper"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_nomedia" />
<ViewFlipper
android:id="@+id/loading_flipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:autoStart="true"
android:flipInterval="1000"
app:layout_constraintBaseline_toBaselineOf="@+id/loading_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/loading_title">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/empty"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_1_period"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_2_period"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_3_period"
android:textSize="20sp" />
</ViewFlipper>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/groups_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadingEdge="none"
android:fastScrollEnabled="true"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="empty"
type="boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchButton">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/groups_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadingEdge="none"
android:fastScrollEnabled="true"
android:gravity="center"
android:numColumns="auto_fit"
android:padding="@dimen/half_default_margin"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:stretchMode="none" />
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<TextView
android:id="@+id/textview_nomedia"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_empty"
android:drawablePadding="@dimen/default_margin"
android:gravity="center"
android:numColumns="auto_fit"
android:padding="@dimen/half_default_margin"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"
android:stretchMode="none" />
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<TextView
android:id="@+id/textview_nomedia"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
android:drawableBottom="@drawable/ic_empty"
android:drawablePadding="@dimen/default_margin"
android:gravity="center"
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
android:maxWidth="600dp"
android:text="@string/nomedia"
android:textSize="20sp"
android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<Button
android:id="@+id/button_nomedia"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_medialibrary_preferences"
android:visibility="@{empty ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textview_nomedia" />
<TextView
android:id="@+id/loading_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/loading"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/loading_flipper"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_nomedia" />
<ViewFlipper
android:id="@+id/loading_flipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:autoStart="true"
android:flipInterval="1000"
app:layout_constraintBaseline_toBaselineOf="@+id/loading_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/loading_title">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/empty"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_1_period"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_2_period"
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@string/load_3_period"
android:textSize="20sp" />
</ViewFlipper>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -13,6 +13,7 @@ import kotlinx.coroutines.channels.actor
import org.videolan.medialibrary.interfaces.media.AbstractFolder
import org.videolan.tools.MultiSelectHelper
import org.videolan.vlc.R
import org.videolan.vlc.databinding.FoldersFragmentBinding
import org.videolan.vlc.gui.SecondaryActivity
import org.videolan.vlc.gui.browser.MediaBrowserFragment
import org.videolan.vlc.gui.dialogs.CtxActionReceiver
......@@ -30,6 +31,7 @@ import org.videolan.vlc.viewmodels.mobile.getViewModel
@ObsoleteCoroutinesApi
class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionReceiver {
private lateinit var binding: FoldersFragmentBinding
private lateinit var adapter: FoldersAdapter
private val actor = actor<FolderAction> {
......@@ -64,7 +66,8 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.folders_fragment, container, false)
binding = FoldersFragmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
......@@ -76,7 +79,28 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
swipeRefreshLayout.isRefreshing = false
adapter.submitList(it)
restoreMultiSelectHelper()
updateEmptyView()
})
val empty = viewModel.isEmpty()
binding.loadingFlipper.visibility = if (empty) View.VISIBLE else View.GONE
binding.loadingTitle.visibility = if (empty) View.VISIBLE else View.GONE
binding.empty = empty
binding.buttonNomedia.setOnClickListener {
val activity = requireActivity()
val intent = Intent(activity.applicationContext, SecondaryActivity::class.java)
intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER)
startActivity(intent)
activity.setResult(RESULT_RESTART)
}
}
private fun updateEmptyView() {
val empty = viewModel.isEmpty()
val working = mediaLibrary.isWorking
binding.loadingFlipper.visibility = if (empty && working) View.VISIBLE else View.GONE
binding.loadingTitle.visibility = if (empty && working) View.VISIBLE else View.GONE
binding.empty = empty && !working
}
override fun onStart() {
......
......@@ -13,6 +13,7 @@ import kotlinx.coroutines.channels.actor
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup
import org.videolan.tools.MultiSelectHelper
import org.videolan.vlc.R
import org.videolan.vlc.databinding.VideogroupsFragmentBinding
import org.videolan.vlc.gui.SecondaryActivity
import org.videolan.vlc.gui.browser.MediaBrowserFragment
import org.videolan.vlc.gui.dialogs.CtxActionReceiver
......@@ -31,6 +32,7 @@ import org.videolan.vlc.viewmodels.mobile.getViewModel
@ExperimentalCoroutinesApi
class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxActionReceiver {
private lateinit var binding: VideogroupsFragmentBinding
private lateinit var adapter: VideoGroupsAdapter
private val actor = actor<VideoGroupAction> {
......@@ -65,7 +67,8 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.videogroups_fragment, container, false)
binding = VideogroupsFragmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
......@@ -77,7 +80,27 @@ class VideoGroupsFragment : MediaBrowserFragment<VideogroupsViewModel>(), CtxAct
swipeRefreshLayout.isRefreshing = false
adapter.submitList(it)
restoreMultiSelectHelper()
updateEmptyView()
})
val empty = viewModel.isEmpty()
binding.loadingFlipper.visibility = if (empty) View.VISIBLE else View.GONE
binding.loadingTitle.visibility = if (empty) View.VISIBLE else View.GONE
binding.empty = empty
binding.buttonNomedia.setOnClickListener {
val activity = requireActivity()
val intent = Intent(activity.applicationContext, SecondaryActivity::class.java)
intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER)
startActivity(intent)
activity.setResult(RESULT_RESTART)
}
}
private fun updateEmptyView() {
val empty = viewModel.isEmpty()
val working = mediaLibrary.isWorking
binding.loadingFlipper.visibility = if (empty && working) View.VISIBLE else View.GONE
binding.loadingTitle.visibility = if (empty && working) View.VISIBLE else View.GONE
binding.empty = empty && !working
}
override fun onStart() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment