Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
OsmarICancino committed Nov 5, 2021
1 parent 72d7c96 commit 38c0c02
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.dalvikmx.moviehunter.utilities

import com.dalvikmx.moviehunter.BuildConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.get

object Constants {
const val BASE_URL = BuildConfig.MOVIES_DB_ENDPOINT
const val DEFAULT_REGION = "US"
const val MOVIE_ITEM_KEY = "MOVIE_ITEM_KEY"
const val API_KEY = "api_key"

val apiKey: String by lazy { FirebaseRemoteConfig.getInstance()[API_KEY].asString()}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.res.Resources
import android.util.DisplayMetrics
import com.dalvikmx.moviehunter.BuildConfig
import com.dalvikmx.moviehunter.data.models.containers.MovieResponse
import com.dalvikmx.moviehunter.utilities.Constants.apiKey

private const val POSTER_SIZE_1 = "w92/"
private const val POSTER_SIZE_2 = "w154/"
Expand All @@ -12,8 +13,9 @@ private const val POSTER_SIZE_4 = "w342/"
private const val POSTER_SIZE_5 = "w500/"
private const val POSTER_SIZE_6 = "w780/"


fun MovieResponse.getUrlImage(): String {
return BuildConfig.MOVIE_IMAGE_ENDPOINT + getSizedURL() + posterPath + "?api_key=42f6037782ffa6d0229e74706d3206de"
return BuildConfig.MOVIE_IMAGE_ENDPOINT + getSizedURL() + posterPath + "?api_key=$apiKey"
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.dalvikmx.moviehunter.utilities.extensions

import com.dalvikmx.moviehunter.BuildConfig
import com.dalvikmx.moviehunter.utilities.Constants.apiKey

fun String.getUrlPosterImage(): String {
return BuildConfig.MOVIE_IMAGE_ENDPOINT + getSizedURL() + this + "?api_key=42f6037782ffa6d0229e74706d3206de"
return BuildConfig.MOVIE_IMAGE_ENDPOINT + getSizedURL() + this + "?api_key=${apiKey}"
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<style name="SplashTheme" parent="Theme.MovieHunter">
<item name="android:windowBackground">@drawable/bg_degraded_reddark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<!-- Custom Themes -->
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<style name="SplashTheme" parent="Theme.MovieHunter">
<item name="android:windowBackground">@drawable/bg_degraded_reddark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<!-- Custom Themes -->
Expand Down

0 comments on commit 38c0c02

Please sign in to comment.