Skip to content

Commit

Permalink
fix submission 3
Browse files Browse the repository at this point in the history
  • Loading branch information
fauzanajipray committed May 25, 2021
1 parent cf7ff51 commit 8c944e0
Show file tree
Hide file tree
Showing 28 changed files with 20 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import com.faprayyy.tonton.data.remote.response.MovieDetail
import com.faprayyy.tonton.data.remote.response.MovieModel
import com.faprayyy.tonton.data.remote.response.SeriesDetail
import com.faprayyy.tonton.data.remote.response.SeriesModel
import com.faprayyy.tonton.utils.Converter.convertGenres
import com.faprayyy.tonton.utils.DataDummy.generateDetailMovie
import com.faprayyy.tonton.utils.DataDummy.generateDetailSeries
import com.faprayyy.tonton.utils.DataDummy.generateMoviesList
import com.faprayyy.tonton.utils.DataDummy.generateSeriesList
import com.faprayyy.tonton.utils.EspressoIdlingResource
import com.faprayyy.tonton.utils.convertGenres
import com.faprayyy.tonton.view.ui.main.MainActivity
import org.junit.After
import org.junit.Before
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Tonton">
<activity android:name=".view.ui.favorite.FavoriteActivity"></activity>
<activity android:name=".view.ui.search.SearchActivity" />
<activity android:name=".view.ui.favorite.FavoriteActivity" />
<activity android:name=".view.ui.detail.detailseries.DetailSeriesActivity" />
<activity android:name=".view.ui.splash.SplashActivity">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ abstract class NetworkBoundResource<ResultType, RequestType>(private val executo
if (shouldFecth(data)){
fetchFromNetwork(dbSource)
}else{
resultData.addSource( dbSource ){ data ->
resultData.value = Resource.success( data )
resultData.addSource( dbSource ){
resultData.value = Resource.success( it )
}
}
}
Expand Down Expand Up @@ -73,6 +73,7 @@ abstract class NetworkBoundResource<ResultType, RequestType>(private val executo
resultData.value = Resource.error(data.message, newData)
}
}
else -> { }
}
}
}
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/java/com/faprayyy/tonton/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ object AppModule {
@Provides
@Singleton
fun provideRemoteDataSource(
herbifyDao: MuviDao
apiService: ApiService
) : RemoteDataSource {
return RemoteDataSource(provideApiService())
return RemoteDataSource(apiService)
}

@Provides
Expand Down
25 changes: 0 additions & 25 deletions app/src/main/java/com/faprayyy/tonton/di/Injection.kt

This file was deleted.

8 changes: 0 additions & 8 deletions app/src/main/java/com/faprayyy/tonton/utils/AppExecutors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@ import java.util.concurrent.Executors

class AppExecutors @VisibleForTesting constructor(
private val diskIO: Executor,
private val networkIO: Executor,
private val mainThread: Executor
) {

companion object {
private const val THREAD_COUNT = 3
}

constructor() : this(
Executors.newSingleThreadExecutor(),
Executors.newFixedThreadPool(THREAD_COUNT),
MainThreadExecutor()
)

fun diskIO(): Executor = diskIO

fun networkIO(): Executor = networkIO

fun mainThread(): Executor = mainThread

private class MainThreadExecutor : Executor {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/faprayyy/tonton/utils/DataDummy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.faprayyy.tonton.view.ui.detail.detailseries.DetailSeriesActivity.Comp
import com.google.gson.Gson

object DataDummy{
const val stringListMovieResponse = "{\"page\":1,\"results\":[" +
private const val stringListMovieResponse = "{\"page\":1,\"results\":[" +
"{\"adult\":false,\"backdrop_path\":\"/fPGeS6jgdLovQAKunNHX8l0avCy.jpg\",\"genre_ids\":[28,12,53,10752],\"id\":567189,\"original_language\":\"en\",\"original_title\":\"Tom Clancy's Without Remorse\",\"overview\":\"An elite Navy SEAL uncovers an international conspiracy while seeking justice for the murder of his pregnant wife.\",\"popularity\":3143.69,\"poster_path\":\"/rEm96ib0sPiZBADNKBHKBv5bve9.jpg\",\"release_date\":\"2021-04-29\",\"title\":\"Tom Clancy's Without Remorse\",\"video\":false,\"vote_average\":7.3,\"vote_count\":876}," +
"{\"adult\":false,\"backdrop_path\":\"/6ELCZlTA5lGUops70hKdB83WJxH.jpg\",\"genre_ids\":[28,14,12],\"id\":460465,\"original_language\":\"en\",\"original_title\":\"Mortal Kombat\",\"overview\":\"Washed-up MMA fighter Cole Young, unaware of his heritage, and hunted by Emperor Shang Tsung's best warrior, Sub-Zero, seeks out and trains with Earth's greatest champions as he prepares to stand against the enemies of Outworld in a high stakes battle for the universe.\",\"popularity\":2681.013,\"poster_path\":\"/nkayOAUBUu4mMvyNf9iHSUiPjF1.jpg\",\"release_date\":\"2021-04-07\",\"title\":\"Mortal Kombat\",\"video\":false,\"vote_average\":7.6,\"vote_count\":2482}," +
"{\"adult\":false,\"backdrop_path\":\"/6zbKgwgaaCyyBXE4Sun4oWQfQmi.jpg\",\"genre_ids\":[28,53,80,35],\"id\":615457,\"original_language\":\"en\",\"original_title\":\"Nobody\",\"overview\":\"Hutch Mansell, a suburban dad, overlooked husband, nothing neighbor — a \\\"nobody.\\\" When two thieves break into his home one night, Hutch's unknown long-simmering rage is ignited and propels him on a brutal path that will uncover dark secrets he fought to leave behind.\",\"popularity\":1602.076,\"poster_path\":\"/oBgWY00bEFeZ9N25wWVyuQddbAo.jpg\",\"release_date\":\"2021-03-26\",\"title\":\"Nobody\",\"video\":false,\"vote_average\":8.4,\"vote_count\":1483}," +
Expand Down Expand Up @@ -53,9 +53,9 @@ object DataDummy{
"{\"backdrop_path\":\"/pLG4ihU1d2XkQbASQDjsFu9U7d9.jpg\",\"first_air_date\":\"2021-03-24\",\"genre_ids\":[18,80,9648],\"id\":120168,\"name\":\"Who Killed Sara?\",\"origin_country\":[\"MX\"],\"original_language\":\"es\",\"original_name\":\"¿Quién mató a Sara?\",\"overview\":\"Hell-bent on exacting revenge and proving he was framed for his sister's murder, Álex sets out to unearth much more than the crime's real culprit.\",\"popularity\":397.662,\"poster_path\":\"/o7uk5ChRt3quPIv8PcvPfzyXdMw.jpg\",\"vote_average\":7.8,\"vote_count\":495}," +
"{\"backdrop_path\":\"/fRYwdeNjMqC30EhofPx5PlDpdun.jpg\",\"first_air_date\":\"2018-10-25\",\"genre_ids\":[10765,18],\"id\":79460,\"name\":\"Legacies\",\"origin_country\":[\"US\"],\"original_language\":\"en\",\"original_name\":\"Legacies\",\"overview\":\"In a place where young witches, vampires, and werewolves are nurtured to be their best selves in spite of their worst impulses, Klaus Mikaelson’s daughter, 17-year-old Hope Mikaelson, Alaric Saltzman’s twins, Lizzie and Josie Saltzman, among others, come of age into heroes and villains at The Salvatore School for the Young and Gifted.\",\"popularity\":388.79,\"poster_path\":\"/qTZIgXrBKURBK1KrsT7fe3qwtl9.jpg\",\"vote_average\":8.6,\"vote_count\":1865}],\"total_pages\":500,\"total_results\":10000}"

const val stringDetailMovieResponse = "{\"adult\":false,\"backdrop_path\":\"/fPGeS6jgdLovQAKunNHX8l0avCy.jpg\",\"belongs_to_collection\":null,\"budget\":0,\"genres\":[{\"id\":28,\"name\":\"Action\"},{\"id\":53,\"name\":\"Thriller\"},{\"id\":10752,\"name\":\"War\"}],\"homepage\":\"https://www.amazon.com/dp/B08VFD1Y3B\",\"id\":567189,\"imdb_id\":\"tt0499097\",\"original_language\":\"en\",\"original_title\":\"Tom Clancy's Without Remorse\",\"overview\":\"An elite Navy SEAL uncovers an international conspiracy while seeking justice for the murder of his pregnant wife.\",\"popularity\":3143.69,\"poster_path\":\"/rEm96ib0sPiZBADNKBHKBv5bve9.jpg\",\"production_companies\":[{\"id\":4,\"logo_path\":\"/fycMZt242LVjagMByZOLUGbCvv3.png\",\"name\":\"Paramount\",\"origin_country\":\"US\"},{\"id\":433,\"logo_path\":null,\"name\":\"Weed Road Pictures\",\"origin_country\":\"US\"},{\"id\":82819,\"logo_path\":\"/5Z8WWr0Lf1tInVWwJsxPP0uMz9a.png\",\"name\":\"Skydance Media\",\"origin_country\":\"US\"},{\"id\":51593,\"logo_path\":null,\"name\":\"Midnight Radio\",\"origin_country\":\"US\"},{\"id\":102334,\"logo_path\":\"/espa8KYmHedu5p7GRrP9FFICLUp.png\",\"name\":\"Outlier Society Productions\",\"origin_country\":\"US\"},{\"id\":114732,\"logo_path\":\"/tNCbisMxO5mX2X2bOQxHHQZVYnT.png\",\"name\":\"New Republic Pictures\",\"origin_country\":\"US\"},{\"id\":20580,\"logo_path\":\"/tkFE81jJIqiFYPP8Tho57MXRQEx.png\",\"name\":\"Amazon Studios\",\"origin_country\":\"US\"}],\"production_countries\":[{\"iso_3166_1\":\"US\",\"name\":\"United States of America\"}],\"release_date\":\"2021-04-29\",\"revenue\":0,\"runtime\":109,\"spoken_languages\":[{\"english_name\":\"English\",\"iso_639_1\":\"en\",\"name\":\"English\"}],\"status\":\"Released\",\"tagline\":\"From Tom Clancy, the author of Rainbow Six.\",\"title\":\"Tom Clancy's Without Remorse\",\"video\":false,\"vote_average\":7.3,\"vote_count\":992}"
private const val stringDetailMovieResponse = "{\"adult\":false,\"backdrop_path\":\"/fPGeS6jgdLovQAKunNHX8l0avCy.jpg\",\"belongs_to_collection\":null,\"budget\":0,\"genres\":[{\"id\":28,\"name\":\"Action\"},{\"id\":53,\"name\":\"Thriller\"},{\"id\":10752,\"name\":\"War\"}],\"homepage\":\"https://www.amazon.com/dp/B08VFD1Y3B\",\"id\":567189,\"imdb_id\":\"tt0499097\",\"original_language\":\"en\",\"original_title\":\"Tom Clancy's Without Remorse\",\"overview\":\"An elite Navy SEAL uncovers an international conspiracy while seeking justice for the murder of his pregnant wife.\",\"popularity\":3143.69,\"poster_path\":\"/rEm96ib0sPiZBADNKBHKBv5bve9.jpg\",\"production_companies\":[{\"id\":4,\"logo_path\":\"/fycMZt242LVjagMByZOLUGbCvv3.png\",\"name\":\"Paramount\",\"origin_country\":\"US\"},{\"id\":433,\"logo_path\":null,\"name\":\"Weed Road Pictures\",\"origin_country\":\"US\"},{\"id\":82819,\"logo_path\":\"/5Z8WWr0Lf1tInVWwJsxPP0uMz9a.png\",\"name\":\"Skydance Media\",\"origin_country\":\"US\"},{\"id\":51593,\"logo_path\":null,\"name\":\"Midnight Radio\",\"origin_country\":\"US\"},{\"id\":102334,\"logo_path\":\"/espa8KYmHedu5p7GRrP9FFICLUp.png\",\"name\":\"Outlier Society Productions\",\"origin_country\":\"US\"},{\"id\":114732,\"logo_path\":\"/tNCbisMxO5mX2X2bOQxHHQZVYnT.png\",\"name\":\"New Republic Pictures\",\"origin_country\":\"US\"},{\"id\":20580,\"logo_path\":\"/tkFE81jJIqiFYPP8Tho57MXRQEx.png\",\"name\":\"Amazon Studios\",\"origin_country\":\"US\"}],\"production_countries\":[{\"iso_3166_1\":\"US\",\"name\":\"United States of America\"}],\"release_date\":\"2021-04-29\",\"revenue\":0,\"runtime\":109,\"spoken_languages\":[{\"english_name\":\"English\",\"iso_639_1\":\"en\",\"name\":\"English\"}],\"status\":\"Released\",\"tagline\":\"From Tom Clancy, the author of Rainbow Six.\",\"title\":\"Tom Clancy's Without Remorse\",\"video\":false,\"vote_average\":7.3,\"vote_count\":996}"

const val stringDetailSeriesResponse = "{\"backdrop_path\":\"/b0WmHGc8LHTdGCVzxRb3IBMur57.jpg\",\"created_by\":[{\"id\":1868712,\"credit_id\":\"605508e2960cde00721fc5e8\",\"name\":\"Malcolm Spellman\",\"gender\":2,\"profile_path\":\"/cNqxh76tysL9D8RcCKR6XqcoyW0.jpg\"}],\"episode_run_time\":[50],\"first_air_date\":\"2021-03-19\",\"genres\":[{\"id\":10765,\"name\":\"Sci-Fi & Fantasy\"},{\"id\":10759,\"name\":\"Action & Adventure\"},{\"id\":18,\"name\":\"Drama\"},{\"id\":10768,\"name\":\"War & Politics\"}],\"homepage\":\"https://www.disneyplus.com/series/the-falcon-and-the-winter-soldier/4gglDBMx8icA\",\"id\":88396,\"in_production\":false,\"languages\":[\"en\"],\"last_air_date\":\"2021-04-23\",\"last_episode_to_air\":{\"air_date\":\"2021-04-23\",\"episode_number\":6,\"id\":2558743,\"name\":\"One World, One People\",\"overview\":\"As The Flag Smashers escalate their efforts, Sam and Bucky take action.\",\"production_code\":\"\",\"season_number\":1,\"still_path\":\"/qXxCqMP7aj3rGndhVfGUyyU6hyq.jpg\",\"vote_average\":7.375,\"vote_count\":8},\"name\":\"The Falcon and the Winter Soldier\",\"next_episode_to_air\":null,\"networks\":[{\"name\":\"Disney+\",\"id\":2739,\"logo_path\":\"/gJ8VX6JSu3ciXHuC2dDGAo2lvwM.png\",\"origin_country\":\"US\"}],\"number_of_episodes\":6,\"number_of_seasons\":1,\"origin_country\":[\"US\"],\"original_language\":\"en\",\"original_name\":\"The Falcon and the Winter Soldier\",\"overview\":\"Following the events of “Avengers: Endgame”, the Falcon, Sam Wilson and the Winter Soldier, Bucky Barnes team up in a global adventure that tests their abilities, and their patience.\",\"popularity\":1143.513,\"poster_path\":\"/6kbAMLteGO8yyewYau6bJ683sw7.jpg\",\"production_companies\":[{\"id\":420,\"logo_path\":\"/hUzeosd33nzE5MCNsZxCGEKTXaQ.png\",\"name\":\"Marvel Studios\",\"origin_country\":\"US\"}],\"production_countries\":[{\"iso_3166_1\":\"US\",\"name\":\"United States of America\"}],\"seasons\":[{\"air_date\":\"2021-03-19\",\"episode_count\":6,\"id\":156676,\"name\":\"Season 1\",\"overview\":\"\",\"poster_path\":\"/fIT6Y6O3cUX1X8qY8pZgzEvxUDQ.jpg\",\"season_number\":1}],\"spoken_languages\":[{\"english_name\":\"English\",\"iso_639_1\":\"en\",\"name\":\"English\"}],\"status\":\"Ended\",\"tagline\":\"Honor the shield.\",\"type\":\"Miniseries\",\"vote_average\":7.9,\"vote_count\":5620}"
private const val stringDetailSeriesResponse = "{\"backdrop_path\":\"/b0WmHGc8LHTdGCVzxRb3IBMur57.jpg\",\"created_by\":[{\"id\":1868712,\"credit_id\":\"605508e2960cde00721fc5e8\",\"name\":\"Malcolm Spellman\",\"gender\":2,\"profile_path\":\"/cNqxh76tysL9D8RcCKR6XqcoyW0.jpg\"}],\"episode_run_time\":[50],\"first_air_date\":\"2021-03-19\",\"genres\":[{\"id\":10765,\"name\":\"Sci-Fi & Fantasy\"},{\"id\":10759,\"name\":\"Action & Adventure\"},{\"id\":18,\"name\":\"Drama\"},{\"id\":10768,\"name\":\"War & Politics\"}],\"homepage\":\"https://www.disneyplus.com/series/the-falcon-and-the-winter-soldier/4gglDBMx8icA\",\"id\":88396,\"in_production\":false,\"languages\":[\"en\"],\"last_air_date\":\"2021-04-23\",\"last_episode_to_air\":{\"air_date\":\"2021-04-23\",\"episode_number\":6,\"id\":2558743,\"name\":\"One World, One People\",\"overview\":\"As The Flag Smashers escalate their efforts, Sam and Bucky take action.\",\"production_code\":\"\",\"season_number\":1,\"still_path\":\"/qXxCqMP7aj3rGndhVfGUyyU6hyq.jpg\",\"vote_average\":7.375,\"vote_count\":8},\"name\":\"The Falcon and the Winter Soldier\",\"next_episode_to_air\":null,\"networks\":[{\"name\":\"Disney+\",\"id\":2739,\"logo_path\":\"/gJ8VX6JSu3ciXHuC2dDGAo2lvwM.png\",\"origin_country\":\"US\"}],\"number_of_episodes\":6,\"number_of_seasons\":1,\"origin_country\":[\"US\"],\"original_language\":\"en\",\"original_name\":\"The Falcon and the Winter Soldier\",\"overview\":\"Following the events of “Avengers: Endgame”, the Falcon, Sam Wilson and the Winter Soldier, Bucky Barnes team up in a global adventure that tests their abilities, and their patience.\",\"popularity\":1143.513,\"poster_path\":\"/6kbAMLteGO8yyewYau6bJ683sw7.jpg\",\"production_companies\":[{\"id\":420,\"logo_path\":\"/hUzeosd33nzE5MCNsZxCGEKTXaQ.png\",\"name\":\"Marvel Studios\",\"origin_country\":\"US\"}],\"production_countries\":[{\"iso_3166_1\":\"US\",\"name\":\"United States of America\"}],\"seasons\":[{\"air_date\":\"2021-03-19\",\"episode_count\":6,\"id\":156676,\"name\":\"Season 1\",\"overview\":\"\",\"poster_path\":\"/fIT6Y6O3cUX1X8qY8pZgzEvxUDQ.jpg\",\"season_number\":1}],\"spoken_languages\":[{\"english_name\":\"English\",\"iso_639_1\":\"en\",\"name\":\"English\"}],\"status\":\"Ended\",\"tagline\":\"Honor the shield.\",\"type\":\"Miniseries\",\"vote_average\":7.9,\"vote_count\":5620}"

fun generateMoviesList() : ArrayList<MovieModel>{
val obj = Gson().fromJson(stringListMovieResponse, DiscoverMovieResponse::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.faprayyy.tonton.view.adapter

import android.annotation.SuppressLint
import android.app.Activity
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.paging.PagedListAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ package com.faprayyy.tonton.view.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.faprayyy.tonton.R
import com.faprayyy.tonton.data.local.entity.MovieEntity
import com.faprayyy.tonton.data.local.entity.SeriesEntity
import com.faprayyy.tonton.data.remote.Config
import com.faprayyy.tonton.data.remote.response.SeriesModel
import com.faprayyy.tonton.databinding.ItemMovieBinding

class SeriesAdapter(private val listener : OnItemClickCallback) : PagedListAdapter<SeriesEntity, SeriesAdapter.SeriesViewHolder>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.faprayyy.tonton.data.remote.response.MovieDetail
import com.faprayyy.tonton.databinding.ActivityDetailMovieBinding
import com.faprayyy.tonton.utils.Converter.convertGenres
import com.faprayyy.tonton.view.ui.detail.DetailViewModel
import com.faprayyy.tonton.view.ui.search.SearchActivity
import com.faprayyy.tonton.view.ui.favorite.FavoriteActivity
import com.faprayyy.tonton.vo.StatusMessage
import dagger.hilt.android.AndroidEntryPoint
import java.util.*
Expand Down Expand Up @@ -201,8 +201,8 @@ class DetailMovieActivity : AppCompatActivity() {
setOnMenuItemClickListener {
when(it?.itemId){
R.id.menu_share_item -> { onShareClick(movieDetail) }
R.id.menu_search_item -> {
val intent = Intent(context, SearchActivity::class.java)
R.id.menu_favorite_item -> {
val intent = Intent(context, FavoriteActivity::class.java)
startActivity(intent)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.faprayyy.tonton.data.remote.response.SeriesDetail
import com.faprayyy.tonton.databinding.ActivityDetailSeriesBinding
import com.faprayyy.tonton.utils.Converter.convertGenres
import com.faprayyy.tonton.view.ui.detail.DetailViewModel
import com.faprayyy.tonton.view.ui.search.SearchActivity
import com.faprayyy.tonton.view.ui.favorite.FavoriteActivity
import com.faprayyy.tonton.vo.StatusMessage
import dagger.hilt.android.AndroidEntryPoint
import java.util.*
Expand Down Expand Up @@ -190,8 +190,8 @@ class DetailSeriesActivity : AppCompatActivity() {
setOnMenuItemClickListener {
when(it?.itemId){
R.id.menu_share_item -> { onShareClick(seriesDetail) }
R.id.menu_search_item -> {
val intent = Intent(context, SearchActivity::class.java)
R.id.menu_favorite_item -> {
val intent = Intent(context, FavoriteActivity::class.java)
startActivity(intent)
}
}
Expand Down
Loading

0 comments on commit 8c944e0

Please sign in to comment.