[Android] Remove uses of mediawrapper type group
Duncan McNamara
git at videolan.org
Wed Sep 6 07:28:29 UTC 2023
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Jul 20 17:35:15 2023 +0200| [b509cbc2e2c4b0fd5657c5c994413e802ab90cf1] | committer: Nicolas Pomepuy
Remove uses of mediawrapper type group
The implementation of groups was changed a couple of years ago, there is
now specific items in the medialibrary for groups and this type is now
deprecated.
> https://code.videolan.org/videolan/vlc-android/commit/b509cbc2e2c4b0fd5657c5c994413e802ab90cf1
---
.../org/videolan/television/ui/CardPresenter.kt | 3 +--
.../main/java/org/videolan/television/ui/TvUtil.kt | 21 ----------------
.../videolan/vlc/gui/video/VideoGridFragment.kt | 5 ++--
.../org/videolan/vlc/gui/video/VideoListAdapter.kt | 29 ++++++++++------------
4 files changed, 16 insertions(+), 42 deletions(-)
diff --git a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
index e09603f1a5..b2a854b3b8 100644
--- a/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/CardPresenter.kt
@@ -77,10 +77,9 @@ class CardPresenter(private val context: Activity, private val isPoster: Boolean
if (item is MediaWrapper) {
if (BuildConfig.DEBUG) Log.d("CardPresenter", "ITEM: ${item.title} // meta = ${item.hasFlag(FAVORITE_FLAG)}")
if (item.hasFlag(FAVORITE_FLAG)) cardView.badgeImage = ContextCompat.getDrawable(cardView.context, R.drawable.ic_favorite_tv_badge)
- val group = item.type == MediaWrapper.TYPE_GROUP
val folder = item.type == MediaWrapper.TYPE_DIR
val video = item.type == MediaWrapper.TYPE_VIDEO
- if (!folder && (group || video && !item.isThumbnailGenerated)) {
+ if (!folder && (video && !item.isThumbnailGenerated)) {
if (noArt) {
cardView.mainImageView.scaleType = ImageView.ScaleType.CENTER_INSIDE
cardView.mainImage = BitmapDrawable(cardView.resources, getDefaultImage(item))
diff --git a/application/television/src/main/java/org/videolan/television/ui/TvUtil.kt b/application/television/src/main/java/org/videolan/television/ui/TvUtil.kt
index 5a5ecb664d..be7aade848 100644
--- a/application/television/src/main/java/org/videolan/television/ui/TvUtil.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/TvUtil.kt
@@ -141,13 +141,6 @@ object TvUtil {
intent.data = item.uri
activity.startActivity(intent)
}
- MediaWrapper.TYPE_GROUP -> {
- val intent = Intent(activity, VerticalGridActivity::class.java)
- intent.putExtra(MainTvActivity.BROWSER_TYPE, HEADER_VIDEO)
- val title = item.title.substring(if (item.title.lowercase(Locale.getDefault()).startsWith("the")) 4 else 0)
- intent.putExtra(KEY_GROUP, title)
- activity.startActivity(intent)
- }
else -> {
MediaUtils.openMedia(activity, item)
}
@@ -184,13 +177,6 @@ object TvUtil {
intent.data = item.uri
activity.startActivity(intent)
}
- MediaWrapper.TYPE_GROUP -> {
- val intent = Intent(activity, VerticalGridActivity::class.java)
- intent.putExtra(MainTvActivity.BROWSER_TYPE, HEADER_VIDEO)
- val title = item.title.substring(if (item.title.lowercase(Locale.getDefault()).startsWith("the")) 4 else 0)
- intent.putExtra(KEY_GROUP, title)
- activity.startActivity(intent)
- }
else -> {
model.run {
if (!Settings.getInstance(activity).getBoolean(FORCE_PLAY_ALL_VIDEO, Settings.tvUI)) {
@@ -238,13 +224,6 @@ object TvUtil {
intent.data = item.uri
activity.startActivity(intent)
}
- MediaWrapper.TYPE_GROUP -> {
- val intent = Intent(activity, VerticalGridActivity::class.java)
- intent.putExtra(MainTvActivity.BROWSER_TYPE, HEADER_VIDEO)
- val title = item.title.substring(if (item.title.lowercase(Locale.getDefault()).startsWith("the")) 4 else 0)
- intent.putExtra(KEY_GROUP, title)
- activity.startActivity(intent)
- }
else -> {
provider.loadPagedList(activity, {
(provider.getAll().toList() as List<MediaWrapper>).filter { it.type != MediaWrapper.TYPE_DIR }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 29345d58d4..5c30fadb8f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -591,11 +591,10 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
is Folder -> showContext(requireActivity(), this at VideoGridFragment, position, item, CTX_FOLDER_FLAGS or if(item.isFavorite) CTX_FAV_REMOVE else CTX_FAV_ADD)
is VideoGroup -> if (item.presentCount == 0) UiTools.snackerMissing(requireActivity()) else showContext(requireActivity(), this at VideoGridFragment, position, item, CTX_VIDEO_GROUP_FLAGS or if(item.isFavorite) CTX_FAV_REMOVE else CTX_FAV_ADD)
is MediaWrapper -> {
- val group = item.type == MediaWrapper.TYPE_GROUP
- var flags = if (group) CTX_VIDEO_GROUP_FLAGS else CTX_VIDEO_FLAGS
+ var flags = CTX_VIDEO_FLAGS
flags = flags or if(item.isFavorite) CTX_FAV_REMOVE else CTX_FAV_ADD
flags = if (item.seen > 0) flags or CTX_MARK_AS_UNPLAYED else flags or CTX_MARK_AS_PLAYED
- if (item.time != 0L && !group) flags = flags or CTX_PLAY_FROM_START
+ if (item.time != 0L) flags = flags or CTX_PLAY_FROM_START
if (viewModel.groupingType == VideoGroupingType.NAME || viewModel.group != null) flags = flags or if (viewModel.group != null) CTX_REMOVE_GROUP else flags or CTX_ADD_GROUP or CTX_GROUP_SIMILAR
//go to folder
if (item.uri.retrieveParent() != null) flags = flags or CTX_GO_TO_FOLDER
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
index 390361097d..b325dc197b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
@@ -170,22 +170,19 @@ class VideoListAdapter(private var isSeenMediaMarkerVisible: Boolean
holder.binding.setVariable(BR.isSD, item.uri.isSD())
holder.binding.setVariable(BR.isPresent, item.isPresent)
- text = if (item.type == MediaWrapper.TYPE_GROUP) {
- item.description
- } else {
- seen = if (isSeenMediaMarkerVisible) item.seen else 0L
- /* Time / Duration */
- if (item.length > 0) {
- val lastTime = item.displayTime
- if (lastTime > 0) {
- max = (item.length / 1000).toInt()
- progress = (lastTime / 1000).toInt()
- }
- if (isListMode && resolution !== null) {
- "${Tools.millisToString(item.length)} • $resolution"
- } else Tools.millisToString(item.length)
- } else null
- }
+
+ seen = if (isSeenMediaMarkerVisible) item.seen else 0L
+ /* Time / Duration */
+ text = if (item.length > 0) {
+ val lastTime = item.displayTime
+ if (lastTime > 0) {
+ max = (item.length / 1000).toInt()
+ progress = (lastTime / 1000).toInt()
+ }
+ if (isListMode && resolution !== null) {
+ "${Tools.millisToString(item.length)} • $resolution"
+ } else Tools.millisToString(item.length)
+ } else null
holder.binding.setVariable(BR.time, text)
holder.binding.setVariable(BR.max, max)
holder.binding.setVariable(BR.progress, progress)
More information about the Android
mailing list