-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Changed channel content from chips to swipable tabs #6026
Conversation
} catch (e: Exception) { | ||
isLoading = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLoading = false
should probably be outside of the catch
block, and not become called in fetchTabNextPage
, just for readability
val tabData = try { | ||
Json.decodeFromString<ChannelTab>(arguments?.getString(IntentData.tabData)?:"") | ||
} catch (e: Exception) { | ||
null | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val tabData = try { | |
Json.decodeFromString<ChannelTab>(arguments?.getString(IntentData.tabData)?:"") | |
} catch (e: Exception) { | |
null | |
} | |
val tabData = runCatching { | |
Json.decodeFromString<ChannelTab>(arguments?.getString(IntentData.tabData).orEmpty()) | |
}.getOrNull() |
val visibleItemCount: Int = recyclerView.layoutManager!!.childCount | ||
val totalItemCount: Int = recyclerView.layoutManager!!.getItemCount() | ||
val firstVisibleItemPosition: Int = | ||
(recyclerView.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val visibleItemCount: Int = recyclerView.layoutManager!!.childCount | |
val totalItemCount: Int = recyclerView.layoutManager!!.getItemCount() | |
val firstVisibleItemPosition: Int = | |
(recyclerView.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() | |
val visibleItemCount = recyclerView.layoutManager!!.childCount | |
val totalItemCount = recyclerView.layoutManager!!.getItemCount() | |
val firstVisibleItemPosition = | |
(recyclerView.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I copy pasted this code hehe that's why I forgot to refactor it because your code for bottom reached listener was misbehaving
fun RecyclerView.addOnBottomReachedListener(onBottomReached: () -> Unit) {
viewTreeObserver.addOnScrollChangedListener {
if (!canScrollVertically(1)) onBottomReached()
}
}
is misbehaving on second time you use it, instead of triggering when reached on bottom. It is triggered on each scroll. Atleast that was happening in my case. you might wanna check it out.
if (!tabData?.data.isNullOrEmpty()) { | ||
loadChannelTab(tabData ?: return) | ||
} else { | ||
val videoDataString = arguments?.getString(IntentData.videoList) | ||
val videos = try { | ||
Json.decodeFromString<List<StreamItem>>(videoDataString!!) | ||
} catch (e: Exception) { | ||
mutableListOf() | ||
} | ||
channelAdapter = VideosAdapter( | ||
videos.toMutableList(), | ||
forceMode = VideosAdapter.Companion.LayoutMode.CHANNEL_ROW | ||
) | ||
binding.channelRecView.adapter = channelAdapter | ||
binding.progressBar.visibility = View.GONE | ||
binding.channelRecView.visibility = View.VISIBLE | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!tabData?.data.isNullOrEmpty()) { | |
loadChannelTab(tabData ?: return) | |
} else { | |
val videoDataString = arguments?.getString(IntentData.videoList) | |
val videos = try { | |
Json.decodeFromString<List<StreamItem>>(videoDataString!!) | |
} catch (e: Exception) { | |
mutableListOf() | |
} | |
channelAdapter = VideosAdapter( | |
videos.toMutableList(), | |
forceMode = VideosAdapter.Companion.LayoutMode.CHANNEL_ROW | |
) | |
binding.channelRecView.adapter = channelAdapter | |
binding.progressBar.visibility = View.GONE | |
binding.channelRecView.visibility = View.VISIBLE | |
} | |
if (tabData?.data.isNullOrEmpty()) { | |
val videoDataString = arguments?.getString(IntentData.videoList) | |
val videos = runCatching { | |
Json.decodeFromString<List<StreamItem>>(videoDataString!!) | |
}.getOrElse { mutableListOf() } | |
channelAdapter = VideosAdapter( | |
videos.toMutableList(), | |
forceMode = VideosAdapter.Companion.LayoutMode.CHANNEL_ROW | |
) | |
binding.channelRecView.adapter = channelAdapter | |
binding.progressBar.visibility = View.GONE | |
binding.channelRecView.visibility = View.VISIBLE | |
} else { | |
loadChannelTab(tabData!!) | |
} |
fragment.arguments = Bundle().apply { | ||
putString(IntentData.tabData, Json.encodeToString(list[position])) | ||
putString(IntentData.videoList, Json.encodeToString(videos)) | ||
putString(IntentData.channelId, channelId) | ||
putString(IntentData.nextPage, nextPage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fragment.arguments = Bundle().apply { | |
putString(IntentData.tabData, Json.encodeToString(list[position])) | |
putString(IntentData.videoList, Json.encodeToString(videos)) | |
putString(IntentData.channelId, channelId) | |
putString(IntentData.nextPage, nextPage) | |
fragment.arguments = bundleOf( | |
IntentData.tabData to Json.encodeToString(list[position]) | |
IntentData.videoList to Json.encodeToString(videos) | |
IntentData.channelId to channelId | |
IntentData.nextPage to nextPage |
app/src/main/res/values/strings.xml
Outdated
<!-- TODO: Remove or change this placeholder text --> | ||
<string name="hello_blank_fragment">Hello blank fragment</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😉
Thanks for your PR, looks great UI/UX-wise! I noticed you did a lot of things like you were writing pure Java, so I'd guess you're coming from a Java background :) Two general suggestions/things concerning this PR:
|
fetchChannelNextPage(nextPage ?: return@launch).let { | ||
nextPage = it | ||
} | ||
} else { | ||
fetchTabNextPage(nextPage ?: return@launch, tab).let { | ||
nextPage = it | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchChannelNextPage(nextPage ?: return@launch).let { | |
nextPage = it | |
} | |
} else { | |
fetchTabNextPage(nextPage ?: return@launch, tab).let { | |
nextPage = it | |
} | |
nextPage = fetchChannelNextPage(nextPage ?: return@launch) | |
} else { | |
nextPage = fetchTabNextPage(nextPage ?: return@launch, tab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Bnyro for all the corrections, I will keep these in mind next time. Got to learn a lot from your corrections. I'll correct it in next commit
Thank you for your work on this PR! I've tried rebasing your code with some small code improvements which you seemed to have disabled unfortunately 😢, hence I merged the changes in #6053. Again, thanks for your PR 👍 |
This PR adds enhancement mentioned in issue #6008
VID_20240514113238.online-video-cutter.com.1.mp4