App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mhr.appandroid.views.LabelledSeekBar Class Reference
Inheritance diagram for mhr.appandroid.views.LabelledSeekBar:

## Classes
class | ExponencialTranslator
interface | LabelledSBChangeListener
class | LinearTranslator
interface | SBValueTranslator
enum | TranslatorType

## Public Member Functions
| LabelledSeekBar (Context context)
| LabelledSeekBar (Context context, AttributeSet attrs)
| LabelledSeekBar (Context context, AttributeSet attrs, int defStyle)
void | setLabelledSBChangeListener (LabelledSBChangeListener listener)
float | getProgress ()
void | setProgress (float progress)
void | setParams (float min, float max, float count, float base)
void | setLabel (String label)
void | setLabelWidth (int labelWidth)
void | setValueWidth (int valueWidth)
void | setType (TranslatorType type)
void | setValueFormat (String format)
void | setTextAppearance (int resId)
void | setProgressDrawable (Drawable dr)
void | setScrubberDrawable (Drawable dr)
void | onProgressChanged (SeekBar seekBar, int progress, boolean fromUser)
void | onStartTrackingTouch (SeekBar seekBar)
void | onStopTrackingTouch (SeekBar seekBar)

## Protected Member Functions
void | initView ()
void | initView (Context context, AttributeSet attrs)

## Protected Attributes
int | count = 100
float | min = 0
float | max = 100
float | base = 10
TextView | labelTV
EditText | valueTV
SeekBar | valueSB
DecimalFormat | format = new DecimalFormat("#.##")
SBValueTranslator | translator
LabelledSBChangeListener | listener = null
TranslatorType | type = TranslatorType.Linear

## Detailed Description

Definition at line 17 of file LabelledSeekBar.java.

## Constructor & Destructor Documentation

mhr.appandroid.views.LabelledSeekBar.LabelledSeekBar | ( | Context | context | ) |
| inline

Definition at line 179 of file LabelledSeekBar.java.

{
super(context);
initView();
}

mhr.appandroid.views.LabelledSeekBar.LabelledSeekBar | ( | Context | context,
|  | AttributeSet | attrs
| ) |  |
| inline

Definition at line 184 of file LabelledSeekBar.java.

{
super(context, attrs);
initView();
initView(context, attrs);
}

mhr.appandroid.views.LabelledSeekBar.LabelledSeekBar | ( | Context | context,
|  | AttributeSet | attrs,
|  | int | defStyle
| ) |  |
| inline

Definition at line 190 of file LabelledSeekBar.java.

{
super(context, attrs, defStyle);
initView();
initView(context, attrs);
}

## Member Function Documentation

float mhr.appandroid.views.LabelledSeekBar.getProgress | ( |  | ) |
| inline

Definition at line 204 of file LabelledSeekBar.java.

{
return translator.getValue();
}

void mhr.appandroid.views.LabelledSeekBar.initView | ( |  | ) |
| inlineprotected

Definition at line 103 of file LabelledSeekBar.java.

{
setGravity(0x03 | 0x10);
labelTV = new TextView(getContext());
valueTV = new EditText(getContext());
valueTV.setBackgroundDrawable(null);
valueTV.setPadding(0, 0, 0, 0);
valueTV.setMaxLines(1);
valueTV.setOnFocusChangeListener(new OnFocusChangeListener() {
// Lepší řešení je TextWatcher, ale je zbytečně komplikované, ikdyž tady zase uživatel musí opustit View, aby se aktualizovala vybraná hodnota...
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
String str = valueTV.getText().toString();
String orig = format.format(translator.getValue());
if (!str.equals(orig)) {
try {
float d = Float.parseFloat(str);
setProgress(d);
} catch (NumberFormatException e) {
valueTV.setText(orig);
}
}
}
}
});
valueSB = new SeekBar(getContext());
valueSB.setMax(count);
valueSB.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
valueSB.setOnSeekBarChangeListener(this);
addView(labelTV);
addView(valueTV);
addView(valueSB);
translator = new LinearTranslator();
}

void mhr.appandroid.views.LabelledSeekBar.initView | ( | Context | context,
|  | AttributeSet | attrs
| ) |  |
| inlineprotected

Definition at line 144 of file LabelledSeekBar.java.

{
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.LabelledSeekBar, 0, 0);
try {
switch (a.getInt(R.styleable.LabelledSeekBar_Scale, 0)) {
case 1:
type = TranslatorType.Exponencial;
break;
default:
type = TranslatorType.Linear;
}
format = new DecimalFormat(a.getString(R.styleable.LabelledSeekBar_ValueStringFormat));
setParams(a.getFloat(R.styleable.LabelledSeekBar_Min, min), a.getFloat(R.styleable.LabelledSeekBar_Max, max), a.getFloat(R.styleable.LabelledSeekBar_Count, count),
a.getFloat(R.styleable.LabelledSeekBar_ExpBase, base));
labelTV.setTextAppearance(getContext(), a.getResourceId(R.styleable.LabelledSeekBar_TextAppearance, 0));
labelTV.setWidth((int) a.getDimension(R.styleable.LabelledSeekBar_LabelWidth, 0));
labelTV.setText(a.getString(R.styleable.LabelledSeekBar_Label));
valueTV.setTextAppearance(getContext(), a.getResourceId(R.styleable.LabelledSeekBar_TextAppearance, 0));
valueTV.setWidth((int) a.getDimension(R.styleable.LabelledSeekBar_ValueWidth, 0));
valueSB.setProgressDrawable(a.getDrawable(R.styleable.LabelledSeekBar_ProgressDrawable));
valueSB.setThumb(a.getDrawable(R.styleable.LabelledSeekBar_ScrubberDrawable));
translator.setValue(Float.parseFloat(a.getString(R.styleable.LabelledSeekBar_Value)));
} finally {
a.recycle();
}
}

void mhr.appandroid.views.LabelledSeekBar.onProgressChanged | ( | SeekBar | seekBar,
|  | int | progress,
|  | boolean | fromUser
| ) |  |
| inline

Definition at line 271 of file LabelledSeekBar.java.

{
valueTV.setText(format.format(translator.getValue()));
if (listener != null) {
listener.onValueChanged(this, translator.getValue(), fromUser);
}
}

void mhr.appandroid.views.LabelledSeekBar.onStartTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 279 of file LabelledSeekBar.java.

{
if (listener != null) {
listener.onValueChangeStart(this);
}
}

void mhr.appandroid.views.LabelledSeekBar.onStopTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 286 of file LabelledSeekBar.java.

{
if (listener != null) {
listener.onValueChangeStop(this);
}
}

void mhr.appandroid.views.LabelledSeekBar.setLabel | ( | String | label | ) |
| inline

Definition at line 234 of file LabelledSeekBar.java.

{
labelTV.setText(label);
}

void mhr.appandroid.views.LabelledSeekBar.setLabelledSBChangeListener | ( | LabelledSBChangeListener | listener | ) |
| inline

Definition at line 200 of file LabelledSeekBar.java.

{
this.listener = listener;
}

void mhr.appandroid.views.LabelledSeekBar.setLabelWidth | ( | int | labelWidth | ) |
| inline

Definition at line 238 of file LabelledSeekBar.java.

{
labelTV.setWidth(labelWidth);
}

void mhr.appandroid.views.LabelledSeekBar.setParams | ( | float | min,
|  | float | max,
|  | float | count,
|  | float | base
| ) |  |
| inline

Definition at line 213 of file LabelledSeekBar.java.

{
this.count = Math.round(count);
if (count <= 0) {
count = 1000;
}
this.min = min;
this.max = max;
this.base = base;
switch (type) {
case Linear:
translator = new LinearTranslator();
break;
case Exponencial:
translator = new ExponencialTranslator();
break;
}
valueSB.setMax(this.count);
translator.setValue(translator.getValue());
}

void mhr.appandroid.views.LabelledSeekBar.setProgress | ( | float | progress | ) |
| inline

Definition at line 208 of file LabelledSeekBar.java.

{
progress = (progress < min) ? min : (progress > max) ? max : progress;
translator.setValue(progress);
}

void mhr.appandroid.views.LabelledSeekBar.setProgressDrawable | ( | Drawable | dr | ) |
| inline

Definition at line 260 of file LabelledSeekBar.java.

{
valueSB.setProgressDrawable(dr);
}

void mhr.appandroid.views.LabelledSeekBar.setScrubberDrawable | ( | Drawable | dr | ) |
| inline

Definition at line 264 of file LabelledSeekBar.java.

{
valueSB.setThumb(dr);
}

void mhr.appandroid.views.LabelledSeekBar.setTextAppearance | ( | int | resId | ) |
| inline

Definition at line 255 of file LabelledSeekBar.java.

{
labelTV.setTextAppearance(getContext(), resId);
valueTV.setTextAppearance(getContext(), resId);
}

void mhr.appandroid.views.LabelledSeekBar.setType | ( | TranslatorType | type | ) |
| inline

Definition at line 246 of file LabelledSeekBar.java.

{
this.type = type;
setParams(min, max, count, base);
}

void mhr.appandroid.views.LabelledSeekBar.setValueFormat | ( | String | format | ) |
| inline

Definition at line 251 of file LabelledSeekBar.java.

{
this.format = new DecimalFormat(format);
}

void mhr.appandroid.views.LabelledSeekBar.setValueWidth | ( | int | valueWidth | ) |
| inline

Definition at line 242 of file LabelledSeekBar.java.

{
valueTV.setWidth(valueWidth);
}

## Member Data Documentation

float mhr.appandroid.views.LabelledSeekBar.base = 10
| protected

Definition at line 87 of file LabelledSeekBar.java.

int mhr.appandroid.views.LabelledSeekBar.count = 100
| protected

Definition at line 84 of file LabelledSeekBar.java.

DecimalFormat mhr.appandroid.views.LabelledSeekBar.format = new DecimalFormat("#.##")
| protected

Definition at line 93 of file LabelledSeekBar.java.

TextView mhr.appandroid.views.LabelledSeekBar.labelTV
| protected

Definition at line 89 of file LabelledSeekBar.java.

LabelledSBChangeListener mhr.appandroid.views.LabelledSeekBar.listener = null
| protected

Definition at line 96 of file LabelledSeekBar.java.

float mhr.appandroid.views.LabelledSeekBar.max = 100
| protected

Definition at line 86 of file LabelledSeekBar.java.

float mhr.appandroid.views.LabelledSeekBar.min = 0
| protected

Definition at line 85 of file LabelledSeekBar.java.

SBValueTranslator mhr.appandroid.views.LabelledSeekBar.translator
| protected

Definition at line 94 of file LabelledSeekBar.java.

TranslatorType mhr.appandroid.views.LabelledSeekBar.type = TranslatorType.Linear
| protected

Definition at line 97 of file LabelledSeekBar.java.

SeekBar mhr.appandroid.views.LabelledSeekBar.valueSB
| protected

Definition at line 91 of file LabelledSeekBar.java.

EditText mhr.appandroid.views.LabelledSeekBar.valueTV
| protected

Definition at line 90 of file LabelledSeekBar.java.

The documentation for this class was generated from the following file:

- /home/xxx/eclipse_workspaces/app/appandroid/src/mhr/appandroid/views/LabelledSeekBar.java