Darcy Wong 2020-08-24 13:34:55 +07:00
parent e98987614c
commit 80fb43afda
2 changed files with 9 additions and 0 deletions

View file

@ -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()) {

View file

@ -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);
}