package cn.zhios.zhiying_base_widget_example;

import android.content.res.Configuration;
import android.content.res.Resources;

import com.example.moblink.MoblinkPlugin;
import com.mob.moblink.MobLink;

import io.flutter.app.FlutterApplication;

public class MyFlutterApplication extends FlutterApplication {

    //防止MobLink在APP杀死进程后无法还原
    @Override
    public void onCreate() {
        super.onCreate();
        MobLink.setRestoreSceneListener(new MoblinkPlugin.SceneListener());
    }
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        
        if (newConfig.fontScale != 1){
            getResources();
        }//非默认值


    }

    @Override
    public Resources getResources() {
        Resources res = super.getResources();
        if (res.getConfiguration().fontScale != 1) {//非默认值
            Configuration newConfig = new Configuration();
            newConfig.setToDefaults();//设置默认
            res.updateConfiguration(newConfig, res.getDisplayMetrics());
        }
        return res;
    }
}
