Prevent crash when aprs symbol cannot be selected

master
sh123 2023-05-08 08:30:29 +03:00
rodzic 2ed8a4074d
commit a59a908c88
3 zmienionych plików z 19 dodań i 8 usunięć

Wyświetl plik

@ -10,8 +10,8 @@ android {
applicationId "com.radio.codec2talkie"
minSdkVersion 23
targetSdkVersion 30
versionCode 153
versionName "1.53"
versionCode 154
versionName "1.54"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Wyświetl plik

@ -95,10 +95,15 @@ public class AprsSymbolTable {
if (symbolIconIndex < 0 || symbolIconIndex >= (_cntWidth * _cntHeight)) return null;
if (table == '/') {
return _primaryTable.get(symbolIconIndex);
} else if (table == '\\') {
return _secondaryTable.get(symbolIconIndex);
try {
if (table == '/') {
return _primaryTable.get(symbolIconIndex);
} else if (table == '\\') {
return _secondaryTable.get(symbolIconIndex);
}
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
return null;
}
if (overlayIconIndex < 0 || overlayIconIndex >= (_cntWidth * _cntHeight)) return null;

Wyświetl plik

@ -18,10 +18,13 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
import com.radio.codec2talkie.R;
import com.radio.codec2talkie.protocol.AudioFrameAggregator;
import com.radio.codec2talkie.protocol.aprs.tools.AprsSymbolTable;
public class AprsSymbolSelectionActivity extends AppCompatActivity {
private static final String TAG = AprsSymbolSelectionActivity.class.getSimpleName();
private SharedPreferences _sharedPreferences;
private ImageView _currentSelectionView;
@ -68,9 +71,12 @@ public class AprsSymbolSelectionActivity extends AppCompatActivity {
float y = event.getY();
_currentSymbolCode = AprsSymbolTable.getSymbolFromCoordinate(x, y, v.getWidth(), v.getHeight());
_currentSelectionText.setText(_currentSymbolCode);
Log.i("---", _currentSymbolCode);
Log.i(TAG, "Selected symbol: " + _currentSymbolCode);
Bitmap currentSymbolBitmap = AprsSymbolTable.getInstance(this).bitmapFromSymbol(_currentSymbolCode, true);
_currentSelectionView.setImageBitmap(currentSymbolBitmap);
if (currentSymbolBitmap == null)
Log.e(TAG, "Cannot select symbol");
else
_currentSelectionView.setImageBitmap(currentSymbolBitmap);
v.performClick();
}
return true;