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
main_recyclerView.adapter = adapter | |
main_recyclerView.layoutManager = LinearLayoutManager(this) | |
paginator = RecyclerViewPaginator( | |
recyclerView = main_recyclerView, | |
isLoading = { viewModel.isLoading }, | |
loadMore = { loadMore(it) }, | |
onLast = { viewModel.isOnLast } | |
) |
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
class RecyclerViewPaginator(val recyclerView: RecyclerView, | |
val isLoading: () -> Boolean, | |
val loadMore: (Int) -> Unit, | |
val onLast: () -> Boolean = { true }): RecyclerView.OnScrollListener() { | |
private val threshold = 10 | |
private var currentPage: Int = 0 | |
init { | |
recyclerView.addOnScrollListener(this) |
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
class HistoryViewHolder(view: View, val delegate: Delegate) : BaseViewHolder(view) { | |
interface Delegate { | |
fun onItemClicked(history: History) | |
fun onDeleteHistory(history: History) | |
} | |
private lateinit var history: History | |
private val binding by lazy { DataBindingUtil.bind<ItemHistoryBinding>(view) } |
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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable name="history" type="com.skydoves.githubfollows.models.History"/> | |
</data> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" |
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
fun getUserKeyName() = profile.nameKeyName() | |
fun getPreferenceMenuPosition() = profile.menuPosition | |
fun putPreferenceMenuPosition(position: Int) { profile.putMenuPosition(position) } | |
fun getUserName() = profile.name |
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
@InjectPreference lateinit var profile: Preference_UserProfile | |
init { | |
Timber.d("Injection GithubUserRepository") | |
PreferenceComponent_PrefAppComponent.getInstance().inject(this) | |
} |
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
@PreferenceComponent(entities = [(Profile::class)]) | |
interface PrefAppComponent { | |
fun inject(target: SearchActivityViewModel) | |
fun inject(target: DetailActivityViewModel) | |
fun inject(target: GithubUserRepository) | |
} |
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
@PreferenceEntity(name = "UserProfile") | |
open class Profile { | |
@KeyName(name = "name") @JvmField val userName = "skydoves" | |
@KeyName(name = "menuPosition") @JvmField val selectedPosition = 0 | |
} |
NewerOlder