List of usage examples for android.content.res TypedArray getIndex
public int getIndex(int at)
From source file:org.alice.jack_blog.widget.refreshContainer.CanRefreshLayout.java
public CanRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CanRefreshLayout, defStyleAttr, 0); try {/*from w w w . j av a2s . com*/ final int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == R.styleable.CanRefreshLayout_can_enabled_up) { setRefreshEnabled(a.getBoolean(attr, true)); } else if (attr == R.styleable.CanRefreshLayout_can_enabled_down) { setLoadMoreEnabled(a.getBoolean(attr, true)); } else if (attr == R.styleable.CanRefreshLayout_can_style_up) { mHeadStyle = a.getInt(attr, CLASSIC); } else if (attr == R.styleable.CanRefreshLayout_can_style_down) { mFootStyle = a.getInt(attr, CLASSIC); } else if (attr == R.styleable.CanRefreshLayout_can_friction) { setFriction(a.getFloat(attr, DEFAULT_FRICTION)); } else if (attr == R.styleable.CanRefreshLayout_can_duration) { mDuration = a.getInt(attr, DEFAULT_DURATION); } else if (attr == R.styleable.CanRefreshLayout_can_smooth_duration) { mSmoothDuration = a.getInt(attr, DEFAULT_SMOOTH_DURATION); } else if (attr == R.styleable.CanRefreshLayout_can_smooth_length) { mSmoothLength = a.getInt(attr, DEFAULT_SMOOTH_LENGTH); } else if (attr == R.styleable.CanRefreshLayout_can_bg_up) { mRefreshBackgroundResource = a.getResourceId(attr, android.R.color.transparent); } else if (attr == R.styleable.CanRefreshLayout_can_bg_down) { mLoadMoreBackgroundResource = a.getResourceId(attr, android.R.color.transparent); } else if (attr == R.styleable.CanRefreshLayout_can_is_coo) { mIsCoo = a.getBoolean(attr, false); } } } finally { a.recycle(); } }
From source file:org.xbmc.kore.ui.NowPlayingFragment.java
/** * Sets whats playing information/* w ww .j a va2 s .c o m*/ * @param getItemResult Return from method {@link org.xbmc.kore.jsonrpc.method.Player.GetItem} */ private void setNowPlayingInfo(PlayerType.PropertyValue getPropertiesResult, final ListType.ItemsAll getItemResult) { final String title, underTitle, art, poster, genreSeason, year, descriptionPlot, votes, maxRating; double rating; switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.tagline; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_EPISODE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.showtitle; art = getItemResult.thumbnail; poster = getItemResult.art.poster; genreSeason = String.format(getString(R.string.season_episode), getItemResult.season, getItemResult.episode); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_SONG: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.description; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_music); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = 0; maxRating = null; votes = null; break; case ListType.ItemsAll.TYPE_CHANNEL: switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = getItemResult.title; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = null; votes = null; break; default: // Other type, just present basic info switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = ""; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = null; year = getItemResult.premiered; descriptionPlot = removeYouTubeMarkup(getItemResult.plot); rating = 0; maxRating = null; votes = null; break; } mediaTitle.setText(title); mediaUndertitle.setText(underTitle); setDurationInfo(getItemResult.type, getPropertiesResult.time, getPropertiesResult.totaltime, getPropertiesResult.speed); mediaSeekbar.setOnSeekBarChangeListener(seekbarChangeListener); if (!TextUtils.isEmpty(year) || !TextUtils.isEmpty(genreSeason)) { mediaYear.setVisibility(View.VISIBLE); mediaGenreSeason.setVisibility(View.VISIBLE); mediaYear.setText(year); mediaGenreSeason.setText(genreSeason); } else { mediaYear.setVisibility(View.GONE); mediaGenreSeason.setVisibility(View.GONE); } // 0 rating will not be shown if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRatingVotes.setVisibility(View.VISIBLE); mediaRating.setText(String.format("%01.01f", rating)); mediaMaxRating.setText(maxRating); mediaRatingVotes.setText(votes); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); mediaRatingVotes.setVisibility(View.GONE); } if (!TextUtils.isEmpty(descriptionPlot)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(descriptionPlot); } else { mediaDescription.setVisibility(View.GONE); } Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.colorAccent, R.attr.iconRepeat, R.attr.iconRepeatOne }); int accentDefaultColor = getResources().getColor(R.color.accent_default); if (getPropertiesResult.repeat.equals(PlayerType.Repeat.OFF)) { repeatButton.setImageResource( styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp)); repeatButton.clearColorFilter(); } else if (getPropertiesResult.repeat.equals(PlayerType.Repeat.ONE)) { repeatButton.setImageResource(styledAttributes.getResourceId(styledAttributes.getIndex(2), R.drawable.ic_repeat_one_white_24dp)); repeatButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } else { repeatButton.setImageResource( styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp)); repeatButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } if (!getPropertiesResult.shuffled) { shuffleButton.clearColorFilter(); } else { shuffleButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } styledAttributes.recycle(); Resources resources = getActivity().getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height), artWidth = displayMetrics.widthPixels; if (!TextUtils.isEmpty(art)) { mediaPoster.setVisibility(View.VISIBLE); int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height); // If not video, change aspect ration of poster to a square boolean isVideo = (getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE)); if (!isVideo) { ViewGroup.LayoutParams layoutParams = mediaPoster.getLayoutParams(); layoutParams.height = layoutParams.width; mediaPoster.setLayoutParams(layoutParams); posterHeight = posterWidth; } UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, art, mediaArt, displayMetrics.widthPixels, artHeight); // Reset padding int paddingLeft = resources.getDimensionPixelOffset(R.dimen.poster_width_plus_padding), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } else { // No fanart, just present the poster mediaPoster.setVisibility(View.GONE); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, mediaArt, artWidth, artHeight); // Reset padding int paddingLeft = mediaTitle.getPaddingRight(), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } // UIUtils.loadImageIntoImageview(hostManager, poster, mediaPoster); // UIUtils.loadImageIntoImageview(hostManager, art, mediaArt); // Continue for videos // if (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE) || // getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) { // TODO: change this check to the commeted out one when jsonrpc returns the correct type // if (getPropertiesResult.type.equals(PlayerType.PropertyValue.TYPE_VIDEO)) { if ((getPropertiesResult.audiostreams != null) && (getPropertiesResult.audiostreams.size() > 0)) { overflowButton.setVisibility(View.VISIBLE); videoCastList.setVisibility(View.VISIBLE); // Save subtitles and audiostreams list availableAudioStreams = getPropertiesResult.audiostreams; availableSubtitles = getPropertiesResult.subtitles; currentAudiostreamIndex = getPropertiesResult.currentaudiostream.index; currentSubtitleIndex = getPropertiesResult.currentsubtitle.index; // Cast list UIUtils.setupCastInfo(getActivity(), getItemResult.cast, videoCastList, AllCastActivity .buildLaunchIntent(getActivity(), title, (ArrayList<VideoType.Cast>) getItemResult.cast)); } else { overflowButton.setVisibility(View.GONE); videoCastList.setVisibility(View.GONE); } }
From source file:net.toload.main.hd.candidate.CandidateView.java
public CandidateView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context;//from w ww . j a v a 2s . c om mCandidateView = this; embeddedComposing = null; // Jeremy '15,6,4 for embedded composing view in candidateView when floating candidateView (not fixed) mLIMEPref = new LIMEPreferenceManager(context); //Jeremy '16,7,24 get themed objects TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.LIMECandidateView, defStyle, R.style.LIMECandidateView); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.LIMECandidateView_suggestHighlight: mDrawableSuggestHighlight = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_voiceInputIcon: mDrawableVoiceInput = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_ExpandButtonIcon: mDrawableExpandButton = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_closeButtonIcon: mDrawableCloseButton = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_candidateBackground: mColorBackground = a.getColor(attr, ContextCompat.getColor(context, R.color.third_background_light)); break; case R.styleable.LIMECandidateView_composingTextColor: mColorComposingText = a.getColor(attr, ContextCompat.getColor(context, R.color.second_foreground_light)); break; case R.styleable.LIMECandidateView_composingBackgroundColor: mColorComposingBackground = a.getColor(attr, ContextCompat.getColor(context, R.color.composing_background_light)); break; case R.styleable.LIMECandidateView_candidateNormalTextColor: mColorNormalText = a.getColor(attr, ContextCompat.getColor(context, R.color.foreground_light)); break; case R.styleable.LIMECandidateView_candidateNormalTextHighlightColor: mColorNormalTextHighlight = a.getColor(attr, ContextCompat.getColor(context, R.color.foreground_light)); break; case R.styleable.LIMECandidateView_composingCodeColor: mColorComposingCode = a.getColor(attr, ContextCompat.getColor(context, R.color.color_common_green_hl)); break; case R.styleable.LIMECandidateView_composingCodeHighlightColor: mColorComposingCodeHighlight = a.getColor(attr, ContextCompat.getColor(context, R.color.third_background_light)); break; case R.styleable.LIMECandidateView_spacerColor: mColorSpacer = a.getColor(attr, ContextCompat.getColor(context, R.color.candidate_spacer)); break; case R.styleable.LIMECandidateView_selKeyColor: mColorSelKey = a.getColor(attr, ContextCompat.getColor(context, R.color.candidate_selection_keys)); break; case R.styleable.LIMECandidateView_selKeyShiftedColor: mColorSelKeyShifted = a.getColor(attr, ContextCompat.getColor(context, R.color.color_common_green_hl)); break; } } a.recycle(); final Resources r = context.getResources(); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point screenSize = new Point(); display.getSize(screenSize); mScreenWidth = screenSize.x; mScreenHeight = screenSize.y; mVerticalPadding = (int) (r.getDimensionPixelSize(R.dimen.candidate_vertical_padding) * mLIMEPref.getFontSize()); configHeight = (int) (r.getDimensionPixelSize(R.dimen.candidate_stripe_height) * mLIMEPref.getFontSize()); mHeight = configHeight + mVerticalPadding; mExpandButtonWidth = r.getDimensionPixelSize(R.dimen.candidate_expand_button_width);// *mLIMEPref.getFontSize()); mCandidatePaint = new Paint(); mCandidatePaint.setColor(mColorNormalText); mCandidatePaint.setAntiAlias(true); mCandidatePaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_size) * mLIMEPref.getFontSize()); mCandidatePaint.setStrokeWidth(0); mSelKeyPaint = new Paint(); mSelKeyPaint.setColor(mColorSelKey); mSelKeyPaint.setAntiAlias(true); mSelKeyPaint .setTextSize(r.getDimensionPixelSize(R.dimen.candidate_number_font_size) * mLIMEPref.getFontSize()); mSelKeyPaint.setStyle(Paint.Style.FILL_AND_STROKE); //final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); //Jeremy '12,4,23 add mContext parameter. The constructor without context is deprecated mGestureDetector = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (DEBUG) Log.i(TAG, "onScroll(): distanceX = " + distanceX + "; distanceY = " + distanceY); //Jeremy '12,4,8 filter out small scroll which is actually candidate selection. if (Math.abs(distanceX) < mHeight / 5 && Math.abs(distanceY) < mHeight / 5) return true; mScrolled = true; // Update full candidate list before scroll checkHasMoreRecords(); int sx = getScrollX(); sx += distanceX; if (sx < 0) { sx = 0; } if (sx + getWidth() > mTotalWidth) { sx -= distanceX; } if (mLIMEPref.getParameterBoolean("candidate_switch", false)) { hasSlide = true; mTargetScrollX = sx; scrollTo(sx, getScrollY()); currentX = getScrollX(); //Jeremy '12,7,6 set currentX to the left edge of current scrollview after scrolled } else { hasSlide = false; if (distanceX < 0) { goLeft = true; goRight = false; } else if (distanceX > 0) { goLeft = false; goRight = true; } else { mTargetScrollX = sx; } } return true; } }); }
From source file:com.albedinsky.android.ui.widget.BaseProgressBar.java
/** * Called from one of constructors of this view to perform its initialization. * <p>/*from w w w . j a va 2 s . c o m*/ * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for * this view specific data from it that can be used to configure this new view instance. The * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data * from the current theme provided by the specified <var>context</var>. */ @SuppressLint("NewApi") private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this.mUiThreadId = Thread.currentThread().getId(); // Use software layer that is required for proper drawing work of progress drawables. if (ProgressDrawable.REQUIRES_SOFTWARE_LAYER) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } onAttachDrawable(); if (mDrawable == null) { throw new IllegalArgumentException("No progress drawable has been attached."); } /** * Process attributes. */ final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ProgressBar, defStyleAttr, defStyleRes); if (typedArray != null) { this.processTintValues(context, typedArray); final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_ProgressBar_android_max) { setMax(typedArray.getInt(index, getMax())); } else if (index == R.styleable.Ui_ProgressBar_android_progress) { setProgress(typedArray.getInt(index, mProgress)); } else if (index == R.styleable.Ui_ProgressBar_uiColorProgress) { mDrawable.setColor(typedArray.getColor(index, mDrawable.getColor())); } else if (index == R.styleable.Ui_ProgressBar_uiColorsProgress) { final int colorsResId = typedArray.getResourceId(index, -1); if (colorsResId > 0 && !isInEditMode()) { mDrawable.setColors(context.getResources().getIntArray(colorsResId)); } } else if (index == R.styleable.Ui_ProgressBar_uiMultiColored) { mDrawable.setMultiColored(typedArray.getBoolean(index, mDrawable.isMultiColored())); } else if (index == R.styleable.Ui_ProgressBar_uiColorProgressBackground) { mDrawable.setBackgroundColor(typedArray.getInt(index, Color.TRANSPARENT)); } else if (index == R.styleable.Ui_ProgressBar_android_thickness) { mDrawable.setThickness(typedArray.getDimensionPixelSize(index, 0)); } else if (index == R.styleable.Ui_ProgressBar_uiRounded) { mDrawable.setRounded(!isInEditMode() && typedArray.getBoolean(index, mDrawable.isRounded())); } else if (index == R.styleable.Ui_ProgressBar_uiIndeterminateSpeed) { mDrawable.setIndeterminateSpeed(typedArray.getFloat(index, 1)); } } } mDrawable.setInEditMode(isInEditMode()); this.applyProgressTint(); this.applyIndeterminateTint(); this.applyProgressBackgroundTint(); }
From source file:org.kde.necessitas.ministro.ExtractStyle.java
public JSONObject extractTextAppearanceInformations(String styleName, String qtClass, AttributeSet attribSet, int textAppearance) { JSONObject json = new JSONObject(); try {/*from www . jav a 2 s .c o m*/ int textColorHighlight = 0; // ColorStateList textColor = null; // ColorStateList textColorHint = null; // ColorStateList textColorLink = null; // int textSize = 15; // int typefaceIndex = -1; // int styleIndex = -1; boolean allCaps = false; Class<?> attrClass = Class.forName("android.R$attr"); int styleId = attrClass.getDeclaredField(styleName).getInt(null); extractViewInformations(styleName, styleId, json, qtClass, attribSet); int[] textViewAttrs = (int[]) styleableClass.getDeclaredField("TextView").get(null); TypedArray a = m_theme.obtainStyledAttributes(null, textViewAttrs, styleId, 0); TypedArray appearance = null; if (-1 == textAppearance) textAppearance = a .getResourceId(styleableClass.getDeclaredField("TextView_textAppearance").getInt(null), -1); if (textAppearance != -1) appearance = m_theme.obtainStyledAttributes(textAppearance, (int[]) styleableClass.getDeclaredField("TextAppearance").get(null)); if (appearance != null) { int n = appearance.getIndexCount(); for (int i = 0; i < n; i++) { int attr = appearance.getIndex(i); if (attr == TextAppearance_textColorHighlight) textColorHighlight = appearance.getColor(attr, textColorHighlight); else if (attr == TextAppearance_textColor) textColor = appearance.getColorStateList(attr); else if (attr == TextAppearance_textColorHint) textColorHint = appearance.getColorStateList(attr); else if (attr == TextAppearance_textColorLink) textColorLink = appearance.getColorStateList(attr); else if (attr == TextAppearance_textSize) textSize = appearance.getDimensionPixelSize(attr, textSize); else if (attr == TextAppearance_typeface) typefaceIndex = appearance.getInt(attr, -1); else if (attr == TextAppearance_textStyle) styleIndex = appearance.getInt(attr, -1); else if (attr == TextAppearance_textAllCaps) allCaps = appearance.getBoolean(attr, false); } appearance.recycle(); } int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); if (attr == TextView_editable) json.put("TextView_editable", a.getBoolean(attr, false)); else if (attr == TextView_inputMethod) json.put("TextView_inputMethod", a.getText(attr)); else if (attr == TextView_numeric) json.put("TextView_numeric", a.getInt(attr, 0)); else if (attr == TextView_digits) json.put("TextView_digits", a.getText(attr)); else if (attr == TextView_phoneNumber) json.put("TextView_phoneNumber", a.getBoolean(attr, false)); else if (attr == TextView_autoText) json.put("TextView_autoText", a.getBoolean(attr, false)); else if (attr == TextView_capitalize) json.put("TextView_capitalize", a.getInt(attr, -1)); else if (attr == TextView_bufferType) json.put("TextView_bufferType", a.getInt(attr, 0)); else if (attr == TextView_selectAllOnFocus) json.put("TextView_selectAllOnFocus", a.getBoolean(attr, false)); else if (attr == TextView_autoLink) json.put("TextView_autoLink", a.getInt(attr, 0)); else if (attr == TextView_linksClickable) json.put("TextView_linksClickable", a.getBoolean(attr, true)); else if (attr == TextView_linksClickable) json.put("TextView_linksClickable", a.getBoolean(attr, true)); else if (attr == TextView_drawableLeft) json.put("TextView_drawableLeft", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableLeft")); else if (attr == TextView_drawableTop) json.put("TextView_drawableTop", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableTop")); else if (attr == TextView_drawableRight) json.put("TextView_drawableRight", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableRight")); else if (attr == TextView_drawableBottom) json.put("TextView_drawableBottom", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableBottom")); else if (attr == TextView_drawableStart) json.put("TextView_drawableStart", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableStart")); else if (attr == TextView_drawableEnd) json.put("TextView_drawableEnd", getDrawable(a.getDrawable(attr), styleName + "_TextView_drawableEnd")); else if (attr == TextView_drawablePadding) json.put("TextView_drawablePadding", a.getDimensionPixelSize(attr, 0)); else if (attr == TextView_textCursorDrawable) json.put("TextView_textCursorDrawable", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textCursorDrawable")); else if (attr == TextView_maxLines) json.put("TextView_maxLines", a.getInt(attr, -1)); else if (attr == TextView_maxHeight) json.put("TextView_maxHeight", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_lines) json.put("TextView_lines", a.getInt(attr, -1)); else if (attr == TextView_height) json.put("TextView_height", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_minLines) json.put("TextView_minLines", a.getInt(attr, -1)); else if (attr == TextView_minHeight) json.put("TextView_minHeight", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_maxEms) json.put("TextView_maxEms", a.getInt(attr, -1)); else if (attr == TextView_maxWidth) json.put("TextView_maxWidth", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_ems) json.put("TextView_ems", a.getInt(attr, -1)); else if (attr == TextView_width) json.put("TextView_width", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_minEms) json.put("TextView_minEms", a.getInt(attr, -1)); else if (attr == TextView_minWidth) json.put("TextView_minWidth", a.getDimensionPixelSize(attr, -1)); else if (attr == TextView_gravity) json.put("TextView_gravity", a.getInt(attr, -1)); else if (attr == TextView_hint) json.put("TextView_hint", a.getText(attr)); else if (attr == TextView_text) json.put("TextView_text", a.getText(attr)); else if (attr == TextView_scrollHorizontally) json.put("TextView_scrollHorizontally", a.getBoolean(attr, false)); else if (attr == TextView_singleLine) json.put("TextView_singleLine", a.getBoolean(attr, false)); else if (attr == TextView_ellipsize) json.put("TextView_ellipsize", a.getInt(attr, -1)); else if (attr == TextView_marqueeRepeatLimit) json.put("TextView_marqueeRepeatLimit", a.getInt(attr, 3)); else if (attr == TextView_includeFontPadding) json.put("TextView_includeFontPadding", a.getBoolean(attr, true)); else if (attr == TextView_cursorVisible) json.put("TextView_cursorVisible", a.getBoolean(attr, true)); else if (attr == TextView_maxLength) json.put("TextView_maxLength", a.getInt(attr, -1)); else if (attr == TextView_textScaleX) json.put("TextView_textScaleX", a.getFloat(attr, 1.0f)); else if (attr == TextView_freezesText) json.put("TextView_freezesText", a.getBoolean(attr, false)); else if (attr == TextView_shadowColor) json.put("TextView_shadowColor", a.getInt(attr, 0)); else if (attr == TextView_shadowDx) json.put("TextView_shadowDx", a.getFloat(attr, 0)); else if (attr == TextView_shadowDy) json.put("TextView_shadowDy", a.getFloat(attr, 0)); else if (attr == TextView_shadowRadius) json.put("TextView_shadowRadius", a.getFloat(attr, 0)); else if (attr == TextView_enabled) json.put("TextView_enabled", a.getBoolean(attr, true)); else if (attr == TextView_textColorHighlight) textColorHighlight = a.getColor(attr, textColorHighlight); else if (attr == TextView_textColor) textColor = a.getColorStateList(attr); else if (attr == TextView_textColorHint) textColorHint = a.getColorStateList(attr); else if (attr == TextView_textColorLink) textColorLink = a.getColorStateList(attr); else if (attr == TextView_textSize) textSize = a.getDimensionPixelSize(attr, textSize); else if (attr == TextView_typeface) typefaceIndex = a.getInt(attr, typefaceIndex); else if (attr == TextView_textStyle) styleIndex = a.getInt(attr, styleIndex); else if (attr == TextView_password) json.put("TextView_password", a.getBoolean(attr, false)); else if (attr == TextView_lineSpacingExtra) json.put("TextView_lineSpacingExtra", a.getDimensionPixelSize(attr, 0)); else if (attr == TextView_lineSpacingMultiplier) json.put("TextView_lineSpacingMultiplier", a.getFloat(attr, 1.0f)); else if (attr == TextView_inputType) json.put("TextView_inputType", a.getInt(attr, EditorInfo.TYPE_NULL)); else if (attr == TextView_imeOptions) json.put("TextView_imeOptions", a.getInt(attr, EditorInfo.IME_NULL)); else if (attr == TextView_imeActionLabel) json.put("TextView_imeActionLabel", a.getText(attr)); else if (attr == TextView_imeActionId) json.put("TextView_imeActionId", a.getInt(attr, 0)); else if (attr == TextView_privateImeOptions) json.put("TextView_privateImeOptions", a.getString(attr)); else if (attr == TextView_textSelectHandleLeft && styleName.equals("textViewStyle")) json.put("TextView_textSelectHandleLeft", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleLeft")); else if (attr == TextView_textSelectHandleRight && styleName.equals("textViewStyle")) json.put("TextView_textSelectHandleRight", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandleRight")); else if (attr == TextView_textSelectHandle && styleName.equals("textViewStyle")) json.put("TextView_textSelectHandle", getDrawable(m_context.getResources().getDrawable(a.getResourceId(attr, 0)), styleName + "_TextView_textSelectHandle")); else if (attr == TextView_textIsSelectable) json.put("TextView_textIsSelectable", a.getBoolean(attr, false)); else if (attr == TextView_textAllCaps) allCaps = a.getBoolean(attr, false); } a.recycle(); json.put("TextAppearance_textColorHighlight", textColorHighlight); json.put("TextAppearance_textColor", getColorStateList(textColor)); json.put("TextAppearance_textColorHint", getColorStateList(textColorHint)); json.put("TextAppearance_textColorLink", getColorStateList(textColorLink)); json.put("TextAppearance_textSize", textSize); json.put("TextAppearance_typeface", typefaceIndex); json.put("TextAppearance_textStyle", styleIndex); json.put("TextAppearance_textAllCaps", allCaps); } catch (Exception e) { e.printStackTrace(); } return json; }
From source file:com.albedinsky.android.support.ui.widget.BaseProgressBar.java
/** * Creates a new instance of BaseProgressBar within the given <var>context</var>. * * @param context Context in which will be this view presented. * @param attrs Set of Xml attributes used to configure the new instance of this view. * @param defStyleAttr An attribute which contains a reference to a default style resource for * this view within a theme of the given context. *//*w ww . j a v a 2 s .c om*/ public BaseProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mResources = context.getResources(); this.mUiThreadId = Thread.currentThread().getId(); onAttachDrawable(); if (mDrawable == null) { throw new IllegalArgumentException("No progress drawable has been attached."); } /** * Process attributes. */ final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_Widget_ProgressBar, defStyleAttr, 0); if (typedArray != null) { this.processTintValues(context, typedArray); final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_Widget_ProgressBar_uiColorProgress) { mDrawable.setColor(typedArray.getColor(index, mDrawable.getColor())); } else if (index == R.styleable.Ui_Widget_ProgressBar_uiColorsProgress) { final int colorsResId = typedArray.getResourceId(index, -1); if (colorsResId > 0) { mDrawable.setColors(mResources.getIntArray(colorsResId)); } } else if (index == R.styleable.Ui_Widget_ProgressBar_uiMultiColored) { mDrawable.setMultiColored(typedArray.getBoolean(index, mDrawable.isMultiColored())); } else if (index == R.styleable.Ui_Widget_ProgressBar_uiColorProgressBackground) { mDrawable.setBackgroundColor(typedArray.getInt(index, Color.TRANSPARENT)); } else if (index == R.styleable.Ui_Widget_ProgressBar_android_thickness) { mDrawable.setThickness(typedArray.getDimensionPixelSize(index, 0)); } else if (index == R.styleable.Ui_Widget_ProgressBar_uiRounded) { mDrawable.setRounded(typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_Widget_ProgressBar_uiIndeterminateSpeed) { mDrawable.setIndeterminateSpeed(typedArray.getFloat(index, 1)); } } } this.applyProgressTint(); this.applyIndeterminateTint(); this.applyProgressBackgroundTint(); }
From source file:com.facebook.litho.InternalNode.java
void applyAttributes(TypedArray a) { for (int i = 0, size = a.getIndexCount(); i < size; i++) { final int attr = a.getIndex(i); if (attr == R.styleable.ComponentLayout_android_layout_width) { int width = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (width >= 0) { widthPx(width);//from www .j a va 2 s. c o m } } else if (attr == R.styleable.ComponentLayout_android_layout_height) { int height = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (height >= 0) { heightPx(height); } } else if (attr == R.styleable.ComponentLayout_android_paddingLeft) { paddingPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingTop) { paddingPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingRight) { paddingPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingBottom) { paddingPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingStart && SUPPORTS_RTL) { paddingPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingEnd && SUPPORTS_RTL) { paddingPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_padding) { paddingPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginLeft) { marginPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginTop) { marginPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginRight) { marginPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginBottom) { marginPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginStart && SUPPORTS_RTL) { marginPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginEnd && SUPPORTS_RTL) { marginPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_margin) { marginPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_importantForAccessibility && SDK_INT >= JELLY_BEAN) { importantForAccessibility(a.getInt(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_duplicateParentState) { duplicateParentState(a.getBoolean(attr, false)); } else if (attr == R.styleable.ComponentLayout_android_background) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_background)) { backgroundColor(a.getColor(attr, 0)); } else { backgroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_foreground) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_foreground)) { foregroundColor(a.getColor(attr, 0)); } else { foregroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_contentDescription) { contentDescription(a.getString(attr)); } else if (attr == R.styleable.ComponentLayout_flex_direction) { flexDirection(YogaFlexDirection.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_wrap) { wrap(YogaWrap.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_justifyContent) { justifyContent(YogaJustify.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignItems) { alignItems(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignSelf) { alignSelf(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_positionType) { positionType(YogaPositionType.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex) { final float flex = a.getFloat(attr, -1); if (flex >= 0f) { flex(flex); } } else if (attr == R.styleable.ComponentLayout_flex_left) { positionPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_top) { positionPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_right) { positionPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_bottom) { positionPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_layoutDirection) { final int layoutDirection = a.getInteger(attr, -1); layoutDirection(YogaDirection.fromInt(layoutDirection)); } } }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java
protected void resetKeyboardTheme(@NonNull KeyboardTheme theme) { final int keyboardThemeStyleResId = getKeyboardStyleResId(theme); final int[] remoteKeyboardThemeStyleable = theme.getResourceMapping() .getRemoteStyleableArrayFromLocal(R.styleable.AnyKeyboardViewTheme); final int[] remoteKeyboardIconsThemeStyleable = theme.getResourceMapping() .getRemoteStyleableArrayFromLocal(R.styleable.AnyKeyboardViewIconsTheme); final int[] padding = new int[] { 0, 0, 0, 0 }; int keyTypeFunctionAttrId = R.attr.key_type_function; int keyActionAttrId = R.attr.key_type_action; int keyActionTypeDoneAttrId = R.attr.action_done; int keyActionTypeSearchAttrId = R.attr.action_search; int keyActionTypeGoAttrId = R.attr.action_go; HashSet<Integer> doneLocalAttributeIds = new HashSet<>(); TypedArray a = theme.getPackageContext().obtainStyledAttributes(keyboardThemeStyleResId, remoteKeyboardThemeStyleable); final int n = a.getIndexCount(); for (int i = 0; i < n; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = R.styleable.AnyKeyboardViewTheme[remoteIndex]; if (setValueFromTheme(a, padding, localAttrId, remoteIndex)) { doneLocalAttributeIds.add(localAttrId); if (localAttrId == R.attr.keyBackground) { //keyTypeFunctionAttrId and keyActionAttrId are remote final int[] keyStateAttributes = theme.getResourceMapping() .getRemoteStyleableArrayFromLocal(KEY_TYPES); keyTypeFunctionAttrId = keyStateAttributes[0]; keyActionAttrId = keyStateAttributes[1]; }//from w w w .ja v a 2s . c o m } } a.recycle(); // taking icons int iconSetStyleRes = getKeyboardIconsStyleResId(theme); if (iconSetStyleRes != 0) { a = theme.getPackageContext().obtainStyledAttributes(iconSetStyleRes, remoteKeyboardIconsThemeStyleable); final int iconsCount = a.getIndexCount(); for (int i = 0; i < iconsCount; i++) { final int remoteIndex = a.getIndex(i); final int localAttrId = R.styleable.AnyKeyboardViewIconsTheme[remoteIndex]; if (setKeyIconValueFromTheme(theme, a, localAttrId, remoteIndex)) { doneLocalAttributeIds.add(localAttrId); if (localAttrId == R.attr.iconKeyAction) { //keyActionTypeDoneAttrId and keyActionTypeSearchAttrId and keyActionTypeGoAttrId are remote final int[] keyStateAttributes = theme.getResourceMapping() .getRemoteStyleableArrayFromLocal(ACTION_KEY_TYPES); keyActionTypeDoneAttrId = keyStateAttributes[0]; keyActionTypeSearchAttrId = keyStateAttributes[1]; keyActionTypeGoAttrId = keyStateAttributes[2]; } } } a.recycle(); } // filling what's missing KeyboardTheme fallbackTheme = KeyboardThemeFactory.getFallbackTheme(getContext().getApplicationContext()); final int keyboardFallbackThemeStyleResId = getKeyboardStyleResId(fallbackTheme); a = fallbackTheme.getPackageContext().obtainStyledAttributes(keyboardFallbackThemeStyleResId, R.styleable.AnyKeyboardViewTheme); final int fallbackCount = a.getIndexCount(); for (int i = 0; i < fallbackCount; i++) { final int index = a.getIndex(i); final int attrId = R.styleable.AnyKeyboardViewTheme[index]; if (doneLocalAttributeIds.contains(attrId)) continue; setValueFromTheme(a, padding, attrId, index); } a.recycle(); // taking missing icons int fallbackIconSetStyleId = fallbackTheme.getIconsThemeResId(); a = fallbackTheme.getPackageContext().obtainStyledAttributes(fallbackIconSetStyleId, R.styleable.AnyKeyboardViewIconsTheme); final int fallbackIconsCount = a.getIndexCount(); for (int i = 0; i < fallbackIconsCount; i++) { final int index = a.getIndex(i); final int attrId = R.styleable.AnyKeyboardViewIconsTheme[index]; if (doneLocalAttributeIds.contains(attrId)) continue; setKeyIconValueFromTheme(fallbackTheme, a, attrId, index); } a.recycle(); //creating the key-drawable state provider, as we suppose to have the entire data now mDrawableStatesProvider = new KeyDrawableStateProvider(keyTypeFunctionAttrId, keyActionAttrId, keyActionTypeDoneAttrId, keyActionTypeSearchAttrId, keyActionTypeGoAttrId); // settings. // don't forget that there are THREE padding, // the theme's and the // background image's padding and the // View Drawable keyboardBackground = super.getBackground(); if (keyboardBackground != null) { Rect backgroundPadding = new Rect(); keyboardBackground.getPadding(backgroundPadding); padding[0] += backgroundPadding.left; padding[1] += backgroundPadding.top; padding[2] += backgroundPadding.right; padding[3] += backgroundPadding.bottom; } setPadding(padding[0], padding[1], padding[2], padding[3]); final Resources res = getResources(); final int viewWidth = (getWidth() > 0) ? getWidth() : res.getDisplayMetrics().widthPixels; mKeyboardDimens.setKeyboardMaxWidth(viewWidth - padding[0] - padding[2]); mPaint.setTextSize(mKeyTextSize); mKeyBackground.getPadding(mKeyBackgroundPadding); }
From source file:com.ruesga.timelinechart.TimelineChartView.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); if (!isInEditMode()) { mAudioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); }//from www . ja v a 2 s .c om final Resources res = getResources(); final Resources.Theme theme = ctx.getTheme(); mTickFormats = getResources().getStringArray(R.array.tlcDefTickLabelFormats); mTickLabels = getResources().getStringArray(R.array.tlcDefTickLabelValues); final DisplayMetrics dp = getResources().getDisplayMetrics(); mSize8 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8, dp); mSize12 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dp); mSize20 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, dp); final ViewConfiguration vc = ViewConfiguration.get(ctx); mLongPressTimeout = ViewConfiguration.getLongPressTimeout(); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int graphBgColor = ContextCompat.getColor(ctx, R.color.tlcDefGraphBackgroundColor); int footerBgColor = ContextCompat.getColor(ctx, R.color.tlcDefFooterBackgroundColor); mDefFooterBarHeight = mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mShowFooter = res.getBoolean(R.bool.tlcDefShowFooter); mGraphMode = res.getInteger(R.integer.tlcDefGraphMode); mPlaySelectionSoundEffect = res.getBoolean(R.bool.tlcDefPlaySelectionSoundEffect); mSelectionSoundEffectSource = res.getInteger(R.integer.tlcDefSelectionSoundEffectSource); mAnimateCursorTransition = res.getBoolean(R.bool.tlcDefAnimateCursorTransition); mFollowCursorPosition = res.getBoolean(R.bool.tlcDefFollowCursorPosition); mAlwaysEnsureSelection = res.getBoolean(R.bool.tlcDefAlwaysEnsureSelection); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(graphBgColor); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(footerBgColor); mTickLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mTickLabelFgPaint.setFakeBoldText(true); mTickLabelFgPaint.setColor(MaterialPaletteHelper.isDarkColor(footerBgColor) ? Color.LTGRAY : Color.DKGRAY); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.tlcTimelineChartView, defStyleAttr, defStyleRes); try { int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); if (attr == R.styleable.tlcTimelineChartView_tlcGraphBackground) { graphBgColor = a.getColor(attr, graphBgColor); mGraphAreaBgPaint.setColor(graphBgColor); } else if (attr == R.styleable.tlcTimelineChartView_tlcShowFooter) { mShowFooter = a.getBoolean(attr, mShowFooter); } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBackground) { footerBgColor = a.getColor(attr, footerBgColor); mFooterAreaBgPaint.setColor(footerBgColor); } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBarHeight) { mFooterBarHeight = a.getDimension(attr, mFooterBarHeight); } else if (attr == R.styleable.tlcTimelineChartView_tlcGraphMode) { mGraphMode = a.getInt(attr, mGraphMode); } else if (attr == R.styleable.tlcTimelineChartView_tlcAnimateCursorTransition) { mAnimateCursorTransition = a.getBoolean(attr, mAnimateCursorTransition); } else if (attr == R.styleable.tlcTimelineChartView_tlcFollowCursorPosition) { mFollowCursorPosition = a.getBoolean(attr, mFollowCursorPosition); } else if (attr == R.styleable.tlcTimelineChartView_tlcAlwaysEnsureSelection) { mAlwaysEnsureSelection = a.getBoolean(attr, mAlwaysEnsureSelection); } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemWidth) { mBarItemWidth = a.getDimension(attr, mBarItemWidth); } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemSpace) { mBarItemSpace = a.getDimension(attr, mBarItemSpace); } else if (attr == R.styleable.tlcTimelineChartView_tlcPlaySelectionSoundEffect) { mPlaySelectionSoundEffect = a.getBoolean(attr, mPlaySelectionSoundEffect); } else if (attr == R.styleable.tlcTimelineChartView_tlcSelectionSoundEffectSource) { mSelectionSoundEffectSource = a.getInt(attr, mSelectionSoundEffectSource); } } } finally { a.recycle(); } // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(ctx, android.R.color.transparent)); } // Minimize the impact of create dynamic layouts by assume that in most case // we will have a day formatter mTickHasDayFormat = true; // Initialize stuff setupBackgroundHandler(); setupTickLabels(); if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) { setupEdgeEffects(); } setupAnimators(); setupSoundEffects(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); // Create a fake data for the edit mode if (isInEditMode()) { setupViewInEditMode(); } }
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.Dialog.java
public Dialog applyStyle(int resId) { Context context = getContext(); TypedArray a = context.obtainStyledAttributes(resId, R.styleable.Dialog); int layout_width = mLayoutWidth; int layout_height = mLayoutHeight; boolean layoutParamsDefined = false; int titleTextAppearance = 0; int titleTextColor = 0; boolean titleTextColorDefined = false; int actionBackground = 0; int actionRipple = 0; int actionTextAppearance = 0; ColorStateList actionTextColors = null; int positiveActionBackground = 0; int positiveActionRipple = 0; int positiveActionTextAppearance = 0; ColorStateList positiveActionTextColors = null; int negativeActionBackground = 0; int negativeActionRipple = 0; int negativeActionTextAppearance = 0; ColorStateList negativeActionTextColors = null; int neutralActionBackground = 0; int neutralActionRipple = 0; int neutralActionTextAppearance = 0; ColorStateList neutralActionTextColors = null; for (int i = 0, count = a.getIndexCount(); i < count; i++) { int attr = a.getIndex(i); if (attr == R.styleable.Dialog_android_layout_width) { layout_width = a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParamsDefined = true;/*from w w w . j a v a 2s.c om*/ } else if (attr == R.styleable.Dialog_android_layout_height) { layout_height = a.getLayoutDimension(attr, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParamsDefined = true; } else if (attr == R.styleable.Dialog_di_maxWidth) maxWidth(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_maxHeight) maxHeight(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_dimAmount) dimAmount(a.getFloat(attr, 0)); else if (attr == R.styleable.Dialog_di_backgroundColor) backgroundColor(a.getColor(attr, 0)); else if (attr == R.styleable.Dialog_di_maxElevation) maxElevation(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_elevation) elevation(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_cornerRadius) cornerRadius(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_layoutDirection) layoutDirection(a.getInteger(attr, 0)); else if (attr == R.styleable.Dialog_di_titleTextAppearance) titleTextAppearance = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_titleTextColor) { titleTextColor = a.getColor(attr, 0); titleTextColorDefined = true; } else if (attr == R.styleable.Dialog_di_actionBackground) actionBackground = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_actionRipple) actionRipple = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_actionTextAppearance) actionTextAppearance = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_actionTextColor) actionTextColors = a.getColorStateList(attr); else if (attr == R.styleable.Dialog_di_positiveActionBackground) positiveActionBackground = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_positiveActionRipple) positiveActionRipple = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_positiveActionTextAppearance) positiveActionTextAppearance = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_positiveActionTextColor) positiveActionTextColors = a.getColorStateList(attr); else if (attr == R.styleable.Dialog_di_negativeActionBackground) negativeActionBackground = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_negativeActionRipple) negativeActionRipple = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_negativeActionTextAppearance) negativeActionTextAppearance = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_negativeActionTextColor) negativeActionTextColors = a.getColorStateList(attr); else if (attr == R.styleable.Dialog_di_neutralActionBackground) neutralActionBackground = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_neutralActionRipple) neutralActionRipple = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_neutralActionTextAppearance) neutralActionTextAppearance = a.getResourceId(attr, 0); else if (attr == R.styleable.Dialog_di_neutralActionTextColor) neutralActionTextColors = a.getColorStateList(attr); else if (attr == R.styleable.Dialog_di_inAnimation) inAnimation(a.getResourceId(attr, 0)); else if (attr == R.styleable.Dialog_di_outAnimation) outAnimation(a.getResourceId(attr, 0)); else if (attr == R.styleable.Dialog_di_dividerColor) dividerColor(a.getColor(attr, 0)); else if (attr == R.styleable.Dialog_di_dividerHeight) dividerHeight(a.getDimensionPixelOffset(attr, 0)); else if (attr == R.styleable.Dialog_di_cancelable) cancelable(a.getBoolean(attr, true)); else if (attr == R.styleable.Dialog_di_canceledOnTouchOutside) canceledOnTouchOutside(a.getBoolean(attr, true)); } a.recycle(); if (layoutParamsDefined) layoutParams(layout_width, layout_height); if (titleTextAppearance != 0) titleTextAppearance(titleTextAppearance); if (titleTextColorDefined) titleColor(titleTextColor); if (actionBackground != 0) actionBackground(actionBackground); if (actionRipple != 0) actionRipple(actionRipple); if (actionTextAppearance != 0) actionTextAppearance(actionTextAppearance); if (actionTextColors != null) actionTextColor(actionTextColors); if (positiveActionBackground != 0) positiveActionBackground(positiveActionBackground); if (positiveActionRipple != 0) positiveActionRipple(positiveActionRipple); if (positiveActionTextAppearance != 0) positiveActionTextAppearance(positiveActionTextAppearance); if (positiveActionTextColors != null) positiveActionTextColor(positiveActionTextColors); if (negativeActionBackground != 0) negativeActionBackground(negativeActionBackground); if (negativeActionRipple != 0) negativeActionRipple(negativeActionRipple); if (negativeActionTextAppearance != 0) negativeActionTextAppearance(negativeActionTextAppearance); if (negativeActionTextColors != null) negativeActionTextColor(negativeActionTextColors); if (neutralActionBackground != 0) neutralActionBackground(neutralActionBackground); if (neutralActionRipple != 0) neutralActionRipple(neutralActionRipple); if (neutralActionTextAppearance != 0) neutralActionTextAppearance(neutralActionTextAppearance); if (neutralActionTextColors != null) neutralActionTextColor(neutralActionTextColors); return this; }