List of usage examples for android.content.res Resources getInteger
public int getInteger(@IntegerRes int id) throws NotFoundException
From source file:com.android.mail.ui.ConversationListFragment.java
@Override public void onCreate(Bundle savedState) { super.onCreate(savedState); // Initialize fragment constants from resources final Resources res = getResources(); TIMESTAMP_UPDATE_INTERVAL = res.getInteger(R.integer.timestamp_update_interval); LOADING_DELAY_MS = res.getInteger(R.integer.conversationview_show_loading_delay); MINIMUM_LOADING_DURATION = res.getInteger(R.integer.conversationview_min_show_loading); mUpdateTimestampsRunnable = new Runnable() { @Override/*from w w w. j a v a 2s .c o m*/ public void run() { mListView.invalidateViews(); mHandler.postDelayed(mUpdateTimestampsRunnable, TIMESTAMP_UPDATE_INTERVAL); } }; // Get the context from the arguments final Bundle args = getArguments(); mViewContext = ConversationListContext.forBundle(args.getBundle(CONVERSATION_LIST_KEY)); mAccount = mViewContext.account; setRetainInstance(false); }
From source file:android.hqs.view.pager.indicator.TitlePageIndicator.java
/** * ?//from ww w. j a va 2 s.co m * @param context * @param attrs * @param defStyle */ @SuppressWarnings("deprecation") public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return; //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight); mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mLinePosition = LinePosition .fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition)); mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_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); }
From source file:cc.flydev.launcher.Folder.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attribtues set containing the Workspace's customization values. */// w w w. j a v a2s .co m public Folder(Context context, AttributeSet attrs) { super(context, attrs); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); setAlwaysDrawnWithCacheEnabled(false); mInflater = LayoutInflater.from(context); mIconCache = app.getIconCache(); Resources res = getResources(); mMaxCountX = (int) grid.numColumns; mMaxCountY = (int) grid.numRows; mMaxNumItems = mMaxCountX * mMaxCountY; mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration); if (sDefaultFolderName == null) { sDefaultFolderName = res.getString(R.string.folder_name); } if (sHintText == null) { sHintText = res.getString(R.string.folder_hint_text); } mLauncher = (Launcher) context; // We need this view to be focusable in touch mode so that when text editing of the folder // name is complete, we have something to focus on, thus hiding the cursor and giving // reliable behvior when clicking the text field (since it will always gain focus on click). setFocusableInTouchMode(true); }
From source file:com.bullmobi.message.ui.fragments.EasyNotificationFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime); mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis); ViewConfiguration vc = ViewConfiguration.get(getActivity()); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); // Clock widget mClockWidget = new ClockWidget(this, this); // Media widget mMediaController = MediaController2.newInstance(getActivity()); mMediaWidget = new MediaWidget(this, this); // Transitions if (Device.hasKitKatApi()) { mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade()).addTransition(new ChangeBounds()); mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT).setDuration(200)) .addTransition(new Fade(Fade.IN).setStartDelay(80)) .addTransition(new ChangeBounds().setStartDelay(80)); }/*from ww w .j a v a 2 s . co m*/ // Timeout mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout(); }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime); mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis); ViewConfiguration vc = ViewConfiguration.get(getActivity()); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); // Clock widget mClockWidget = getConfig().isCustomWidgetEnabled() ? new HostWidget(this, this) : new ClockWidget(this, this); // Media widget mMediaController = MediaController2.newInstance(getActivity()).asyncWrap(); mMediaWidget = new MediaWidget(this, this); // Transitions if (Device.hasKitKatApi()) { mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade()).addTransition(new ChangeBounds()); mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT).setDuration(200)) .addTransition(new Fade(Fade.IN).setStartDelay(80)) .addTransition(new ChangeBounds().setStartDelay(80)); }// w ww. j a v a 2 s . c om // Timeout mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout(); }
From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java
private void updateMediasPreview() { final int count = mMediaPreviewAdapter.getCount(); final Resources res = getResources(); final int maxColumns = res.getInteger(R.integer.grid_column_image_preview); mMediasPreviewGrid.setNumColumns(MathUtils.clamp(count, maxColumns, 1)); }
From source file:com.android.tv.menu.MenuLayoutManager.java
public MenuLayoutManager(Context context, MenuView menuView) { mMenuView = menuView;//from ww w. java 2s .c o m // Load dimensions Resources res = context.getResources(); mRowAlignFromBottom = res.getDimensionPixelOffset(R.dimen.menu_row_align_from_bottom); mRowContentsPaddingTop = res.getDimensionPixelOffset(R.dimen.menu_row_contents_padding_top); mRowContentsPaddingBottomMax = res.getDimensionPixelOffset(R.dimen.menu_row_contents_padding_bottom_max); mRowTitleTextDescenderHeight = res.getDimensionPixelOffset(R.dimen.menu_row_title_text_descender_height); mMenuMarginBottomMin = res.getDimensionPixelOffset(R.dimen.menu_margin_bottom_min); mRowTitleHeight = res.getDimensionPixelSize(R.dimen.menu_row_title_height); mRowScrollUpAnimationOffset = res.getDimensionPixelOffset(R.dimen.menu_row_scroll_up_anim_offset); mRowAnimationDuration = res.getInteger(R.integer.menu_row_selection_anim_duration); mOldContentsFadeOutDuration = res.getInteger(R.integer.menu_previous_contents_fade_out_duration); mCurrentContentsFadeInDuration = res.getInteger(R.integer.menu_current_contents_fade_in_duration); }
From source file:com.aidy.launcher3.ui.folder.Folder.java
/** * Used to inflate the Workspace from XML. * //w w w . j a va 2 s.c o m * @param context * The application's context. * @param attrs * The attribtues set containing the Workspace's customization * values. */ public Folder(Context context, AttributeSet attrs) { super(context, attrs); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); setAlwaysDrawnWithCacheEnabled(false); mInflater = LayoutInflater.from(context); mIconCache = app.getIconCache(); Resources res = getResources(); mMaxCountX = (int) grid.numColumns; mMaxCountY = (int) grid.numRows; mMaxNumItems = mMaxCountX * mMaxCountY; mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration); if (sDefaultFolderName == null) { sDefaultFolderName = res.getString(R.string.folder_name); } if (sHintText == null) { sHintText = res.getString(R.string.folder_hint_text); } mLauncher = (Launcher) context; // We need this view to be focusable in touch mode so that when text // editing of the folder // name is complete, we have something to focus on, thus hiding the // cursor and giving // reliable behvior when clicking the text field (since it will always // gain focus on click). setFocusableInTouchMode(true); }
From source file:com.tct.mail.ui.AnimatedAdapter.java
public AnimatedAdapter(Context context, ConversationCursor cursor, ConversationSelectionSet batch, ControllableActivity activity, SwipeableListView listView, final List<ConversationSpecialItemView> specialViews) { super(context, -1, cursor, UIProvider.CONVERSATION_PROJECTION, null, 0); mContext = context;/*w w w . ja v a 2 s .co m*/ mBatchConversations = batch; setAccount(mAccountListener.initialize(activity.getAccountController())); mActivity = activity; mShowFooter = false; mListView = listView; /// M: add search params @{ ActivityController controller = (ActivityController) mActivity.getAccountController(); mListContext = controller.getCurrentListContext(); /// @} mSendersImagesCache = mActivity.getSenderImageCache(); mContactResolver = mActivity.getContactResolver(mContext.getContentResolver(), mSendersImagesCache); mHandler = new Handler(); if (sDismissAllShortDelay == -1) { final Resources r = context.getResources(); sDismissAllShortDelay = r.getInteger(R.integer.dismiss_all_leavebehinds_short_delay); sDismissAllLongDelay = r.getInteger(R.integer.dismiss_all_leavebehinds_long_delay); } if (specialViews != null) { mFleetingViews = new ArrayList<ConversationSpecialItemView>(specialViews); } else { mFleetingViews = new ArrayList<ConversationSpecialItemView>(0); } /** Total number of special views */ final int size = mFleetingViews.size(); mSpecialViews = new SparseArray<ConversationSpecialItemView>(size); mColumnViews = new SparseArray<ConversationTimeColumnView>(size); //TS: zheng.zou 2015-09-01 EMAIL BUGFIX_539892 ADD // Set the adapter in teaser views. for (final ConversationSpecialItemView view : mFleetingViews) { view.setAdapter(this); } updateSpecialViews(); }
From source file:com.llf.android.launcher3.Folder.java
/** * Used to inflate the Workspace from XML. * /* w w w.j av a2 s . c om*/ * @param context * The application's context. * @param attrs * The attribtues set containing the Workspace's customization * values. */ public Folder(Context context, AttributeSet attrs) { super(context, attrs); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); setAlwaysDrawnWithCacheEnabled(false); mInflater = LayoutInflater.from(context); mIconCache = app.getIconCache(); Resources res = getResources(); mMaxCountX = (int) grid.numColumns; mMaxCountY = (int) grid.numRows; mMaxNumItems = mMaxCountX * mMaxCountY; mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration); if (sDefaultFolderName == null) { sDefaultFolderName = res.getString(R.string.folder_name); } if (sHintText == null) { sHintText = res.getString(R.string.folder_hint_text); } IActivity act = ((com.llf.core.main.Launcher) context).getActivity(); mLauncher = (Launcher) act; // We need this view to be focusable in touch mode so that when text // editing of the folder // name is complete, we have something to focus on, thus hiding the // cursor and giving // reliable behvior when clicking the text field (since it will always // gain focus on click). setFocusableInTouchMode(true); }