parent
45ee5f49b5
commit
4f27117c8d
@ -1,40 +0,0 @@
|
||||
package com.fox2code.mmm.compat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.LocaleList;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class CompatWrapper extends android.content.ContextWrapper {
|
||||
|
||||
public CompatWrapper(Context base) {
|
||||
super(base);
|
||||
}
|
||||
|
||||
public static ContextWrapper setLocale(Context context, Locale newLocale) {
|
||||
|
||||
Resources res = context.getResources();
|
||||
Configuration configuration = res.getConfiguration();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
configuration.setLocale(newLocale);
|
||||
|
||||
LocaleList localeList = new LocaleList(newLocale);
|
||||
LocaleList.setDefault(localeList);
|
||||
configuration.setLocales(localeList);
|
||||
|
||||
context = context.createConfigurationContext(configuration);
|
||||
|
||||
} else {
|
||||
configuration.setLocale(newLocale);
|
||||
context = context.createConfigurationContext(configuration);
|
||||
|
||||
}
|
||||
|
||||
return new ContextWrapper(context);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 511 KiB |
Binary file not shown.
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 592 KiB |
Loading…
Reference in New Issue