本文整理汇总了Java中android.app.Activity.getResources方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getResources方法的具体用法?Java Activity.getResources怎么用?Java Activity.getResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getResources方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLabel
import android.app.Activity; //导入方法依赖的package包/类
/**
* 获取 activity 的 label 属性
*/
private static String getLabel(Activity activity, ActivityInfo ai) {
String label;
Resources res = activity.getResources();
// 获取 Activity label(如有)
label = getLabelById(res, ai.labelRes);
// 获取插件 Application Label(如有)
if (TextUtils.isEmpty(label)) {
label = getLabelById(res, ai.applicationInfo.labelRes);
}
// 获取宿主 App label
if (TextUtils.isEmpty(label)) {
Context appContext = RePluginInternal.getAppContext();
Resources appResource = appContext.getResources();
ApplicationInfo appInfo = appContext.getApplicationInfo();
label = getLabelById(appResource, appInfo.labelRes);
}
if (LOG) {
LogDebug.d(TAG, "label = " + label);
}
return label;
}
示例2: getStatusBarHeight
import android.app.Activity; //导入方法依赖的package包/类
/**
* 获取顶部status bar 高度
*/
public static int getStatusBarHeight(Activity mActivity) {
Resources resources = mActivity.getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
int height = resources.getDimensionPixelSize(resourceId);
Log.i("height","Status height:" + height);
return height;
}
示例3: getNavigationBarHeight
import android.app.Activity; //导入方法依赖的package包/类
/**
* 获取NavigationBar的高度
*
* @param activity activity
* @return NavigationBar高度
*/
public static int getNavigationBarHeight(Activity activity) {
Resources resources = activity.getResources();
int rid = resources.getIdentifier("config_showNavigationBar", "bool", "android");
if (rid > 0) Log.v(TAG, "导航栏是否显示?" + resources.getBoolean(rid));
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) return resources.getDimensionPixelSize(resourceId);
return 0;
}
示例4: downloadImageUrl
import android.app.Activity; //导入方法依赖的package包/类
private void downloadImageUrl(final Activity activity, final String imageUrl) {
final SimpleTarget<Bitmap> target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
mUserImage = new BitmapDrawable(activity.getResources(), bitmap);
mFacebookLoginResultCallBack.onFacebookLoginSuccess(mLoginResult);
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
mFacebookLoginResultCallBack.onFacebookLoginImageDownloadFailed();
}
};
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
RequestOptions options = new RequestOptions()
.placeholder(R.mipmap.ic_launcher_round);
Glide.with(activity.getApplicationContext())
.asBitmap()
.apply(options)
.load(imageUrl)
.into(target);
}
});
}
示例5: setBarTheme
import android.app.Activity; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static void setBarTheme(Activity activity, int theme) {
Button menuButton = (Button)activity.findViewById(R.id.menuButton);
Button searchButton = (Button)activity.findViewById(R.id.searchButton);
Button webSearchButton = (Button)activity.findViewById(R.id.webSearchButton);
EditText searchField = (EditText)activity.findViewById(R.id.textField);
Resources resources = activity.getResources();
switch (theme) {
case DEFAULT_THEME:
case LIGHT:
case WALLPAPER_LIGHT:
if (Build.VERSION.SDK_INT >= 16) {
menuButton.setBackground(resources.getDrawable(R.drawable.menu_bg));
searchButton.setBackground(resources.getDrawable(R.drawable.search_bg));
webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_bg));
} else {
menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_bg));
searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_bg));
webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_bg));
}
searchField.setTextColor(Color.WHITE);
break;
default:
if (Build.VERSION.SDK_INT >= 16) {
menuButton.setBackground(resources.getDrawable(R.drawable.menu_dark_bg));
searchButton.setBackground(resources.getDrawable(R.drawable.search_dark_bg));
webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_dark_bg));
} else {
menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_dark_bg));
searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_dark_bg));
webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_dark_bg));
}
searchField.setTextColor(Color.BLACK);
}
}
示例6: SystemBarConfig
import android.app.Activity; //导入方法依赖的package包/类
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
mTranslucentStatusBar = translucentStatusBar;
mTranslucentNavBar = traslucentNavBar;
}
示例7: StopOnLastElement
import android.app.Activity; //导入方法依赖的package包/类
public void StopOnLastElement(Bitmap bitmap[], Activity activity, int IdOfView, final int Duration)
{
LAST_FLAG_VALUE=bitmap.length;
view=activity.findViewById(IdOfView);
drawable=new Drawable[bitmap.length];
for (int i=0;i<bitmap.length;i++)
{
drawable[i]=new BitmapDrawable(activity.getResources(),bitmap[i]);
}
StopOnLastElementExecute(drawable,Duration);
}
示例8: getMessageForEnablingOsGlobalPermission
import android.app.Activity; //导入方法依赖的package包/类
@Override
protected String getMessageForEnablingOsGlobalPermission(Activity activity) {
Resources resources = activity.getResources();
if (enabledForChrome(activity)) {
return resources.getString(R.string.android_location_off_globally);
}
return resources.getString(R.string.android_location_also_off_globally);
}
示例9: ActivityConfig
import android.app.Activity; //导入方法依赖的package包/类
public ActivityConfig(@NonNull Activity activity) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = mNavigationBarHeight > 0;
}
示例10: BarConfig
import android.app.Activity; //导入方法依赖的package包/类
public BarConfig(Activity activity) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
}
示例11: SystemBarConfig
import android.app.Activity; //导入方法依赖的package包/类
private SystemBarConfig(Activity activity, boolean translucentStatusBar,
boolean traslucentNavBar) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
mHasNavigationBar = (mNavigationBarHeight > 0);
mTranslucentStatusBar = translucentStatusBar;
mTranslucentNavBar = traslucentNavBar;
}
示例12: AppAdapter
import android.app.Activity; //导入方法依赖的package包/类
public AppAdapter(Activity activity, RecyclerView recyclerView) {
super(activity, recyclerView);
mResources = activity.getResources();
mMatrix = new ColorMatrix();
mMatrix.setSaturation(0); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。
mColorFilterGrey = new ColorMatrixColorFilter(mMatrix);
mMatrix.setSaturation(1); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。
mColorFilterNormal = new ColorMatrixColorFilter(mMatrix);
mMatrix.setSaturation(0.2f); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。
mColorFilter50 = new ColorMatrixColorFilter(mMatrix);
}
示例13: hasNavBar
import android.app.Activity; //导入方法依赖的package包/类
public static boolean hasNavBar(Activity activity) {
Resources resources = activity.getResources();
int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0) {
return resources.getBoolean(id);
} else { // Check for keys
boolean hasMenuKey = ViewConfiguration.get(activity).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
return !hasMenuKey && !hasBackKey;
}
}
示例14: ValidateActivityResource
import android.app.Activity; //导入方法依赖的package包/类
private boolean ValidateActivityResource(Activity activity){
String exceptionString = null;
String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
BundleImpl b = (BundleImpl)Framework.getBundle(bundleName);
String bundlePath = null;
if (b != null){
bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
}
Resources resource = null;
if (AtlasHacks.ContextThemeWrapper_mResources != null){
resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
} else {
resource = activity.getResources();
}
Resources resource_runtime = RuntimeVariables.delegateResources;
if (resource == resource_runtime){
return true;
}
List<String> paths = getAssetPathFromResources(resource);
String pathsOfHis = DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
List<String> pathsRuntime = getAssetPathFromResources(resource_runtime);
if ((bundlePath != null) && (paths != null) && !paths.contains(bundlePath)){
exceptionString += "(1.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
if (!pathsOfHis.contains(bundlePath)){
exceptionString += "(1.2) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (!pathsRuntime.contains(bundlePath)){
exceptionString += "(1.3) paths in runtime not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (b.getArchive().getArchiveFile().exists() == false){
exceptionString += "(1.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
exceptionString += "(1.5) Activity Resources paths length:" + paths.size();
}
if (exceptionString != null){
return false;
}
return true;
}
示例15: HandleResourceNotFound
import android.app.Activity; //导入方法依赖的package包/类
private void HandleResourceNotFound(Activity activity, Bundle icicle, Exception e) {
if(activity!=null && !ErrorActivityRecords.contains(activity.getClass().getName())){
//fix #8224429
ErrorActivityRecords.add(activity.getClass().getName());
try {
activity.finish();
}catch(Throwable e2){}
return;
}
String exceptionString = null;
try{
Resources resource = null;
if (AtlasHacks.ContextThemeWrapper_mResources != null){
resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
} else {
resource = activity.getResources();
}
List<String> paths = getAssetPathFromResources(resource);
List<String> pathsRuntime = getAssetPathFromResources(RuntimeVariables.delegateResources);
String pathsOfHis = DelegateResources.getCurrentAssetpathStr(resource.getAssets());
String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
BundleImpl b = (BundleImpl)Framework.getBundle(bundleName);
exceptionString += "Paths: " + paths;
if (b != null){
String bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
if (!paths.contains(bundlePath)){
exceptionString += "(2.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (!pathsRuntime.contains(bundlePath)){
exceptionString += "(2.2) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (!pathsOfHis.contains(bundlePath)){
exceptionString += "(2.3) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (b.getArchive().getArchiveFile().exists() == false){
exceptionString += "(2.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
if (FileUtils.CheckFileValidation(b.getArchive().getArchiveFile().getAbsolutePath())){
exceptionString += "(2.5) Bundle archive file can not opened with stream:" + b.getArchive().getArchiveFile().getAbsolutePath();
}
}
if (resource == RuntimeVariables.delegateResources){
exceptionString += "(2.6) DelegateResources equals Activity Resources";
}
exceptionString += "(2.7) Activity Resources paths length:" + paths.size();
} catch (Exception e1){
String pathsInRunTime = " " + DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
exceptionString = "(2.8) paths in history:" + pathsInRunTime + " getAssetPath fail: " + e1;
}
throw new RuntimeException( exceptionString, e);
}