SHARE
TWEET

Untitled

a guest Oct 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.alhaz.tutorial.architecturecomponent.views.movies.list
  2.  
  3. import android.content.Intent
  4. import androidx.appcompat.app.AppCompatActivity
  5. import android.os.Bundle
  6. import android.view.View
  7. import androidx.recyclerview.widget.LinearLayoutManager
  8. import kotlinx.android.synthetic.main.activity_movie_list.*
  9. import me.alhaz.tutorial.architecturecomponent.R
  10. import me.alhaz.tutorial.architecturecomponent.models.database.DataDummy
  11. import me.alhaz.tutorial.architecturecomponent.models.repositories.movie.remote.response.Movie
  12. import me.alhaz.tutorial.architecturecomponent.views.movies.detail.MovieDetailActivity
  13.  
  14. class MovieListActivity : AppCompatActivity() {
  15.  
  16.     private lateinit var movieListAdapter: MovieListAdapter
  17.     private lateinit var movies: ArrayList<Movie>
  18.  
  19.     override fun onCreate(savedInstanceState: Bundle?) {
  20.         super.onCreate(savedInstanceState)
  21.         setContentView(R.layout.activity_movie_list)
  22.  
  23.         setupData()
  24.         setupLayout()
  25.     }
  26.  
  27.     fun setupData() {
  28.         movies = DataDummy.generateListMovie()
  29.     }
  30.  
  31.     fun setupLayout() {
  32.         rvMovies.setHasFixedSize(true)
  33.         rvMovies.layoutManager = LinearLayoutManager(this)
  34.         movieListAdapter = MovieListAdapter(this, movies, clickListener = { movie ->
  35.             openDetailMoviePage(movie)
  36.         })
  37.         rvMovies.adapter = movieListAdapter
  38.         if (movies.size > 0) {
  39.             progressBar.visibility = View.GONE
  40.             rvMovies.visibility = View.VISIBLE
  41.         }
  42.         else {
  43.             progressBar.visibility = View.VISIBLE
  44.             rvMovies.visibility = View.GONE
  45.         }
  46.     }
  47.  
  48.     fun openDetailMoviePage(movie: Movie) {
  49.         val intent = Intent(this, MovieDetailActivity::class.java)
  50.         intent.putExtra("movie", movie)
  51.         startActivity(intent)
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top