You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
8 years ago
|
/*
|
||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*/
|
||
|
|
||
|
package codetoanalyze.java.checkers;
|
||
|
|
||
|
import javax.annotation.concurrent.ThreadSafe;
|
||
|
|
||
|
import android.content.res.AssetManager;
|
||
|
import android.content.res.Configuration;
|
||
|
import android.content.res.Resources;
|
||
|
import android.util.DisplayMetrics;
|
||
|
|
||
|
class MyResources extends Resources {
|
||
|
|
||
|
public MyResources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
|
||
|
super(assets, metrics, config);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
@ThreadSafe
|
||
|
public class AndroidModels {
|
||
|
|
||
|
Resources mResources;
|
||
|
MyResources mMyResources;
|
||
|
|
||
|
Object mField;
|
||
|
|
||
|
// assume that some Resources methods are annotated with @Functional
|
||
|
public void resourceMethodFunctionalOk() {
|
||
|
mField = mResources.getString(0);
|
||
|
}
|
||
|
|
||
|
// and subclasses of Resources too
|
||
|
public void customResourceMethodFunctionalOk() {
|
||
|
mField = mResources.getString(0);
|
||
|
}
|
||
|
|
||
|
// but not all of them
|
||
|
public void someResourceMethodsNotFunctionalBad() {
|
||
|
// configuration can change whenever the device rotates
|
||
|
mField = mResources.getConfiguration();
|
||
|
}
|
||
|
|
||
|
}
|