本文整理匯總了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);
}