Commit 08671c5f authored by yangwu.jia's avatar yangwu.jia

Null pointer fixed

parent a5aeb476
...@@ -259,8 +259,15 @@ public class XFlutterView extends FrameLayout { ...@@ -259,8 +259,15 @@ public class XFlutterView extends FrameLayout {
protected void onConfigurationChanged(@NonNull Configuration newConfig) { protected void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
Log.v(TAG, "Configuration changed. Sending locales and user settings to Flutter."); Log.v(TAG, "Configuration changed. Sending locales and user settings to Flutter.");
sendLocalesToFlutter(newConfig); try {
sendUserSettingsToFlutter();
sendLocalesToFlutter(newConfig);
sendUserSettingsToFlutter();
}catch (Throwable e){
Log.e(TAG, "onConfigurationChanged error ");
}
} }
/** /**
...@@ -760,7 +767,9 @@ public class XFlutterView extends FrameLayout { ...@@ -760,7 +767,9 @@ public class XFlutterView extends FrameLayout {
} else { } else {
locales.add(config.locale); locales.add(config.locale);
} }
flutterEngine.getLocalizationChannel().sendLocales(locales); if(flutterEngine!=null&&flutterEngine.getLocalizationChannel()!=null){
flutterEngine.getLocalizationChannel().sendLocales(locales);
}
} }
/** /**
...@@ -772,10 +781,12 @@ public class XFlutterView extends FrameLayout { ...@@ -772,10 +781,12 @@ public class XFlutterView extends FrameLayout {
* FlutterEngine must be non-null when this method is invoked. * FlutterEngine must be non-null when this method is invoked.
*/ */
private void sendUserSettingsToFlutter() { private void sendUserSettingsToFlutter() {
if(flutterEngine!=null&&flutterEngine.getSettingsChannel()!=null){
flutterEngine.getSettingsChannel().startMessage() flutterEngine.getSettingsChannel().startMessage()
.setTextScaleFactor(getResources().getConfiguration().fontScale) .setTextScaleFactor(getResources().getConfiguration().fontScale)
.setUse24HourFormat(DateFormat.is24HourFormat(getContext())) .setUse24HourFormat(DateFormat.is24HourFormat(getContext()))
.send(); .send();
}
} }
// TODO(mattcarroll): consider introducing a system channel for this communication instead of JNI // TODO(mattcarroll): consider introducing a system channel for this communication instead of JNI
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment