當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.getValue方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getValue方法的具體用法?Java Resources.getValue怎麽用?Java Resources.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getValue方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: enableFullscreenFlags

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Enable fullscreen related startup flags.
 * @param resources Resources to use while calculating initialization constants.
 * @param resControlContainerHeight The resource id for the height of the browser controls.
 */
public static void enableFullscreenFlags(
        Resources resources, Context context, int resControlContainerHeight) {
    ContentApplication.initCommandLine(context);

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN)) return;

    TypedValue threshold = new TypedValue();
    resources.getValue(R.dimen.top_controls_show_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_SHOW_THRESHOLD, threshold.coerceToString().toString());
    resources.getValue(R.dimen.top_controls_hide_threshold, threshold, true);
    Log.w("renshuai: ", "hello" + threshold.coerceToString().toString());
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_HIDE_THRESHOLD, threshold.coerceToString().toString());

}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:23,代碼來源:ApplicationInitialization.java

示例2: init

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Init
 *
 * @param context context application context
 */
static public void init(@NonNull final Context context)
{
	if (!Graphics.initDone)
	{
		final Resources resources = context.getApplicationContext().getResources();

		// font factor for resolution
		Graphics.PT2PX = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, 1, resources.getDisplayMetrics());

		// font factor for screen size
		final TypedValue outValue = new TypedValue();
		resources.getValue(R.dimen.font_factor, outValue, true);
		Graphics.fontFactor = outValue.getFloat();

		Graphics.initDone = true;
	}
}
 
開發者ID:1313ou,項目名稱:TreebolicLib,代碼行數:23,代碼來源:Graphics.java

示例3: FeatureOverlayQuery

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Constructor
 *
 * @param context
 * @param boundedOverlay
 * @param featureTiles
 * @since 1.2.5
 */
public FeatureOverlayQuery(Context context, BoundedOverlay boundedOverlay, FeatureTiles featureTiles) {
    this.boundedOverlay = boundedOverlay;
    this.featureTiles = featureTiles;

    Resources resources = context.getResources();

    // Get the screen percentage to determine when a feature is clicked
    TypedValue screenPercentage = new TypedValue();
    resources.getValue(R.dimen.map_feature_overlay_click_screen_percentage, screenPercentage, true);
    screenClickPercentage = screenPercentage.getFloat();

    maxFeaturesInfo = resources.getBoolean(R.bool.map_feature_overlay_max_features_info);
    featuresInfo = resources.getBoolean(R.bool.map_feature_overlay_features_info);

    FeatureDao featureDao = featureTiles.getFeatureDao();
    featureInfoBuilder = new FeatureInfoBuilder(context, featureDao);
}
 
開發者ID:ngageoint,項目名稱:geopackage-android-map,代碼行數:26,代碼來源:FeatureOverlayQuery.java

示例4: generateResourceNameFromId

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Generates a Resource name from resourceId located in res/ folder.
 *
 * @param resourceId id of the resource, must be greater then 0.
 * @return resourceName in format folder/file.extension.
 */
public static String generateResourceNameFromId(int resourceId) {
  try {
    if (resourceId <= 0) {
      Log.w("Provided resource id is invalid.");
      return null;
    }
    Resources resources = Leanplum.getContext().getResources();
    // Get entryName from resourceId, which represents a file name in res/ directory.
    String entryName = resources.getResourceEntryName(resourceId);
    // Get typeName from resourceId, which represents a folder where file is located in
    // res/ directory.
    String typeName = resources.getResourceTypeName(resourceId);

    // By using TypedValue we can get full path of a file with extension.
    TypedValue value = new TypedValue();
    resources.getValue(resourceId, value, true);

    // Regex matching to find real file extension, "image.img.png" will produce "png".
    String[] fullFileName = value.string.toString().split("\\.(?=[^\\.]+$)");
    String extension = "";
    // If extension is found, we will append dot before it.
    if (fullFileName.length == 2) {
      extension = "." + fullFileName[1];
    }

    // Return full resource name in format: drawable/image.png
    return typeName + "/" + entryName + extension;
  } catch (Exception e) {
    Log.w("Failed to generate resource name from provided resource id: ", e);
    Util.handleException(e);
  }
  return null;
}
 
開發者ID:Leanplum,項目名稱:Leanplum-Android-SDK,代碼行數:40,代碼來源:Util.java

示例5: PhoneTabSwitcherLayout

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Creates a new layout, which implements the functionality of a {@link TabSwitcher} on
 * smartphones.
 *
 * @param tabSwitcher
 *         The tab switcher, the layout belongs to, as an instance of the class {@link
 *         TabSwitcher}. The tab switcher may not be null
 * @param model
 *         The model of the tab switcher, the layout belongs to, as an instance of the class
 *         {@link TabSwitcherModel}. The model may not be null
 * @param arithmetics
 *         The arithmetics, which should be used by the layout, as an instance of the class
 *         {@link PhoneArithmetics}. The arithmetics may not be null
 * @param style
 *         The style, which allows to retrieve style attributes of the tab switcher, as an
 *         instance of the class {@link TabSwitcherStyle}. The style may not be null
 * @param touchEventDispatcher
 *         The dispatcher, which is used to dispatch touch events to event handlers, as an
 *         instance of the class {@link TouchEventDispatcher}. The dispatcher may not be null
 */
public PhoneTabSwitcherLayout(@NonNull final TabSwitcher tabSwitcher,
                              @NonNull final TabSwitcherModel model,
                              @NonNull final PhoneArithmetics arithmetics,
                              @NonNull final TabSwitcherStyle style,
                              @NonNull final TouchEventDispatcher touchEventDispatcher) {
    super(tabSwitcher, model, arithmetics, style, touchEventDispatcher);
    Resources resources = tabSwitcher.getResources();
    stackedTabCount = resources.getInteger(R.integer.phone_stacked_tab_count);
    tabInset = resources.getDimensionPixelSize(R.dimen.tab_inset);
    tabBorderWidth = resources.getDimensionPixelSize(R.dimen.tab_border_width);
    tabTitleContainerHeight =
            resources.getDimensionPixelSize(R.dimen.tab_title_container_height);
    maxCameraDistance = resources.getDimensionPixelSize(R.dimen.max_camera_distance);
    TypedValue typedValue = new TypedValue();
    resources.getValue(R.dimen.swiped_tab_scale, typedValue, true);
    swipedTabScale = typedValue.getFloat();
    resources.getValue(R.dimen.swiped_tab_alpha, typedValue, true);
    swipedTabAlpha = typedValue.getFloat();
    showSwitcherAnimationDuration =
            resources.getInteger(R.integer.show_switcher_animation_duration);
    hideSwitcherAnimationDuration =
            resources.getInteger(R.integer.hide_switcher_animation_duration);
    toolbarVisibilityAnimationDuration =
            resources.getInteger(R.integer.toolbar_visibility_animation_duration);
    toolbarVisibilityAnimationDelay =
            resources.getInteger(R.integer.toolbar_visibility_animation_delay);
    swipeAnimationDuration = resources.getInteger(R.integer.swipe_animation_duration);
    relocateAnimationDuration = resources.getInteger(R.integer.relocate_animation_duration);
    revertOvershootAnimationDuration =
            resources.getInteger(R.integer.revert_overshoot_animation_duration);
    revealAnimationDuration = resources.getInteger(R.integer.reveal_animation_duration);
    peekAnimationDuration = resources.getInteger(R.integer.peek_animation_duration);
    emptyViewAnimationDuration = resources.getInteger(R.integer.empty_view_animation_duration);
    maxStartOvershootAngle = resources.getInteger(R.integer.max_start_overshoot_angle);
    maxEndOvershootAngle = resources.getInteger(R.integer.max_end_overshoot_angle);
    swipedTabDistance = resources.getDimensionPixelSize(R.dimen.swiped_tab_distance);
    tabViewBottomMargin = -1;
    toolbarAnimation = null;
}
 
開發者ID:michael-rapp,項目名稱:ChromeLikeTabSwitcher,代碼行數:60,代碼來源:PhoneTabSwitcherLayout.java

示例6: PhoneTabSwitcherLayout

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Creates a new layout, which implements the functionality of a {@link TabSwitcher} on
 * smartphones.
 *
 * @param tabSwitcher
 *         The tab switcher, the layout belongs to, as an instance of the class {@link
 *         TabSwitcher}. The tab switcher may not be null
 * @param model
 *         The model of the tab switcher, the layout belongs to, as an instance of the class
 *         {@link TabSwitcherModel}. The model may not be null
 * @param arithmetics
 *         The arithmetics, which should be used by the layout, as an instance of the class
 *         {@link PhoneArithmetics}. The arithmetics may not be null
 */
public PhoneTabSwitcherLayout(@NonNull final TabSwitcher tabSwitcher,
                              @NonNull final TabSwitcherModel model,
                              @NonNull final PhoneArithmetics arithmetics) {
    super(tabSwitcher, model, arithmetics);
    Resources resources = tabSwitcher.getResources();
    tabInset = resources.getDimensionPixelSize(R.dimen.tab_inset);
    tabBorderWidth = resources.getDimensionPixelSize(R.dimen.tab_border_width);
    tabTitleContainerHeight =
            resources.getDimensionPixelSize(R.dimen.tab_title_container_height);
    stackedTabCount = resources.getInteger(R.integer.stacked_tab_count);
    stackedTabSpacing = resources.getDimensionPixelSize(R.dimen.stacked_tab_spacing);
    maxCameraDistance = resources.getDimensionPixelSize(R.dimen.max_camera_distance);
    TypedValue typedValue = new TypedValue();
    resources.getValue(R.dimen.swiped_tab_scale, typedValue, true);
    swipedTabScale = typedValue.getFloat();
    resources.getValue(R.dimen.swiped_tab_alpha, typedValue, true);
    swipedTabAlpha = typedValue.getFloat();
    showSwitcherAnimationDuration =
            resources.getInteger(R.integer.show_switcher_animation_duration);
    hideSwitcherAnimationDuration =
            resources.getInteger(R.integer.hide_switcher_animation_duration);
    toolbarVisibilityAnimationDuration =
            resources.getInteger(R.integer.toolbar_visibility_animation_duration);
    toolbarVisibilityAnimationDelay =
            resources.getInteger(R.integer.toolbar_visibility_animation_delay);
    swipeAnimationDuration = resources.getInteger(R.integer.swipe_animation_duration);
    clearAnimationDelay = resources.getInteger(R.integer.clear_animation_delay);
    relocateAnimationDuration = resources.getInteger(R.integer.relocate_animation_duration);
    relocateAnimationDelay = resources.getInteger(R.integer.relocate_animation_delay);
    revertOvershootAnimationDuration =
            resources.getInteger(R.integer.revert_overshoot_animation_duration);
    revealAnimationDuration = resources.getInteger(R.integer.reveal_animation_duration);
    peekAnimationDuration = resources.getInteger(R.integer.peek_animation_duration);
    maxStartOvershootAngle = resources.getInteger(R.integer.max_start_overshoot_angle);
    maxEndOvershootAngle = resources.getInteger(R.integer.max_end_overshoot_angle);
    tabViewBottomMargin = -1;
    toolbarAnimation = null;
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:53,代碼來源:PhoneTabSwitcherLayout.java

示例7: init

import android.content.res.Resources; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
    if (isInEditMode()) {
        return;
    }

    LayoutInflater layoutInflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    layoutInflater.inflate(R.layout.number_picker, this);

    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.ScrollableNumberPicker);
    Resources res = getResources();

    downIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconDown, downIcon);
    upIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconUp, upIcon);
    leftIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconLeft, leftIcon);
    rightIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconRight, rightIcon);

    mMinValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_minValue,
        res.getInteger(R.integer.default_minValue));
    mMaxValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_maxValue,
        res.getInteger(R.integer.default_maxValue));

    mStepSize = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_stepSize,
        res.getInteger(R.integer.default_stepSize));

    mUpdateIntervalMillis = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_updateInterval,
        res.getInteger(R.integer.default_updateInterval));

    mOrientation = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_orientation,
        LinearLayout.HORIZONTAL);

    mValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_value,
        res.getInteger(R.integer.default_value));

    mValueTextSize = typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_value_text_size,
        INVALID_RES);
    mValueTextColor = typedArray.getColor(R.styleable.ScrollableNumberPicker_snp_value_text_color,
        0);
    mValueTextAppearanceResId = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_value_text_appearance, INVALID_RES);

    mScrollEnabled = typedArray.getBoolean(R.styleable.ScrollableNumberPicker_snp_scrollEnabled,
        res.getBoolean(R.bool.default_scrollEnabled));

    mButtonColorStateList = ContextCompat.getColorStateList(context, typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonBackgroundTintSelector, R.color.btn_tint_selector));

    mValueMarginStart = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_start));
    mValueMarginEnd = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_end));

    mButtonPaddingLeft = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingLeft, res.getDimension(R.dimen.default_button_padding_left));
    mButtonPaddingRight = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingRight, res.getDimension(R.dimen.default_button_padding_right));
    mButtonPaddingTop = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingTop, res.getDimension(R.dimen.default_button_padding_top));
    mButtonPaddingBottom = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingBottom, res.getDimension(R.dimen.default_button_padding_bottom));

    TypedValue outValue = new TypedValue();
    res.getValue(R.dimen.default_button_scale_factor, outValue, true);
    float defaultValue = outValue.getFloat();
    mButtonTouchScaleFactor = typedArray.getFloat(R.styleable.ScrollableNumberPicker_snp_buttonTouchScaleFactor, defaultValue);

    typedArray.recycle();

    initViews();

    mAutoIncrement = false;
    mAutoDecrement = false;

    mUpdateIntervalHandler = new Handler();
}
 
開發者ID:michaelmuenzer,項目名稱:ScrollableNumberPicker,代碼行數:69,代碼來源:ScrollableNumberPicker.java

示例8: getDataBinderMapper

import android.content.res.Resources; //導入方法依賴的package包/類
private static Object getDataBinderMapper(Application application, Resources resource, int resourceId)
{
    TypedValue value = new TypedValue();
    resource.getValue(resourceId, value, false);
    int cookie = value.assetCookie;
    try
    {
        String className = null;
        String bundleLocation = null;
        String assetsPath = (String)AssetManager.class.getMethod("getCookieName", new Class[] { Integer.TYPE }).invoke(resource.getAssets(), new Object[] { Integer.valueOf(cookie) });
        if (assetsPath.endsWith(".zip"))
        {
            bundleLocation = substringBetween(assetsPath, "/storage/", "/version.");
            className = String.format("%s.%s", new Object[] { bundleLocation, "DataBinderMapper" });
        }
        else if (assetsPath.endsWith(".so"))
        {
            List<Bundle> bundles = Atlas.getInstance().getBundles();
            for (int x = 0; x < bundles.size(); x++)
            {
                BundleImpl impl = (BundleImpl)bundles.get(x);
                if (impl.getArchive().getArchiveFile().getAbsolutePath().equals(assetsPath))
                {
                    bundleLocation = impl.getLocation();
                    className = String.format("%s.%s", new Object[] { bundleLocation, "DataBinderMapper" });
                    break;
                }
            }
        }
        else
        {
            className = "android.databinding.DataBinderMapper";
        }
        if (TextUtils.isEmpty(className)) {
            throw new RuntimeException("can not find DatabindMapper : " + assetsPath);
        }
        Class clazz = application.getClassLoader().loadClass(className);
        Object dataMapper = clazz.newInstance();
        sMappers.put(bundleLocation, dataMapper);
        return dataMapper;
    }
    catch (Throwable e)
    {
        throw new RuntimeException(e);
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:47,代碼來源:AtlasDataBindingUtil.java

示例9: loadDrawableFromDelegates

import android.content.res.Resources; //導入方法依賴的package包/類
private Drawable loadDrawableFromDelegates(@NonNull Context context, @DrawableRes int resId) {
    if (this.mDelegates == null || this.mDelegates.isEmpty()) {
        return null;
    }
    if (this.mKnownDrawableIdTags != null) {
        String cachedTagName = (String) this.mKnownDrawableIdTags.get(resId);
        if (SKIP_DRAWABLE_TAG.equals(cachedTagName) || (cachedTagName != null && this.mDelegates.get(cachedTagName) == null)) {
            return null;
        }
    }
    this.mKnownDrawableIdTags = new SparseArray();
    if (this.mTypedValue == null) {
        this.mTypedValue = new TypedValue();
    }
    TypedValue tv = this.mTypedValue;
    Resources res = context.getResources();
    res.getValue(resId, tv, true);
    long key = (((long) tv.assetCookie) << 32) | ((long) tv.data);
    Drawable dr = getCachedDelegateDrawable(context, key);
    if (dr != null) {
        return dr;
    }
    if (tv.string != null && tv.string.toString().endsWith(".xml")) {
        try {
            int type;
            XmlPullParser parser = res.getXml(resId);
            AttributeSet attrs = Xml.asAttributeSet(parser);
            do {
                type = parser.next();
                if (type == 2) {
                    break;
                }
            } while (type != 1);
            if (type != 2) {
                throw new XmlPullParserException("No start tag found");
            }
            String tagName = parser.getName();
            this.mKnownDrawableIdTags.append(resId, tagName);
            InflateDelegate delegate = (InflateDelegate) this.mDelegates.get(tagName);
            if (delegate != null) {
                dr = delegate.createFromXmlInner(context, parser, attrs, context.getTheme());
            }
            if (dr != null) {
                dr.setChangingConfigurations(tv.changingConfigurations);
                if (addCachedDelegateDrawable(context, key, dr)) {
                }
            }
        } catch (Exception e) {
            Log.e(TAG, "Exception while inflating drawable", e);
        }
    }
    if (dr != null) {
        return dr;
    }
    this.mKnownDrawableIdTags.append(resId, SKIP_DRAWABLE_TAG);
    return dr;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:58,代碼來源:AppCompatDrawableManager.java


注:本文中的android.content.res.Resources.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。