Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseoRyu committed Jan 1, 2025
1 parent 26d7eb7 commit 4aff3fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/com/flab/deepsleep/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -45,17 +45,18 @@ class MainActivity : AppCompatActivity() {
})

/* 에러 관찰 */
photoViewModel.errorMessage.observe(this, Observer {
it -> it?.let {
showErrorDialog(it)
}
photoViewModel.errorMessage.observe(this, Observer { it ->
it?.let {
showErrorDialog(it)
}
})
}// ./onCreate()

private fun setupRecyclerView() {
photoRecyclerView.layoutManager = LinearLayoutManager(this)
photoRecyclerView.adapter = photoAdapter
}

private fun showErrorDialog(message: String) {
AlertDialog.Builder(this)
.setTitle("Error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import com.flab.deepsleep.data.repo.UnplashRepositoryImpl

class PhotoPagingSource(
private val unplashRepositoryImpl: UnplashRepositoryImpl,
private val photoIdList: List<String>): PagingSource<Int, SinglePhoto>() {
private val photoIdList: List<String>
) : PagingSource<Int, SinglePhoto>() {

override suspend fun load(params: LoadParams<Int>): LoadResult<Int, SinglePhoto> {
return try {
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/flab/deepsleep/ui/photo/PhotoAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class PhotoAdapter(private var images: List<String?>) :

companion object {
private val PHOTO_COMPARATOR = object : DiffUtil.ItemCallback<SinglePhoto>() {
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
}
}

Expand Down

0 comments on commit 4aff3fe

Please sign in to comment.