private void createParamaterizedInterpolator()

in AnimationsInterpolatorPlayground/app/src/main/java/com/example/android/interpolatorplayground/MainActivity.java [175:224]


    private void createParamaterizedInterpolator(LinearLayout parent,
        final Constructor constructor, final String name,
        final float min, final float max, final float defaultValue) {
        LinearLayout inputContainer = new LinearLayout(this);
        inputContainer.setOrientation(LinearLayout.HORIZONTAL);
        LayoutParams params = new LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(mDefaultMargin, mDefaultMargin, mDefaultMargin, mDefaultMargin);
        inputContainer.setLayoutParams(params);

        final TextView label = new TextView(this);
        params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.weight = .5f;
        label.setLayoutParams(params);
        String formattedValue = String.format(" %.2f", defaultValue);
        label.setText(name + formattedValue);

        final SeekBar seek = new SeekBar(this);
        params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.weight = .5f;
        seek.setLayoutParams(params);
        seek.setMax(100);
        seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                float percentage = (float) i / 100;
                float value = min + percentage * (max - min);
                String formattedValue = String.format(" %.2f", value);
                try {
                    mVisualizer.setInterpolator((Interpolator) constructor.newInstance(value));
                } catch (Throwable error) {
                    Log.e("interpolatorPlayground", error.getMessage());
                }
                label.setText(name + formattedValue);
            }
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {}
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {}
        });
        inputContainer.addView(label);
        inputContainer.addView(seek);
        parent.addView(inputContainer);

        try {
            mVisualizer.setInterpolator((Interpolator) constructor.newInstance(defaultValue));
        } catch (Throwable error) {
            Log.e("interpolatorPlayground", error.getMessage());
        }
    }