mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -04:00
Fix[controls]: Take into account framework rounding
This commit is contained in:
parent
641eae051b
commit
012685b3c9
@ -63,10 +63,13 @@ public class EditControlPopup {
|
||||
if(internalChanges) return;
|
||||
|
||||
internalChanges = true;
|
||||
if(right != (int)safeParseFloat(mWidthEditText.getText().toString())){
|
||||
int width = (int)(safeParseFloat(mWidthEditText.getText().toString()));
|
||||
|
||||
if(width >= 0 && Math.abs(right - width) > 1){
|
||||
mWidthEditText.setText(String.valueOf(right - left));
|
||||
}
|
||||
if(bottom != (int) safeParseFloat(mHeightEditText.getText().toString())){
|
||||
int height = (int)(safeParseFloat(mHeightEditText.getText().toString()));
|
||||
if(height >= 0 && Math.abs(bottom - height) > 1){
|
||||
mHeightEditText.setText(String.valueOf(bottom - top));
|
||||
}
|
||||
|
||||
@ -211,7 +214,6 @@ public class EditControlPopup {
|
||||
mAdapter = new ArrayAdapter<>(mRootView.getContext(), R.layout.item_centered_textview);
|
||||
mSpecialArray = ControlData.buildSpecialButtonArray();
|
||||
for (int i = 0; i < mSpecialArray.length; i++) {
|
||||
//TODO this will break for sure
|
||||
mSpecialArray[i] = "SPECIAL_" + mSpecialArray[i];
|
||||
}
|
||||
Collections.reverse(Arrays.asList(mSpecialArray));
|
||||
@ -386,8 +388,11 @@ public class EditControlPopup {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if(internalChanges) return;
|
||||
|
||||
mCurrentlyEditedButton.getProperties().setWidth(safeParseFloat(s.toString()));
|
||||
mCurrentlyEditedButton.updateProperties();
|
||||
float width = safeParseFloat(s.toString());
|
||||
if(width >= 0){
|
||||
mCurrentlyEditedButton.getProperties().setWidth(width);
|
||||
mCurrentlyEditedButton.updateProperties();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -401,8 +406,11 @@ public class EditControlPopup {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if(internalChanges) return;
|
||||
|
||||
mCurrentlyEditedButton.getProperties().setHeight(safeParseFloat(s.toString()));
|
||||
mCurrentlyEditedButton.updateProperties();
|
||||
float height = safeParseFloat(s.toString());
|
||||
if(height >= 0){
|
||||
mCurrentlyEditedButton.getProperties().setHeight(height);
|
||||
mCurrentlyEditedButton.updateProperties();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -522,7 +530,7 @@ public class EditControlPopup {
|
||||
}
|
||||
|
||||
private float safeParseFloat(String string){
|
||||
float out = 10; // 10 px as a fallback
|
||||
float out = -1; // -1
|
||||
try {
|
||||
out = Float.parseFloat(string);
|
||||
}catch (NumberFormatException e){
|
||||
|
Loading…
x
Reference in New Issue
Block a user