本文整理汇总了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()));
}));
}
示例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;
}
});
}
示例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;
}
});
}