Created
January 18, 2020 07:14
-
-
Save SurajBahadur/6c7430270f835e50f62b24399dc1a2f1 to your computer and use it in GitHub Desktop.
Filter the model class based on like,comment and whatever you want in kotlin java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Use below method to filter the list | |
Collections.sort(data.videos, MoreViewComparator()) | |
*/ | |
data class VideosItem( | |
@field:SerializedName("author_name") | |
val authorName: String? = null, | |
@field:SerializedName("updated_on") | |
val updatedOn: Any? = null, | |
@field:SerializedName("total_comments") | |
val totalComments: Int? = null, | |
@field:SerializedName("video_image") | |
val videoImage: String? = null, | |
@field:SerializedName("video_url") | |
val videoUrl: String? = null, | |
@field:SerializedName("video_title") | |
val videoTitle: String? = null, | |
@field:SerializedName("total_view") | |
val totalView: Int? = null, | |
@field:SerializedName("created_on") | |
val createdOn: String? = null, | |
@field:SerializedName("video_status") | |
val videoStatus: String? = null, | |
@field:SerializedName("id") | |
val id: Int? = null, | |
@field:SerializedName("total_likes") | |
val totalLikes: Int? = null | |
) : Serializable | |
class MoreViewComparator : Comparator<VideosItem?> { | |
override fun compare(o1: VideosItem?, o2: VideosItem?): Int { | |
return o2!!.totalView!!.compareTo(o1!!.totalView!!) | |
} | |
} | |
class MorelikesComparator : Comparator<VideosItem?> { | |
override fun compare(o1: VideosItem?, o2: VideosItem?): Int { | |
return o2!!.totalLikes!!.compareTo(o1!!.totalLikes!!) | |
} | |
} | |
class DateComparator : Comparator<VideosItem?> { | |
override fun compare(o1: VideosItem?, o2: VideosItem?): Int { | |
return o2!!.createdOn!!.compareTo(o1!!.createdOn!!) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment