当前位置: 首页>>代码示例>>Java>>正文


Java DiscreteSeekBar.setNumericTransformer方法代码示例

本文整理汇总了Java中org.adw.library.widgets.discreteseekbar.DiscreteSeekBar.setNumericTransformer方法的典型用法代码示例。如果您正苦于以下问题:Java DiscreteSeekBar.setNumericTransformer方法的具体用法?Java DiscreteSeekBar.setNumericTransformer怎么用?Java DiscreteSeekBar.setNumericTransformer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.adw.library.widgets.discreteseekbar.DiscreteSeekBar的用法示例。


在下文中一共展示了DiscreteSeekBar.setNumericTransformer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindToModel

import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar; //导入方法依赖的package包/类
@BindingAdapter("model")
public static void bindToModel(DiscreteSeekBar seekBar, final SeekBarModel model) {
    DiscreteSeekBar.NumericTransformer transformer = seekBar.getNumericTransformer();

    if (!(transformer instanceof NumericTransformer)) {
        transformer = new NumericTransformer();
        seekBar.setNumericTransformer(transformer);
    }

    final NumericTransformer customTransformer = (NumericTransformer) transformer;
    customTransformer.setValues(model.getMinValue(), model.getMaxValue());

    seekBar.setMin(0);
    seekBar.setMax(100);

    final int percentage = (int) customTransformer.transformToPercentage(model.getValue().get());
    // Bug in the library
    seekBar.setProgress(1);
    seekBar.setProgress(percentage);

    seekBar.setOnProgressChangeListener(
            SimpleOnProgressChangeListener.forStopTrackingTouch(seekBar1 -> {
                model.getValue().set(customTransformer.transformFromPercentage(seekBar.getProgress()));
            }));
}
 
开发者ID:Appolica,项目名称:Flubber,代码行数:26,代码来源:BindingAdapters.java

示例2: onCreate

import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    DiscreteSeekBar discreteSeekBar1 = (DiscreteSeekBar) findViewById(R.id.discrete1);
    discreteSeekBar1.setNumericTransformer(new DiscreteSeekBar.NumericTransformer() {
        @Override
        public int transform(int value) {
            return value * 100;
        }
    });
}
 
开发者ID:sathishmscict,项目名称:DiscreteSeekBar,代码行数:13,代码来源:MainActivity.java

示例3: setUpSeekbar

import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar; //导入方法依赖的package包/类
private void setUpSeekbar(){
    seekBar = (DiscreteSeekBar) findViewById(R.id.discrete_bar);
    seekBar.setMin(0);
    seekBar.setMax(5);
    //set what the seekbar bubble displays based on the time option selected in the spinner
    seekBar.setNumericTransformer(new DiscreteSeekBar.NumericTransformer() {
        @Override
        public int transform(int value) {
            int newValue = 0;
            if (spinnerSelectedValue == 1) { //hours
                switch (value) {
                    case 0:
                        newValue = 0;
                        break;
                    case 1:
                        newValue = 1;
                        break;
                    case 2:
                        newValue = 2;
                        break;
                    case 3:
                        newValue = 5;
                        break;
                    case 4:
                        newValue = 10;
                        break;
                    case 5:
                        newValue = 12;
                        break;
                }
                repeatTime = newValue * 60;
            } else if (spinnerSelectedValue == 2) { //days
                switch (value) {
                    case 0:
                        newValue = 0;
                        break;
                    case 1:
                        newValue = 1;
                        break;
                    case 2:
                        newValue = 7;
                        break;
                    case 3:
                        newValue = 14;
                        break;
                    case 4:
                        newValue = 21;
                        break;
                    case 5:
                        newValue = 28;
                        break;
                }
                repeatTime = newValue * 60 * 24;
            } else { //minutes
                switch (value) {
                    case 0:
                        newValue = 0;
                        break;
                    case 1:
                        newValue = 5;
                        break;
                    case 2:
                        newValue = 10;
                        break;
                    case 3:
                        newValue = 15;
                        break;
                    case 4:
                        newValue = 30;
                        break;
                    case 5:
                        newValue = 45;
                        break;
                }
                repeatTime = newValue;
            }
            return newValue;
        }
    });
}
 
开发者ID:jt19056,项目名称:Notey,代码行数:81,代码来源:AlarmActivity.java


注:本文中的org.adw.library.widgets.discreteseekbar.DiscreteSeekBar.setNumericTransformer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。