Skip to content

Instantly share code, notes, and snippets.

☕️
Coffee coffee

Jaewoong Eum skydoves

☕️
Coffee coffee
Block or report user

Report or block skydoves

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PowerMenuExample06.java
CustomPowerMenu customPowerMenu = new CustomPowerMenu.Builder<>(context, new IconMenuAdapter())
.addItem(new IconPowerMenuItem(context.getResources().getDrawable(R.drawable.ic_wechat), "WeChat"))
.addItem(new IconPowerMenuItem(context.getResources().getDrawable(R.drawable.ic_facebook), "Facebook"))
.addItem(new IconPowerMenuItem(context.getResources().getDrawable(R.drawable.ic_twitter), "Twitter"))
.addItem(new IconPowerMenuItem(context.getResources().getDrawable(R.drawable.ic_line), "Line"))
.setOnMenuItemClickListener(onIconMenuItemClickListener)
.setAnimation(MenuAnimation.SHOWUP_TOP_RIGHT)
.setMenuRadius(10f)
.setMenuShadow(10f)
.build();
View PowerMenuExample.java
PowerMenu powerMenu = new PowerMenu.Builder(context)
.addItemList(list) // list has "Novel", "Poerty", "Art"
.addItem(new PowerMenuItem("Journals", false))
.addItem(new PowerMenuItem("Travel", false))
.setAnimation(MenuAnimation.SHOWUP_TOP_LEFT) // Animation start point (TOP | LEFT)
.setMenuRadius(10f)
.setMenuShadow(10f)
.setTextColor(context.getResources().getColor(R.color.md_grey_800))
.setSelectedTextColor(Color.WHITE)
.setMenuColor(Color.WHITE)
View paginator.kt
main_recyclerView.adapter = adapter
main_recyclerView.layoutManager = LinearLayoutManager(this)
paginator = RecyclerViewPaginator(
recyclerView = main_recyclerView,
isLoading = { viewModel.isLoading },
loadMore = { loadMore(it) },
onLast = { viewModel.isOnLast }
)
View RecyclerViewPaginator.kt
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)
View HistoryViewHolder.kt
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) }
View item_history.xml
<?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"
View Preference_Profile.kt
fun getUserKeyName() = profile.nameKeyName()
fun getPreferenceMenuPosition() = profile.menuPosition
fun putPreferenceMenuPosition(position: Int) { profile.putMenuPosition(position) }
fun getUserName() = profile.name
@skydoves
skydoves / PreferenceComponent_PrefAppComponent.kt
Created Mar 16, 2018
PreferenceComponent_PrefAppComponent
View PreferenceComponent_PrefAppComponent.kt
@InjectPreference lateinit var profile: Preference_UserProfile
init {
Timber.d("Injection GithubUserRepository")
PreferenceComponent_PrefAppComponent.getInstance().inject(this)
}
View PrefAppComponent.kt
@PreferenceComponent(entities = [(Profile::class)])
interface PrefAppComponent {
fun inject(target: SearchActivityViewModel)
fun inject(target: DetailActivityViewModel)
fun inject(target: GithubUserRepository)
}
View Profile.kt
@PreferenceEntity(name = "UserProfile")
open class Profile {
@KeyName(name = "name") @JvmField val userName = "skydoves"
@KeyName(name = "menuPosition") @JvmField val selectedPosition = 0
}
You can’t perform that action at this time.