Skip to content
Snippets Groups Projects
Commit aac61601 authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: use setValue to change parameters

parent ce4c682d
Branches
Tags
No related merge requests found
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
</activity> </activity>
<activity <activity
android:name=".ModelList" android:name=".ModelList"
android:label="@string/title_activity_main"> android:label="@string/title_activity_main" />
</activity>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/title_activity_main" android:label="@string/title_activity_main"
...@@ -44,11 +43,12 @@ ...@@ -44,11 +43,12 @@
</activity> </activity>
<activity <activity
android:name=".PostProcessingActivity" android:name=".PostProcessingActivity"
android:label="@string/title_activity_main"> android:label="@string/title_activity_main"
</activity> android:screenOrientation="landscape" />
<activity <activity
android:name=".OptionsActivity" android:name=".OptionsActivity"
android:label="@string/title_activity_options"></activity> android:label="@string/title_activity_options"
android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -82,7 +82,8 @@ public class ParameterNumber extends Parameter{ ...@@ -82,7 +82,8 @@ public class ParameterNumber extends Parameter{
if(value == _value) return; if(value == _value) return;
_value = value; _value = value;
_changed = true; _changed = true;
//if(mListener != null) mListener.OnParameterChanged(); _gmsh.setParam(getType(), getName(), String.valueOf(value));
if(mListener != null) mListener.OnParameterChanged();
} }
public void setMin(double min) {_min = min;this.update();} public void setMin(double min) {_min = min;this.update();}
public void setMax(double max) {_max = max;this.update();} public void setMax(double max) {_max = max;this.update();}
...@@ -170,8 +171,7 @@ public class ParameterNumber extends Parameter{ ...@@ -170,8 +171,7 @@ public class ParameterNumber extends Parameter{
_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { _spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onNothingSelected(AdapterView<?> arg0) {} public void onNothingSelected(AdapterView<?> arg0) {}
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
_gmsh.setParam(getType(), getName(), String.valueOf(_values.get(pos))); setValue(_values.get(pos));
if(mListener != null) mListener.OnParameterChanged();
} }
}); });
} }
...@@ -180,18 +180,12 @@ public class ParameterNumber extends Parameter{ ...@@ -180,18 +180,12 @@ public class ParameterNumber extends Parameter{
_bar.setEnabled(!_readOnly); _bar.setEnabled(!_readOnly);
_bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { _bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
double value = getMin() + (getMax() - getMin())*seekBar.getProgress()/100; setValue(getMin() + (getMax() - getMin())*seekBar.getProgress()/100);
value = (value >= _min)? value : _min;
_gmsh.setParam(getType(), getName(), String.valueOf(value));
if(mListener != null) mListener.OnParameterChanged();
} }
public void onStartTrackingTouch(SeekBar seekBar) {} public void onStartTrackingTouch(SeekBar seekBar) {}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {}
}
}); });
} }
else if(_checkbox != null) { else if(_checkbox != null) {
...@@ -201,8 +195,7 @@ public class ParameterNumber extends Parameter{ ...@@ -201,8 +195,7 @@ public class ParameterNumber extends Parameter{
_checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { _checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
_gmsh.setParam(getType(), getName(), (isChecked)? "1" : "0"); setValue((isChecked)? 1 : 0);
if(mListener != null) mListener.OnParameterChanged();
} }
}); });
} }
...@@ -216,8 +209,7 @@ public class ParameterNumber extends Parameter{ ...@@ -216,8 +209,7 @@ public class ParameterNumber extends Parameter{
InputMethodManager imm = (InputMethodManager)_context.getSystemService( InputMethodManager imm = (InputMethodManager)_context.getSystemService(
Context.INPUT_METHOD_SERVICE); Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(_edittext.getWindowToken(), 0); imm.hideSoftInputFromWindow(_edittext.getWindowToken(), 0);
_gmsh.setParam(getType(), getName(), String.valueOf(_value)); setValue(_value);
if(mListener != null) mListener.OnParameterChanged();
_edittext.clearFocus(); _edittext.clearFocus();
return true; return true;
} }
...@@ -229,18 +221,15 @@ public class ParameterNumber extends Parameter{ ...@@ -229,18 +221,15 @@ public class ParameterNumber extends Parameter{
_edittext.addTextChangedListener(new TextWatcher() { _edittext.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
double value = 1;
try { try {
if(s.length() < 1) value = 1; if(s.length() < 1) _value = 1;
else value = Double.parseDouble(s.toString()); else _value = Double.parseDouble(s.toString());
} }
catch(NumberFormatException e) catch(NumberFormatException e)
{ {
value = 1; _value = 1;
//_edittext.setText(""); //_edittext.setText("");
} }
_value = value;
_changed = true;
} }
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} // UNUSED Auto-generated method stub public void beforeTextChanged(CharSequence s, int start, int count, int after) {} // UNUSED Auto-generated method stub
......
...@@ -48,10 +48,10 @@ public class ParameterString extends Parameter{ ...@@ -48,10 +48,10 @@ public class ParameterString extends Parameter{
public void setValue(int index) { public void setValue(int index) {
if(index == _index) return; if(index == _index) return;
if(mListener != null) mListener.OnParameterChanged();
_changed = true; _changed = true;
_index = index; _index = index;
this.update(); _gmsh.setParam(getType(), getName(), _choices.get(_index));
if(mListener != null) mListener.OnParameterChanged();
} }
public void setValue(String value) { public void setValue(String value) {
int index = _choices.indexOf(value); int index = _choices.indexOf(value);
...@@ -60,10 +60,10 @@ public class ParameterString extends Parameter{ ...@@ -60,10 +60,10 @@ public class ParameterString extends Parameter{
index = _choices.indexOf(value); index = _choices.indexOf(value);
} }
if(index == _index) return; if(index == _index) return;
if(mListener != null) mListener.OnParameterChanged();
_changed = true; _changed = true;
_index = index; _index = index;
this.update(); _gmsh.setParam(getType(), getName(), value);
if(mListener != null) mListener.OnParameterChanged();
} }
public void setKind(String kind) {_kind = kind;} public void setKind(String kind) {_kind = kind;}
public void addChoices(String choice) { public void addChoices(String choice) {
...@@ -109,11 +109,8 @@ public class ParameterString extends Parameter{ ...@@ -109,11 +109,8 @@ public class ParameterString extends Parameter{
public void onNothingSelected(AdapterView<?> arg0) {} public void onNothingSelected(AdapterView<?> arg0) {}
public void onItemSelected(AdapterView<?> parent, View view, public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
int pos, long id) {
if(getValue() == getChoices().get(pos)) return;
setValue(pos); setValue(pos);
_gmsh.setParam(getType(), getName(), String.valueOf(getValue()));
} }
}); });
...@@ -136,10 +133,11 @@ public class ParameterString extends Parameter{ ...@@ -136,10 +133,11 @@ public class ParameterString extends Parameter{
}); });
_edittext.addTextChangedListener(new TextWatcher() { _edittext.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) { } // UNUSED Auto-generated method stub public void onTextChanged(CharSequence s, int start, int before, int count) {
_choices.clear(); _choices.add(s.toString());
}
public void beforeTextChanged(CharSequence s, int start, int count, public void beforeTextChanged(CharSequence s, int start, int count, int after) {} // UNUSED Auto-generated method stub
int after) {} // UNUSED Auto-generated method stub
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
_gmsh.setParam(getType(), getName(), _choices.get(0)); _gmsh.setParam(getType(), getName(), _choices.get(0));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment