diff --git a/src/app/src/main/java/io/github/lonamiwebs/stringlate/dialogs/LocaleSelectionDialog.java b/src/app/src/main/java/io/github/lonamiwebs/stringlate/dialogs/LocaleSelectionDialog.java index 87d47d3..b0f841f 100644 --- a/src/app/src/main/java/io/github/lonamiwebs/stringlate/dialogs/LocaleSelectionDialog.java +++ b/src/app/src/main/java/io/github/lonamiwebs/stringlate/dialogs/LocaleSelectionDialog.java @@ -1,6 +1,7 @@ package io.github.lonamiwebs.stringlate.dialogs; +import android.app.Activity; import android.app.Dialog; import android.app.DialogFragment; import android.content.Context; @@ -167,6 +168,19 @@ public void onAttach(Context context) { } } + // Old devices don't have onAttach(Context), so onLocaleSelected remains null. + // We can implement both methods (since this is "deprecated") to avoid #195. + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + onLocaleSelected = (OnLocaleSelected) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnLocaleSelected"); + } + } + //endregion //region Events