Skip to content

Instantly share code, notes, and snippets.

Frank Frank1234

  • Amsterdam, Netherlands
Block or report user

Report or block Frank1234

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 FragmentExtensions.kt
* Navigates only if this is safely possible; when this Fragment is still the current destination.
fun Fragment.navigateSafe(
@IdRes resId: Int,
args: Bundle? = null,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
if (mayNavigate()) findNavController().navigate(
View FragmentExtensions-withoutSafeNagivateMethod.kt
* Returns true if the navigation controller is still pointing at 'this' fragment, or false if it already navigated away.
fun Fragment.mayNavigate(): Boolean {
val navController = findNavController()
val destinationIdInNavController = navController.currentDestination?.id
// add tag_navigation_destination_id to your ids.xml so that it's unique:
val destinationIdOfThisFragment = view?.getTag( ?: destinationIdInNavController
Frank1234 / ApiMainHeadersProvider.kt
Last active Feb 27, 2020
Provides Retrofit Headers
View ApiMainHeadersProvider.kt
class ApiMainHeadersProvider {
* Public headers for calls that do not need an authenticated user.
fun getPublicHeaders(): PublicHeaders =
PublicHeaders().apply {
Frank1234 / ViewBindingHolder.kt
Last active Mar 14, 2020
Holds and manages ViewBinding inside a Fragment.
View ViewBindingHolder.kt
* Holds and manages ViewBinding inside a Fragment.
interface ViewBindingHolder<T : ViewBinding> {
val binding: T?
* Saves the binding for cleanup on onDestroy, calls the specified function [onBound] with `this` value
* as its receiver and returns the bound view root.
Frank1234 / ExampleFragment.kt
Last active Feb 16, 2020
Example Fragment for ViewBindingHolder
View ExampleFragment.kt
class ExampleFragment : Fragment(), ViewBindingHolder<FragmentExampleBinding> by ViewBindingHolderImpl() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = initBinding(FragmentExampleBinding.inflate(layoutInflater), this) {
// do your onCreateView logic here, where 'this' is the binding object.
textTitle.text = "Clean ViewBinding and Lifecycle handling"
Frank1234 / EspressoViewFinder.kt
Last active Nov 23, 2019
Helper methods for Espresso and React Native.
View EspressoViewFinder.kt
import android.view.View
import android.view.ViewGroup
Frank1234 / testUtils.js
Last active Nov 23, 2019
Class that can add testIDs on both Android and iOS debug builds
View testUtils.js
import {Platform} from 'react-native';
const getPlatformTestId = (id: string) =>
Platform.OS === 'ios' ? {testID: id} : {accessible: true, accessibilityLabel: id};
* Adds a testID to the views on Android and iOS in their specific ways. On Android,
* this will result in a ContentDescription on Debug builds (and no changes on live builds).
const setTestID = (id : string) =>
Frank1234 /
Last active Oct 5, 2017
PieGraph, showing progress on a circle chart.
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
* Shows progress on a circle chart.
You can’t perform that action at this time.