List of usage examples for android.content.res TypedArray getIndex
public int getIndex(int at)
From source file:com.steve.wanqureader.presentation.ui.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 ww w . j ava2 s. c o m*/ 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); } } } finally { a.recycle(); } }
From source file:com.albedinsky.android.ui.widget.ViewPagerWidget.java
/** * Called from one of constructors of this view to perform its initialization. * <p>//from w w w . j a v a2 s . com * 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>. */ private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this.ensureDecorator(); mDecorator.processAttributes(context, attrs, defStyleAttr, defStyleRes); final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ViewPager, defStyleAttr, defStyleRes); if (typedArray != null) { final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_ViewPager_android_background) { int resID = typedArray.getResourceId(index, -1); if (resID != -1) { setBackgroundResource(resID); } else { setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT)); } } else if (index == R.styleable.Ui_ViewPager_uiPageMargin) { setPageMargin(typedArray.getDimensionPixelSize(index, 0)); } else if (index == R.styleable.Ui_ViewPager_uiPageMarginDrawable) { setPageMarginDrawable(typedArray.getDrawable(index)); } else if (index == R.styleable.Ui_ViewPager_uiPageSwipingEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true)); } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingSensitivity) { this.mPageFlingSwipingSensitivity = Math.max(0, typedArray.getFloat(index, mPageFlingSwipingSensitivity)); } else if (index == R.styleable.Ui_ViewPager_uiCurrentPage) { this.mCurrentPage = typedArray.getInteger(index, 0); } else if (index == R.styleable.Ui_ViewPager_uiOffScreenPageLimit) { setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit())); } else if (index == R.styleable.Ui_ViewPager_uiPageScrollDuration) { this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration); } else if (index == R.styleable.Ui_ViewPager_uiPageScrollRelativeDurationEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_ViewPager_uiPullEnabled) { setPullEnabled(typedArray.getBoolean(index, false)); } } typedArray.recycle(); } // Override default scroller so we can use custom durations for scroll if requested. setScroller(new WidgetScroller(context, SCROLLER_INTERPOLATOR)); }
From source file:com.canyinghao.canrefresh.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 a v a 2s . c om*/ 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); } } } finally { a.recycle(); } }
From source file:com.albedinsky.android.support.ui.widget.ViewPagerWidget.java
/** * Creates a new instance of ViewPagerWidget 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. *//*from w w w . j a v a 2 s .co m*/ public ViewPagerWidget(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs); /** * Process attributes. */ final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_Widget_ViewPager, defStyleAttr, 0); if (typedArray != null) { this.ensurePullController(); mPullController.setUpFromAttrs(context, attrs, defStyleAttr); final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_Widget_ViewPager_android_background) { int resID = typedArray.getResourceId(index, -1); if (resID != -1) { setBackgroundResource(resID); } else { setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT)); } } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageMargin) { setPageMargin(typedArray.getDimensionPixelSize(index, 0)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageMarginDrawable) { setPageMarginDrawable(typedArray.getDrawable(index)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageSwipingEnabled) { updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageFlingSwipingEnabled) { updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageFlingSwipingSensitivity) { this.mPageFlingSwipingSensitivity = Math.max(0, typedArray.getFloat(index, mPageFlingSwipingSensitivity)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiCurrentPage) { this.mCurrentPage = typedArray.getInteger(index, 0); } else if (index == R.styleable.Ui_Widget_ViewPager_uiOffScreenPageLimit) { setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit())); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageScrollDuration) { this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPageScrollRelativeDurationEnabled) { updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_Widget_ViewPager_uiPullEnabled) { setPullEnabled(typedArray.getBoolean(index, false)); } } } // Override default scroller so we can use custom durations for scroll if requested. this.mScroller = new WidgetScroller(context, SCROLLER_INTERPOLATOR); }
From source file:com.wit.and.dialog.LoginDialog.java
/** * /* ww w. ja v a2 s . c o m*/ */ @Override protected void onStyleDialog(View dialogView, TypedArray parsedArray) { final Context context = getActivity(); final int loginDialogStyle = parsedArray.getResourceId(R.styleable.And_Theme_Dialog_loginDialogStyle, R.style.And_Dialog_LoginDialog); final TypedArray dialogArray = context.obtainStyledAttributes(loginDialogStyle, R.styleable.And_Theme_Dialog_LoginDialog); if (dialogArray != null) { final int n = dialogArray.getIndexCount(); for (int i = 0; i < n; i++) { int attr = dialogArray.getIndex(i); /** * Obtain login dialog sub-dialog style. */ if (attr == R.styleable.And_Theme_Dialog_LoginDialog_dialogStyle) { /** * Let super to process login dialog sub-dialog style. */ super.onStyleDialog(dialogView, dialogArray.getResourceId(attr, R.style.And_Dialog_Dialog)); } // Set up login dialog edit texts divider style. else if (attr == R.styleable.And_Theme_Dialog_LoginDialog_dialogDividerStyle) { final DialogDivider divider = (DialogDivider) findViewByID( R.id.And_Dialog_Divider_LoginDialog_EditTexts); if (divider != null) { DIVIDER_STYLER.performStyling( dialogArray.getResourceId(attr, R.style.And_Dialog_Divider_EditText), divider); // Remove any custom orientation, only horizontal divider is allowed. divider.setOrientation(DialogDivider.HORIZONTAL); } } /** * Set up login dialog edit style. */ else if (attr == R.styleable.And_Theme_Dialog_LoginDialog_android_editTextStyle) { final int editStyle = dialogArray.getResourceId(attr, R.style.And_Dialog_EditText); EDIT_STYLER.performStyling(editStyle, mUsername); EDIT_STYLER.performStyling(editStyle, mPassword); } /** * Set up empty circle progress bar style. */ else if (attr == R.styleable.And_Theme_Dialog_LoginDialog_android_progressBarStyle) { final ProgressBar progressBar = (ProgressBar) findViewByID(R.id.And_Dialog_ProgressBar); if (progressBar != null) { PROGRESS_STYLER.performStyling( dialogArray.getResourceId(attr, R.style.And_Dialog_ProgressBar), progressBar); } } } dialogArray.recycle(); } /** * Set type face to text views. */ Typeface typeface = obtainTypeface(loginDialogStyle); if (typeface != null) { applyTypeface(typeface, mUsername); applyTypeface(typeface, mPassword); } }
From source file:org.xbmc.kore.ui.NavigationDrawerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w ww. j a v a2 s .c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { DrawerItem item = (DrawerItem) parent.getItemAtPosition(position); selectItem(item, position); } }); Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.iconHosts, R.attr.iconRemote, R.attr.iconMovies, R.attr.iconTvShows, R.attr.iconMusic, R.attr.iconPVR, R.attr.iconFiles, R.attr.iconAddons, R.attr.iconSettings, }); HostInfo hostInfo = HostManager.getInstance(getActivity()).getHostInfo(); String hostName = (hostInfo != null) ? hostInfo.getName() : getString(R.string.xbmc_media_center); int hostId = (hostInfo != null) ? hostInfo.getId() : 0; Set<String> shownItems = PreferenceManager.getDefaultSharedPreferences(getActivity()).getStringSet( Settings.getNavDrawerItemsPrefKey(hostId), new HashSet<>(Arrays.asList(getResources().getStringArray(R.array.entry_values_nav_drawer_items)))); ArrayList<DrawerItem> items = new ArrayList<>(15); items.add(new DrawerItem(DrawerItem.TYPE_HOST, ACTIVITY_HOSTS, hostName, styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_HOSTS), 0))); items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_REMOTE, getString(R.string.remote), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_REMOTE), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_MOVIES))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MOVIES, getString(R.string.movies), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MOVIES), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_TVSHOWS))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_TVSHOWS, getString(R.string.tv_shows), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_TVSHOWS), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_MUSIC))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MUSIC, getString(R.string.music), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MUSIC), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_PVR))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_PVR, getString(R.string.pvr), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_PVR), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_FILES))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_FILES, getString(R.string.files), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_FILES), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_ADDONS))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_ADDONS, getString(R.string.addons), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_ADDONS), 0))); items.add(new DrawerItem()); // Divider items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_SETTINGS, getString(R.string.settings), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_SETTINGS), 0))); styledAttributes.recycle(); mDrawerListView.setAdapter(new DrawerItemAdapter(getActivity(), R.layout.list_item_navigation_drawer, items.toArray(new DrawerItem[items.size()]))); return mDrawerListView; }
From source file:org.xbmc.kore.ui.generic.NavigationDrawerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from w w w.j av a 2 s . c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { DrawerItem item = (DrawerItem) parent.getItemAtPosition(position); selectItem(item, position); } }); Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.iconHosts, R.attr.iconRemote, R.attr.iconMovies, R.attr.iconTvShows, R.attr.iconMusic, R.attr.iconPVR, R.attr.iconFiles, R.attr.iconAddons, R.attr.iconSettings, R.attr.iconFavourites }); HostInfo hostInfo = HostManager.getInstance(getActivity()).getHostInfo(); String hostName = (hostInfo != null) ? hostInfo.getName() : getString(R.string.xbmc_media_center); int hostId = (hostInfo != null) ? hostInfo.getId() : 0; Set<String> shownItems = PreferenceManager.getDefaultSharedPreferences(getActivity()).getStringSet( Settings.getNavDrawerItemsPrefKey(hostId), new HashSet<>(Arrays.asList(getResources().getStringArray(R.array.entry_values_nav_drawer_items)))); ArrayList<DrawerItem> items = new ArrayList<>(15); items.add(new DrawerItem(DrawerItem.TYPE_HOST, ACTIVITY_HOSTS, hostName, styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_HOSTS), 0))); items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_REMOTE, getString(R.string.remote), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_REMOTE), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_MOVIES))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MOVIES, getString(R.string.movies), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MOVIES), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_TVSHOWS))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_TVSHOWS, getString(R.string.tv_shows), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_TVSHOWS), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_MUSIC))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_MUSIC, getString(R.string.music), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_MUSIC), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_PVR))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_PVR, getString(R.string.pvr), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_PVR), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_FAVOURITES))) items.add( new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_FAVOURITES, getString(R.string.favourites), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_FAVOURITES), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_FILES))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_FILES, getString(R.string.files), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_FILES), 0))); if (shownItems.contains(String.valueOf(ACTIVITY_ADDONS))) items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_ADDONS, getString(R.string.addons), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_ADDONS), 0))); items.add(new DrawerItem()); // Divider items.add(new DrawerItem(DrawerItem.TYPE_NORMAL_ITEM, ACTIVITY_SETTINGS, getString(R.string.settings), styledAttributes.getResourceId(styledAttributes.getIndex(ACTIVITY_SETTINGS), 0))); styledAttributes.recycle(); mDrawerListView.setAdapter(new DrawerItemAdapter(getActivity(), R.layout.list_item_navigation_drawer, items.toArray(new DrawerItem[items.size()]))); return mDrawerListView; }
From source file:com.albedinsky.android.ui.widget.SearchView.java
/** * Called from one of constructors of this view to perform its initialization. * <p>/* w w w . j av a 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>. */ @SuppressWarnings("ResourceType") private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this.mContext = context; setOrientation(HORIZONTAL); setGravity(Gravity.CENTER_VERTICAL); this.inflateHierarchy(context, R.layout.ui_search_view); this.mProgressBarAnimator = createProgressBarAnimator(); this.mDefaultRevealAnimationHandler = createRevealAnimationHandler(); ColorStateList tintList = null; PorterDuff.Mode tintMode = PorterDuff.Mode.SRC_IN; /** * Process attributes. */ final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_SearchView, defStyleAttr, defStyleRes); if (typedArray != null) { final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_SearchView_android_queryHint) { setQueryHint(typedArray.getText(index)); } else if (index == R.styleable.Ui_SearchView_uiTint) { tintList = typedArray.getColorStateList(index); } else if (index == R.styleable.Ui_SearchView_uiTintMode) { tintMode = TintManager.parseTintMode(typedArray.getInt(R.styleable.Ui_SearchView_uiTintMode, 0), tintList != null ? PorterDuff.Mode.SRC_IN : null); } else if (index == R.styleable.Ui_SearchView_uiRevealDuration) { mDefaultRevealAnimationHandler.revealDuration = typedArray.getInt(index, 0); } else if (index == R.styleable.Ui_SearchView_uiConcealDuration) { mDefaultRevealAnimationHandler.concealDuration = typedArray.getInt(index, 0); } else if (index == R.styleable.Ui_SearchView_uiRevealInterpolator) { final int resId = typedArray.getResourceId(index, 0); if (resId != 0) { mDefaultRevealAnimationHandler.interpolator = AnimationUtils.loadInterpolator(context, resId); } } } typedArray.recycle(); } if (tintList != null || tintMode != null) { this.mTintInfo = new SearchTintInfo(); this.mTintInfo.tintList = tintList; this.mTintInfo.hasTintList = tintList != null; this.mTintInfo.tintMode = tintMode; this.mTintInfo.hasTintMode = tintMode != null; } final Resources.Theme theme = context.getTheme(); final TypedValue typedValue = new TypedValue(); if (theme.resolveAttribute(R.attr.uiSearchSelectHandleColor, typedValue, true)) { if (mTintInfo == null) { this.mTintInfo = new SearchTintInfo(); } if (typedValue.resourceId > 0) { mTintInfo.textSelectHandleTintList = ResourceUtils.getColorStateList(getResources(), typedValue.resourceId, theme); } else { mTintInfo.textSelectHandleTintList = ColorStateList.valueOf(typedValue.data); } mTintInfo.hasTextSelectHandleTintList = mTintInfo.textSelectHandleTintList != null; } this.applyTint(); this.mRevealAnimationHandler = mDefaultRevealAnimationHandler; }
From source file:org.kde.necessitas.ministro.ExtractStyle.java
public void extractViewInformations(String styleName, int styleId, JSONObject json, String qtClassName, AttributeSet attribSet) { try {// w ww. j a v a 2 s . co m int[] viewAttrs; viewAttrs = (int[]) styleableClass.getDeclaredField("View").get(null); TypedArray a = m_theme.obtainStyledAttributes(attribSet, viewAttrs, styleId, 0); if (null != qtClassName) json.put("qtClass", qtClassName); final int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == View_background) json.put("View_background", getDrawable(a.getDrawable(attr), styleName + "_View_background")); else if (attr == View_padding) json.put("View_padding", a.getDimensionPixelSize(attr, -1)); else if (attr == View_paddingLeft) json.put("View_paddingLeft", a.getDimensionPixelSize(attr, -1)); else if (attr == View_paddingTop) json.put("View_paddingTop", a.getDimensionPixelSize(attr, -1)); else if (attr == View_paddingRight) json.put("View_paddingRight", a.getDimensionPixelSize(attr, -1)); else if (attr == View_paddingBottom) json.put("View_paddingBottom", a.getDimensionPixelSize(attr, -1)); else if (attr == View_scrollX) json.put("View_paddingBottom", a.getDimensionPixelOffset(attr, 0)); else if (attr == View_scrollY) json.put("View_scrollY", a.getDimensionPixelOffset(attr, 0)); else if (attr == View_id) json.put("View_id", a.getResourceId(attr, -1)); else if (attr == View_tag) json.put("View_tag", a.getText(attr)); else if (attr == View_fitsSystemWindows) json.put("View_fitsSystemWindows", a.getBoolean(attr, false)); else if (attr == View_focusable) json.put("View_focusable", a.getBoolean(attr, false)); else if (attr == View_focusableInTouchMode) json.put("View_focusableInTouchMode", a.getBoolean(attr, false)); else if (attr == View_clickable) json.put("View_clickable", a.getBoolean(attr, false)); else if (attr == View_longClickable) json.put("View_longClickable", a.getBoolean(attr, false)); else if (attr == View_saveEnabled) json.put("View_saveEnabled", a.getBoolean(attr, true)); else if (attr == View_duplicateParentState) json.put("View_duplicateParentState", a.getBoolean(attr, false)); else if (attr == View_visibility) json.put("View_visibility", a.getInt(attr, 0)); else if (attr == View_drawingCacheQuality) json.put("View_drawingCacheQuality", a.getInt(attr, 0)); else if (attr == View_drawingCacheQuality) json.put("View_contentDescription", a.getString(attr)); else if (attr == View_soundEffectsEnabled) json.put("View_soundEffectsEnabled", a.getBoolean(attr, true)); else if (attr == View_hapticFeedbackEnabled) json.put("View_hapticFeedbackEnabled", a.getBoolean(attr, true)); else if (attr == View_scrollbars) json.put("View_scrollbars", a.getInt(attr, 0)); else if (attr == View_fadingEdge) json.put("View_fadingEdge", a.getInt(attr, 0)); else if (attr == View_scrollbarStyle) json.put("View_scrollbarStyle", a.getInt(attr, 0)); else if (attr == View_isScrollContainer) json.put("View_isScrollContainer", a.getBoolean(attr, false)); else if (attr == View_keepScreenOn) json.put("View_keepScreenOn", a.getBoolean(attr, false)); else if (attr == View_filterTouchesWhenObscured) json.put("View_filterTouchesWhenObscured", a.getBoolean(attr, false)); else if (attr == View_nextFocusLeft) json.put("View_nextFocusLeft", a.getResourceId(attr, -1)); else if (attr == View_nextFocusRight) json.put("View_nextFocusRight", a.getResourceId(attr, -1)); else if (attr == View_nextFocusUp) json.put("View_nextFocusUp", a.getResourceId(attr, -1)); else if (attr == View_nextFocusDown) json.put("View_nextFocusDown", a.getResourceId(attr, -1)); else if (attr == View_minWidth) json.put("View_minWidth", a.getDimensionPixelSize(attr, 0)); else if (attr == View_minHeight) json.put("View_minHeight", a.getDimensionPixelSize(attr, 0)); else if (attr == View_onClick) json.put("View_onClick", a.getString(attr)); else if (attr == View_overScrollMode) json.put("View_overScrollMode", a.getInt(attr, 1)); } a.recycle(); } catch (Exception e) { e.printStackTrace(); } }
From source file:am.widget.indicatortabstrip.IndicatorTabStrip.java
public IndicatorTabStrip(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setItemClickable(true);/*from w w w. j a v a2s. co m*/ setClickSmoothScroll(true); final float density = getResources().getDisplayMetrics().density; mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextAlign(Align.CENTER); if (Build.VERSION.SDK_INT > 4) { updateTextPaintDensity(); } mTagLocation = new TagLocation(TagLocation.LOCATION_EDGE); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); int n = a.getIndexCount(); int textSize = (int) (DEFAULT_TEXT_SIZE * density); ColorStateList textColors = null; Drawable divider = null; for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case 0: textSize = a.getDimensionPixelSize(attr, textSize); break; case 1: textColors = a.getColorStateList(attr); break; case 2: divider = a.getDrawable(attr); break; } } a.recycle(); float scale = 1; Drawable itemBackground = null; ColorStateList gradient = null; Drawable indicator = null; int indicatorWidthMode = INDICATOR_WIDTH_MODE_SET; int indicatorPadding = 0; int indicatorWidth = INDICATOR_WIDTH_BY_DRAWABLE; int indicatorHeight = INDICATOR_HEIGHT_BY_DRAWABLE; Drawable interval = null; int minItemWidth = (int) (DEFAULT_ITEM_WIDTH * density); int minItemHeight = (int) (DEFAULT_ITEM_HEIGHT * density); int tagTextSize = (int) (DEFAULT_TAG_TEXT_SIZE * density); int tagTextColor = DEFAULT_TAG_TEXT_COLOR; Drawable tagBackground = getDefaultTagBackground(); int tagMinSizeMode = TAG_MIN_SIZE_MODE_HAS_TEXT; int tagMinWidth = (int) (DEFAULT_TAG_MIN_SIZE * density); int tagMinHeight = (int) (DEFAULT_TAG_MIN_SIZE * density); int tagPaddingLeft = 0; int tagPaddingTop = 0; int tagPaddingRight = 0; int tagPaddingBottom = 0; int tagMarginLeft = 0; int tagMarginTop = 0; int tagMarginRight = 0; int tagMarginBottom = 0; TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.IndicatorTabStrip); textSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTextSize, textSize); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTextColor)) textColors = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsTextColor); scale = custom.getFloat(R.styleable.IndicatorTabStrip_ttsTextScale, scale); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsBackground)) itemBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsBackground); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsGradient)) gradient = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsGradient); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsDivider)) divider = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsDivider); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsIndicator)) indicator = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsIndicator); indicatorWidthMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsIndicatorWidthMode, indicatorWidthMode); indicatorPadding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorPadding, indicatorPadding); indicatorWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorWidth, indicatorWidth); indicatorHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorHeight, indicatorHeight); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsInterval)) interval = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsInterval); minItemWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemWidth, minItemWidth); minItemHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemHeight, minItemHeight); tagTextSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTagTextSize, tagTextSize); tagTextColor = custom.getColor(R.styleable.IndicatorTabStrip_ttsTagTextColor, tagTextColor); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagBackground)) tagBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsTagBackground); tagMinSizeMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsTagMinSizeMode, tagMinSizeMode); tagMinWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinWidth, tagMinWidth); tagMinHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinHeight, tagMinHeight); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagPadding)) { final int padding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPadding, 0); tagPaddingLeft = padding; tagPaddingTop = padding; tagPaddingRight = padding; tagPaddingBottom = padding; } tagPaddingLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingLeft, tagPaddingLeft); tagPaddingTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingTop, tagPaddingTop); tagPaddingRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingRight, tagPaddingRight); tagPaddingBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingBottom, tagPaddingBottom); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagMargin)) { final int margin = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMargin, 0); tagMarginLeft = margin; tagMarginTop = margin; tagMarginRight = margin; tagMarginBottom = margin; } tagMarginLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginLeft, tagMarginLeft); tagMarginTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginTop, tagMarginTop); tagMarginRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginRight, tagMarginRight); tagMarginBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginBottom, tagMarginBottom); custom.recycle(); setTextSize(textSize); if (textColors != null) { setTextColor(textColors); } else { setTextColor(DEFAULT_TEXT_COLOR); } setTextScale(scale); setItemBackground(itemBackground); setGradient(gradient); setDivider(divider); setIndicator(indicator); setIndicatorWidthMode(indicatorWidthMode); setIndicatorPadding(indicatorPadding); setIndicatorWidth(indicatorWidth); setIndicatorHeight(indicatorHeight); setInterval(interval); setMinItemWidth(minItemWidth); setMinItemHeight(minItemHeight); setTagTextSize(tagTextSize); setTagTextColor(tagTextColor); setTagBackground(tagBackground); setTagMinSizeMode(tagMinSizeMode); setTagMinWidth(tagMinWidth); setTagMinHeight(tagMinHeight); setTagPadding(tagPaddingLeft, tagPaddingTop, tagPaddingRight, tagPaddingBottom); setTagMargin(tagMarginLeft, tagMarginTop, tagMarginRight, tagMarginBottom); }