-
Connect the device via USB and make sure debugging is enabled.
-
Run
adb tcpip 5555
-
Find the IP address
MACOS: adb shell ip route
fun RecyclerView.applyToolbarNavigationViewWithFabInsets() { | |
applyVerticalInsets() | |
clipToPadding = false | |
addItemDecoration(RecyclerViewToolbarItemDecoration()) | |
addItemDecoration(RecyclerViewBottomNavigationViewFabItemDecoration()) | |
} |
open class RecyclerViewMarginItemDecoration( | |
private val sizeInDp: Int = 16, | |
private val isTop: Boolean = false | |
) : RecyclerView.ItemDecoration() { | |
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { | |
super.getItemOffsets(outRect, view, parent, state) | |
if (isTop) { | |
if (parent.getChildAdapterPosition(view) == 0) { | |
outRect.top = sizeInDp.toPx() |
// Extension function | |
fun TabLayout.setupWithViewPager2( | |
viewPager: ViewPager2, | |
callback: (TabLayout.Tab, Int) -> Unit | |
) { | |
TabLayoutMediator(this, viewPager) { tab, position -> | |
callback.invoke(tab, position) | |
}.attach() | |
} |
import androidx.recyclerview.widget.ListAdapter | |
/** | |
* Creates a copy of itself if no new [data] is passed, this is used | |
* so [ListAdapter] correctly diffs and animates. :facepalms: | |
*/ | |
fun <T> List<T>.refresh(data: List<T> = this): List<T> { | |
return mutableListOf<T>().apply { addAll(data) }.toList() | |
} |
/** | |
* Subclass of VideoView to enable video scaling | |
* CustomAttribute: "scaleType": "normal", "centerCrop", "fill" | |
* <p> | |
* Add this stylable: | |
* <declare-styleable name="IntroVideoView"> | |
* <attr name="scaleType" format="integer"> | |
* <flag name="normal" value="0" /> | |
* <flag name="centerCrop" value="1" /> | |
* <flag name="fill" value="2" /> |
/************************************************ | |
* Insets Section * | |
************************************************/ | |
/******************* | |
* Utility methods * | |
*******************/ | |
fun View.applySystemBarPaddingInsets() { | |
this.doOnApplyWindowInsets { view, insets, padding, _ -> |
We need to generate a unique SSH key for our second GitHub account.
ssh-keygen -t rsa -C "your-email-address"
Be careful that you don't over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY
. In my case, I've saved the file to ~/.ssh/id_rsa_work
.
killall ssh-agent; eval `ssh-agent` |