MCPcopy Create free account
hub / github.com/Cutta/TagView / initialize

Method initialize

library/src/main/java/com/cunoraz/tagview/TagView.java:104–126  ·  view source on GitHub ↗

initalize instance @param ctx @param attrs @param defStyle

(Context ctx, AttributeSet attrs, int defStyle)

Source from the content-addressed store, hash-verified

102 * @param defStyle
103 */
104 private void initialize(Context ctx, AttributeSet attrs, int defStyle) {
105 mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
106 mViewTreeObserber = getViewTreeObserver();
107 mViewTreeObserber.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
108 @Override
109 public void onGlobalLayout() {
110 if (!mInitialized) {
111 mInitialized = true;
112 drawTags();
113 }
114 }
115 });
116
117 // get AttributeSet
118 TypedArray typeArray = ctx.obtainStyledAttributes(attrs, R.styleable.TagView, defStyle, defStyle);
119 this.lineMargin = (int) typeArray.getDimension(R.styleable.TagView_lineMargin, Utils.dipToPx(this.getContext(), Constants.DEFAULT_LINE_MARGIN));
120 this.tagMargin = (int) typeArray.getDimension(R.styleable.TagView_tagMargin, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_MARGIN));
121 this.textPaddingLeft = (int) typeArray.getDimension(R.styleable.TagView_textPaddingLeft, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_LEFT));
122 this.textPaddingRight = (int) typeArray.getDimension(R.styleable.TagView_textPaddingRight, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_RIGHT));
123 this.textPaddingTop = (int) typeArray.getDimension(R.styleable.TagView_textPaddingTop, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_TOP));
124 this.textPaddingBottom = (int) typeArray.getDimension(R.styleable.TagView_textPaddingBottom, Utils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_BOTTOM));
125 typeArray.recycle();
126 }
127
128 /**
129 * onSizeChanged

Callers 1

TagViewMethod · 0.95

Calls 1

dipToPxMethod · 0.95

Tested by

no test coverage detected