diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6543156..5149636 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,12 +6,32 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/mixsteroids/mixjar/main.kt b/src/main/java/com/mixsteroids/mixjar/main.kt index 2a8a71c..77d21b3 100644 --- a/src/main/java/com/mixsteroids/mixjar/main.kt +++ b/src/main/java/com/mixsteroids/mixjar/main.kt @@ -1,9 +1,11 @@ package com.mixsteroids.mixjar fun main(){ - val mixCloudServiceImpl = MixCloud() - val item = mixCloudServiceImpl.getShow("spartacus","party-time",1) - println(item) +// val mixCloudServiceImpl = MixCloud() +// val item1 = mixCloudServiceImpl.getShow("spartacus","party-time",1) +// val item = mixCloudServiceImpl.getUser("DjChief254") +// println("actualItem: ${item?.username}") +// println("getShow: $item1") // mixCloudServiceImpl.getUser("DjChief254") // mixCloudServiceImpl.getUserCloudCast("DjChief254",2) // mixCloudServiceImpl.getCity("nairobi"); diff --git a/src/main/java/com/mixsteroids/mixjar/models/CityAndTagLatestResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/CityAndTagLatestResponse.kt index d02a57f..7c74663 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/CityAndTagLatestResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/CityAndTagLatestResponse.kt @@ -6,7 +6,12 @@ data class CityAndTagLatestResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : CityAndTagLatestResponsePaging -) +){ + constructor(cityAndTagLatestResponse: CityAndTagLatestResponse):this( + cityAndTagLatestResponse.data, + cityAndTagLatestResponse.paging + ) +} data class CityAndTagLatestResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/CityAndTagPopularResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/CityAndTagPopularResponse.kt index 9c6f421..cf9d29f 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/CityAndTagPopularResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/CityAndTagPopularResponse.kt @@ -7,7 +7,12 @@ data class CityAndTagPopularResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : CityAndTagPopularResponsePaging -) +){ + constructor(cityAndTagPopularResponse: CityAndTagPopularResponse):this( + cityAndTagPopularResponse.data, + cityAndTagPopularResponse.paging + ) +} data class CityAndTagPopularResponseData ( @SerializedName("key") val key : String, diff --git a/src/main/java/com/mixsteroids/mixjar/models/CityLatestResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/CityLatestResponse.kt index f3e8597..7846bdf 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/CityLatestResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/CityLatestResponse.kt @@ -7,7 +7,12 @@ data class CityLatestResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : CityLatestResponsePaging -) +){ + constructor(cityLatestResponse: CityLatestResponse):this( + cityLatestResponse.data, + cityLatestResponse.paging + ) +} data class CityLatestResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/CityPopularResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/CityPopularResponse.kt index a289ceb..95d0be6 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/CityPopularResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/CityPopularResponse.kt @@ -6,7 +6,12 @@ data class CityPopularResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : CityPopularResponsePaging -) +){ + constructor(cityPopularResponse: CityPopularResponse):this( + cityPopularResponse.data, + cityPopularResponse.paging + ) +} data class CityPopularResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/LatestTagResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/LatestTagResponse.kt index 255df39..462c95a 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/LatestTagResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/LatestTagResponse.kt @@ -7,7 +7,12 @@ data class LatestTagResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : LatestTagResponsePaging -) +){ + constructor(latestTagResponse: LatestTagResponse):this( + latestTagResponse.data, + latestTagResponse.paging + ) +} data class LatestTagResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/PopularTagResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/PopularTagResponse.kt index 904a7d6..5edcda3 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/PopularTagResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/PopularTagResponse.kt @@ -7,7 +7,12 @@ data class PopularTagResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : PopularTagResponsePaging -) +){ + constructor(popularTagResponse: PopularTagResponse):this( + popularTagResponse.data, + popularTagResponse.paging + ) +} data class PopularTagResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/ShowCommentsResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/ShowCommentsResponse.kt index 56eaad0..c4fca82 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/ShowCommentsResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/ShowCommentsResponse.kt @@ -8,7 +8,13 @@ data class ShowCommentsResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : ShowCommentsResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(showCommentsResponse: ShowCommentsResponse):this( + showCommentsResponse.data, + showCommentsResponse.paging, + showCommentsResponse.name + ) +} data class ShowCommentsResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/ShowFavoritesResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/ShowFavoritesResponse.kt index 239957d..e5978cb 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/ShowFavoritesResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/ShowFavoritesResponse.kt @@ -7,7 +7,10 @@ data class ShowFavoritesResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : ShowFavoritesResponsePaging -) +){ + constructor(showFavoritesResponse: ShowFavoritesResponse): + this(showFavoritesResponse.data,showFavoritesResponse.paging) +} data class ShowFavoritesResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/ShowListenersResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/ShowListenersResponse.kt index c8f4ac1..464baf2 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/ShowListenersResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/ShowListenersResponse.kt @@ -8,7 +8,14 @@ data class ShowListenersResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : ShowListenersResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(showListenersResponse: ShowListenersResponse): + this( + showListenersResponse.data, + showListenersResponse.paging, + showListenersResponse.name + ) +} data class ShowListenersResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/ShowResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/ShowResponse.kt index 1ed0cf9..6c4af7f 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/ShowResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/ShowResponse.kt @@ -25,7 +25,31 @@ data class ShowResponse ( @SerializedName("picture_primary_color") val picture_primary_color : Int, @SerializedName("type") val type : String, @SerializedName("metadata") val metadata : ShowResponseMetadata -) +){ + constructor(showResponse: ShowResponse): + this( + showResponse.key, + showResponse.url, + showResponse.name, + showResponse.tags, + showResponse.created_time, + showResponse.updated_time, + showResponse.play_count, + showResponse.favorite_count, + showResponse.comment_count, + showResponse.listener_count, + showResponse.repost_count, + showResponse.pictures, + showResponse.slug, + showResponse.user, + showResponse.audio_length, + showResponse.description, + showResponse.sections, + showResponse.picture_primary_color, + showResponse.type, + showResponse.metadata + ) +} data class ShowResponseConnections ( @SerializedName("favorites") val favorites : String, diff --git a/src/main/java/com/mixsteroids/mixjar/models/ShowSimilarResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/ShowSimilarResponse.kt index 68a7835..2beb8b3 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/ShowSimilarResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/ShowSimilarResponse.kt @@ -8,7 +8,13 @@ data class ShowSimilarResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : ShowSimilarResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(showSimilarResponse: ShowSimilarResponse):this( + showSimilarResponse.data, + showSimilarResponse.paging, + showSimilarResponse.name, + ) +} data class ShowSimilarResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/TagResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/TagResponse.kt index 584da39..a822dff 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/TagResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/TagResponse.kt @@ -10,7 +10,15 @@ data class TagResponse ( @SerializedName("name") val name : String, @SerializedName("type") val type : String, @SerializedName("metadata") val metadata : Metadata -) +){ + constructor(tagResponse: TagResponse):this( + tagResponse.key, + tagResponse.url, + tagResponse.name, + tagResponse.type, + tagResponse.metadata + ) +} data class CityResponse ( @SerializedName("key") val key : String, @@ -18,7 +26,15 @@ data class CityResponse ( @SerializedName("name") val name : String, @SerializedName("type") val type : String, @SerializedName("metadata") val metadata : Metadata -) +){ + constructor(cityResponse: CityResponse):this( + cityResponse.key, + cityResponse.url, + cityResponse.name, + cityResponse.type, + cityResponse.metadata + ) +} data class TagAndCityResponse ( @SerializedName("key") val key : String, @@ -26,7 +42,15 @@ data class TagAndCityResponse ( @SerializedName("name") val name : String, @SerializedName("type") val type : String, @SerializedName("metadata") val metadata : Metadata -) +){ + constructor(tagAndCityResponse: TagAndCityResponse):this( + tagAndCityResponse.key, + tagAndCityResponse.url, + tagAndCityResponse.name, + tagAndCityResponse.type, + tagAndCityResponse.metadata + ) +} data class Metadata ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserCloudCastResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserCloudCastResponse.kt index ec8df7c..f4c857a 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserCloudCastResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserCloudCastResponse.kt @@ -7,7 +7,13 @@ data class UserCloudCastResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserCloudCastResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(userCloudCastResponse: UserCloudCastResponse):this( + userCloudCastResponse.data, + userCloudCastResponse.paging, + userCloudCastResponse.name + ) +} data class UserCloudCastResponseUser ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserCommentsResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserCommentsResponse.kt index 59a19cf..d92e058 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserCommentsResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserCommentsResponse.kt @@ -8,7 +8,13 @@ data class UserCommentsResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserCommentsResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(userCommentsResponse: UserCommentsResponse):this( + userCommentsResponse.data, + userCommentsResponse.paging, + userCommentsResponse.name + ) +} data class UserCommentsResponseUser ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserFavoritesResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserFavoritesResponse.kt index 6e459bd..a0a95e1 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserFavoritesResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserFavoritesResponse.kt @@ -8,7 +8,13 @@ data class UserFavoritesResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserFavoritesResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(userFavoritesResponse: UserFavoritesResponse):this( + userFavoritesResponse.data, + userFavoritesResponse.paging, + userFavoritesResponse.name + ) +} data class UserFavoritesResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserFeedResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserFeedResponse.kt index b50ab50..196fd9b 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserFeedResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserFeedResponse.kt @@ -8,7 +8,12 @@ data class UserFeedResponse ( @SerializedName("paging") var paging : UserFeedPaging, @SerializedName("name") var name : String - ) + ){ + constructor(userFeedResponse: UserFeedResponse): + this(userFeedResponse.data, + userFeedResponse.paging, + userFeedResponse.name) +} data class UserFeedPictures ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserFollowersResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserFollowersResponse.kt index da6bcb4..099ccc4 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserFollowersResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserFollowersResponse.kt @@ -8,7 +8,13 @@ data class UserFollowersResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserFollowersPaging, @SerializedName("name") val name : String -) +){ + constructor(userFollowersResponse: UserFollowersResponse):this( + userFollowersResponse.data, + userFollowersResponse.paging, + userFollowersResponse.name + ) +} data class UserFollowersData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserFollowingResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserFollowingResponse.kt index be096a8..efb9555 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserFollowingResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserFollowingResponse.kt @@ -7,7 +7,12 @@ data class UserFollowingResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserFollowingResponsePaging -) +){ + constructor(userFollowingResponse: UserFollowingResponse):this( + userFollowingResponse.data, + userFollowingResponse.paging + ) +} data class UserFollowingResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserListensResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserListensResponse.kt index f03041e..ac79f14 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserListensResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserListensResponse.kt @@ -8,7 +8,13 @@ data class UserListensResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserListensResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(userListensResponse: UserListensResponse):this( + userListensResponse.data, + userListensResponse.paging, + userListensResponse.name + ) +} data class UserListensResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserPlaylistsResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserPlaylistsResponse.kt index 7aa251f..29b4f99 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserPlaylistsResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserPlaylistsResponse.kt @@ -8,7 +8,13 @@ data class UserPlaylistsResponse ( @SerializedName("data") val data : List, @SerializedName("paging") val paging : UserPlaylistsResponsePaging, @SerializedName("name") val name : String -) +){ + constructor(userPlaylistsResponse: UserPlaylistsResponse):this( + userPlaylistsResponse.data, + userPlaylistsResponse.paging, + userPlaylistsResponse.name + ) +} data class UserPlaylistsResponseData ( diff --git a/src/main/java/com/mixsteroids/mixjar/models/UserResponse.kt b/src/main/java/com/mixsteroids/mixjar/models/UserResponse.kt index 21ccda1..8176018 100644 --- a/src/main/java/com/mixsteroids/mixjar/models/UserResponse.kt +++ b/src/main/java/com/mixsteroids/mixjar/models/UserResponse.kt @@ -25,7 +25,30 @@ data class UserResponse ( @SerializedName("picture_primary_color") val picture_primary_color : Int, @SerializedName("type") val type : String, @SerializedName("metadata") val metadata : UserResponseMetadata -) +){ + constructor( userResponse:UserResponse) : this( + userResponse.key, + userResponse.url, + userResponse.name, + userResponse.username, + userResponse.pictures, + userResponse.biog, + userResponse.created_time, + userResponse.updated_time, + userResponse.follower_count, + userResponse.following_count, + userResponse.cloudcast_count, + userResponse.favorite_count, + userResponse.listen_count, + userResponse.is_pro, + userResponse.is_premium, + userResponse.city, + userResponse.country, + userResponse.cover_pictures, + userResponse.picture_primary_color, + userResponse.type, + userResponse.metadata) +} data class UserResponsePictures ( diff --git a/src/main/java/com/mixsteroids/mixjar/services/MixCloudService.kt b/src/main/java/com/mixsteroids/mixjar/services/MixCloudService.kt index fec26e2..1687a16 100644 --- a/src/main/java/com/mixsteroids/mixjar/services/MixCloudService.kt +++ b/src/main/java/com/mixsteroids/mixjar/services/MixCloudService.kt @@ -4,7 +4,6 @@ package com.mixsteroids.mixjar.services import com.mixsteroids.mixjar.models.* import com.mixsteroids.mixjar.utils.Mixcloud.LIMIT_VALUE import io.reactivex.Single -import retrofit2.Call import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query @@ -14,69 +13,69 @@ interface MixCloudService { fun getUser(@Path("user")username:String): Single @GET("{user}/cloudcasts") - fun getUserCloudCasts(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserCloudCasts(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/comments") - fun getUserComments(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserComments(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/favorites") - fun getUserFavorites(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserFavorites(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/feed") - fun getUserFeed(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserFeed(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/followers") - fun getUserFollowers(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserFollowers(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/following") - fun getUserFollowing(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserFollowing(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/listens") - fun getUserListens(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserListens(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{user}/playlists") - fun getUserPlaylists(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getUserPlaylists(@Path("user")username: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{entertainer}/{showname}/?metadata=1") - fun getShow(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0): Call + fun getShow(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0): Single @GET("{entertainer}/{showname}/favorites/") - fun getShowFavorites(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0): Call + fun getShowFavorites(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0): Single @GET("{entertainer}/{showname}/listeners/") - fun getShowListeners(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getShowListeners(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{entertainer}/{showname}/comments/") - fun getShowComments(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getShowComments(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("{entertainer}/{showname}/similar/") - fun getShowSimilar(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getShowSimilar(@Path("entertainer") entertainer:String, @Path("showname") showName:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/{tag}/?metadata=1") - fun getTag(@Path("tag") tag:String):Call + fun getTag(@Path("tag") tag:String):Single @GET("discover/{tag}/popular/") - fun getPopularTag(@Path("tag") tag:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getPopularTag(@Path("tag") tag:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/{tag}/latest/") - fun getLatestTag(@Path("tag") tag:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getLatestTag(@Path("tag") tag:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/city:{city}/?metadata=1") - fun getCity(@Path("city") city:String):Call + fun getCity(@Path("city") city:String):Single @GET("discover/city:{city}/popular/") - fun getCityPopular(@Path("city") city:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getCityPopular(@Path("city") city:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/city:{city}/latest/") - fun getCityLatest(@Path("city") city:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getCityLatest(@Path("city") city:String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/{tag}+city:{city}/?metadata=1") - fun getTagAndCity(@Path("tag")tag:String,@Path("city") city: String):Call + fun getTagAndCity(@Path("tag")tag:String,@Path("city") city: String):Single @GET("discover/{tag}+city:{city}/popular/") - fun getTagAndCityPopular(@Path("tag")tag:String,@Path("city") city: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getTagAndCityPopular(@Path("tag")tag:String,@Path("city") city: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single @GET("discover/{tag}+city:{city}/latest/") - fun getTagAndCityLatest(@Path("tag")tag:String,@Path("city") city: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Call + fun getTagAndCityLatest(@Path("tag")tag:String,@Path("city") city: String,@Query("limit")limit:Int = LIMIT_VALUE, @Query("offset")offset:Int = 0):Single } \ No newline at end of file diff --git a/src/main/java/com/mixsteroids/mixjar/services/MixCloudServiceImpl.kt b/src/main/java/com/mixsteroids/mixjar/services/MixCloudServiceImpl.kt index e902f0a..ed994a4 100644 --- a/src/main/java/com/mixsteroids/mixjar/services/MixCloudServiceImpl.kt +++ b/src/main/java/com/mixsteroids/mixjar/services/MixCloudServiceImpl.kt @@ -12,117 +12,209 @@ class MixCloudServiceImpl : MixCloudInterface { override fun getShow(entertainer: String, show: String, page: Int): ShowResponse? { val showCall = mixCloudApi.getShow(entertainer, show, offset = getOffsetFromPage(page)!!) - return executeRequest(showCall) + var showResponseRx:ShowResponse? = null + showCall.subscribe { showResponse, throwable -> + showResponseRx = ShowResponse(showResponse) + } + return showResponseRx } - override fun getShowFavorites(entertainer: String, show: String, page: Int): ShowFavoritesResponse { + override fun getShowFavorites(entertainer: String, show: String, page: Int): ShowFavoritesResponse? { val showFavoritesCall = mixCloudApi.getShowFavorites(entertainer, show, offset = getOffsetFromPage(page)!!) - return executeRequest(showFavoritesCall)!! + var showFavoritesRx:ShowFavoritesResponse? = null + showFavoritesCall.subscribe { showFavoritesResponse, throwable -> + showFavoritesRx = ShowFavoritesResponse(showFavoritesResponse) + } + return showFavoritesRx } override fun getShowListeners(entertainer: String, show: String, page: Int): ShowListenersResponse? { val showListenersCall = mixCloudApi.getShowListeners(entertainer, show, offset = getOffsetFromPage(page)!!) - return executeRequest(showListenersCall) + var showListenersRx:ShowListenersResponse? = null + showListenersCall.subscribe { showListenersResponse, throwable -> + showListenersRx = ShowListenersResponse(showListenersResponse) + } + return showListenersRx } override fun getShowComments(entertainer: String, show: String, page: Int): ShowCommentsResponse? { val showCommentsCall = mixCloudApi.getShowComments(entertainer, show, offset = getOffsetFromPage(page)!!) - return executeRequest(showCommentsCall) + var showCommentsResponseRx:ShowCommentsResponse? = null + showCommentsCall.subscribe { showCommentsResponse, throwable -> + showCommentsResponseRx = ShowCommentsResponse(showCommentsResponse) + } + return showCommentsResponseRx } override fun getShowSimilar(entertainer: String, show: String, page: Int): ShowSimilarResponse? { val showSimilarCall = mixCloudApi.getShowSimilar(entertainer, show, offset = getOffsetFromPage(page)!!) - return executeRequest(showSimilarCall) + var showSimilarResponseRx:ShowSimilarResponse? = null + showSimilarCall.subscribe { showSimilarResponse, throwable -> + showSimilarResponseRx = ShowSimilarResponse(showSimilarResponse) + } + return showSimilarResponseRx } override fun getUser(username: String): UserResponse? { val userCall = mixCloudApi.getUser(username) - return executeRequest(userCall) + var userResponselocal:UserResponse? = null + userCall.subscribe { userResponse, throwable -> + userResponselocal = UserResponse(userResponse) + } + return userResponselocal } override fun getUserCloudCasts(username: String, page: Int): UserCloudCastResponse? { val cloudCastCall = mixCloudApi.getUserCloudCasts(username, offset = getOffsetFromPage(page)!!) - return executeRequest(cloudCastCall) + var userCloudCastResponseRx:UserCloudCastResponse? = null + cloudCastCall.subscribe { userCloudCastResponse, throwable -> + userCloudCastResponseRx = UserCloudCastResponse(userCloudCastResponse) + } + return userCloudCastResponseRx } override fun getUserComments(username: String, page: Int): UserCommentsResponse? { val userCommentsCall = mixCloudApi.getUserComments(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userCommentsCall) + var userCommentsResponseRx:UserCommentsResponse? = null + userCommentsCall.subscribe { userCommentsResponse, throwable -> + userCommentsResponseRx = UserCommentsResponse(userCommentsResponse) + } + return userCommentsResponseRx } override fun getUserFavorites(username: String, page: Int): UserFavoritesResponse? { val userFavorites = mixCloudApi.getUserFavorites(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userFavorites) + var userFavoritesResponseRx: UserFavoritesResponse? = null + userFavorites.subscribe { userFavoritesResponse, throwable -> + userFavoritesResponseRx = UserFavoritesResponse(userFavoritesResponse) + } + return userFavoritesResponseRx } override fun getUserFeed(username: String, page: Int): UserFeedResponse? { val userFeedCall = mixCloudApi.getUserFeed(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userFeedCall) + var userFeedResponseRx:UserFeedResponse? = null + userFeedCall.subscribe { userFeedResponse, throwable -> + userFeedResponseRx = UserFeedResponse(userFeedResponse) + } + return userFeedResponseRx } override fun getUserFollowers(username: String, page: Int): UserFollowersResponse? { val userFollowersCall = mixCloudApi.getUserFollowers(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userFollowersCall) + var userFollowersResponseRx:UserFollowersResponse? = null + userFollowersCall.subscribe { userFollowersResponse, throwable -> + userFollowersResponseRx = UserFollowersResponse(userFollowersResponse) + } + return userFollowersResponseRx } override fun getUserFollowing(username: String, page: Int): UserFollowingResponse? { val userFollowingCall = mixCloudApi.getUserFollowing(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userFollowingCall) + var userFollowingResponseRx:UserFollowingResponse? = null + userFollowingCall.subscribe { userFollowingResponse, throwable -> + userFollowingResponseRx = UserFollowingResponse(userFollowingResponse) + } + return userFollowingResponseRx } override fun getUserListens(username: String, page: Int): UserListensResponse? { val userListensCall = mixCloudApi.getUserListens(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userListensCall) + var userListensResponseRx:UserListensResponse? = null + userListensCall.subscribe { userListensResponse, throwable -> + userListensResponseRx = UserListensResponse(userListensResponse) + } + return userListensResponseRx } override fun getUserPlaylists(username: String, page: Int): UserPlaylistsResponse? { val userPlaylistCall = mixCloudApi.getUserPlaylists(username, offset = getOffsetFromPage(page)!!) - return executeRequest(userPlaylistCall) + var userPlayListsResponseRx:UserPlaylistsResponse? = null + userPlaylistCall.subscribe { userPlaylistsResponse, throwable -> + userPlayListsResponseRx = UserPlaylistsResponse(userPlaylistsResponse) + } + return userPlayListsResponseRx } override fun getTag(tag: String): TagResponse? { val tagCall = mixCloudApi.getTag(tag) - return executeRequest(tagCall) + var tagResponseRx:TagResponse? = null + tagCall.subscribe { tagResponse, throwable -> + tagResponseRx = TagResponse(tagResponse) + } + return tagResponseRx } override fun getLatestTag(tag: String, page: Int): LatestTagResponse? { val latestTagCall = mixCloudApi.getLatestTag(tag, offset = getOffsetFromPage(page)!!) - return executeRequest(latestTagCall) + var latestTagResponseRx: LatestTagResponse? = null + latestTagCall.subscribe { latestTagResponse, throwable -> + latestTagResponseRx = LatestTagResponse(latestTagResponse) + } + return latestTagResponseRx } override fun getPopularTag(tag: String, page: Int): PopularTagResponse? { val popularTagCall = mixCloudApi.getPopularTag(tag, offset = getOffsetFromPage(page)!!) - return executeRequest(popularTagCall) + var popularTagResponseRx:PopularTagResponse? = null + popularTagCall.subscribe { popularTagResponse, throwable -> + popularTagResponseRx = PopularTagResponse(popularTagResponse) + } + return popularTagResponseRx } override fun getCity(city: String): CityResponse? { val cityCall = mixCloudApi.getCity(city) - return executeRequest(cityCall) + var cityResponseRx: CityResponse? = null + cityCall.subscribe { cityResponse, throwable -> + cityResponseRx = CityResponse(cityResponse) + } + return cityResponseRx } override fun getCityPopular(city: String, page: Int): CityPopularResponse? { val cityPopularCall = mixCloudApi.getCityPopular(city, offset = getOffsetFromPage(page)!!) - return executeRequest(cityPopularCall) + var cityPopularResponseRx: CityPopularResponse? = null + cityPopularCall.subscribe { cityPopularResponse, throwable -> + cityPopularResponseRx = CityPopularResponse(cityPopularResponse) + } + return cityPopularResponseRx } override fun getCityLatest(city: String, page: Int): CityLatestResponse? { val cityLatest = mixCloudApi.getCityLatest(city, offset = getOffsetFromPage(page)!!) - return executeRequest(cityLatest) + var cityLatestResponseRx:CityLatestResponse? = null + cityLatest.subscribe { cityLatestResponse, throwable -> + cityLatestResponseRx = CityLatestResponse(cityLatestResponse) + } + return cityLatestResponseRx } override fun getTagAndCity(tag: String, city: String): TagAndCityResponse? { val tagAndCityCall = mixCloudApi.getTagAndCity(tag, city) - return executeRequest(tagAndCityCall) + var tagAndCityResponseRx:TagAndCityResponse? = null + tagAndCityCall.subscribe { tagAndCityResponse, throwable -> + tagAndCityResponseRx = TagAndCityResponse(tagAndCityResponse) + } + return tagAndCityResponseRx } override fun getTagAndCityPopular(tag: String, city: String, page: Int): CityAndTagPopularResponse? { val tagAndCityPopularCall = mixCloudApi.getTagAndCityPopular(tag, city, offset = getOffsetFromPage(page)!!) - return executeRequest(tagAndCityPopularCall) + var tagAndCityResponseRx:CityAndTagPopularResponse? = null + tagAndCityPopularCall.subscribe { cityAndTagPopularResponse, throwable -> + tagAndCityResponseRx = CityAndTagPopularResponse(cityAndTagPopularResponse) + } + return tagAndCityResponseRx } override fun getTagAndCityLatest(tag: String, city: String, page: Int): CityAndTagLatestResponse? { val tagAndCityLatestCall = mixCloudApi.getTagAndCityLatest(tag, city, offset = getOffsetFromPage(page)!!) - return executeRequest(tagAndCityLatestCall) + var cityAndTagLatestResponseRx:CityAndTagLatestResponse? = null + tagAndCityLatestCall.subscribe { cityAndTagLatestResponse, throwable -> + cityAndTagLatestResponseRx = CityAndTagLatestResponse(cityAndTagLatestResponse) + } + return cityAndTagLatestResponseRx } diff --git a/src/main/java/com/mixsteroids/mixjar/services/Utils.kt b/src/main/java/com/mixsteroids/mixjar/services/Utils.kt index 93c49fa..3c98293 100644 --- a/src/main/java/com/mixsteroids/mixjar/services/Utils.kt +++ b/src/main/java/com/mixsteroids/mixjar/services/Utils.kt @@ -1,5 +1,6 @@ package com.mixsteroids.mixjar.services +import com.mixsteroids.mixjar.models.UserResponse import io.reactivex.Single import retrofit2.Call import retrofit2.Callback @@ -23,13 +24,12 @@ fun executeRequest(call: Call): T? { } }) return item?.t -}fun executeRxRequest(call: Single): T? { -// var item:T? = null -// call.subscribeWith(object ) } + + fun getOffsetFromPage(page: Int): Int? { if (page >= 0 && page <= Int.MAX_VALUE) { return page.times(20)