private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray attr =
        context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0);
    mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, 0xFFDA4336);
    mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, 0xFFE75043);
    mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled, 0xFFAAAAAA);
    mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple, 0x99FFFFFF);
    mShowShadow = attr.getBoolean(R.styleable.FloatingActionButton_fab_showShadow, true);
    mShadowColor = attr.getColor(R.styleable.FloatingActionButton_fab_shadowColor, 0x66000000);
    mShadowRadius =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowRadius, mShadowRadius);
    mShadowXOffset =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowXOffset, mShadowXOffset);
    mShadowYOffset =
        attr.getDimensionPixelSize(
            R.styleable.FloatingActionButton_fab_shadowYOffset, mShadowYOffset);
    mFabSize = attr.getInt(R.styleable.FloatingActionButton_fab_size, SIZE_NORMAL);
    mLabelText = attr.getString(R.styleable.FloatingActionButton_fab_label);
    mShouldProgressIndeterminate =
        attr.getBoolean(R.styleable.FloatingActionButton_fab_progress_indeterminate, false);
    mProgressColor = attr.getColor(R.styleable.FloatingActionButton_fab_progress_color, 0xFF009688);
    mProgressBackgroundColor =
        attr.getColor(R.styleable.FloatingActionButton_fab_progress_backgroundColor, 0x4D000000);
    mProgressMax = attr.getInt(R.styleable.FloatingActionButton_fab_progress_max, mProgressMax);
    mShowProgressBackground =
        attr.getBoolean(R.styleable.FloatingActionButton_fab_progress_showBackground, true);

    if (attr.hasValue(R.styleable.FloatingActionButton_fab_progress)) {
      mProgress = attr.getInt(R.styleable.FloatingActionButton_fab_progress, 0);
      mShouldSetProgress = true;
    }

    if (attr.hasValue(R.styleable.FloatingActionButton_fab_elevationCompat)) {
      float elevation =
          attr.getDimensionPixelOffset(R.styleable.FloatingActionButton_fab_elevationCompat, 0);
      if (isInEditMode()) {
        setElevation(elevation);
      } else {
        setElevationCompat(elevation);
      }
    }

    initShowAnimation(attr);
    initHideAnimation(attr);
    attr.recycle();

    if (isInEditMode()) {
      if (mShouldProgressIndeterminate) {
        setIndeterminate(true);
      } else if (mShouldSetProgress) {
        saveButtonOriginalPosition();
        setProgress(mProgress, false);
      }
    }

    //        updateBackground();
    setClickable(true);
  }
  /**
   * @param anim The animator, must not be null
   * @param arrayAnimator Incoming typed array for Animator's attributes.
   * @param arrayObjectAnimator Incoming typed array for Object Animator's attributes.
   */
  private static void parseAnimatorFromTypeArray(
      ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator) {
    long duration = arrayAnimator.getInt(R.styleable.Animator_android_duration, 300);

    long startDelay = arrayAnimator.getInt(R.styleable.Animator_android_startOffset, 0);

    int valueType = arrayAnimator.getInt(R.styleable.Animator_vc_valueType, 0);

    TypeEvaluator evaluator = null;

    // Must be a path animator by the time I reach here
    if (valueType == VALUE_TYPE_PATH) {
      evaluator = setupAnimatorForPath(anim, arrayAnimator);
    } else {
      throw new IllegalArgumentException("target is not a pathType target");
    }

    anim.setDuration(duration);
    anim.setStartDelay(startDelay);

    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatCount)) {
      anim.setRepeatCount(arrayAnimator.getInt(R.styleable.Animator_android_repeatCount, 0));
    }
    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatMode)) {
      anim.setRepeatMode(
          arrayAnimator.getInt(R.styleable.Animator_android_repeatMode, ValueAnimator.RESTART));
    }
    if (evaluator != null) {
      anim.setEvaluator(evaluator);
    }

    if (arrayObjectAnimator != null) {
      setupObjectAnimator(anim, arrayObjectAnimator);
    }
  }
Exemplo n.º 3
0
  public void init(AttributeSet attrs) {
    TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.SlantedTextView);

    mTextSize = array.getDimension(R.styleable.SlantedTextView_slantedTextSize, mTextSize);
    mTextColor = array.getColor(R.styleable.SlantedTextView_slantedTextColor, mTextColor);
    mSlantedLength = array.getDimension(R.styleable.SlantedTextView_slantedLength, mSlantedLength);
    mSlantedBackgroundColor =
        array.getColor(R.styleable.SlantedTextView_slantedBackgroundColor, mSlantedBackgroundColor);

    if (array.hasValue(R.styleable.SlantedTextView_slantedText)) {
      mSlantedText = array.getString(R.styleable.SlantedTextView_slantedText);
    }

    if (array.hasValue(R.styleable.SlantedTextView_slantedMode)) {
      mMode = array.getInt(R.styleable.SlantedTextView_slantedMode, 0);
    }
    array.recycle();

    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
    mPaint.setAntiAlias(true);
    mPaint.setColor(mSlantedBackgroundColor);

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
  }
  public ParallaxImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Instantiate future objects
    mTranslationMatrix = new Matrix();
    mSensorInterpreter = new SensorInterpreter();

    // Sets scale type
    setScaleType(ScaleType.MATRIX);

    // Set available attributes
    if (attrs != null) {
      final TypedArray customAttrs =
          context.obtainStyledAttributes(attrs, R.styleable.ParallaxImageView);

      if (customAttrs != null) {
        if (customAttrs.hasValue(R.styleable.ParallaxImageView_intensity))
          setParallaxIntensity(
              customAttrs.getFloat(R.styleable.ParallaxImageView_intensity, mParallaxIntensity));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_scaledIntensity))
          setScaledIntensities(
              customAttrs.getBoolean(
                  R.styleable.ParallaxImageView_scaledIntensity, mScaledIntensities));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_tiltSensitivity))
          setTiltSensitivity(
              customAttrs.getFloat(
                  R.styleable.ParallaxImageView_tiltSensitivity,
                  mSensorInterpreter.getTiltSensitivity()));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_forwardTiltOffset))
          setForwardTiltOffset(
              customAttrs.getFloat(
                  R.styleable.ParallaxImageView_forwardTiltOffset,
                  mSensorInterpreter.getForwardTiltOffset()));

        customAttrs.recycle();
      }
    }

    // Configure matrix as early as possible by posting to MessageQueue
    post(
        new Runnable() {
          @Override
          public void run() {
            configureMatrix();
          }
        });
  }
Exemplo n.º 5
0
 private KeyboardRow parseRowAttributes(final XmlPullParser parser) throws XmlPullParserException {
   final AttributeSet attr = Xml.asAttributeSet(parser);
   final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
   try {
     if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
       throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
     }
     if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
       throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
     }
     return new KeyboardRow(mResources, mParams, parser, mCurrentY);
   } finally {
     keyboardAttr.recycle();
   }
 }
  @SuppressWarnings("deprecation")
  private void init(Context context, AttributeSet attrs) {
    setOrientation(LinearLayout.VERTICAL);

    ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();

    // Styleables from XML
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);

    if (a.hasValue(R.styleable.PullToRefresh_ptrMode)) {
      mMode = Mode.mapIntToMode(a.getInteger(R.styleable.PullToRefresh_ptrMode, 0));
    }

    // Refreshable View
    // By passing the attrs, we can add ListView/GridView params via XML
    mRefreshableView = createRefreshableView(context, attrs);
    addRefreshableView(context, mRefreshableView);

    // We need to create now layouts now
    mHeaderLayout = createLoadingLayout(context, Mode.PULL_DOWN_TO_REFRESH, a);
    mFooterLayout = createLoadingLayout(context, Mode.PULL_UP_TO_REFRESH, a);

    // Styleables from XML
    if (a.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
      Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
      if (null != background) {
        setBackgroundDrawable(background);
      }
    }
    if (a.hasValue(R.styleable.PullToRefresh_ptrAdapterViewBackground)) {
      Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrAdapterViewBackground);
      if (null != background) {
        mRefreshableView.setBackgroundDrawable(background);
      }
    }
    if (a.hasValue(R.styleable.PullToRefresh_ptrOverScroll)) {
      mOverScrollEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrOverScroll, true);
    }

    // Let the derivative classes have a go at handling attributes, then
    // recycle them...
    handleStyledAttributes(a);
    a.recycle();

    // Finally update the UI for the modes
    updateUIForMode();
  }
Exemplo n.º 7
0
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);

    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
    if (delayMillis < 0) {
      delayMillis = 0;
    }

    barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);

    barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize);

    textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor);

    // if the text is empty , so ignore it
    if (a.hasValue(R.styleable.ProgressWheel_text)) {
      setText(a.getString(R.styleable.ProgressWheel_text));
    }

    rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor);

    circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor);

    contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);
    contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);

    // Recycle
    a.recycle();
  }
Exemplo n.º 8
0
 public IntegerFieldEdit(Context context, AttributeSet attrs) {
   super(context, attrs, R.layout.imog__field_edit_numeric);
   TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumberField, 0, 0);
   if (a.hasValue(R.styleable.NumberField_intMin)) {
     setMin(a.getInt(R.styleable.NumberField_intMin, 0));
   } else {
     setMin(null);
   }
   if (a.hasValue(R.styleable.NumberField_intMax)) {
     setMax(a.getInt(R.styleable.NumberField_intMax, 0));
   } else {
     setMax(null);
   }
   a.recycle();
   setFocusable(false);
 }
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    this.barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, this.barWidth);

    this.rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, this.rimWidth);

    this.spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, this.spinSpeed);

    this.delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, this.delayMillis);
    if (this.delayMillis < 0) {
      this.delayMillis = 0;
    }

    this.barColor = a.getColor(R.styleable.ProgressWheel_barColor, this.barColor);

    this.barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, this.barLength);

    this.textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, this.textSize);

    this.textColor = a.getColor(R.styleable.ProgressWheel_textColor, this.textColor);

    // if the text is empty , so ignore it
    if (a.hasValue(R.styleable.ProgressWheel_text)) {
      setText(a.getString(R.styleable.ProgressWheel_text));
    }

    this.rimColor = a.getColor(R.styleable.ProgressWheel_rimColor, this.rimColor);

    this.circleColor = a.getColor(R.styleable.ProgressWheel_circleColor, this.circleColor);

    // Recycle
    a.recycle();
  }
Exemplo n.º 10
0
 private void initIndexBarColorPressed(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_indexBarColorPressed)) {
     mIndexBarColorPressed =
         attributes.getColor(R.styleable.IndexBar_indexBarColorPressed, mIndexBarColorPressed);
     Log.v(LOG_TAG, "Initialized Index Bar Color Pressed: " + getIndexBarColorPressed());
   }
 }
Exemplo n.º 11
0
 private void initIndexBarColor(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_indexBarColorNormal)) {
     mIndexBarColorNormal =
         attributes.getColor(R.styleable.IndexBar_indexBarColorNormal, mIndexBarColorNormal);
     Log.v(LOG_TAG, "Initialized Index Bar Color: " + getIndexBarColor());
   }
 }
Exemplo n.º 12
0
 private void initAlphabetTextSize(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetTextSize)) {
     mAlphabetTextSize =
         attributes.getDimension(R.styleable.IndexBar_alphabetTextSize, mAlphabetTextSize);
     Log.v(LOG_TAG, "Initialized Alphabet TextSize: " + getAlphabetTextSize());
   }
 }
Exemplo n.º 13
0
 private void parseKeyStyle(final XmlPullParser parser, final boolean skip)
     throws XmlPullParserException, IOException {
   final AttributeSet attr = Xml.asAttributeSet(parser);
   final TypedArray keyStyleAttr =
       mResources.obtainAttributes(attr, R.styleable.Keyboard_KeyStyle);
   final TypedArray keyAttrs = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
   try {
     if (!keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_styleName)) {
       throw new XmlParseUtils.ParseException(
           "<" + TAG_KEY_STYLE + "/> needs styleName attribute", parser);
     }
     if (DEBUG) {
       startEndTag(
           "<%s styleName=%s />%s",
           TAG_KEY_STYLE,
           keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName),
           skip ? " skipped" : "");
     }
     if (!skip) {
       mParams.mKeyStyles.parseKeyStyleAttributes(keyStyleAttr, keyAttrs, parser);
     }
   } finally {
     keyStyleAttr.recycle();
     keyAttrs.recycle();
   }
   XmlParseUtils.checkEndTag(TAG_KEY_STYLE, parser);
 }
Exemplo n.º 14
0
  @Override
  protected void handleStyledAttributes(TypedArray a) {
    super.handleStyledAttributes(a);

    mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

    if (mListViewExtrasEnabled) {
      final FrameLayout.LayoutParams lp =
          new FrameLayout.LayoutParams(
              FrameLayout.LayoutParams.MATCH_PARENT,
              FrameLayout.LayoutParams.WRAP_CONTENT,
              Gravity.CENTER_HORIZONTAL);

      // Create Loading Views ready for use later
      FrameLayout frame = new FrameLayout(getContext());
      mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a);
      mHeaderLoadingView.setVisibility(View.GONE);
      frame.addView(mHeaderLoadingView, lp);
      mRefreshableView.addHeaderView(frame, null, false);

      mLvFooterLoadingFrame = new FrameLayout(getContext());
      mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a);
      mFooterLoadingView.setVisibility(View.GONE);
      mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);

      /**
       * If the value for Scrolling While Refreshing hasn't been explicitly set via XML, enable
       * Scrolling While Refreshing.
       */
      if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
        setScrollingWhileRefreshingEnabled(true);
      }
    }
  }
Exemplo n.º 15
0
 private void initAlphabetPadding(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetPadding)) {
     mAlphabetPadding =
         attributes.getDimension(R.styleable.IndexBar_alphabetPadding, mAlphabetPadding);
     Log.v(LOG_TAG, "Initialized Alphabet Offset: " + getAlphabetPadding());
   }
 }
Exemplo n.º 16
0
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth);
    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed);
    barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis);
    if (delayMillis < 0) {
      delayMillis = 10;
    }

    // Only set the text if it is explicitly defined
    if (a.hasValue(R.styleable.ProgressWheel_pwText)) {
      setText(a.getString(R.styleable.ProgressWheel_pwText));
    }

    barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor);
    textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor);
    rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor);
    circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor);
    contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize);
    contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize);

    a.recycle();
  }
Exemplo n.º 17
0
  private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    final TypedArray a =
        getContext().obtainStyledAttributes(attrs, R.styleable.MyView, defStyle, 0);

    mExampleString = a.getString(R.styleable.MyView_exampleString);
    mExampleColor = a.getColor(R.styleable.MyView_exampleColor, mExampleColor);
    // Use getDimensionPixelSize or getDimensionPixelOffset when dealing with
    // values that should fall on pixel boundaries.
    mExampleDimension = a.getDimension(R.styleable.MyView_exampleDimension, mExampleDimension);

    if (a.hasValue(R.styleable.MyView_exampleDrawable)) {
      mExampleDrawable = a.getDrawable(R.styleable.MyView_exampleDrawable);
      mExampleDrawable.setCallback(this);
    }

    a.recycle();

    // Set up a default TextPaint object
    mTextPaint = new TextPaint();
    mTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextAlign(Paint.Align.LEFT);

    // Update TextPaint and text measurements from attributes
    invalidateTextPaintAndMeasurements();
  }
Exemplo n.º 18
0
 protected String[] parseStringArray(final TypedArray a, final int index) {
   if (a.hasValue(index)) {
     final String text = mTextsSet.resolveTextReference(a.getString(index));
     return MoreKeySpec.splitKeySpecs(text);
   }
   return null;
 }
Exemplo n.º 19
0
 private void initAlphabetTextColor(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetTextColor)) {
     mAlphabetTextColor =
         attributes.getColor(R.styleable.IndexBar_alphabetTextColor, mAlphabetTextColor);
     Log.v(LOG_TAG, "Initialized Alphabet TextColor: " + getAlphabetTextColor());
   }
 }
Exemplo n.º 20
0
    /** Called when the parser is pointing to an item tag. */
    public void readItem(AttributeSet attrs) {
      TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SherlockMenuItem);

      // Inherit attributes from the group as default value
      itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
      final int category =
          a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
      final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
      itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
      itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
      itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
      itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
      itemAlphabeticShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
      itemNumericShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
      if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
        // Item has attribute checkable, use it
        itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
      } else {
        // Item does not have attribute, use the group's (group can have one more state
        // for checkable that represents the exclusive checkable)
        itemCheckable = groupCheckable;
      }

      itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
      itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
      itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);

      TypedValue value = new TypedValue();
      a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
      itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;

      itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
      itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
      itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
      itemActionProviderClassName =
          a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);

      final boolean hasActionProvider = itemActionProviderClassName != null;
      if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
        itemActionProvider =
            newInstance(
                itemActionProviderClassName,
                ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
                mActionProviderConstructorArguments);
      } else {
        if (hasActionProvider) {
          Log.w(
              LOG_TAG,
              "Ignoring attribute 'actionProviderClass'." + " Action view already specified.");
        }
        itemActionProvider = null;
      }

      a.recycle();

      itemAdded = false;
    }
 public ToggleButton(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TextView, defStyle, 0);
   if (a.hasValue(R.styleable.TextView_android_textAllCaps)) {
     allCaps = a.getBoolean(R.styleable.TextView_android_textAllCaps, false);
   } else {
     allCaps = a.getBoolean(R.styleable.TextView_textAllCaps, false);
   }
   CharSequence text = null;
   if (a.hasValue(R.styleable.TextView_android_text)) {
     text = a.getText(R.styleable.TextView_android_text);
   }
   a.recycle();
   if (text != null) {
     setText(text);
   }
 }
Exemplo n.º 22
0
  private void readAttrs(AttributeSet attrs) {
    TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SettingView);

    if (a.hasValue(R.styleable.SettingView_iOSStyle)) {
      iOSStyleable = a.getBoolean(R.styleable.SettingView_iOSStyle, false);
    }

    a.recycle();
  }
Exemplo n.º 23
0
  public ScrollHeaderFrame(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.ScrollHeaderFrame, 0, 0);
    if (arr != null) {
      if (arr.hasValue(R.styleable.ScrollHeaderFrame_scrollheaderframe_header)) {
        mHeaderId = arr.getResourceId(R.styleable.ScrollHeaderFrame_scrollheaderframe_header, 0);
      }
      if (arr.hasValue(R.styleable.ScrollHeaderFrame_scrollheaderframe_conent_container)) {
        mContainerId =
            arr.getResourceId(R.styleable.ScrollHeaderFrame_scrollheaderframe_conent_container, 0);
      }
      if (arr.hasValue(R.styleable.ScrollHeaderFrame_scrollheaderframe_disable)) {
        mDisabled = arr.getBoolean(R.styleable.ScrollHeaderFrame_scrollheaderframe_disable, false);
      }
      arr.recycle();
    }
  }
Exemplo n.º 24
0
 private void initStyle(AttributeSet attributeSet, int defStyleAttr) {
   TypedArray attr =
       mContext.obtainStyledAttributes(attributeSet, R.styleable.SearchView, defStyleAttr, 0);
   if (attr != null) {
     try {
       if (attr.hasValue(R.styleable.SearchView_search_style)) {
         setStyle(attr.getInt(R.styleable.SearchView_search_style, 0));
       }
       if (attr.hasValue(R.styleable.SearchView_search_theme)) {
         setTheme(attr.getInt(R.styleable.SearchView_search_theme, 0));
       }
       if (attr.hasValue(R.styleable.SearchView_search_divider)) {
         setDivider(attr.getBoolean(R.styleable.SearchView_search_divider, false));
       }
     } finally {
       attr.recycle();
     }
   }
 }
Exemplo n.º 25
0
 public FabTransform(Context context, AttributeSet attrs) {
   super(context, attrs);
   TypedArray a = null;
   try {
     a = context.obtainStyledAttributes(attrs, R.styleable.FabTransform);
     if (!a.hasValue(R.styleable.FabTransform_fabColor)
         || !a.hasValue(R.styleable.FabTransform_fabIcon)) {
       throw new IllegalArgumentException("Must provide both color & icon.");
     }
     color = a.getColor(R.styleable.FabTransform_fabColor, Color.TRANSPARENT);
     icon = a.getResourceId(R.styleable.FabTransform_fabIcon, 0);
     setPathMotion(new GravityArcMotion());
     if (getDuration() < 0) {
       setDuration(DEFAULT_DURATION);
     }
   } finally {
     a.recycle();
   }
 }
Exemplo n.º 26
0
 public TipsView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) {
   super(paramContext, paramAttributeSet, paramInt);
   TypedArray localTypedArray =
       paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.TipsView);
   if (localTypedArray.hasValue(0)) {
     int i = localTypedArray.getResourceId(0, 0);
     if (i != 0) setTip(i);
   }
   localTypedArray.recycle();
 }
Exemplo n.º 27
0
  @SuppressLint("NewApi")
  public ListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (context instanceof Activity) {
      setActivity((Activity) context);
    }
    if (HoloEverywhere.DISABLE_OVERSCROLL_EFFECT && VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
      setOverScrollMode(OVER_SCROLL_NEVER);
    }

    mOnItemLongClickListenerWrapper = new OnItemLongClickListenerWrapper();
    super.setOnItemLongClickListener(mOnItemLongClickListenerWrapper);
    setLongClickable(false);

    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
      super.setFastScrollAlwaysVisible(false);
    }
    super.setFastScrollEnabled(false);
    super.setChoiceMode(CHOICE_MODE_NONE);
    TypedArray a =
        context.obtainStyledAttributes(
            attrs,
            new int[] {
              android.R.attr.fastScrollEnabled,
              android.R.attr.fastScrollAlwaysVisible,
              android.R.attr.choiceMode,
              android.R.attr.overScrollFooter,
              android.R.attr.overScrollHeader
            },
            defStyle,
            R.style.Holo_ListView);
    setFastScrollEnabled(a.getBoolean(0, false));
    setFastScrollAlwaysVisible(a.getBoolean(1, false));
    setChoiceMode(a.getInt(2, CHOICE_MODE_NONE));
    if (!a.hasValue(3) && VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
      super.setOverscrollFooter(null);
    }
    if (!a.hasValue(4) && VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
      super.setOverscrollHeader(null);
    }
    a.recycle();
  }
Exemplo n.º 28
0
  private void init(Context context, AttributeSet attrs) {
    setOrientation(LinearLayout.VERTICAL);

    ViewConfiguration config = ViewConfiguration.get(context);
    mTouchSlop = config.getScaledTouchSlop();

    // Styleables from XML
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);
    handleStyledAttributes(a);

    if (a.hasValue(R.styleable.PullToRefresh_ptrMode)) {
      mMode = Mode.mapIntToMode(a.getInteger(R.styleable.PullToRefresh_ptrMode, 0));
    }

    // Refreshable View
    // By passing the attrs, we can add ListView/GridView params via XML
    mRefreshableView = createRefreshableView(context, attrs);
    addRefreshableView(context, mRefreshableView);

    // We need to create now layouts now
    mHeaderLayout = new LoadingLayout(context, Mode.PULL_DOWN_TO_REFRESH, a);
    mFooterLayout = new LoadingLayout(context, Mode.PULL_UP_TO_REFRESH, a);

    // Add Header/Footer Views
    updateUIForMode();

    // Styleables from XML
    if (a.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
      Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
      if (null != background) {
        setBackgroundDrawable(background);
      }
    }
    if (a.hasValue(R.styleable.PullToRefresh_ptrAdapterViewBackground)) {
      Drawable background = a.getDrawable(R.styleable.PullToRefresh_ptrAdapterViewBackground);
      if (null != background) {
        mRefreshableView.setBackgroundDrawable(background);
      }
    }
    a.recycle();
    a = null;
  }
  @SuppressWarnings("deprecation")
  protected void init(Context context, AttributeSet attributes, int defStyleAttr) {
    EditText reference = new EditText(getContext());

    setOrientation(VERTICAL);
    setPadding(
        reference.getLeft() + reference.getCompoundPaddingLeft(),
        0,
        reference.getRight() + reference.getCompoundPaddingRight(),
        0);

    hint =
        (TextView)
            LayoutInflater.from(context).inflate(R.layout.floating_label_layout_hint, this, false);

    error =
        (TextView)
            LayoutInflater.from(context).inflate(R.layout.floating_label_layout_error, this, false);

    TypedArray array =
        context.obtainStyledAttributes(
            attributes,
            R.styleable.TextInputLayout,
            defStyleAttr,
            R.style.Widget_Design_TextInputLayout);

    hint.setText(array.getString(R.styleable.TextInputLayout_android_hint));

    if (array.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
      hint.setTextColor(array.getColorStateList(R.styleable.TextInputLayout_android_textColorHint));
    }

    if (array.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1) != -1) {
      setHintTextAppearance(array.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0));
    }

    final int errorAppearance =
        array.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0);

    try {
      error.setTextAppearance(getContext(), errorAppearance);
    } catch (Exception exception) {
      // Probably caused by our theme not extending from Theme.Design*. Instead
      // we manually set something appropriate
      error.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Caption);
      error.setTextColor(
          ContextCompat.getColor(getContext(), R.color.design_textinput_error_color_light));
    }

    error.setVisibility(
        array.getBoolean(R.styleable.TextInputLayout_errorEnabled, false) ? VISIBLE : GONE);

    array.recycle();
  }
Exemplo n.º 30
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    // a fix to reset paddingLeft attribute
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
      TypedArray a =
          context.obtainStyledAttributes(
              attrs,
              new int[] {android.R.attr.padding, android.R.attr.paddingLeft},
              defStyleAttr,
              defStyleRes);

      if (!a.hasValue(0) && !a.hasValue(1))
        setPadding(0, getPaddingTop(), getPaddingRight(), getPaddingBottom());

      a.recycle();
    }

    setClickable(true);
    applyStyle(context, attrs, defStyleAttr, defStyleRes);
  }