當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。