mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #4056 from Isira-Seneviratne/Comment_Parcelable
Make the Comment class parcelable
This commit is contained in:
commit
0627a6760f
@ -1,8 +1,11 @@
|
||||
package com.github.libretube.api.obj
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@Parcelize
|
||||
data class Comment(
|
||||
val author: String,
|
||||
val commentId: String,
|
||||
@ -16,4 +19,4 @@ data class Comment(
|
||||
val thumbnail: String,
|
||||
val verified: Boolean,
|
||||
val replyCount: Long,
|
||||
)
|
||||
) : Parcelable
|
||||
|
@ -17,7 +17,6 @@ import androidx.fragment.app.commit
|
||||
import androidx.fragment.app.replace
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.JsonHelper
|
||||
import com.github.libretube.api.obj.Comment
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.databinding.CommentsRowBinding
|
||||
@ -31,7 +30,6 @@ import com.github.libretube.ui.viewholders.CommentsViewHolder
|
||||
import com.github.libretube.util.HtmlParser
|
||||
import com.github.libretube.util.LinkHandler
|
||||
import com.github.libretube.util.TextUtils
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
||||
class CommentsAdapter(
|
||||
private val fragment: Fragment?,
|
||||
@ -61,10 +59,7 @@ class CommentsAdapter(
|
||||
}
|
||||
|
||||
private fun navigateToReplies(comment: Comment) {
|
||||
val args = bundleOf(
|
||||
IntentData.videoId to videoId,
|
||||
IntentData.comment to JsonHelper.json.encodeToString(comment),
|
||||
)
|
||||
val args = bundleOf(IntentData.videoId to videoId, IntentData.comment to comment)
|
||||
fragment!!.parentFragmentManager.commit {
|
||||
replace<CommentsRepliesFragment>(R.id.commentFragContainer, args = args)
|
||||
addToBackStack(null)
|
||||
|
@ -10,13 +10,13 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.github.libretube.api.JsonHelper
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.obj.Comment
|
||||
import com.github.libretube.api.obj.CommentsPage
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.databinding.FragmentCommentsBinding
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.extensions.parcelable
|
||||
import com.github.libretube.ui.adapters.CommentsAdapter
|
||||
import com.github.libretube.ui.extensions.filterNonEmptyComments
|
||||
import com.github.libretube.ui.models.CommentsViewModel
|
||||
@ -45,11 +45,9 @@ class CommentsRepliesFragment : Fragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val videoId = arguments?.getString(IntentData.videoId) ?: ""
|
||||
val comment = JsonHelper.json.decodeFromString(
|
||||
Comment.serializer(),
|
||||
arguments?.getString(IntentData.comment)!!,
|
||||
)
|
||||
val arguments = requireArguments()
|
||||
val videoId = arguments.getString(IntentData.videoId, "")
|
||||
val comment = arguments.parcelable<Comment>(IntentData.comment)!!
|
||||
|
||||
repliesAdapter = CommentsAdapter(
|
||||
null,
|
||||
|
Loading…
Reference in New Issue
Block a user