|
|
|
@@ -10,8 +10,10 @@ import android.content.Intent; |
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
|
|
|
import android.text.style.TabStopSpan;
|
|
|
|
|
|
|
|
@@ -87,6 +89,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi |
|
|
|
private static final int MIN_DISTANCE = 50;
|
|
|
|
private static final double CENTI = 0.01;
|
|
|
|
private static final double MILLI = 0.001;
|
|
|
|
private static final int MAX_TRAJ_POINTS = 200;
|
|
|
|
|
|
|
|
private ViewFlipper viewFlipper;
|
|
|
|
private ScrollView paramsScrollView;
|
|
|
|
@@ -148,6 +151,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi |
|
|
|
|
|
|
|
initializeComponents();
|
|
|
|
addTouchListeners();
|
|
|
|
addValueChangeListeners();
|
|
|
|
|
|
|
|
xTextViewUp(this.txtViewParams);
|
|
|
|
|
|
|
|
@@ -504,6 +508,43 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi |
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addValueChangeListeners() {
|
|
|
|
this.arrowV0TxtFld.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(final Editable s) {
|
|
|
|
if (!RBSMainActivity.this.arrowV0TxtFld.getText().toString().isEmpty()
|
|
|
|
&& !RBSMainActivity.this.shootingDistanzTxtFld.getText().toString().isEmpty()) {
|
|
|
|
calculateAndSetPerformantAccuracy(Double.valueOf(RBSMainActivity.this.arrowV0TxtFld.getText().toString()),
|
|
|
|
Double.valueOf(RBSMainActivity.this.shootingDistanzTxtFld.getText().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.shootingDistanzTxtFld.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(final Editable s) {
|
|
|
|
if (!RBSMainActivity.this.arrowV0TxtFld.getText().toString().isEmpty()
|
|
|
|
&& !RBSMainActivity.this.shootingDistanzTxtFld.getText().toString().isEmpty()) {
|
|
|
|
calculateAndSetPerformantAccuracy(Double.valueOf(RBSMainActivity.this.arrowV0TxtFld.getText().toString()),
|
|
|
|
Double.valueOf(RBSMainActivity.this.shootingDistanzTxtFld.getText().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onPrepareOptionsMenu(final Menu menu) {
|
|
|
|
@@ -699,7 +740,7 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi |
|
|
|
this.scSightSpinner.fireSelectionChangedEvent();
|
|
|
|
this.scVertScaleMiddleTxtFld.setText(DF.format(archerySetup.getSightVertSkalaMiddle()));
|
|
|
|
|
|
|
|
this.airTemperatureTxtFld.setText("25");
|
|
|
|
this.airTemperatureTxtFld.setText("23");
|
|
|
|
this.airRelativeHumidityTxtFld.setText("50");
|
|
|
|
this.shootingDistanzTxtFld.setText("18");
|
|
|
|
|
|
|
|
@@ -938,5 +979,23 @@ public class RBSMainActivity extends Activity implements ChooseArcherySetupDlgDi |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void calculateAndSetPerformantAccuracy(final Double v0, final Double shootingDistance) {
|
|
|
|
|
|
|
|
String[] calcAccuracies = getResources().getStringArray(R.array.CalculationTimeIntervals);
|
|
|
|
String calcAccuracyToSet = calcAccuracies[calcAccuracies.length - 1];
|
|
|
|
Double approxFlightTime = shootingDistance / v0;
|
|
|
|
Double approxIntervalTime = approxFlightTime / MAX_TRAJ_POINTS;
|
|
|
|
|
|
|
|
for (int i = 0; i < calcAccuracies.length - 1; i++) {
|
|
|
|
Double accLow = Double.valueOf(calcAccuracies[i]);
|
|
|
|
Double accHigh = Double.valueOf(calcAccuracies[i + 1]);
|
|
|
|
if (accHigh < approxIntervalTime && approxIntervalTime <= accLow) {
|
|
|
|
calcAccuracyToSet = calcAccuracies[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.calcTimeIntervalCboBox.setSelectionByVal(calcAccuracyToSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|