本文整理了Java中android.content.res.Configuration.<init>()
方法的一些代码示例,展示了Configuration.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.<init>()
方法的具体详情如下:
包路径:android.content.res.Configuration
类名称:Configuration
方法名:<init>
暂无
代码示例来源:origin: robolectric/robolectric
static Configuration ConstructConfigurationObject(/* JNIEnv* env,*/ ResTable_config config) {
// jobject result =
// env.NewObject(gConfigurationOffsets.classObject, gConfigurationOffsets.constructor);
Configuration result = new Configuration();
// if (result == null) {
// return null;
// }
result.smallestScreenWidthDp = config.smallestScreenWidthDp;
result.screenWidthDp = config.screenWidthDp;
result.screenHeightDp = config.screenHeightDp;
return result;
}
代码示例来源:origin: facebook/litho
static synchronized ResourceCache getLatest(Configuration configuration) {
if (latest == null || !latest.mConfiguration.equals(configuration)) {
latest = new LruResourceCache(new Configuration(configuration));
}
return latest;
}
代码示例来源:origin: facebook/litho
public static ComparableResDrawable create(Context context, @DrawableRes int resId) {
Configuration config = new Configuration(context.getResources().getConfiguration());
Drawable drawable = ContextCompat.getDrawable(context, resId);
return new ComparableResDrawable(resId, config, drawable);
}
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected static Resources getSystem() {
if (system == null) {
AssetManager assetManager = AssetManager.getSystem();
DisplayMetrics metrics = new DisplayMetrics();
Configuration config = new Configuration();
system = new Resources(assetManager, metrics, config);
}
return system;
}
代码示例来源:origin: robolectric/robolectric
@Override
public void onConfigurationChanged(Configuration newConfig) {
this.newConfig = new Configuration(newConfig);
super.onConfigurationChanged(newConfig);
}
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
configuration = new Configuration();
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
configuration = new Configuration();
displayMetrics = new DisplayMetrics();
optsForO = RuntimeEnvironment.getApiLevel() >= O
? "nowidecg-lowdr-"
: "";
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void createConfigurationContext() {
Configuration configuration = new Configuration(context.getResources().getConfiguration());
configuration.mcc = 234;
Context configurationContext = context.createConfigurationContext(configuration);
assertThat(configurationContext).isNotNull();
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
configuration = new Configuration();
displayMetrics = new DisplayMetrics();
apiLevel = RuntimeEnvironment.getApiLevel();
optsForO = RuntimeEnvironment.getApiLevel() >= O
? "nowidecg-lowdr-"
: "";
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testConstructCopy() {
configuration.setToDefaults();
Configuration clone = new Configuration(configuration);
assertThat(configuration).isEqualTo(clone);
}
代码示例来源:origin: robolectric/robolectric
@Test public void testToString_shouldntExplode() throws Exception {
assertThat(new Configuration().toString()).contains("mcc");
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Adds an event to be returned by {@link UsageStatsManager#queryEvents}.
*
* This method won't affect the results of {@link #queryUsageStats} method.
*
* @deprecated Use {@link #addEvent(Event)} and {@link EventBuilder} instead.
*/
@Deprecated
public void addEvent(String packageName, long timeStamp, int eventType) {
EventBuilder eventBuilder =
EventBuilder.buildEvent()
.setPackage(packageName)
.setTimeStamp(timeStamp)
.setEventType(eventType);
if (eventType == Event.CONFIGURATION_CHANGE) {
eventBuilder.setConfiguration(new Configuration());
}
addEvent(eventBuilder.build());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void configurationChange_callsLifecycleMethodsAndAppliesConfig() {
Configuration config =
new Configuration(
ApplicationProvider.getApplicationContext().getResources().getConfiguration());
final float newFontScale = config.fontScale *= 2;
controller.setup();
transcript.clear();
controller.configurationChange(config);
assertThat(transcript).containsAllOf("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume");
assertThat(controller.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale);
}
代码示例来源:origin: robolectric/robolectric
public static EventBuilder fromEvent(Event event) {
EventBuilder eventBuilder =
new EventBuilder()
.setPackage(event.mPackage)
.setClass(event.mClass)
.setTimeStamp(event.mTimeStamp)
.setEventType(event.mEventType)
.setConfiguration(event.mConfiguration);
if (event.mEventType == Event.CONFIGURATION_CHANGE) {
eventBuilder.setConfiguration(new Configuration());
}
return eventBuilder;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void configurationChange_callsOnConfigurationChangedAndAppliesConfigWhenAllManaged() {
Configuration config =
new Configuration(
ApplicationProvider.getApplicationContext().getResources().getConfiguration());
final float newFontScale = config.fontScale *= 2;
ActivityController<ConfigAwareActivity> configController =
Robolectric.buildActivity(ConfigAwareActivity.class).setup();
transcript.clear();
configController.configurationChange(config);
assertThat(transcript).contains("onConfigurationChanged");
assertThat(configController.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale);
}
代码示例来源:origin: facebook/litho
@Test
public void testSameConfigurationNewInstanceDoesNotUpdateResourceCache() {
Configuration configuration = RuntimeEnvironment.application.getResources().getConfiguration();
ResourceCache cache = ResourceCache.getLatest(configuration);
assertThat(cache).isEqualTo(ResourceCache.getLatest(new Configuration(configuration)));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void configurationChange_callsLifecycleMethodsAndAppliesConfigWhenAnyNonManaged() {
Configuration config =
new Configuration(
ApplicationProvider.getApplicationContext().getResources().getConfiguration());
final float newFontScale = config.fontScale *= 2;
final int newOrientation = config.orientation = (config.orientation + 1) % 3;
ActivityController<ConfigAwareActivity> configController =
Robolectric.buildActivity(ConfigAwareActivity.class).setup();
transcript.clear();
configController.configurationChange(config);
assertThat(transcript).containsAllOf("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onResume");
assertThat(configController.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale);
assertThat(configController.get().getResources().getConfiguration().orientation).isEqualTo(newOrientation);
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(qualifiers = "land")
public void configurationChange_restoresTheme() {
Configuration config =
new Configuration(
ApplicationProvider.getApplicationContext().getResources().getConfiguration());
config.orientation = Configuration.ORIENTATION_PORTRAIT;
controller.get().setTheme(android.R.style.Theme_Black);
controller.setup();
transcript.clear();
controller.configurationChange(config);
int restoredTheme = shadowOf((ContextThemeWrapper) controller.get()).callGetThemeResId();
assertThat(restoredTheme).isEqualTo(android.R.style.Theme_Black);
}
代码示例来源:origin: facebook/litho
@Test
public void testDifferentLocaleUpdatesResourceCache() {
Configuration configuration =
new Configuration(RuntimeEnvironment.application.getResources().getConfiguration());
setLocale(configuration, new Locale("en"));
ResourceCache cache = ResourceCache.getLatest(configuration);
setLocale(configuration, new Locale("it"));
assertThat(cache).isNotEqualTo(ResourceCache.getLatest(configuration));
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(qualifiers = "land")
public void configurationChange_reattachesRetainedFragments() {
Configuration config =
new Configuration(
ApplicationProvider.getApplicationContext().getResources().getConfiguration());
config.orientation = Configuration.ORIENTATION_PORTRAIT;
ActivityController<NonConfigStateActivity> configController =
Robolectric.buildActivity(NonConfigStateActivity.class).setup();
NonConfigStateActivity activity = configController.get();
Fragment retainedFragment = activity.retainedFragment;
Fragment otherFragment = activity.nonRetainedFragment;
configController.configurationChange(config);
activity = configController.get();
assertThat(activity.retainedFragment).isNotNull();
assertThat(activity.retainedFragment).isSameAs(retainedFragment);
assertThat(activity.nonRetainedFragment).isNotNull();
assertThat(activity.nonRetainedFragment).isNotSameAs(otherFragment);
}
内容来源于网络,如有侵权,请联系作者删除!