{% setvar book_path %}/reference/dokkatest/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SamplerKt

public final class SamplerKt


Summary

Public methods

static final @NonNull Pair<@NonNull Float, @NonNull Float>

top-level extension property docs

static final String

top-level non-extension property docs

static final @NonNull Pair<@NonNull Float, @NonNull Float>

top-level extension function docs

static final void

top-level non-extension function docs

Public methods

getTopLevelExtensionProperty

public static final @NonNull Pair<@NonNull Float, @NonNull FloatgetTopLevelExtensionProperty(@NonNull List<@NonNull String> receiver)

top-level extension property docs

import androidx.notARealLibrary.Thingy1

class CustomPainter() {

    val size: Pair<Float, Float>
        get() = Pair(300.0f, 300.0f)

    override fun toString(): String {
        return "ahahahaha"
    }

    val weAreUsingThingy1 = Thingy1()

}

and after some text, we have another sample

import androidx.anotherFakeLibrary.FooFooFoo

val weAreUsingFooFooFoo by lazy { FooFooFoo() }

getTopLevelProperty

public static final String getTopLevelProperty()

top-level non-extension property docs

import androidx.notARealLibrary.Thingy1

class CustomPainter() {

    val size: Pair<Float, Float>
        get() = Pair(300.0f, 300.0f)

    override fun toString(): String {
        return "ahahahaha"
    }

    val weAreUsingThingy1 = Thingy1()

}

and this is a Java sample from Kotlin source using Kotlin syntax (does not work):

dokkatest.sampleAnnotation.samples.FragmentArgumentsSupport.onCreate

and this is a Java sample from Kotlin source using Java syntax:

public static class MyFragment extends Fragment {
    CharSequence mLabel;

    /**
     * Create a new instance of MyFragment that will be initialized
     * with the given arguments.
     */
    static MyFragment newInstance(CharSequence label) {
        MyFragment f = new MyFragment();
        Bundle b = new Bundle();
        b.putCharSequence("label", label);
        f.setArguments(b);
        return f;
    }

    /**
     * Parse attributes during inflation from a view hierarchy into the
     * arguments we handle.
     */
    @Override
    public void onInflate(@NonNull Context context, @NonNull AttributeSet attrs,
                          @Nullable Bundle savedInstanceState) {
        super.onInflate(context, attrs, savedInstanceState);

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.FragmentArguments);
        mLabel = a.getText(R.styleable.FragmentArguments_android_label);
        a.recycle();
    }

    /**
     * During creation, if arguments have been supplied to the fragment
     * then parse those out.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle args = getArguments();
        if (args != null) {
            CharSequence label = args.getCharSequence("label");
            if (label != null) {
                mLabel = label;
            }
        }
    }

    /**
     * Create the view for this fragment, using the arguments given to it.
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.hello_world, container, false);
        View tv = v.findViewById(R.id.text);
        ((TextView)tv).setText(mLabel != null ? mLabel : "(no label)");
        ViewCompat.setBackground(
                tv, ContextCompat.getDrawable(getContext(), android.R.drawable.gallery_thumb));
        return v;
    }
}

topLevelExtensionFunction

public static final @NonNull Pair<@NonNull Float, @NonNull FloattopLevelExtensionFunction(@NonNull List<@NonNull String> receiver)

top-level extension function docs

import androidx.notARealLibrary.Thingy1

class CustomPainter() {

    val size: Pair<Float, Float>
        get() = Pair(300.0f, 300.0f)

    override fun toString(): String {
        return "ahahahaha"
    }

    val weAreUsingThingy1 = Thingy1()

}

and this is an XML sample from Kotlin source: {@sample frameworks/support/samples/Support4Demos/src/main/res/layout/fragment_arguments_support.xml from_attributes}

topLevelFunction

public static final void topLevelFunction()

top-level non-extension function docs

import androidx.notARealLibrary.Thingy1

class CustomPainter() {

    val size: Pair<Float, Float>
        get() = Pair(300.0f, 300.0f)

    override fun toString(): String {
        return "ahahahaha"
    }

    val weAreUsingThingy1 = Thingy1()

}