Skip to content

Commit

Permalink
fixes on ui and architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
kl3jvi committed May 24, 2022
1 parent c2a3da3 commit f4108c5
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 99 deletions.
13 changes: 8 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId "com.kl3jvi.animity"
minSdk 21
targetSdk 32
versionCode 9
versionName "1.0.8"
versionCode 10
versionName "1.0.9"
archivesBaseName = "Animity-v$versionName"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -47,11 +47,11 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildFeatures {
viewBinding true
Expand Down Expand Up @@ -211,6 +211,9 @@ dependencies {
// def brainTree = "6.0.2"
// implementation "com.braintreepayments.api:drop-in:$brainTree"

implementation 'org.mozilla:rhino:1.7.13'


def epoxyVersion = "5.0.0-beta03"
implementation "com.airbnb.android:epoxy:$epoxyVersion"
implementation "com.airbnb.android:epoxy-databinding:$epoxyVersion"
Expand Down
34 changes: 17 additions & 17 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"type": "UNIVERSAL",
"filters": [],
"attributes": [],
"versionCode": 9,
"versionName": "1.0.8",
"outputFile": "Animity-v1.0.8-universal-release.apk"
"versionCode": 10,
"versionName": "1.0.9",
"outputFile": "Animity-v1.0.9-universal-release.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -24,9 +24,9 @@
}
],
"attributes": [],
"versionCode": 9,
"versionName": "1.0.8",
"outputFile": "Animity-v1.0.8-x86_64-release.apk"
"versionCode": 10,
"versionName": "1.0.9",
"outputFile": "Animity-v1.0.9-x86_64-release.apk"
},
{
"type": "ONE_OF_MANY",
Expand All @@ -37,35 +37,35 @@
}
],
"attributes": [],
"versionCode": 9,
"versionName": "1.0.8",
"outputFile": "Animity-v1.0.8-x86-release.apk"
"versionCode": 10,
"versionName": "1.0.9",
"outputFile": "Animity-v1.0.9-x86-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 9,
"versionName": "1.0.8",
"outputFile": "Animity-v1.0.8-armeabi-v7a-release.apk"
"versionCode": 10,
"versionName": "1.0.9",
"outputFile": "Animity-v1.0.9-arm64-v8a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 9,
"versionName": "1.0.8",
"outputFile": "Animity-v1.0.8-arm64-v8a-release.apk"
"versionCode": 10,
"versionName": "1.0.9",
"outputFile": "Animity-v1.0.9-armeabi-v7a-release.apk"
}
],
"elementType": "File"
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/graphql/Query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -394,20 +394,6 @@ fragment HomeMedia on Media {
large
medium
}
# recommendations(
# page: 1
# perPage: 25
# sort:ID
# ){
# edges {
# node {
# media {
#
# }
# }
# }
#
# }
streamingEpisodes {
title
thumbnail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class EpisodeModel(
var episodeName: String = "",
var episodeNumber: String,
var episodeUrl: String,
var episodeType: String,
var episodeType: String = "",
var percentage: Int = 0,
var isFiller: Boolean = false
) : Parcelable
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/com/kl3jvi/animity/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.kl3jvi.animity.di


import android.content.Context
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.network.okHttpClient
import com.kl3jvi.animity.data.network.anilist_service.AniListClient
Expand All @@ -11,29 +10,28 @@ import com.kl3jvi.animity.data.network.anime_service.AnimeService
import com.kl3jvi.animity.data.network.interceptor.HeaderInterceptor
import com.kl3jvi.animity.domain.repositories.activity_repositories.LoginRepository
import com.kl3jvi.animity.domain.repositories.persistence_repositories.LocalStorage
import com.kl3jvi.animity.utils.Apollo
import com.kl3jvi.animity.utils.Constants.Companion.ANILIST_API_URL
import com.kl3jvi.animity.utils.Constants.Companion.BASE_URL
import com.kl3jvi.animity.utils.RetrofitClient
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Named
import javax.inject.Singleton
import kotlin.reflect.KParameter

@InstallIn(SingletonComponent::class)
@Module
object NetworkModule {

/* Providing an OkHttpClient to the dagger. */
@Provides
@Singleton
@Apollo
fun provideOkHttpClient(
localStorage: LocalStorage,
loginRepository: LoginRepository,
Expand All @@ -49,10 +47,9 @@ object NetworkModule {
.build()
}


@Provides
@Singleton
@Named("RetrofitOkHttp")
@RetrofitClient
fun provideRetrofitOkHttpClient(): OkHttpClient {
return OkHttpClient.Builder()
.addInterceptor(HttpLoggingInterceptor().apply {
Expand All @@ -68,7 +65,7 @@ object NetworkModule {
@Provides
@Singleton
fun provideRetrofit(
@Named("RetrofitOkHttp") okHttpClient: OkHttpClient
@RetrofitClient okHttpClient: OkHttpClient
): Retrofit {
return Retrofit.Builder()
.baseUrl(BASE_URL)
Expand All @@ -86,7 +83,7 @@ object NetworkModule {
@Provides
@Singleton
fun provideApolloClient(
okHttpClient: OkHttpClient,
@Apollo okHttpClient: OkHttpClient,
): ApolloClient {
return ApolloClient.Builder()
.serverUrl(ANILIST_API_URL)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/kl3jvi/animity/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.ExperimentalCoroutinesApi

@Module
@InstallIn(SingletonComponent::class)
@ExperimentalCoroutinesApi
abstract class RepositoryModule {

@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ package com.kl3jvi.animity.domain.repositories.persistence_repositories

/* It's an interface that defines the properties that are used to store data in the local storage */
interface LocalStorage {
/* It's a property that is used to store the bearer token in the local storage. */
var bearerToken: String?
var refreshToken: String?
var guestToken: String?
var aniListUserId: String?

/* It's a part of the encryption algorithm. */
var iv: String?
var key: String?
var secondKey: String?

/**
* Clears the storage and logs out
*/
fun clearStorage()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.kl3jvi.animity.ui.activities.player

import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageButton
import android.widget.ImageView
Expand Down Expand Up @@ -47,7 +46,6 @@ import okhttp3.OkHttpClient
import okhttp3.dnsoverhttps.DnsOverHttps
import java.io.File
import java.net.InetAddress
import kotlin.math.pow


@ExperimentalCoroutinesApi
Expand Down Expand Up @@ -98,7 +96,7 @@ class PlayerActivity : AppCompatActivity() {

initialisePlayerLayout()
viewModel.updateEpisodeUrl(getIntentData?.episodeUrl.toString())
Log.e("Playback position", playbackPosition.toString())
hideSystemUi()
}
}

Expand All @@ -116,7 +114,6 @@ class PlayerActivity : AppCompatActivity() {

public override fun onResume() {
super.onResume()
hideSystemUi()
if (Util.SDK_INT <= 23 && player == null) {
initializePlayer()
onIsPlayingChanged(isPlaying = true)
Expand Down Expand Up @@ -318,6 +315,7 @@ class PlayerActivity : AppCompatActivity() {
.setAllowChunklessPreparation(true)
.createMediaSource(mediaItem)
} else {
/* Creating a data source factory. */
val dataSource = {
val dataSource: DataSource.Factory = DefaultHttpDataSource.Factory()
.setUserAgent(Constants.USER_AGENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import com.airbnb.epoxy.EpoxyModel
import com.airbnb.epoxy.preload.EpoxyModelPreloader
import com.airbnb.epoxy.preload.PreloadRequestHolder
import com.airbnb.epoxy.preload.ViewMetadata
import androidx.lifecycle.lifecycleScope
import com.kl3jvi.animity.databinding.FragmentHomeBinding
import com.kl3jvi.animity.episodeLarge
import com.kl3jvi.animity.title
import com.kl3jvi.animity.ui.activities.main.MainActivity
import com.kl3jvi.animity.ui.base.BaseFragment
import com.kl3jvi.animity.utils.NetworkUtils.isConnectedToInternet
import com.kl3jvi.animity.utils.observeLiveData
import com.kl3jvi.animity.utils.collectFlow
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch


@ExperimentalCoroutinesApi
@AndroidEntryPoint
class HomeFragment : BaseFragment<HomeViewModel, FragmentHomeBinding>() {
override val viewModel: HomeViewModel by viewModels()
Expand All @@ -33,7 +31,7 @@ class HomeFragment : BaseFragment<HomeViewModel, FragmentHomeBinding>() {
}

private fun fetchHomeData() {
observeLiveData(viewModel.homeData, viewLifecycleOwner) { result ->
collectFlow(viewModel.homeData) { result ->
binding.mainRv.withModels {
binding.loadingIndicator.isVisible = result.newAnime.isEmpty()
buildHome(result, firebaseAnalytics)
Expand All @@ -48,8 +46,9 @@ class HomeFragment : BaseFragment<HomeViewModel, FragmentHomeBinding>() {

private fun handleNetworkChanges() {
requireActivity().isConnectedToInternet(viewLifecycleOwner) { isConnected ->
/* Checking if the user is connected to the internet and if so, it will fetch the data from
the server. */
if (isConnected) fetchHomeData()

binding.apply {
mainRv.isVisible = isConnected
loadingIndicator.isVisible = isConnected
Expand All @@ -58,6 +57,9 @@ class HomeFragment : BaseFragment<HomeViewModel, FragmentHomeBinding>() {
}
}

/**
* It handles network changes.
*/
override fun onStart() {
super.onStart()
handleNetworkChanges()
Expand All @@ -67,27 +69,14 @@ class HomeFragment : BaseFragment<HomeViewModel, FragmentHomeBinding>() {


override fun initViews() {
// binding.button2.setOnClickListener {
// requireContext().launchActivity<PaymentActivity> {
// val dropInRequest = DropInRequest()
// dropInClient = DropInClient(
// requireContext(),
// "sandbox_ykvmgk4j_fssw4nqtc2phhht8",
// dropInRequest
// )
// dropInClient.launchDropInForResult(
// requireActivity(),
// PaymentActivity.DROP_IN_REQUEST_CODE
// )
// }
// }
lifecycleScope.launch {

}
}

override fun getViewBinding(): FragmentHomeBinding = FragmentHomeBinding.inflate(layoutInflater)

companion object {
const val DROP_IN_REQUEST_CODE = 800
}

}


Loading

0 comments on commit f4108c5

Please sign in to comment.