mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 20:05:34 +00:00
fix(android): Fix crashes involving Keyboard Picker
This fixes the null-pointer-exceptions reported in Crashlytics * [MapCompat](https://console.firebase.google.com/u/0/project/kmapro-ee779/crashlytics/app/android:com.tavultesoft.kmapro/issues/d1bbc6248a6cf73a4a2607646670a73b?time=last-seven-days&sessionId=5F43249600B0000169B855CBEB66027A_DNE_0_v2) * [KeyboardPickerActivity](https://console.firebase.google.com/u/0/project/kmapro-ee779/crashlytics/app/android:com.tavultesoft.kmapro/issues/f0e89e2ad194b4d55394461f07dbed92?time=last-seven-days&sessionId=5F42B17B01DB00011DEB0D57B0E2AF4E_DNE_0_v2)
This commit is contained in:
parent
e98987614c
commit
80fb43afda
2 changed files with 9 additions and 0 deletions
|
|
@ -469,6 +469,10 @@ public final class KeyboardPickerActivity extends AppCompatActivity {
|
|||
@SuppressWarnings("unchecked")
|
||||
private static ArrayList<HashMap<String, String>> getList(Context context, String filename) {
|
||||
ArrayList<HashMap<String, String>> list = null;
|
||||
if (context == null) {
|
||||
KMLog.LogError(TAG, "getList() where context is null.");
|
||||
return list;
|
||||
}
|
||||
|
||||
File file = new File(context.getDir("userdata", Context.MODE_PRIVATE), filename);
|
||||
if (file.exists()) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,13 @@ import java.util.HashMap;
|
|||
* Reference: https://stackoverflow.com/questions/41211960/alternative-to-getordefault-for-devices-below-api-24-android
|
||||
*/
|
||||
public final class MapCompat {
|
||||
private static final String TAG = "MapCompat";
|
||||
|
||||
public static <K, V> V getOrDefault(HashMap<K, V> map, K key, V defaultValue) {
|
||||
if (map == null) {
|
||||
KMLog.LogError(TAG, "map is null, returning default value " + defaultValue);
|
||||
return defaultValue;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return map.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue