diff --git a/app/src/main/java/com/flab/deepsleep/MainActivity.kt b/app/src/main/java/com/flab/deepsleep/MainActivity.kt index f4a5614..bd8ddfa 100644 --- a/app/src/main/java/com/flab/deepsleep/MainActivity.kt +++ b/app/src/main/java/com/flab/deepsleep/MainActivity.kt @@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity() { /* 버튼 누르면 검색 */ val searchButton: ImageView = binding.searchButton - searchButton.setOnClickListener{ + searchButton.setOnClickListener { val query: String = binding.editText.text.toString() photoViewModel.getSearchPhotos(query) } @@ -45,10 +45,10 @@ class MainActivity : AppCompatActivity() { }) /* 에러 관찰 */ - photoViewModel.errorMessage.observe(this, Observer { - it -> it?.let { - showErrorDialog(it) - } + photoViewModel.errorMessage.observe(this, Observer { it -> + it?.let { + showErrorDialog(it) + } }) }// ./onCreate() @@ -56,6 +56,7 @@ class MainActivity : AppCompatActivity() { photoRecyclerView.layoutManager = LinearLayoutManager(this) photoRecyclerView.adapter = photoAdapter } + private fun showErrorDialog(message: String) { AlertDialog.Builder(this) .setTitle("Error") diff --git a/app/src/main/java/com/flab/deepsleep/data/source/PhotoPagingSource.kt b/app/src/main/java/com/flab/deepsleep/data/source/PhotoPagingSource.kt index 4ffda5a..f05aabd 100644 --- a/app/src/main/java/com/flab/deepsleep/data/source/PhotoPagingSource.kt +++ b/app/src/main/java/com/flab/deepsleep/data/source/PhotoPagingSource.kt @@ -8,7 +8,8 @@ import com.flab.deepsleep.data.repo.UnplashRepositoryImpl class PhotoPagingSource( private val unplashRepositoryImpl: UnplashRepositoryImpl, - private val photoIdList: List): PagingSource() { + private val photoIdList: List +) : PagingSource() { override suspend fun load(params: LoadParams): LoadResult { return try { diff --git a/app/src/main/java/com/flab/deepsleep/ui/photo/PhotoAdapter.kt b/app/src/main/java/com/flab/deepsleep/ui/photo/PhotoAdapter.kt index f9dd67c..848b3f4 100644 --- a/app/src/main/java/com/flab/deepsleep/ui/photo/PhotoAdapter.kt +++ b/app/src/main/java/com/flab/deepsleep/ui/photo/PhotoAdapter.kt @@ -37,8 +37,11 @@ class PhotoAdapter(private var images: List) : companion object { private val PHOTO_COMPARATOR = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: SinglePhoto, newItem: SinglePhoto): Boolean = oldItem.id == newItem.id - override fun areContentsTheSame(oldItem: SinglePhoto, newItem: SinglePhoto): Boolean = oldItem == newItem + override fun areItemsTheSame(oldItem: SinglePhoto, newItem: SinglePhoto): Boolean = + oldItem.id == newItem.id + + override fun areContentsTheSame(oldItem: SinglePhoto, newItem: SinglePhoto): Boolean = + oldItem == newItem } }