forked from woowacourse-teams/2023-emmsale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: 행사 목록 스크롤 시 버벅거림 (woowacourse-teams#913)
Related to: woowacourse-teams#912
- Loading branch information
Showing
12 changed files
with
93 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
.../com/emmsale/presentation/ui/conferenceList/recyclerView/ConferenceRecyclerViewAdapter.kt
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
.../java/com/emmsale/presentation/ui/conferenceList/recyclerView/EventRecyclerViewAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.emmsale.presentation.ui.conferenceList.recyclerView | ||
|
||
import android.graphics.drawable.Drawable | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.ListPreloader.PreloadModelProvider | ||
import com.bumptech.glide.RequestBuilder | ||
import com.bumptech.glide.RequestManager | ||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader | ||
import com.bumptech.glide.load.resource.bitmap.CenterCrop | ||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners | ||
import com.bumptech.glide.util.ViewPreloadSizeProvider | ||
import com.emmsale.data.model.Event | ||
import com.emmsale.presentation.common.extension.dp | ||
|
||
class EventRecyclerViewAdapter( | ||
private val fragment: Fragment, | ||
private val onClickConference: (Event) -> Unit, | ||
private val onPreloaderReady: (preloader: RecyclerViewPreloader<Event>) -> Unit, | ||
) : ListAdapter<Event, EventViewHolder>(EventDiffUtil), PreloadModelProvider<Event> { | ||
|
||
private var isFirstPreloader: Boolean = true | ||
|
||
private val requestManager: RequestManager = Glide.with(fragment) | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int, | ||
): EventViewHolder = EventViewHolder( | ||
parent = parent, | ||
onClickConference = onClickConference, | ||
onEventPosterPreDraw = { view -> | ||
if (isFirstPreloader) { | ||
isFirstPreloader = false | ||
val preloader = RecyclerViewPreloader( | ||
fragment, | ||
this, | ||
ViewPreloadSizeProvider(view), | ||
MAX_PRELOAD, | ||
) | ||
onPreloaderReady(preloader) | ||
} | ||
}, | ||
) | ||
|
||
override fun onBindViewHolder(holder: EventViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
|
||
override fun getPreloadItems(position: Int): MutableList<Event> = | ||
mutableListOf(getItem(position)) | ||
|
||
override fun getPreloadRequestBuilder(event: Event): RequestBuilder<Drawable> = requestManager | ||
.load(event.posterImageUrl) | ||
.transform(CenterCrop(), RoundedCorners(15.dp)) | ||
|
||
companion object { | ||
private const val MAX_PRELOAD = 8 | ||
} | ||
} |
12 changes: 8 additions & 4 deletions
12
...List/recyclerView/ConferenceViewHolder.kt → ...renceList/recyclerView/EventViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.