Package com.github.dreipol.dreidroid.utils

Types

AnimationHelper
Link copied to clipboard
object AnimationHelper

Helper to use for overriding animations in fragments.

BaseViewModelFactory
Link copied to clipboard
class BaseViewModelFactory<T>(creator: () -> T) : ViewModelProvider.Factory
ViewUtils
Link copied to clipboard
object ViewUtils

Functions

allNotNull
Link copied to clipboard
inline fun <R, S, X> allNotNull(a: R?, b: S?, block: (R, S) -> X): X?
inline fun <R, S, T, X> allNotNull(a: R?, b: S?, c: T?, block: (R, S, T) -> X): X?

Execute block if and only if all inputs are not null. Not null parameters are passed to block as input parameters.

awaitCall
Link copied to clipboard
suspend fun <T> awaitCall(call: Call<T>): Response<T>

Awaits retrofit call in coroutine.

disableBackground
Link copied to clipboard
fun disableBackground(view: View, disableBackground: Boolean)

Exposes the attribute "app:disableBackground" for View to use it with viewBinding

getCurrentTab
Link copied to clipboard
fun getCurrentTab(pager: ViewPager): Int

Getter for the bidirectional binding attribute "app:currentTab" for ViewPager

getIsRefreshing
Link copied to clipboard
fun getIsRefreshing(swipeRefreshLayout: SwipeRefreshLayout): Boolean

Getter for the bidirectional binding attribute "app:isRefreshing" for SwipeRefreshLayout

getViewModel
Link copied to clipboard
inline fun <T : ViewModel> Fragment.getViewModel(noinline creator: () -> T? = null): T
inline fun <T : ViewModel> FragmentActivity.getViewModel(noinline creator: () -> T? = null): T
launchInSingleThread
Link copied to clipboard
fun launchInSingleThread(block: suspend CoroutineScope.() -> Unit): Job

Launch a coroutine in a scope that ensure execution on one thread. This is useful when working with realm objects as they can only be used on the thread on which they are created.

onNavigationClicked
Link copied to clipboard
fun onNavigationClicked(toolbar: Toolbar, navigator: Runnable)

Exposes the attribute "app:onNavigationClicked" for Toolbar to use it with viewBinding

onViewClick
Link copied to clipboard
fun onViewClick(view: View, action: Runnable?)

Overrides the attribute "android:onClick" for View to use it with viewBinding

setAdapter
Link copied to clipboard
fun setAdapter(recyclerView: RecyclerView, adapter: RecyclerView.Adapter<RecyclerView.ViewHolder>)

Exposes the attribute "app:adapter" for RecyclerView to use it with viewBinding

setElevation
Link copied to clipboard
fun setElevation(view: View, resource: Int)

Exposes the attribute "android:adapter" for View to use it with viewBinding

setImageResource
Link copied to clipboard
fun setImageResource(imageView: ImageView, resource: Int)

Exposes the attribute "android:src" for ImageView to use it with viewBinding

setIsRefreshing
Link copied to clipboard
fun setIsRefreshing(swipeRefreshLayout: SwipeRefreshLayout, isRefreshing: Boolean)

Setter for the bidirectional binding attribute "app:isRefreshing" for SwipeRefreshLayout

setIsRefreshingListener
Link copied to clipboard
fun setIsRefreshingListener(swipeRefreshLayout: SwipeRefreshLayout, attrChange: InverseBindingListener)

Sets the InverseBindingListener for the bidirectional binding attribute "app:isRefreshing" for SwipeRefreshLayout

setListeners
Link copied to clipboard
fun setListeners(pager: ViewPager, attrChange: InverseBindingListener)

Sets the InverseBindingListener for the bidirectional binding attribute "app:currentTab" for ViewPager

setNewTab
Link copied to clipboard
fun setNewTab(pager: ViewPager, newTab: Int)

Setter for the bidirectional binding attribute "app:currentTab" for ViewPager

setOnNavigationItemSelected
Link copied to clipboard
fun setOnNavigationItemSelected(bottomNavigationView: BottomNavigationView, onNavigationItemSelected: NavigationBarView.OnItemSelectedListener)

Exposes the attribute "app:onNavigationItemSelected" for BottomNavigationView to use it with viewBinding

setOptionalText
Link copied to clipboard
fun setOptionalText(textView: TextView, text: String?)

Exposes the attribute "app:optionalText" for TextView to use it with viewBinding

setOptionalTextResource
Link copied to clipboard
fun setOptionalTextResource(textView: TextView, resource: Int?)

Exposes the attribute "app:optionalTextResource" for TextView to use it with viewBinding

setProgessBarColor
Link copied to clipboard
fun setProgessBarColor(progressBar: ProgressBar, color: Int)

Exposes the attribute "app:progessBarColor" for ProgressBar to use it with viewBinding

setSelectedItem
Link copied to clipboard
fun setSelectedItem(bottomNavigationView: BottomNavigationView, selectedMenuItemResource: Int)

Exposes the attribute "app:selectedItem" for BottomNavigationView to use it with viewBinding

setShowNavigationIcon
Link copied to clipboard
fun setShowNavigationIcon(toolbar: Toolbar, showNavigationIcon: Boolean)

Exposes the attribute "app:showNavigationIcon" for Toolbar to use it with viewBinding

setVisibility
Link copied to clipboard
fun setVisibility(view: View, visible: Boolean)

Exposes the attribute "android:visibility" for View to use it with viewBinding

viewModelFactoryFromCreator
Link copied to clipboard
fun <T : ViewModel> viewModelFactoryFromCreator(creator: () -> T? = null): BaseViewModelFactory<T>?
withStyledAttributes
Link copied to clipboard
fun withStyledAttributes(context: Context, attributes: AttributeSet, styleableId: IntArray, block: (styledAttributes: TypedArray) -> Unit)

Execute block safely with styled attributes