Skip to content

Commit

Permalink
can display posts now but not feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
YohannesTz committed Nov 6, 2022
1 parent d8d8eeb commit 6a5cd6a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 20 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ dependencies {
//youtube library
implementation files('libs/YouTubeAndroidPlayerApi.jar')

//expandable textview and time ago
//expandable textview,time ago, shimmer layout
implementation 'io.github.glailton.expandabletextview:expandabletextview:1.0.2'
implementation 'com.github.marlonlom:timeago:4.0.3'
implementation 'com.facebook.shimmer:shimmer:0.5.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
val splashScreen = installSplashScreen()
activityMainBinding = ActivityMainBinding.inflate(layoutInflater)
val view = activityMainBinding.root
setContentView(view)
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/res/layout/fragment_post_listing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,5 @@

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<ProgressBar
android:id="@+id/postListingProgress"
style="?android:attr/progressBarStyle"
android:layout_gravity="center"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</FrameLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/post_listing_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</LinearLayout>
</LinearLayout>

<io.github.glailton.expandabletextview.ExpandableTextView
<TextView
android:id="@+id/postContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.yohannestz.kraw.models

data class TokenRequestBody(
val grant_type: String,
val username: String,
val password: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.yohannestz.kraw.models

data class TokenResponse(
val access_token: String?,
val token_type: String?,
val expires_in: String?,
val refresh_token: String?,
val scope: String?,
val created_at: String?
)
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package com.github.yohannestz.kraw.service

import androidx.annotation.NonNull
import com.github.yohannestz.kraw.models.Resource
import com.github.yohannestz.kraw.models.*
import com.github.yohannestz.kraw.models.Collection
import com.github.yohannestz.kraw.models.PostCollection
import com.github.yohannestz.kraw.utils.Endpoints
import org.jetbrains.annotations.NotNull
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface KitsuService {

@POST(Endpoints.AUTH_TOKEN_URL)
suspend fun getToken(
@Body tokenRequestBody: TokenRequestBody
): Response<TokenResponse>

@GET(Endpoints.ANIME_URL)
suspend fun getAnimeList(
@Query("filter[season]") season: String? = null,
@Query("filter[seasonYear]") seasonYear: String? = null,
@Query("filter[streamers]") streamers: String? = null,
@Query("filter[ageRating]") ageRating: String? = null,
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

Expand All @@ -31,7 +35,6 @@ interface KitsuService {
@GET(Endpoints.EPISODE_URL)
suspend fun getEpisodeList(
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

Expand All @@ -41,14 +44,12 @@ interface KitsuService {
@GET(Endpoints.TRENDING_ANIME_URL)
suspend fun getTrendingAnimeList(
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

@GET(Endpoints.MANGA_URL)
suspend fun getMangaList(
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

Expand All @@ -62,7 +63,6 @@ interface KitsuService {
@Query("filter[mangaId]") mangaId: Int? = null,
@Query("filter[number]") number: Int? = null,
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

Expand All @@ -72,7 +72,6 @@ interface KitsuService {
@GET(Endpoints.TRENDING_MANGA_URL)
suspend fun getTrendingMangaList(
@Query("page[limit]") pageLimit: Int = 15,

@Query("page[offset]") offset: Int
): Response<Collection>

Expand All @@ -81,7 +80,6 @@ interface KitsuService {
@Query("filter[parentId]") parentId: Int? = null,
@Query("filter[slug]") slug: String? = null,
@Query("filter[nsfw]") nsfw: Boolean? = null,

@Query("page[offset]") offset: Int,
@Query("page[limit]") pageLimit: Int = 15
): Response<Collection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object Endpoints {
//auth
const val AUTH_URL = "oauth"
const val AUTH_URL_TOKEN = "token"
const val AUTH_TOKEN_URL = "oauth/token"

//resource
const val ANIME_URL = "anime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class KitsuApiServiceTest {
try {
val response = apiService.getPostList(offset = 0, include = "user")
assert(response.isSuccessful)
val postList = response.body()!!.attributes
val postList = response.body()!!.data
assert(postList.isNotEmpty())
} catch (ex: Exception) {
print("TestError: " + ex.message.toString())
Expand Down

0 comments on commit 6a5cd6a

Please sign in to comment.