Skip to content

Instantly share code, notes, and snippets.

View skydoves's full-sized avatar
💡
Practice is the only shortcut

Jaewoong Eum skydoves

💡
Practice is the only shortcut
View GitHub Profile
@skydoves
skydoves / PowerMenuExample06.java
Created January 23, 2019 10:51
PowerMenuExample06
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();
@skydoves
skydoves / PowerMenuExample.java
Created January 23, 2019 10:21
PowerMenu Example
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)
@skydoves
skydoves / paginator.kt
Created March 16, 2018 02:46
paginator
main_recyclerView.adapter = adapter
main_recyclerView.layoutManager = LinearLayoutManager(this)
paginator = RecyclerViewPaginator(
recyclerView = main_recyclerView,
isLoading = { viewModel.isLoading },
loadMore = { loadMore(it) },
onLast = { viewModel.isOnLast }
)
@skydoves
skydoves / RecyclerViewPaginator.kt
Created March 16, 2018 02:44
RecyclerViewPaginator
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)
@skydoves
skydoves / HistoryViewHolder.kt
Created March 16, 2018 02:34
HistoryViewHolder
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) }
@skydoves
skydoves / item_history.xml
Created March 16, 2018 02:30
item_history
<?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"
@skydoves
skydoves / Preference_Profile.kt
Created March 16, 2018 02:18
Preference_Profile
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 March 16, 2018 02:13
PreferenceComponent_PrefAppComponent
@InjectPreference lateinit var profile: Preference_UserProfile
init {
Timber.d("Injection GithubUserRepository")
PreferenceComponent_PrefAppComponent.getInstance().inject(this)
}
@skydoves
skydoves / PrefAppComponent.kt
Created March 16, 2018 02:09
PrefAppComponent
@PreferenceComponent(entities = [(Profile::class)])
interface PrefAppComponent {
fun inject(target: SearchActivityViewModel)
fun inject(target: DetailActivityViewModel)
fun inject(target: GithubUserRepository)
}
@skydoves
skydoves / Profile.kt
Created March 16, 2018 02:08
Profile Entity
@PreferenceEntity(name = "UserProfile")
open class Profile {
@KeyName(name = "name") @JvmField val userName = "skydoves"
@KeyName(name = "menuPosition") @JvmField val selectedPosition = 0
}