@Override
  protected View createScreenletView(Context context, AttributeSet attributes) {
    TypedArray typedArray =
        context
            .getTheme()
            .obtainStyledAttributes(attributes, R.styleable.UserPortraitScreenlet, 0, 0);

    _autoLoad = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_autoLoad, true);
    _male = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_male, true);
    _portraitId = typedArray.getInt(R.styleable.UserPortraitScreenlet_portraitId, 0);
    _uuid = typedArray.getString(R.styleable.UserPortraitScreenlet_uuid);
    _editable = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_editable, false);

    int offlinePolicy =
        typedArray.getInt(
            R.styleable.UserPortraitScreenlet_offlinePolicy, OfflinePolicy.REMOTE_ONLY.ordinal());
    _offlinePolicy = OfflinePolicy.values()[offlinePolicy];

    _userId =
        castToLongOrUseDefault(typedArray.getString(R.styleable.UserPortraitScreenlet_userId), 0L);

    if (SessionContext.hasUserInfo() && _portraitId == 0 && _uuid == null && _userId == 0) {
      _userId = SessionContext.getLoggedUser().getId();
    }

    int layoutId =
        typedArray.getResourceId(R.styleable.UserPortraitScreenlet_layoutId, getDefaultLayoutId());

    typedArray.recycle();

    return LayoutInflater.from(context).inflate(layoutId, null);
  }
  private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.IncreasingSeekBar, defStyle, 0);
    try {
      mOrientation =
          Orientation.fromId(
              typedArray.getInt(
                  R.styleable.IncreasingSeekBar_isb_orientation, Orientation.HORIZONTAL.id));
      mMaxRang = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_max, DEF_MAX_RANG);
      mCurrValue = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_curr_value, 0);
      mGapWidthPercent =
          typedArray.getFraction(
              R.styleable.IncreasingSeekBar_isb_gap_percent, 1, 1, DEF_GAP_PERCENT);
      mAllowUserTouch =
          typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_allow_user_touch, true);
      mDrawBorder = typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_draw_border, false);
      mBorderColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_border_color, DEF_COLOR);
      mBorderWidth =
          typedArray.getDimension(R.styleable.IncreasingSeekBar_isb_border_width, DEF_BORDER_WIDTH);
      mMainColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color, DEF_COLOR);
      mStartColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_start, -1);
      mEndColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_end, -1);

    } finally {
      typedArray.recycle();
    }

    mBarItemPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBarItemPaint.setColor(mMainColor);
    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setStrokeWidth(mBorderWidth);
    mBarItemPaint.setColor(mBorderColor);
  }
Exemplo n.º 3
0
  private void initWithContext(Context context, AttributeSet attrs) {

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    // 根据属性设置参数
    if (attrs != null) {
      TypedArray a =
          context.getTheme().obtainStyledAttributes(attrs, R.styleable.XRefreshView, 0, 0);

      try {
        isHeightMatchParent = a.getBoolean(R.styleable.XRefreshView_isHeightMatchParent, true);
        isWidthMatchParent = a.getBoolean(R.styleable.XRefreshView_isHeightMatchParent, true);
        autoRefresh = a.getBoolean(R.styleable.XRefreshView_autoRefresh, false);
        autoLoadMore = a.getBoolean(R.styleable.XRefreshView_autoLoadMore, true);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        a.recycle();
      }
    }
    mHeaderView = new XRefreshViewHeader(getContext());
    mFooterView = new XRefreshViewFooter(context);
    this.getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new OnGlobalLayoutListener() {

              @Override
              public void onGlobalLayout() {
                addHeaderView();
                addFooterView(this);
              }
            });
  }
Exemplo n.º 4
0
 public MultiCardMenu(Context context, AttributeSet attrs, int defStyleAttr) {
   super(context, attrs, defStyleAttr);
   mContext = context;
   ViewConfiguration vc = ViewConfiguration.get(context);
   mMaxVelocity = vc.getScaledMaximumFlingVelocity();
   mMinVelocity = vc.getScaledMinimumFlingVelocity() * 8;
   mTouchSlop = vc.getScaledTouchSlop();
   mDensity = context.getResources().getDisplayMetrics().density;
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.MultiCardMenu, defStyleAttr, 0);
   MAX_CLICK_DISTANCE =
       mTitleBarHeightNoDisplay =
           a.getDimension(
               R.styleable.MultiCardMenu_title_bar_height_no_display,
               dip2px(DEFAULT_TITLE_BAR_HEIGHT_NO_DISPLAY));
   mTitleBarHeightDisplay =
       a.getDimension(
           R.styleable.MultiCardMenu_title_bar_height_display,
           dip2px(DEFAULT_TITLE_BAR_HEIGHT_DISPLAY));
   mMarginTop =
       a.getDimension(R.styleable.MultiCardMenu_margin_top, dip2px(DEFAULT_CARD_MARGIN_TOP));
   mMoveDistanceToTrigger =
       a.getDimension(
           R.styleable.MultiCardMenu_move_distance_to_trigger,
           dip2px(DEFAULT_MOVE_DISTANCE_TO_TRIGGER));
   mBackgroundRid = a.getResourceId(R.styleable.MultiCardMenu_background_layout, -1);
   mDuration = a.getInt(R.styleable.MultiCardMenu_animator_duration, DEFAULT_DURATION);
   isFade = a.getBoolean(R.styleable.MultiCardMenu_fade, true);
   mBoundary = a.getBoolean(R.styleable.MultiCardMenu_boundary, false);
   a.recycle();
   initBackgroundView();
 }
Exemplo n.º 5
0
  public MaxToggleView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaxToggleView, 0, 0);

    if (a != null) {
      try {
        setIgnoreClick(a.getBoolean(R.styleable.MaxToggleView_ignore_click, false));
        setChecked(a.getBoolean(R.styleable.MaxToggleView_checked, false));
        setBackgroundColor(
            a.getColor(
                R.styleable.MaxToggleView_background_color,
                getResources().getColor(android.R.color.background_dark)));
        setCheckedColor(
            a.getColor(
                R.styleable.MaxToggleView_checked_color,
                getResources().getColor(android.R.color.darker_gray)));
        setBorderColor(
            a.getColor(
                R.styleable.MaxToggleView_border_color,
                getResources().getColor(android.R.color.darker_gray)));
      } finally {
        a.recycle();
      }
    }
    init();
  }
  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);
  }
 public LinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
   super(context, attrs, defStyleAttr, defStyleRes);
   this.mBaselineAligned = true;
   this.mBaselineAlignedChildIndex = -1;
   this.mBaselineChildTop = SHOW_DIVIDER_NONE;
   this.mGravity = 8388659;
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.LinearLayout, defStyleAttr, defStyleRes);
   int index = a.getInt(VERTICAL, -1);
   if (index >= 0) {
     setOrientation(index);
   }
   index = a.getInt(SHOW_DIVIDER_NONE, -1);
   if (index >= 0) {
     setGravity(index);
   }
   boolean baselineAligned = a.getBoolean(SHOW_DIVIDER_MIDDLE, true);
   if (!baselineAligned) {
     setBaselineAligned(baselineAligned);
   }
   this.mWeightSum =
       a.getFloat(
           VERTICAL_GRAVITY_COUNT,
           android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE);
   this.mBaselineAlignedChildIndex = a.getInt(INDEX_FILL, -1);
   this.mUseLargestChild = a.getBoolean(6, false);
   setDividerDrawable(a.getDrawable(5));
   this.mShowDividers = a.getInt(7, SHOW_DIVIDER_NONE);
   this.mDividerPadding = a.getDimensionPixelSize(8, SHOW_DIVIDER_NONE);
   a.recycle();
 }
  public MaterialRippleLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, longClickListener);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialRippleLayout);
    rippleColor = a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleColor, DEFAULT_COLOR);
    rippleDiameter =
        a.getDimensionPixelSize(
            R.styleable.MaterialRippleLayout_rippleDimension,
            (int) dpToPx(getResources(), DEFAULT_DIAMETER_DP));
    rippleOverlay =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleOverlay, DEFAULT_RIPPLE_OVERLAY);
    rippleHover = a.getBoolean(R.styleable.MaterialRippleLayout_rippleHover, DEFAULT_HOVER);
    rippleDuration = a.getInt(R.styleable.MaterialRippleLayout_rippleDuration, DEFAULT_DURATION);
    rippleAlpha =
        (int) (255 * a.getFloat(R.styleable.MaterialRippleLayout_rippleAlpha, DEFAULT_ALPHA));
    rippleDelayClick =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleDelayClick, DEFAULT_DELAY_CLICK);
    rippleFadeDuration =
        a.getInteger(R.styleable.MaterialRippleLayout_rippleFadeDuration, DEFAULT_FADE_DURATION);
    rippleBackground =
        new ColorDrawable(
            a.getColor(R.styleable.MaterialRippleLayout_rippleBackground, DEFAULT_BACKGROUND));
    ripplePersistent =
        a.getBoolean(R.styleable.MaterialRippleLayout_ripplePersistent, DEFAULT_PERSISTENT);
    rippleInAdapter =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleInAdapter, DEFAULT_SEARCH_ADAPTER);

    a.recycle();

    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);
  }
Exemplo n.º 9
0
  public FrameLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    initFrameLayout();

    TypedArray a =
        context.obtainStyledAttributes(
            attrs, com.android.internal.R.styleable.FrameLayout, defStyle, 0);

    mForegroundGravity =
        a.getInt(
            com.android.internal.R.styleable.FrameLayout_foregroundGravity, mForegroundGravity);

    final Drawable d = a.getDrawable(com.android.internal.R.styleable.FrameLayout_foreground);
    if (d != null) {
      setForeground(d);
    }

    if (a.getBoolean(com.android.internal.R.styleable.FrameLayout_measureAllChildren, false)) {
      setMeasureAllChildren(true);
    }

    mForegroundInPadding =
        a.getBoolean(com.android.internal.R.styleable.FrameLayout_foregroundInsidePadding, true);

    a.recycle();
  }
  public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground);
    foregroundPadding =
        a.getBoolean(R.styleable.ForegroundLayout_foregroundLayoutInsidePadding, false);

    backgroundAsForeground =
        a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false);

    // Apply foreground padding for ninepatches automatically
    if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) {
      final NinePatchDrawable npd = (NinePatchDrawable) getBackground();
      if (npd != null && npd.getPadding(rectPadding)) {
        foregroundPadding = true;
      }
    }

    final Drawable b = getBackground();
    if (backgroundAsForeground && b != null) {
      setForeground(b);
    } else if (d != null) {
      setForeground(d);
    }

    a.recycle();
  }
  /**
   * Constructor for the sliding layer.<br>
   * By default this panel will
   *
   * <ol>
   *   <li>{@link #setStickTo(int)} with param {@link #STICK_TO_AUTO}
   *   <li>Use no shadow drawable. (i.e. with width of 0)
   *   <li>Close when the panel is tapped
   *   <li>Open when the offset is tapped, but will have an offset of 0
   * </ol>
   *
   * @param context a reference to an existing context
   * @param attrs attribute set constructed from attributes set in android .xml file
   * @param defStyle style res id
   */
  public SlidingLayer(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Style
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer);

    // Set the side of the screen
    setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_AUTO));

    // Sets the shadow drawable
    int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, -1);
    if (shadowRes != -1) {
      setShadowDrawable(shadowRes);
    }

    // Sets the shadow width
    setShadowWidth((int) ta.getDimension(R.styleable.SlidingLayer_shadowWidth, 0));

    // Sets the ability to close the layer by tapping in any empty space
    closeOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_closeOnTapEnabled, true);
    // Sets the ability to open the layout by tapping on any of the exposed closed layer
    openOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_openOnTapEnabled, true);

    // How much of the view sticks out when closed
    setOffsetWidth(ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetWidth, 0));

    ta.recycle();

    init();
  }
    public AdapterViewAnimator(
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.AdapterViewAnimator, defStyleAttr, defStyleRes);
        int resource = a.getResourceId(
                com.android.internal.R.styleable.AdapterViewAnimator_inAnimation, 0);
        if (resource > 0) {
            setInAnimation(context, resource);
        } else {
            setInAnimation(getDefaultInAnimation());
        }

        resource = a.getResourceId(com.android.internal.R.styleable.AdapterViewAnimator_outAnimation, 0);
        if (resource > 0) {
            setOutAnimation(context, resource);
        } else {
            setOutAnimation(getDefaultOutAnimation());
        }

        boolean flag = a.getBoolean(
                com.android.internal.R.styleable.AdapterViewAnimator_animateFirstView, true);
        setAnimateFirstView(flag);

        mLoopViews = a.getBoolean(
                com.android.internal.R.styleable.AdapterViewAnimator_loopViews, false);

        a.recycle();

        initViewAnimator();
    }
Exemplo n.º 13
0
 private void initialize(Context context, AttributeSet attrs, int defStyleAttr) {
   TypedArray a =
       context.obtainStyledAttributes(
           attrs, R.styleable.CardView, defStyleAttr, R.style.CardView_Light);
   int backgroundColor = a.getColor(R.styleable.CardView_cardBackgroundColor, 0);
   float radius = a.getDimension(R.styleable.CardView_cardCornerRadius, 0);
   float elevation = a.getDimension(R.styleable.CardView_cardElevation, 0);
   float maxElevation = a.getDimension(R.styleable.CardView_cardMaxElevation, 0);
   mCompatPadding = a.getBoolean(R.styleable.CardView_cardUseCompatPadding, false);
   mPreventCornerOverlap = a.getBoolean(R.styleable.CardView_cardPreventCornerOverlap, true);
   int defaultPadding = a.getDimensionPixelSize(R.styleable.CardView_contentPadding, 0);
   mContentPadding.left =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingLeft, defaultPadding);
   mContentPadding.top =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingTop, defaultPadding);
   mContentPadding.right =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingRight, defaultPadding);
   mContentPadding.bottom =
       a.getDimensionPixelSize(R.styleable.CardView_contentPaddingBottom, defaultPadding);
   if (elevation > maxElevation) {
     maxElevation = elevation;
   }
   a.recycle();
   IMPL.initialize(this, context, backgroundColor, radius, elevation, maxElevation);
 }
Exemplo n.º 14
0
 /**
  * get attrs
  *
  * @param context
  * @param attrs
  */
 private void getAttrs(Context context, AttributeSet attrs) {
   TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.drop_down_list_attr);
   isDropDownStyle = ta.getBoolean(R.styleable.drop_down_list_attr_isDropDownStyle, false);
   isOnBottomStyle = ta.getBoolean(R.styleable.drop_down_list_attr_isOnBottomStyle, false);
   isAutoLoadOnBottom = ta.getBoolean(R.styleable.drop_down_list_attr_isAutoLoadOnBottom, false);
   ta.recycle();
 }
  public void init(Context context, AttributeSet attrs, int defStyle) {
    mActiveMediaPlayer = new MediaPlayer();
    if (attrs != null) {
      TypedArray ta =
          context.getTheme().obtainStyledAttributes(attrs, R.styleable.OnemomentPlayerView, 0, 0);

      try {
        mShowPlayBtn = ta.getBoolean(R.styleable.OnemomentPlayerView_showPlayButton, true);
        mAutoplay = ta.getBoolean(R.styleable.OnemomentPlayerView_autoplay, false);
        mShowTags = ta.getBoolean(R.styleable.OnemomentPlayerView_showTags, true);
      } finally {
        ta.recycle();
      }
    }
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (inflater != null) {
      inflater.inflate(R.layout.onemoment_player_view, this);
    }

    // get views
    mVideo = (SurfaceView) findViewById(R.id.om_video_surface);
    mPlayBtn = (ImageView) findViewById(R.id.om_play_btn);
    mTagsContainer = (VideoTagsContainer) findViewById(R.id.om_tags_container);
    mHeadsContainer = (LinearLayout) findViewById(R.id.om_heads_container);

    // add listeners
    mVideoSurfaceHolder = mVideo.getHolder();
    mVideoSurfaceHolder.addCallback(this);
    mActiveMediaPlayer.setOnCompletionListener(this);
  }
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) {
   // We transform the default values from DIP to pixels
   DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
   barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
   rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
   circleRadius =
       (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
   circleRadius =
       (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
   fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
   barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
   rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
   float baseSpinSpeed =
       a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
   spinSpeed = baseSpinSpeed * 360;
   barSpinCycleTime =
       a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
   barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
   rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
   linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
   if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
     spin();
   }
   // Recycle
   a.recycle();
 }
Exemplo n.º 17
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;
    }
 private void parseAttributes(AttributeSet attrs) {
   TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view);
   confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true);
   fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true);
   loginText = a.getString(R.styleable.com_facebook_login_view_login_text);
   logoutText = a.getString(R.styleable.com_facebook_login_view_logout_text);
   a.recycle();
 }
Exemplo n.º 19
0
  /**
   * Does all the initial setup of the button such as retrieving all the attributes that were set in
   * xml and inflating the like button's view and initial state.
   *
   * @param context
   * @param attrs
   * @param defStyle
   */
  private void init(Context context, AttributeSet attrs, int defStyle) {
    LayoutInflater.from(getContext()).inflate(R.layout.likeview, this, true);
    icon = (ImageView) findViewById(R.id.icon);
    dotsView = (DotsView) findViewById(R.id.dots);
    circleView = (CircleView) findViewById(R.id.circle);

    final TypedArray array =
        context.obtainStyledAttributes(attrs, R.styleable.LikeButton, defStyle, 0);

    iconSize = array.getDimensionPixelSize(R.styleable.LikeButton_icon_size, -1);
    if (iconSize == -1) iconSize = 40;

    String iconType = array.getString(R.styleable.LikeButton_icon_type);

    likeDrawable = array.getDrawable(R.styleable.LikeButton_like_drawable);

    if (likeDrawable != null) setLikeDrawable(likeDrawable);

    unLikeDrawable = array.getDrawable(R.styleable.LikeButton_unlike_drawable);

    if (unLikeDrawable != null) setUnlikeDrawable(unLikeDrawable);

    if (iconType != null) if (!iconType.isEmpty()) currentIcon = parseIconType(iconType);

    circleStartColor = array.getColor(R.styleable.LikeButton_circle_start_color, 0);

    if (circleStartColor != 0) circleView.setStartColor(circleStartColor);

    circleEndColor = array.getColor(R.styleable.LikeButton_circle_end_color, 0);

    if (circleEndColor != 0) circleView.setEndColor(circleEndColor);

    dotPrimaryColor = array.getColor(R.styleable.LikeButton_dots_primary_color, 0);
    dotSecondaryColor = array.getColor(R.styleable.LikeButton_dots_secondary_color, 0);

    if (dotPrimaryColor != 0 && dotSecondaryColor != 0) {
      dotsView.setColors(dotPrimaryColor, dotSecondaryColor);
    }

    if (likeDrawable == null && unLikeDrawable == null) {
      if (currentIcon != null) {

        setLikeDrawableRes(currentIcon.getOnIconResourceId());
        setUnlikeDrawableRes(currentIcon.getOffIconResourceId());
      } else {
        currentIcon = parseIconType(IconType.Heart);
        setLikeDrawableRes(currentIcon.getOnIconResourceId());
        setUnlikeDrawableRes(currentIcon.getOffIconResourceId());
      }
    }

    setEnabled(array.getBoolean(R.styleable.LikeButton_enabled, true));
    Boolean status = array.getBoolean(R.styleable.LikeButton_liked, false);
    setAnimationScaleFactor(array.getFloat(R.styleable.LikeButton_anim_scale_factor, 3));
    setLiked(status);
    setOnClickListener(this);
    array.recycle();
  }
Exemplo n.º 20
0
  /**
   * Initiates data and parameters from styles
   *
   * @param attrs a collection of attributes.
   * @param defStyle The default style to apply to this view.
   */
  protected void initAttributes(AttributeSet attrs, int defStyle) {
    TypedArray a =
        getContext().obtainStyledAttributes(attrs, R.styleable.AbstractWheelView, defStyle, 0);
    mVisibleItems = a.getInt(R.styleable.AbstractWheelView_visibleItems, DEF_VISIBLE_ITEMS);
    mIsAllVisible = a.getBoolean(R.styleable.AbstractWheelView_isAllVisible, false);
    mIsCyclic = a.getBoolean(R.styleable.AbstractWheelView_isCyclic, DEF_IS_CYCLIC);

    a.recycle();
  }
Exemplo n.º 21
0
  public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mUiThreadId = Thread.currentThread().getId();
    initProgressBar();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, 0);

    mNoInvalidate = true;

    Drawable drawable = a.getDrawable(R.styleable.ProgressBar_progressDrawable);
    if (drawable != null) {
      drawable = tileify(drawable, false);
      // Calling this method can set mMaxHeight, make sure the corresponding
      // XML attribute for mMaxHeight is read after calling this method
      setProgressDrawable(drawable);
    }

    mDuration = a.getInt(R.styleable.ProgressBar_indeterminateDuration, mDuration);

    mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_minWidth, mMinWidth);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_maxWidth, mMaxWidth);
    mMinHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_minHeight, mMinHeight);
    mMaxHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_maxHeight, mMaxHeight);

    mBehavior = a.getInt(R.styleable.ProgressBar_indeterminateBehavior, mBehavior);

    final int resID =
        a.getResourceId(
            com.android.internal.R.styleable.ProgressBar_interpolator,
            android.R.anim.linear_interpolator); // default to linear interpolator
    if (resID > 0) {
      setInterpolator(context, resID);
    }

    setMax(a.getInt(R.styleable.ProgressBar_max, mMax));

    setProgress(a.getInt(R.styleable.ProgressBar_progress, mProgress));

    setSecondaryProgress(a.getInt(R.styleable.ProgressBar_secondaryProgress, mSecondaryProgress));

    drawable = a.getDrawable(R.styleable.ProgressBar_indeterminateDrawable);
    if (drawable != null) {
      drawable = tileifyIndeterminate(drawable);
      setIndeterminateDrawable(drawable);
    }

    mOnlyIndeterminate =
        a.getBoolean(R.styleable.ProgressBar_indeterminateOnly, mOnlyIndeterminate);

    mNoInvalidate = false;

    setIndeterminate(
        mOnlyIndeterminate || a.getBoolean(R.styleable.ProgressBar_indeterminate, mIndeterminate));

    a.recycle();
  }
Exemplo n.º 22
0
  private void init(Context context, AttributeSet attrs) {
    mDisplayMetrics = context.getResources().getDisplayMetrics();

    mStrokeWidth = mStrokeWidth * mDisplayMetrics.density;
    mTextSize = mTextSize * mDisplayMetrics.scaledDensity;

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressPieView);
    final Resources res = getResources();

    mMax = a.getInteger(R.styleable.ProgressPieView_max1, mMax);
    mProgress = a.getInteger(R.styleable.ProgressPieView_progress1, mProgress);
    mStartAngle = a.getInt(R.styleable.ProgressPieView_startAngle, mStartAngle);
    mStrokeWidth = a.getDimension(R.styleable.ProgressPieView_strokeWidth, mStrokeWidth);
    mTypeface = a.getString(R.styleable.ProgressPieView_typeface);
    mTextSize = a.getDimension(R.styleable.ProgressPieView_android_textSize, mTextSize);
    mText = a.getString(R.styleable.ProgressPieView_android_text);

    mShowStroke = a.getBoolean(R.styleable.ProgressPieView_showStroke, mShowStroke);
    mShowText = a.getBoolean(R.styleable.ProgressPieView_showText, mShowText);
    mImage = a.getDrawable(R.styleable.ProgressPieView_image);

    int backgroundColor = res.getColor(R.color.default_background_color);
    backgroundColor = a.getColor(R.styleable.ProgressPieView_backgroundColor, backgroundColor);
    int progressColor = res.getColor(R.color.default_progress_color);
    progressColor = a.getColor(R.styleable.ProgressPieView_progressColor1, progressColor);
    int strokeColor = res.getColor(R.color.default_stroke_color);
    strokeColor = a.getColor(R.styleable.ProgressPieView_strokeColor, strokeColor);
    int textColor = res.getColor(R.color.default_text_color);
    textColor = a.getColor(R.styleable.ProgressPieView_android_textColor, textColor);

    mProgressFillType =
        a.getInteger(R.styleable.ProgressPieView_progressFillType, mProgressFillType);

    a.recycle();

    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setColor(backgroundColor);
    mBackgroundPaint.setStyle(Paint.Style.FILL);

    mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressPaint.setColor(progressColor);
    mProgressPaint.setStyle(Paint.Style.FILL);

    mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mStrokePaint.setColor(strokeColor);
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setStrokeWidth(mStrokeWidth);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setColor(textColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);

    mInnerRectF = new RectF();
    mImageRect = new Rect();
  }
 @Override
 public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
   super.onInflate(activity, attrs, savedInstanceState);
   TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
   mChoiceMode =
       a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
   mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
   mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
   a.recycle();
 }
  @Override
  public boolean init(final Context context, final AttributeSet attrs) {
    if (!super.init(context, attrs)) {
      return false;
    }

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AwesomePreference);

    int filePath = -1, filePathList = -1, fileValue = -1;
    if (a != null) {
      filePath = a.getResourceId(R.styleable.AwesomePreference_filePath, -1);
      filePathList = a.getResourceId(R.styleable.AwesomePreference_filePathList, -1);
      fileValue = a.getResourceId(R.styleable.AwesomePreference_fileValue, -1);
      mStartup = a.getBoolean(R.styleable.AwesomePreference_startup, mStartup);
      mMultiFile = a.getBoolean(R.styleable.AwesomePreference_multifile, mMultiFile);
      mValueChecked = a.getString(R.styleable.AwesomePreference_valueChecked);
      mValueNotChecked = a.getString(R.styleable.AwesomePreference_valueNotChecked);
      a.recycle();
    }

    final Resources res = context.getResources();
    if (filePath != -1) {
      mPath = Utils.checkPath(res.getString(filePath));
      mPaths = null;
    } else if (filePathList != -1) {
      mPaths = res.getStringArray(filePathList);
      mPath = Utils.checkPaths(mPaths);
      if (mPath.isEmpty() || !mMultiFile) {
        mPaths = null;
      }
    } else {
      mPath = "";
      mPaths = null;
    }

    if (!TextUtils.isEmpty(mPath) && filePathList != -1 && fileValue != -1) {
      final int index = Arrays.asList(res.getStringArray(filePathList)).indexOf(mPath);
      final String[] values = res.getStringArray(fileValue)[index].split(";");
      mValueChecked = values[0];
      mValueNotChecked = values[1];
      Logger.d(
          this, "mValueChecked -> %s\nmValueNotChecked -> %s", mValueChecked, mValueNotChecked);
    }

    if (TextUtils.isEmpty(mValueChecked)) {
      mValueChecked = "1";
    }
    if (TextUtils.isEmpty(mValueNotChecked)) {
      mValueNotChecked = "0";
    }

    handleSelf(true);

    return true;
  }
  private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.GoogleCircleProgressView, defStyleAttr, 0);
    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor =
        a.getColor(
            R.styleable.GoogleCircleProgressView_gcp_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor =
        a.getColor(
            R.styleable.GoogleCircleProgressView_gcp_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] {mProgressColor};

    mInnerRadius =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_inner_radius, -1);

    mProgressStokeWidth =
        a.getDimensionPixelOffset(
            R.styleable.GoogleCircleProgressView_gcp_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_arrow_width, -1);
    mArrowHeight =
        a.getDimensionPixelOffset(R.styleable.GoogleCircleProgressView_gcp_arrow_height, -1);
    mTextSize =
        a.getDimensionPixelOffset(
            R.styleable.GoogleCircleProgressView_gcp_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor =
        a.getColor(R.styleable.GoogleCircleProgressView_gcp_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.GoogleCircleProgressView_gcp_show_arrow, true);
    mCircleBackgroundEnabled =
        a.getBoolean(R.styleable.GoogleCircleProgressView_gcp_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.GoogleCircleProgressView_gcp_progress, 0);
    mMax = a.getInt(R.styleable.GoogleCircleProgressView_gcp_max, 100);
    int textVisible =
        a.getInt(R.styleable.GoogleCircleProgressView_gcp_progress_text_visibility, 1);
    if (textVisible != 1) {
      mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
  }
Exemplo n.º 26
0
  public PagerHeader(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;

    Resources resources = context.getResources();
    mDisplayMetrics = resources.getDisplayMetrics();

    // Get attributes from the layout xml
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerHeader, 0, 0);
    //		mActiveTextColor = new ColorSet(
    //				a.getColor(R.styleable.PagerHeader_activeTextColor, Color.GREEN));
    mActiveTextColor = new ColorSet(resources.getColor(R.color.cputuner_green));
    mInactiveTextColor =
        new ColorSet(a.getColor(R.styleable.PagerHeader_inactiveTextColor, Color.LTGRAY));
    mTabColor =
        new ColorSet(a.getColor(R.styleable.PagerHeader_tabColor, mActiveTextColor.getColor()));
    mTabHeight = a.getDimensionPixelSize(R.styleable.PagerHeader_tabHeight, dipToPixels(4));
    mTabPadding = a.getDimensionPixelSize(R.styleable.PagerHeader_tabPadding, dipToPixels(10));
    mPaddingPush = a.getDimensionPixelSize(R.styleable.PagerHeader_paddingPush, dipToPixels(50));
    mFadingEdgeLength =
        a.getDimensionPixelSize(R.styleable.PagerHeader_fadingEdgeLength, dipToPixels(30));
    mShowTopShadow = a.getBoolean(R.styleable.PagerHeader_showTopShadow, true);
    mShowBottomBar = a.getBoolean(R.styleable.PagerHeader_showBottomBar, true);
    mShowTab = a.getBoolean(R.styleable.PagerHeader_showTab, true);

    ColorSet fadingEdgeColorHint = new ColorSet(0);
    int backgroundColor = a.getColor(R.styleable.PagerHeader_backgroundColor, Color.DKGRAY);
    setBackgroundColor(backgroundColor);
    fadingEdgeColorHint.setColor(backgroundColor);

    mTabDrawable = new ShapeDrawable(new RectShape());
    mTabDrawable.getPaint().setColor(mTabColor.getColor());

    mBottomBar = new ShapeDrawable(new RectShape());
    mBottomBar.getPaint().setColor(mTabColor.getColor());
    mBottomBarHeight = dipToPixels(2);

    mShadow =
        new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x88000000, 0x00000000});
    mShadowHeight = dipToPixels(3);

    int[] fadingEdgeGradient =
        new int[] {fadingEdgeColorHint.getColor(), fadingEdgeColorHint.getColor(0)};
    mFadingEdgeLeft =
        new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, fadingEdgeGradient);
    mFadingEdgeRight =
        new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, fadingEdgeGradient);

    final ViewConfiguration config = ViewConfiguration.get(context);
    int touchSlop = config.getScaledTouchSlop();
    mTouchSlopSquare = touchSlop * touchSlop;
  }
  public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth =
        res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    // Retrieve styles attributes
    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation =
        a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(
        a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(
        a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(
        a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    // custom------
    /*mPaintText.setTextAlign(Align.CENTER);
    mPaintText.setTextSize(15);
    mPaintText.setColor(Color.WHITE);*/

    // -----------
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
  }
  private void init(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FamiliarRecyclerView);
    Drawable divider = ta.getDrawable(R.styleable.FamiliarRecyclerView_frv_divider);
    int dividerHeight =
        (int) ta.getDimension(R.styleable.FamiliarRecyclerView_frv_dividerHeight, -1);
    mVerticalDivider = ta.getDrawable(R.styleable.FamiliarRecyclerView_frv_dividerVertical);
    mHorizontalDivider = ta.getDrawable(R.styleable.FamiliarRecyclerView_frv_dividerHorizontal);
    mVerticalDividerHeight =
        (int) ta.getDimension(R.styleable.FamiliarRecyclerView_frv_dividerVerticalHeight, -1);
    mHorizontalDividerHeight =
        (int) ta.getDimension(R.styleable.FamiliarRecyclerView_frv_dividerHorizontalHeight, -1);
    mItemViewBothSidesMargin =
        (int) ta.getDimension(R.styleable.FamiliarRecyclerView_frv_itemViewBothSidesMargin, 0);
    mEmptyViewResId = ta.getResourceId(R.styleable.FamiliarRecyclerView_frv_emptyView, -1);
    isKeepShowHeadOrFooter =
        ta.getBoolean(R.styleable.FamiliarRecyclerView_frv_isEmptyViewKeepShowHeadOrFooter, false);
    isHeaderDividersEnabled =
        ta.getBoolean(R.styleable.FamiliarRecyclerView_frv_headerDividersEnabled, false);
    isFooterDividersEnabled =
        ta.getBoolean(R.styleable.FamiliarRecyclerView_frv_footerDividersEnabled, false);
    if (ta.hasValue(R.styleable.FamiliarRecyclerView_frv_layoutManager)) {
      int layoutManagerType =
          ta.getInt(R.styleable.FamiliarRecyclerView_frv_layoutManager, DEF_LAYOUT_MANAGER_TYPE);
      int layoutManagerOrientation =
          ta.getInt(
              R.styleable.FamiliarRecyclerView_frv_layoutManagerOrientation,
              DEF_LAYOUT_MANAGER_ORIENTATION);
      boolean isReverseLayout =
          ta.getBoolean(R.styleable.FamiliarRecyclerView_frv_isReverseLayout, false);
      int gridSpanCount =
          ta.getInt(R.styleable.FamiliarRecyclerView_frv_spanCount, DEF_GRID_SPAN_COUNT);

      switch (layoutManagerType) {
        case LAYOUT_MANAGER_TYPE_LINEAR:
          processGridDivider(divider, dividerHeight, false, layoutManagerOrientation);
          setLayoutManager(
              new LinearLayoutManager(context, layoutManagerOrientation, isReverseLayout));
          break;
        case LAYOUT_MANAGER_TYPE_GRID:
          processGridDivider(divider, dividerHeight, false, layoutManagerOrientation);
          setLayoutManager(
              new GridLayoutManager(
                  context, gridSpanCount, layoutManagerOrientation, isReverseLayout));
          break;
        case LAYOUT_MANAGER_TYPE_STAGGERED_GRID:
          processGridDivider(divider, dividerHeight, false, layoutManagerOrientation);
          setLayoutManager(new StaggeredGridLayoutManager(gridSpanCount, layoutManagerOrientation));
          break;
      }
    }
    ta.recycle();
  }
Exemplo n.º 29
0
  /**
   * Method that initializes all fields and sets listeners
   *
   * @param context Context used to create this view
   * @param attrs Attribute used to initialize fields
   */
  private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode()) return;

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleView);
    rippleColor =
        typedArray.getColor(
            R.styleable.RippleView_rv_color, getResources().getColor(R.color.white));
    rippleType = typedArray.getInt(R.styleable.RippleView_rv_type, 0);
    hasToZoom = typedArray.getBoolean(R.styleable.RippleView_rv_zoom, false);
    isCentered = typedArray.getBoolean(R.styleable.RippleView_rv_centered, false);
    rippleDuration =
        typedArray.getInteger(R.styleable.RippleView_rv_rippleDuration, rippleDuration);
    frameRate = typedArray.getInteger(R.styleable.RippleView_rv_framerate, frameRate);
    rippleAlpha = typedArray.getInteger(R.styleable.RippleView_rv_alpha, rippleAlpha);
    ripplePadding = typedArray.getDimensionPixelSize(R.styleable.RippleView_rv_ripplePadding, 0);
    canvasHandler = new Handler();
    zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
    zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
    typedArray.recycle();
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);
    this.setWillNotDraw(false);

    gestureDetector =
        new GestureDetector(
            context,
            new GestureDetector.SimpleOnGestureListener() {
              @Override
              public void onLongPress(MotionEvent event) {
                super.onLongPress(event);
                animateRipple(event);
                sendClickEvent(true);
              }

              @Override
              public boolean onSingleTapConfirmed(MotionEvent e) {
                return true;
              }

              @Override
              public boolean onSingleTapUp(MotionEvent e) {
                return true;
              }
            });

    this.setDrawingCacheEnabled(true);
    this.setClickable(true);
  }
Exemplo n.º 30
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  public CirclePageIndicatorBlack(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    // Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.text_normal);
    final int defaultFillColor = res.getColor(R.color.text_bold);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.text_normal);
    final float defaultStrokeWidth =
        res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius_black);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    // Retrieve styles attributes
    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation =
        a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(
        a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(
        a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(
        a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(background);
      } else {
        setBackgroundDrawable(background);
      }
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
  }