Skip to content

Commit

Permalink
tried new approach for the app
Browse files Browse the repository at this point in the history
  • Loading branch information
kl3jvi committed Nov 13, 2022
1 parent 054621f commit 5211a49
Show file tree
Hide file tree
Showing 60 changed files with 1,127 additions and 573 deletions.
7 changes: 6 additions & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id "com.apollographql.apollo3" version("3.5.0")
id "com.apollographql.apollo3" version("3.7.0")
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
id "org.jlleitschuh.gradle.ktlint" version("11.0.0")
}
Expand Down Expand Up @@ -217,7 +217,7 @@ dependencies {
implementation "androidx.browser:browser:$inAppBrowserVersion"

// Apollo GraphQl
def apolloVersion = '3.5.0'
def apolloVersion = '3.7.0'
implementation "com.apollographql.apollo3:apollo-runtime:$apolloVersion"

// DataStore
Expand Down Expand Up @@ -246,23 +246,22 @@ dependencies {
debugImplementation "com.github.chuckerteam.chucker:library:3.5.2"
releaseImplementation "com.github.chuckerteam.chucker:library-no-op:3.5.2"

implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.google.code.gson:gson:2.10'

debugImplementation "com.squareup.leakcanary:leakcanary-android:2.9.1"

def work_version = "2.7.1"
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation 'androidx.hilt:hilt-work:1.0.0'

kapt 'androidx.hilt:hilt-compiler:1.0.0'

testImplementation 'app.cash.turbine:turbine:0.9.0'
testImplementation 'app.cash.turbine:turbine:0.12.1'
testImplementation "junit:junit:4.13.2"
testImplementation "androidx.test:core:1.4.0"
testImplementation 'org.mockito:mockito-core:4.7.0'
testImplementation "androidx.test:core:1.5.0"
testImplementation 'org.mockito:mockito-core:4.8.1'
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
testImplementation 'io.mockk:mockk:1.12.7'
testImplementation 'io.mockk:mockk:1.13.2'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"
testImplementation('com.apollographql.apollo3:apollo-testing-support:3.5.0')
testImplementation('com.apollographql.apollo3:apollo-testing-support:3.7.0')

}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Add project specific ProGuard rules here.
## You can control the set of applied configuration files using the
## proguardFiles setting in build.gradle.kts.
## proguardFiles setting in build.gradle.kts.kts.
##
## For more details, see
## http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.kl3jvi.animity

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.kl3jvi.animity", appContext.packageName)
}
}
//import androidx.test.ext.junit.runners.AndroidJUnit4
//import androidx.test.platform.app.InstrumentationRegistry
//import org.junit.Assert.assertEquals
//import org.junit.Test
//import org.junit.runner.RunWith
//
///**
// * Instrumented test, which will execute on an Android device.
// *
// * See [testing documentation](http://d.android.com/tools/testing).
// */
//@RunWith(AndroidJUnit4::class)
//class ExampleInstrumentedTest {
// @Test
// fun useAppContext() {
// // Context of the app under test.
// val appContext = InstrumentationRegistry.getInstrumentation().targetContext
// assertEquals("com.kl3jvi.animity", appContext.packageName)
// }
//}
130 changes: 5 additions & 125 deletions app/src/main/graphql/Query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -98,51 +98,7 @@ query AnimeListCollectionQuery(

updatedAt
createdAt
media {
id
title {
romaji
english
native
userPreferred
}
description
type
format
status(version: 2)
startDate {
year
month
day
}
season
seasonYear
episodes
duration
countryOfOrigin
source
isFavourite
coverImage {
large
}
genres
synonyms
averageScore
popularity
tags {
name
}
isAdult
nextAiringEpisode {
id
airingAt
episode
mediaId
}
externalLinks {
site
}
}
media {...HomeMedia}
}
name
isCustomList
Expand Down Expand Up @@ -202,22 +158,9 @@ query FavoritesAnimeQuery($id: Int, $page: Int) {
name
favourites {
anime(page: $page) {

edges {
node {
id
title {
romaji
userPreferred
}
coverImage {
large
}
description
nextAiringEpisode {
airingAt
episode
}
node{
...HomeMedia
}
favouriteOrder
}
Expand All @@ -241,71 +184,7 @@ query SearchAnimeQuery(
search: $search,
type: ANIME
) {
id
idMal
seasonYear
startDate { year month day }
title {
romaji
userPreferred
}
description
coverImage {
extraLarge
large
medium
}
nextAiringEpisode {
airingAt
episode
}
genres
averageScore
meanScore
nextAiringEpisode {
airingAt
episode
}
streamingEpisodes {
title
thumbnail
}
trailer { id site thumbnail }
bannerImage
recommendations {
nodes {
id
mediaRecommendation {
id
title {
english
romaji
userPreferred
}
idMal
coverImage { medium large }
averageScore
}
}
}
relations {
edges {
id
relationType(version: 2)
node {
format
id
idMal
coverImage { medium large }
averageScore
title {
english
romaji
userPreferred
}
}
}
}
...HomeMedia
}
}
}
Expand Down Expand Up @@ -423,6 +302,7 @@ fragment HomeMedia on Media {
userPreferred
}
type
isFavourite
status(version: 2)
format
description(asHtml: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.kl3jvi.animity.data.mapper

import com.apollographql.apollo3.api.ApolloResponse
import com.kl3jvi.animity.FavoritesAnimeQuery
import com.kl3jvi.animity.data.model.ui_models.AniListMedia
import com.kl3jvi.animity.data.model.ui_models.MediaCoverImage
import com.kl3jvi.animity.data.model.ui_models.MediaTitle
import com.kl3jvi.animity.data.model.ui_models.*

/* It's a function that converts the data from the graphql query to the data model that we use in the
app. */
Expand All @@ -13,12 +11,7 @@ fun ApolloResponse<FavoritesAnimeQuery.Data>.convert(): List<AniListMedia> {
var data = listOf<AniListMedia>()
if (!this.hasErrors() && this.data != null) {
data = favoritesResponse?.user?.favourites?.anime?.edges?.mapNotNull {
AniListMedia(
idAniList = it?.node?.id ?: 0,
title = MediaTitle(userPreferred = it?.node?.title?.userPreferred.orEmpty()),
coverImage = MediaCoverImage(large = it?.node?.coverImage?.large.orEmpty()),
description = it?.node?.description.orEmpty()
)
it?.node?.homeMedia.convert()
} ?: emptyList()
}
return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fun HomeMedia?.convert(): AniListMedia {
title = MediaTitle(userPreferred = this?.title?.userPreferred.orEmpty()),
type = this?.type,
format = this?.format,
isFavourite = this?.isFavourite?:false,
streamingEpisode = this?.streamingEpisodes?.mapNotNull { it.convert() },
nextAiringEpisode = this?.nextAiringEpisode?.airingAt,
status = this?.status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package com.kl3jvi.animity.data.mapper
import com.apollographql.apollo3.api.ApolloResponse
import com.kl3jvi.animity.AnimeListCollectionQuery
import com.kl3jvi.animity.UserQuery
import com.kl3jvi.animity.data.model.ui_models.ProfileRow
import com.kl3jvi.animity.data.model.ui_models.AniListMedia
import com.kl3jvi.animity.data.model.ui_models.FuzzyDate
import com.kl3jvi.animity.data.model.ui_models.Genre
import com.kl3jvi.animity.data.model.ui_models.MediaCoverImage
import com.kl3jvi.animity.data.model.ui_models.MediaTitle
import com.kl3jvi.animity.data.model.ui_models.User
import com.kl3jvi.animity.data.model.ui_models.UserAvatar

Expand Down Expand Up @@ -42,40 +39,9 @@ fun ApolloResponse<AnimeListCollectionQuery.Data>.convert(): List<ProfileRow> {

private fun List<AnimeListCollectionQuery.Entry?>?.convert(): List<AniListMedia> {
return this?.mapNotNull {
AniListMedia(
idAniList = it?.media?.id ?: 0,
title = MediaTitle(userPreferred = it?.media?.title?.userPreferred.orEmpty()),
type = it?.media?.type,
format = it?.media?.format,
status = it?.media?.status,
nextAiringEpisode = it?.media?.nextAiringEpisode?.airingAt,
description = it?.media?.description.orEmpty(),
startDate = if (it?.media?.startDate?.year != null) {
FuzzyDate(
it.media.startDate.year,
it.media.startDate.month,
it.media.startDate.day
)
} else {
null
},
coverImage = MediaCoverImage(
it?.media?.coverImage?.large.orEmpty(),
it?.media?.coverImage?.large.orEmpty(),
it?.media?.coverImage?.large.orEmpty()
),
genres = it?.media?.genres?.mapNotNull { Genre(name = it.orEmpty()) } ?: listOf(),
averageScore = it?.media?.averageScore ?: 0
)
it?.media?.homeMedia.convert()
} ?: listOf()
}

data class ProfileData(
val userData: User = User(),
val profileRow: List<ProfileRow> = emptyList()
)

data class ProfileRow(
val title: String = "",
val anime: List<AniListMedia> = emptyList()
)

Loading

0 comments on commit 5211a49

Please sign in to comment.