Compare commits

..

4 Commits

Author SHA1 Message Date
Koen J 418f34c7e8 Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay 2025-06-04 15:13:42 +02:00
Koen J 21c2ab21b2 Disable drag long press for search playlists. 2025-06-04 15:13:25 +02:00
Kelvin 1ace7318f3 Submodules 2025-06-04 13:17:31 +02:00
Koen J 48052b88db Made task handler and retry dialogs more robust. 2025-06-04 13:00:32 +02:00
23 changed files with 49 additions and 29 deletions
@@ -319,7 +319,11 @@ class UIDialogs {
closeAction?.invoke()
}, UIDialogs.ActionStyle.NONE),
UIDialogs.Action(context.getString(R.string.retry), {
retryAction?.invoke();
try {
retryAction?.invoke();
} catch (e: Throwable) {
Logger.e(TAG, "Unhandled exception retrying", e)
}
}, UIDialogs.ActionStyle.PRIMARY)
);
else
@@ -333,7 +337,11 @@ class UIDialogs {
closeAction?.invoke()
}, UIDialogs.ActionStyle.NONE),
UIDialogs.Action(context.getString(R.string.retry), {
retryAction?.invoke();
try {
retryAction?.invoke();
} catch (e: Throwable) {
Logger.e(TAG, "Unhandled exception retrying", e)
}
}, UIDialogs.ActionStyle.PRIMARY)
);
}
@@ -82,7 +82,11 @@ class TaskHandler<TParameter, TResult> {
handled = true;
} catch (e: Throwable) {
Logger.w(TAG, "Handled exception in TaskHandler onSuccess.", e);
onError.emit(e, parameter);
try {
onError.emit(e, parameter);
} catch (e: Throwable) {
Logger.e(TAG, "Unhandled exception in .exception handler 1", e)
}
handled = true;
}
}
@@ -99,10 +103,14 @@ class TaskHandler<TParameter, TResult> {
if (id != _idGenerator)
return@withContext;
if (!onError.emit(e, parameter)) {
Logger.e(TAG, "Uncaught exception handled by TaskHandler.", e);
} else {
//Logger.w(TAG, "Handled exception in TaskHandler invoke.", e); (Prevents duplicate logs)
try {
if (!onError.emit(e, parameter)) {
Logger.e(TAG, "Uncaught exception handled by TaskHandler.", e);
} else {
//Logger.w(TAG, "Handled exception in TaskHandler invoke.", e); (Prevents duplicate logs)
}
} catch (e: Throwable) {
Logger.e(TAG, "Unhandled exception in .exception handler 2", e)
}
}
}
@@ -619,6 +619,7 @@ class VideoDetailView : ConstraintLayout {
loadCurrentVideo(lastPositionMilliseconds);
updatePillButtonVisibilities();
setCastEnabled(false);
}
else -> {}
}
@@ -10,10 +10,11 @@ class ItemMoveCallback : ItemTouchHelper.Callback {
var onRowMoved = Event2<Int, Int>();
var onRowSelected = Event1<ViewHolder>();
var onRowClear = Event1<ViewHolder>();
var canEdit = true
constructor() : super() { }
override fun isLongPressDragEnabled(): Boolean { return true; }
override fun isLongPressDragEnabled(): Boolean { return canEdit; }
override fun isItemViewSwipeEnabled(): Boolean { return false; }
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
@@ -26,6 +26,7 @@ class VideoListEditorView : FrameLayout {
val onVideoOptions = Event1<IPlatformVideo>();
val onVideoClicked = Event1<IPlatformVideo>();
val isEmpty get() = _videos.isEmpty();
val itemMoveCallback: ItemMoveCallback
constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) {
val recyclerPlaylist = RecyclerView(context, attrs);
@@ -34,14 +35,14 @@ class VideoListEditorView : FrameLayout {
recyclerPlaylist.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
addView(recyclerPlaylist);
val callback = ItemMoveCallback();
val touchHelper = ItemTouchHelper(callback);
itemMoveCallback = ItemMoveCallback();
val touchHelper = ItemTouchHelper(itemMoveCallback);
val adapterVideos = VideoListEditorAdapter(touchHelper);
recyclerPlaylist.adapter = adapterVideos;
recyclerPlaylist.layoutManager = LinearLayoutManager(context);
touchHelper.attachToRecyclerView(recyclerPlaylist);
callback.onRowMoved.subscribe { fromPosition, toPosition ->
itemMoveCallback.onRowMoved.subscribe { fromPosition, toPosition ->
synchronized(_videos) {
if (fromPosition < toPosition) {
for (i in fromPosition until toPosition)
@@ -94,6 +95,7 @@ class VideoListEditorView : FrameLayout {
synchronized(_videos) {
_videos.clear();
_videos.addAll(videos ?: listOf());
itemMoveCallback.canEdit = canEdit
_adapterVideos?.setVideos(_videos, canEdit);
}
}