diff --git a/app/src/main/java/com/example/movist/presentation/adapter/MovieFavAdapter.kt b/app/src/main/java/com/example/movist/presentation/adapter/MovieFavAdapter.kt index 79316f9..2523787 100644 --- a/app/src/main/java/com/example/movist/presentation/adapter/MovieFavAdapter.kt +++ b/app/src/main/java/com/example/movist/presentation/adapter/MovieFavAdapter.kt @@ -51,6 +51,10 @@ class MovieFavAdapter(private val onMovieClickListener : OnMovieClickListener) onMovieClickListener.removeMovie(item, items.size) removeSingle(item) } + + cvItem.setOnClickListener { + onMovieClickListener.onItemClick(item.movieId) + } } } } @@ -63,5 +67,6 @@ class MovieFavAdapter(private val onMovieClickListener : OnMovieClickListener) interface OnMovieClickListener{ fun removeMovie(movie: MovieFavorite, size : Int) + fun onItemClick(id : Int) } } \ No newline at end of file diff --git a/app/src/main/java/com/example/movist/presentation/view/favorite/FavoriteActivity.kt b/app/src/main/java/com/example/movist/presentation/view/favorite/FavoriteActivity.kt index 2733f2f..708a1f7 100644 --- a/app/src/main/java/com/example/movist/presentation/view/favorite/FavoriteActivity.kt +++ b/app/src/main/java/com/example/movist/presentation/view/favorite/FavoriteActivity.kt @@ -1,10 +1,12 @@ package com.example.movist.presentation.view.favorite +import android.content.Intent import android.os.Bundle import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import com.example.movist.databinding.ActivityFavoriteMoviesBinding import com.example.movist.presentation.adapter.MovieFavAdapter +import com.example.movist.presentation.view.detail.DetailActivity import com.example.movist.services.storage.entities.MovieFavorite import com.example.movist.util.remove import com.example.movist.util.show @@ -21,6 +23,11 @@ class FavoriteActivity : AppCompatActivity() { private var size = 0 + override fun onResume() { + super.onResume() + _viewModel.getFavMovie() + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) _binding = ActivityFavoriteMoviesBinding.inflate(layoutInflater) @@ -39,6 +46,11 @@ class FavoriteActivity : AppCompatActivity() { _viewModel.removeFavMovie(movie) size = mSize } + + override fun onItemClick(id: Int) { + startActivity(Intent(this@FavoriteActivity, DetailActivity::class.java) + .putExtra("movie_id",id)) + } }) ibTrash.setOnClickListener { @@ -48,10 +60,15 @@ class FavoriteActivity : AppCompatActivity() { rvContent.adapter = _adapter _viewModel.movies.observe(this@FavoriteActivity,{ data -> + _adapter.removeAll() + if(data.isNotEmpty()){ clEmptyFavorite.remove() ibTrash.isEnabled = true _adapter.populatedData(data) + }else{ + clEmptyFavorite.show() + ibTrash.isEnabled = false } }) diff --git a/app/src/main/java/com/example/movist/presentation/view/splashScreen/SplashScreenActivity.kt b/app/src/main/java/com/example/movist/presentation/view/splashScreen/SplashScreenActivity.kt index 2c25977..10bf751 100644 --- a/app/src/main/java/com/example/movist/presentation/view/splashScreen/SplashScreenActivity.kt +++ b/app/src/main/java/com/example/movist/presentation/view/splashScreen/SplashScreenActivity.kt @@ -17,6 +17,7 @@ class SplashScreenActivity : AppCompatActivity() { setContentView(view) val r = Runnable { + finish() startActivity(Intent(this, DashboardActivity::class.java)) }