Purge view cache when layout direction is changed.
This commit is contained in:
parent
006e7dc736
commit
b4ba565923
1 changed files with 11 additions and 2 deletions
|
@ -93,6 +93,7 @@ public class CachedInflater {
|
||||||
private long lastClearTime;
|
private long lastClearTime;
|
||||||
private int nightModeConfiguration;
|
private int nightModeConfiguration;
|
||||||
private float fontScale;
|
private float fontScale;
|
||||||
|
private int layoutDirection;
|
||||||
|
|
||||||
static ViewCache getInstance() {
|
static ViewCache getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
|
@ -103,11 +104,16 @@ public class CachedInflater {
|
||||||
Configuration configuration = context.getResources().getConfiguration();
|
Configuration configuration = context.getResources().getConfiguration();
|
||||||
int currentNightModeConfiguration = ConfigurationUtil.getNightModeConfiguration(configuration);
|
int currentNightModeConfiguration = ConfigurationUtil.getNightModeConfiguration(configuration);
|
||||||
float currentFontScale = ConfigurationUtil.getFontScale(configuration);
|
float currentFontScale = ConfigurationUtil.getFontScale(configuration);
|
||||||
|
int currentLayoutDirection = configuration.getLayoutDirection();
|
||||||
|
|
||||||
if (nightModeConfiguration != currentNightModeConfiguration || fontScale != currentFontScale) {
|
if (nightModeConfiguration != currentNightModeConfiguration ||
|
||||||
|
fontScale != currentFontScale ||
|
||||||
|
layoutDirection != currentLayoutDirection)
|
||||||
|
{
|
||||||
clear();
|
clear();
|
||||||
nightModeConfiguration = currentNightModeConfiguration;
|
nightModeConfiguration = currentNightModeConfiguration;
|
||||||
fontScale = currentFontScale;
|
fontScale = currentFontScale;
|
||||||
|
layoutDirection = currentLayoutDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncLayoutInflater inflater = new AsyncLayoutInflater(context);
|
AsyncLayoutInflater inflater = new AsyncLayoutInflater(context);
|
||||||
|
@ -147,7 +153,10 @@ public class CachedInflater {
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
@Nullable View pull(@LayoutRes int layoutRes, @NonNull Configuration configuration) {
|
@Nullable View pull(@LayoutRes int layoutRes, @NonNull Configuration configuration) {
|
||||||
if (this.nightModeConfiguration != ConfigurationUtil.getNightModeConfiguration(configuration) || this.fontScale != ConfigurationUtil.getFontScale(configuration)) {
|
if (this.nightModeConfiguration != ConfigurationUtil.getNightModeConfiguration(configuration) ||
|
||||||
|
this.fontScale != ConfigurationUtil.getFontScale(configuration) ||
|
||||||
|
this.layoutDirection != configuration.getLayoutDirection())
|
||||||
|
{
|
||||||
clear();
|
clear();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue