Ejemplo n.º 1
0
 /** 检查是否处于透明背景状态 */
 private void checkRightSlidingFinishActivity() {
   /** 解析是否可以使用右滑 finish activity功能 */
   if (!this.ignoreRightSlidingFinishActivity) {
     String windowIsTranslucent, windowBackground;
     TypedValue outValue = new TypedValue();
     getTheme().resolveAttribute(android.R.attr.windowIsTranslucent, outValue, true);
     windowIsTranslucent = String.valueOf(outValue.coerceToString());
     getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true);
     windowBackground = String.valueOf(outValue.coerceToString());
     this.ignoreRightSlidingFinishActivity =
         !("true".equals(windowIsTranslucent) && "#0".equals(windowBackground));
   }
 }
 public String getAttributeValue(int index) {
   int offset = getAttributeOffset(index);
   int valueType = m_attributes[offset + ATTRIBUTE_IX_VALUE_TYPE];
   if (valueType == TypedValue.TYPE_STRING) {
     int valueString = m_attributes[offset + ATTRIBUTE_IX_VALUE_STRING];
     return m_strings.getRaw(valueString);
   }
   int valueData = m_attributes[offset + ATTRIBUTE_IX_VALUE_DATA];
   return TypedValue.coerceToString(valueType, valueData);
 }
 /**
  * Retrieve the string value associated with a particular resource identifier for the current
  * configuration / skin.
  */
 /*package*/ final CharSequence getResourceBagText(int ident, int bagEntryId) {
   synchronized (this) {
     TypedValue tmpValue = mValue;
     int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true);
     if (block >= 0) {
       if (tmpValue.type == TypedValue.TYPE_STRING) {
         return mStringBlocks[block].get(tmpValue.data);
       }
       return tmpValue.coerceToString();
     }
   }
   return null;
 }
Ejemplo n.º 4
0
  /**
   * Retrieve the styled string value for the attribute at <var>index</var>.
   *
   * @param index Index of attribute to retrieve.
   * @return CharSequence holding string data. May be styled. Returns null if the attribute is not
   *     defined.
   */
  public CharSequence getText(int index) {
    index *= AssetManager.STYLE_NUM_ENTRIES;
    final int[] data = mData;
    final int type = data[index + AssetManager.STYLE_TYPE];
    if (type == TypedValue.TYPE_NULL) {
      return null;
    } else if (type == TypedValue.TYPE_STRING) {
      return loadStringValueAt(index);
    }

    TypedValue v = mValue;
    if (getValueAt(index, v)) {
      Log.w(Resources.TAG, "Converting to string: " + v);
      return v.coerceToString();
    }
    Log.w(Resources.TAG, "getString of bad type: 0x" + Integer.toHexString(type));
    return null;
  }
Ejemplo n.º 5
0
  /**
   * Retrieve the integer value for the attribute at <var>index</var>.
   *
   * @param index Index of attribute to retrieve.
   * @param defValue Value to return if the attribute is not defined.
   * @return Attribute int value, or defValue if not defined.
   */
  public int getInt(int index, int defValue) {
    index *= AssetManager.STYLE_NUM_ENTRIES;
    final int[] data = mData;
    final int type = data[index + AssetManager.STYLE_TYPE];
    if (type == TypedValue.TYPE_NULL) {
      return defValue;
    } else if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
      return data[index + AssetManager.STYLE_DATA];
    }

    TypedValue v = mValue;
    if (getValueAt(index, v)) {
      Log.w(Resources.TAG, "Converting to int: " + v);
      return XmlUtils.convertValueToInt(v.coerceToString(), defValue);
    }
    Log.w(Resources.TAG, "getInt of bad type: 0x" + Integer.toHexString(type));
    return defValue;
  }
Ejemplo n.º 6
0
  /**
   * @hide Retrieve the string value for the attribute at <var>index</var> that is not allowed to
   *     change with the given configurations.
   * @param index Index of attribute to retrieve.
   * @param allowedChangingConfigs Bit mask of configurations from ActivityInfo that are allowed to
   *     change.
   * @return String holding string data. Any styling information is removed. Returns null if the
   *     attribute is not defined.
   */
  public String getNonConfigurationString(int index, int allowedChangingConfigs) {
    index *= AssetManager.STYLE_NUM_ENTRIES;
    final int[] data = mData;
    final int type = data[index + AssetManager.STYLE_TYPE];
    if ((data[index + AssetManager.STYLE_CHANGING_CONFIGURATIONS] & ~allowedChangingConfigs) != 0) {
      return null;
    }
    if (type == TypedValue.TYPE_NULL) {
      return null;
    } else if (type == TypedValue.TYPE_STRING) {
      return loadStringValueAt(index).toString();
    }

    TypedValue v = mValue;
    if (getValueAt(index, v)) {
      Log.w(Resources.TAG, "Converting to string: " + v);
      CharSequence cs = v.coerceToString();
      return cs != null ? cs.toString() : null;
    }
    Log.w(Resources.TAG, "getString of bad type: 0x" + Integer.toHexString(type));
    return null;
  }
Ejemplo n.º 7
0
  /**
   * Retrieve the float value for the attribute at <var>index</var>.
   *
   * @param index Index of attribute to retrieve.
   * @return Attribute float value, or defValue if not defined..
   */
  public float getFloat(int index, float defValue) {
    index *= AssetManager.STYLE_NUM_ENTRIES;
    final int[] data = mData;
    final int type = data[index + AssetManager.STYLE_TYPE];
    if (type == TypedValue.TYPE_NULL) {
      return defValue;
    } else if (type == TypedValue.TYPE_FLOAT) {
      return Float.intBitsToFloat(data[index + AssetManager.STYLE_DATA]);
    } else if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
      return data[index + AssetManager.STYLE_DATA];
    }

    TypedValue v = mValue;
    if (getValueAt(index, v)) {
      Log.w(Resources.TAG, "Converting to float: " + v);
      CharSequence str = v.coerceToString();
      if (str != null) {
        return Float.parseFloat(str.toString());
      }
    }
    Log.w(Resources.TAG, "getFloat of bad type: 0x" + Integer.toHexString(type));
    return defValue;
  }