fixes
This commit is contained in:
parent
017d5907c2
commit
7d97b28821
@ -202,6 +202,8 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
for (PreferenceType preferenceType : PreferenceType.values()) {
|
for (PreferenceType preferenceType : PreferenceType.values()) {
|
||||||
for (DragDirection dragDirection : DragDirection.values()) {
|
for (DragDirection dragDirection : DragDirection.values()) {
|
||||||
|
|
||||||
|
Log.d(DragButtonCalibrationActivity.class.getName(), "Determining drag preference for " + preferenceType + ", " + dragDirection);
|
||||||
|
|
||||||
final Interval<Float> defaultValue;
|
final Interval<Float> defaultValue;
|
||||||
switch (preferenceType) {
|
switch (preferenceType) {
|
||||||
case angle:
|
case angle:
|
||||||
@ -210,7 +212,7 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
defaultValue = new IntervalImpl<Float>(130f, 180f);
|
defaultValue = new IntervalImpl<Float>(130f, 180f);
|
||||||
break;
|
break;
|
||||||
case down:
|
case down:
|
||||||
defaultValue = new IntervalImpl<Float>(0f, 50f);
|
defaultValue = new IntervalImpl<Float>(130f, 180f);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
defaultValue = new IntervalImpl<Float>(0f, 0f);
|
defaultValue = new IntervalImpl<Float>(0f, 0f);
|
||||||
@ -226,12 +228,17 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
defaultValue = new IntervalImpl<Float>(DEFAULT_VALUE, DEFAULT_VALUE);
|
defaultValue = new IntervalImpl<Float>(DEFAULT_VALUE, DEFAULT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String value = preferences.getString(getPreferenceId(preferenceType, dragDirection), mapper.formatValue(defaultValue));
|
final String preferenceId = getPreferenceId(preferenceType, dragDirection);
|
||||||
|
final String value = preferences.getString(preferenceId, mapper.formatValue(defaultValue));
|
||||||
|
Log.d(DragButtonCalibrationActivity.class.getName(), "For " + preferenceId + " next value found in persistence: " + value);
|
||||||
|
|
||||||
final Interval<Float> interval = mapper.parseValue(value);
|
final Interval<Float> interval = mapper.parseValue(value);
|
||||||
|
assert interval != null;
|
||||||
|
|
||||||
transformInterval(preferenceType, dragDirection, interval);
|
transformInterval(preferenceType, dragDirection, interval);
|
||||||
if (new IntervalImpl<Float>(DEFAULT_VALUE, DEFAULT_VALUE).equals(interval)) {
|
if (!new IntervalImpl<Float>(DEFAULT_VALUE, DEFAULT_VALUE).equals(interval)) {
|
||||||
assert interval != null;
|
Log.d(DragButtonCalibrationActivity.class.getName(), "Preference retrieved from persistence. Preference id: " + preferenceId + ", value: " + interval.toString());
|
||||||
|
|
||||||
final DragPreference directionPreference = new DragPreference(dragDirection, interval);
|
final DragPreference directionPreference = new DragPreference(dragDirection, interval);
|
||||||
|
|
||||||
Preference preference = result.getPreferencesMap().get(preferenceType);
|
Preference preference = result.getPreferencesMap().get(preferenceType);
|
||||||
@ -243,7 +250,7 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
preference.getDirectionPreferences().put(dragDirection, directionPreference);
|
preference.getDirectionPreferences().put(dragDirection, directionPreference);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.e(DragButtonCalibrationActivity.class.getName(), "New preference type added: default preferences should be defined!");
|
Log.e(DragButtonCalibrationActivity.class.getName(), "New preference type added: default preferences should be defined. Preference id: " + preferenceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,9 +261,11 @@ public class DragButtonCalibrationActivity extends Activity {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static Interval<Float> transformInterval(@NotNull PreferenceType preferenceType, @NotNull DragDirection dragDirection, @NotNull Interval<Float> interval) {
|
private static Interval<Float> transformInterval(@NotNull PreferenceType preferenceType, @NotNull DragDirection dragDirection, @NotNull Interval<Float> interval) {
|
||||||
if ( preferenceType == PreferenceType.angle && dragDirection == DragDirection.down ) {
|
if ( preferenceType == PreferenceType.angle && dragDirection == DragDirection.down ) {
|
||||||
final Interval<Float> clone = interval.clone();
|
final Float leftBorder = interval.getLeftBorder();
|
||||||
interval.setLeftBorder(180f - clone.getRightBorder());
|
final Float rightBorder = interval.getRightBorder();
|
||||||
interval.setRightBorder(180f - clone.getLeftBorder());
|
|
||||||
|
interval.setLeftBorder(180f - rightBorder);
|
||||||
|
interval.setRightBorder(180f - leftBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return interval;
|
return interval;
|
||||||
|
Loading…
Reference in New Issue
Block a user