当前位置: 首页>>代码示例>>Java>>正文


Java Application.getResources方法代码示例

本文整理汇总了Java中android.app.Application.getResources方法的典型用法代码示例。如果您正苦于以下问题:Java Application.getResources方法的具体用法?Java Application.getResources怎么用?Java Application.getResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Application的用法示例。


在下文中一共展示了Application.getResources方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.app.Application; //导入方法依赖的package包/类
/**
 * Initializes Lex with custom delimiters.  Must be called before any other Lex methods are invoked and should be called
 * ONLY from {@link Application#onCreate()}.
 * @param app
 * @param openDelimiter
 * @param closeDelimiter
 */
public static void init(@NonNull Application app, @NonNull String openDelimiter, @NonNull String closeDelimiter) {
    if(Lex.resources != null) {
        throw new LexAlreadyInitializedException();
    }

    Lex.resources = app.getResources();
    LexContext.setDefaultDelimiters(openDelimiter, closeDelimiter);
}
 
开发者ID:halfhp,项目名称:lex,代码行数:16,代码来源:Lex.java

示例2: estimateContentSize

import android.app.Application; //导入方法依赖的package包/类
/**
 * Provides an estimate of the contents size.
 *
 * The estimate is likely to be incorrect. This is not a problem, as the aim
 * is to avoid getting a different layout and resources than needed at
 * render time.
 * @param application The application to use for getting resources.
 * @param convertToDp Whether the value should be converted to dp from pixels.
 * @return The estimated prerender size in pixels or dp.
 */
public static Rect estimateContentSize(Application application, boolean convertToDp) {
    // The size is estimated as:
    // X = screenSizeX
    // Y = screenSizeY - top bar - bottom bar - custom tabs bar
    // The bounds rectangle includes the bottom bar and the custom tabs bar as well.
    Rect screenBounds = new Rect();
    Point screenSize = new Point();
    WindowManager wm = (WindowManager) application.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getSize(screenSize);
    Resources resources = application.getResources();
    int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
    try {
        screenSize.y -= resources.getDimensionPixelSize(statusBarId);
    } catch (Resources.NotFoundException e) {
        // Nothing, this is just a best effort estimate.
    }
    screenBounds.set(0,
            resources.getDimensionPixelSize(R.dimen.custom_tabs_control_container_height),
            screenSize.x, screenSize.y);

    if (convertToDp) {
        float density = resources.getDisplayMetrics().density;
        screenBounds.top = (int) Math.ceil(screenBounds.top / density);
        screenBounds.left = (int) Math.ceil(screenBounds.left / density);
        screenBounds.right = (int) Math.ceil(screenBounds.right / density);
        screenBounds.bottom = (int) Math.ceil(screenBounds.bottom / density);
    }
    return screenBounds;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:40,代码来源:ExternalPrerenderHandler.java

示例3: ChaosflixViewModel

import android.app.Application; //导入方法依赖的package包/类
public ChaosflixViewModel(Application application){
	super(application);
	Resources res = application.getResources();
	String recordingUrl = res.getString(R.string.api_media_ccc_url);
	String streamingUrl = res.getString(R.string.streaming_media_ccc_url);

	OkHttpClient client = new OkHttpClient();
	GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create();
	RxJava2CallAdapterFactory rxJava2CallAdapterFactory = RxJava2CallAdapterFactory.create();

	Retrofit retrofitRecordings = new Retrofit.Builder()
			.baseUrl(recordingUrl)
			.client(client)
			.addConverterFactory(gsonConverterFactory)
			.addCallAdapterFactory(rxJava2CallAdapterFactory)
			.build();
	recordingApi = retrofitRecordings.create(RecordingService.class);

	Retrofit retrofigStreaming = new Retrofit.Builder()
			.baseUrl(streamingUrl)
			.client(client)
			.addConverterFactory(gsonConverterFactory)
			.addCallAdapterFactory(rxJava2CallAdapterFactory)
			.build();
	streamingApi = retrofigStreaming.create(StreamingService.class);

	database = Room.databaseBuilder(getApplication().getApplicationContext(), ChaosflixDatabase.class, "mediaccc.db").build();
}
 
开发者ID:NiciDieNase,项目名称:chaosflix,代码行数:29,代码来源:ChaosflixViewModel.java

示例4: TrackerManager

import android.app.Application; //导入方法依赖的package包/类
private TrackerManager(Application application, int analyticsConfigLocation) {
    resources = application.getResources();
    mGaConfigLocation = analyticsConfigLocation;
    mTracker = getDefaultTracker(application);
}
 
开发者ID:smashingboxes,项目名称:android-analytics,代码行数:6,代码来源:TrackerManager.java

示例5: init

import android.app.Application; //导入方法依赖的package包/类
/**
 * Init the framework
 * 
 * @param application
 * @return
 * @throws Exception
 */
public void init(Application application,boolean reset) throws AssertionArrayException, Exception {
    if(application==null){
        throw new RuntimeException("application is null");
    }
    ApplicationInfo app_info = application.getApplicationInfo();
    sAPKSource = app_info.sourceDir;
    boolean DEBUG = (app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    RuntimeVariables.androidApplication = application;
    RuntimeVariables.delegateResources  = application.getResources();
    DelegateResources.walkroundActionMenuTextColor(RuntimeVariables.delegateResources);
    Framework.containerVersion = RuntimeVariables.sInstalledVersionName;
    ClassLoader cl = Atlas.class.getClassLoader();
    Framework.systemClassLoader = cl;
    // defineAndVerify
    String packageName = application.getPackageName();
    // 
    DelegateClassLoader newClassLoader = new DelegateClassLoader(cl);
    // init RuntimeVariables
    RuntimeVariables.delegateClassLoader = newClassLoader;

    AndroidHack.injectClassLoader(packageName, newClassLoader);
    AndroidHack.injectInstrumentationHook(new InstrumentationHook(AndroidHack.getInstrumentation(), application.getBaseContext()));
    // add listeners
    bundleLifecycleHandler = new BundleLifecycleHandler();
    Framework.syncBundleListeners.add(bundleLifecycleHandler);
    frameworkLifecycleHandler = new FrameworkLifecycleHandler();
    Framework.frameworkListeners.add(frameworkLifecycleHandler);

    try {
        ActivityManagerDelegate activityManagerProxy = new ActivityManagerDelegate();

        Object gDefault = null;
        if(Build.VERSION.SDK_INT>25 || (Build.VERSION.SDK_INT==25&&Build.VERSION.PREVIEW_SDK_INT>0)){
            gDefault=AtlasHacks.ActivityManager_IActivityManagerSingleton.get(AtlasHacks.ActivityManager.getmClass());
        }else{
            gDefault=AtlasHacks.ActivityManagerNative_gDefault.get(AtlasHacks.ActivityManagerNative.getmClass());
        }
        AtlasHacks.Singleton_mInstance.hijack(gDefault, activityManagerProxy);
    }catch(Throwable e){}
    AndroidHack.hackH();
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:49,代码来源:Atlas.java

示例6: resolver

import android.app.Application; //导入方法依赖的package包/类
@Provides
static StringResolver resolver(Application application) {
  return new StringResolver(application.getResources());
}
 
开发者ID:ashdavies,项目名称:eternity,代码行数:5,代码来源:ApplicationModule.java


注:本文中的android.app.Application.getResources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。