List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:com.chauffeurprive.kronos.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/*from w ww.java 2s . c o m*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); mDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mMonthDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mDisabledDayTextColor = ContextCompat.getColor(context, mController.getDisabledTextColor()); mHighlightedDayTextColor = ContextCompat.getColor(context, mController.getTextColor()); mSelectedDayTextColor = ContextCompat.getColor(context, mController.getSelectedTextColor()); mTodayNumberColor = ContextCompat.getColor(context, mController.getTodayTextColor()); mMonthTitleColor = ContextCompat.getColor(context, mController.getTextColor()); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
@Nullable @Override//from w w w .j a v a 2s. c om public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_list, container, false); Context context = getContext2(); Assert.assertNotNull(context); Resources resources = context.getResources(); mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mShowActionFab = true; View mainLayout = ViewUtils.$$(view, R.id.main_layout); ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout); mRecyclerView = contentLayout.getRecyclerView(); FastScroller fastScroller = contentLayout.getFastScroller(); RefreshLayout refreshLayout = contentLayout.getRefreshLayout(); mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout); mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar); mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout); mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab); int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar); int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab); mViewTransition = new ViewTransition(contentLayout, mSearchLayout); mHelper = new GalleryListHelper(); mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit)); contentLayout.setHelper(mHelper); contentLayout.getFastScroller().setOnDragHandlerListener(this); mAdapter = new GalleryListAdapter(inflater, resources, mRecyclerView, Settings.getListMode()); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false)); mRecyclerView.setDrawSelectorOnTop(true); mRecyclerView.hasFixedSize(); mRecyclerView.setClipToPadding(false); mRecyclerView.setOnItemClickListener(this); mRecyclerView.setOnItemLongClickListener(this); mRecyclerView.addOnScrollListener(mOnScrollListener); fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB, fastScroller.getPaddingRight(), fastScroller.getPaddingBottom()); refreshLayout.setHeaderTranslationY(paddingTopSB); mLeftDrawable = new DrawerArrowDrawable(context); mRightDrawable = new AddDeleteDrawable(context); mSearchBar.setLeftDrawable(mLeftDrawable); mSearchBar.setRightDrawable(mRightDrawable); mSearchBar.setHelper(this); mSearchBar.setOnStateChangeListener(this); setSearchBarHint(context, mSearchBar); mSearchLayout.setHelper(this); mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB, mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab); mFabLayout.setAutoCancel(true); mFabLayout.setExpanded(false); mFabLayout.setHidePrimaryFab(false); mFabLayout.setOnClickFabListener(this); mFabLayout.setOnExpandListener(this); addAboveSnackView(mFabLayout); mActionFabDrawable = new AddDeleteDrawable(context); mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark)); mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable); mSearchFab.setOnClickListener(this); mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout); // Update list url builder onUpdateUrlBuilder(); // Restore state int newState = mState; mState = STATE_NORMAL; setState(newState, false); // Only refresh for the first time if (!mHasFirstRefresh) { mHasFirstRefresh = true; mHelper.firstRefresh(); } guideQuickSearch(); return view; }
From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java
@SuppressLint("SetTextI18n") private void bindPreviews(GalleryDetail gd) { LayoutInflater inflater = getLayoutInflater2(); Resources resources = getResources2(); if (null == inflater || null == resources || null == mGridLayout || null == mPreviewText) { return;//from w w w . ja v a2 s . com } mGridLayout.removeAllViews(); PreviewSet previewSet = gd.previewSet; if (gd.previewPages <= 0 || previewSet == null || previewSet.size() == 0) { mPreviewText.setText(R.string.no_previews); return; } else if (gd.previewPages == 1) { mPreviewText.setText(R.string.no_more_previews); } else { mPreviewText.setText(R.string.more_previews); } int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId()); mGridLayout.setColumnSize(columnWidth); mGridLayout.setStrategy(SimpleGridAutoSpanLayout.STRATEGY_SUITABLE_SIZE); for (int i = 0, size = previewSet.size(); i < size; i++) { View view = inflater.inflate(R.layout.item_gallery_preview, mGridLayout, false); mGridLayout.addView(view); LoadImageView image = (LoadImageView) view.findViewById(R.id.image); previewSet.load(image, gd.gid, i); image.setTag(R.id.index, i); image.setOnClickListener(this); TextView text = (TextView) view.findViewById(R.id.text); text.setText(Integer.toString(previewSet.getPosition(i) + 1)); } }
From source file:com.tct.mail.browse.ConversationItemView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //[BUGFIX]-Add-BEGIN by TSNJ,Zhenhua.Fan,04/01/2014,PR-891052, if (mActivity == null || mActivity.getViewMode() == null) return;//w w w .j a va 2s . c o m //[BUGFIX]-Add-END by TSNJ,Zhenhua.Fan Utils.traceBeginSection("CIVC.measure"); final int wSize = MeasureSpec.getSize(widthMeasureSpec); final int currentMode = mActivity.getViewMode().getMode(); if (wSize != mViewWidth || mPreviousMode != currentMode) { mViewWidth = wSize; mPreviousMode = currentMode; } mHeader.viewWidth = mViewWidth; mConfig.updateWidth(wSize).setViewMode(currentMode).setLayoutDirection(ViewCompat.getLayoutDirection(this)); Resources res = getResources(); mHeader.standardScaledDimen = res.getDimensionPixelOffset(R.dimen.standard_scaled_dimen); mCoordinates = ConversationItemViewCoordinates.forConfig(mContext, mConfig, mAdapter.getCoordinatesCache()); if (mPhotoBitmap != null) { mPhotoRect = new Rect(0, 0, mCoordinates.contactImagesWidth, mCoordinates.contactImagesHeight); } final int h = (mAnimatedHeightFraction != 1.0f) ? Math.round(mAnimatedHeightFraction * mCoordinates.height) : mCoordinates.height; setMeasuredDimension(mConfig.getWidth(), h); Utils.traceEndSection(); }
From source file:com.mohamadamin.persianmaterialdatetimepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;//from w w w . j a v a 2 s.co m Resources res = context.getResources(); mDayLabelCalendar = new PersianCalendar(); mPersianCalendar = new PersianCalendar(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = res.getColor(R.color.mdtp_white); mTodayNumberColor = res.getColor(R.color.mdtp_accent_color); mMonthTitleColor = res.getColor(R.color.mdtp_white); mStringBuilder = new StringBuilder(50); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.tct.mail.ui.ConversationViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { LogUtils.d(LOG_TAG, "IN CVF.onActivityCreated, this=%s visible=%s", this, isUserVisible()); super.onActivityCreated(savedInstanceState); if (mActivity == null || mActivity.isFinishing()) { // Activity is finishing, just bail. return;//from w w w .ja v a 2s .c o m } Context context = getContext(); mTemplates = new HtmlConversationTemplates(context); final FormattedDateBuilder dateBuilder = new FormattedDateBuilder(context); mNavigationController = mActivity.getKeyboardNavigationController(); mAdapter = new ConversationViewAdapter(mActivity, this, getLoaderManager(), this, this, getContactInfoSource(), this, this, getListController(), this, mAddressCache, dateBuilder, mBidiFormatter, this); mConversationContainer.setOverlayAdapter(mAdapter); // set up snap header (the adapter usually does this with the other ones) mConversationContainer.getSnapHeader().initialize(this, mAddressCache, this, getContactInfoSource(), mActivity.getAccountController().getVeiledAddressMatcher()); final Resources resources = getResources(); mMaxAutoLoadMessages = resources.getInteger(R.integer.max_auto_load_messages); mSideMarginPx = resources.getDimensionPixelOffset(R.dimen.conversation_message_content_margin_side); mUrlToMessageIdMap = new ArrayMap<String, String>(); final InlineAttachmentViewIntentBuilderCreator creator = InlineAttachmentViewIntentBuilderCreatorHolder .getInlineAttachmentViewIntentCreator(); final WebViewContextMenu contextMenu = new WebViewContextMenu(getActivity(), creator .createInlineAttachmentViewIntentBuilder(mAccount, mConversation != null ? mConversation.id : -1)); contextMenu.setCallbacks(this); mWebView.setOnCreateContextMenuListener(contextMenu); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_S mWebView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_UP && webViewScaleHasChanged) { mWebView.loadUrl(String.format("javascript:setConversationHeaderSpacerHeight(%s);", mCovHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); if (mAdapter.getMessageHeaderItem() != null) { mWebView.loadUrl(String.format("javascript:setMessageHeaderSpacerHeight('%s', %s);", mTemplates.getMessageDomId(mAdapter.getMessageHeaderItem().getMessage()), mMsgHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); } mWebView.loadUrl(String.format("javascript:setConversationFooterSpacerHeight(%s);", mCovFooterHegiht * mWebView.getInitialScale() / mWebView.getScale())); webViewScaleHasChanged = false; } return mWebView.onTouchEvent(event); } }); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_E //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S mFabButton.setAccountController(this); //Because we can't get the webview's contentHeight when onPageFinished(),so set the PictureListener //to get the contentHeight and judge if it's initialized bottom,and then do the animation. mWebView.setPictureListener(new PictureListener() { int previousHeight; @Deprecated public void onNewPicture(WebView w, Picture picture) { // TODO Auto-generated method stub int height = w.getContentHeight(); if (previousHeight == height) return; previousHeight = height; if (mWebView.isInitializedBottom()) { mWebView.animateBottom(true); } else { mWebView.animateHideFooter(); } } }); //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E // set this up here instead of onCreateView to ensure the latest Account is loaded setupOverviewMode(); // Defer the call to initLoader with a Handler. // We want to wait until we know which fragments are present and their final visibility // states before going off and doing work. This prevents extraneous loading from occurring // as the ViewPager shifts about before the initial position is set. // // e.g. click on item #10 // ViewPager.setAdapter() actually first loads #0 and #1 under the assumption that #0 is // the initial primary item // Then CPC immediately sets the primary item to #10, which tears down #0/#1 and sets up // #9/#10/#11. getHandler().post(new FragmentRunnable("showConversation", this) { @Override public void go() { showConversation(); } }); if (mConversation != null && mConversation.conversationBaseUri != null && !Utils.isEmpty(mAccount.accountCookieQueryUri)) { // Set the cookie for this base url new SetCookieTask(getContext(), mConversation.conversationBaseUri.toString(), mAccount.accountCookieQueryUri).execute(); } // Find the height of the screen for manually scrolling the webview via keyboard. final Rect screen = new Rect(); mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(screen); mMaxScreenHeight = screen.bottom; mTopOfVisibleScreen = screen.top + mActivity.getSupportActionBar().getHeight(); //[BUGFIX]-Add-BEGIN?by?TSCD.zheng.zou,01/14/2015,887972 //[Email]It?still?display?download?remaining?when?rotate?the?screen?during?loading //note:use initLoader to reconnect with the previous loader. if (savedInstanceState != null) { mIsDownloadingRemaining = savedInstanceState.getBoolean(IS_DOWNLOADING_REMAINING); mIsPopDownloadRemain = savedInstanceState.getBoolean(IS_POP_DOWNLOAD_REMAIN); } LoaderManager lm = getLoaderManager(); if (lm.getLoader(LOADER_DOWNLOAD_REMAINING) != null) { lm.initLoader(LOADER_DOWNLOAD_REMAINING, null, mDownloadRemainCallback); } //[BUGFIX]-Add-END?by?TSCD.zheng.zou }
From source file:com.borax12.materialdaterangepicker.multi.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;//from www . java 2 s . co m Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = res.getColor(R.color.mdtp_white); mTodayNumberColor = res.getColor(R.color.mdtp_accent_color); mMonthTitleColor = res.getColor(R.color.mdtp_white); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.leavjenn.smoothdaterangepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr, SmoothDateRangePickerController controller) { super(context, attr); mController = controller;/*from www. jav a 2 s . c om*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = res.getColor(R.color.mdtp_white); mTodayNumberColor = res.getColor(R.color.mdtp_accent_color); mMonthTitleColor = res.getColor(R.color.mdtp_white); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.borax12.materialdaterangepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/*w w w .j a va 2s. co m*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtrp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtrp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_normal_dark_theme); mMonthDayTextColor = res.getColor(R.color.mdtrp_date_picker_month_day_dark_theme); mDisabledDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_normal); mMonthDayTextColor = res.getColor(R.color.mdtrp_date_picker_month_day); mDisabledDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_disabled); mHighlightedDayTextColor = res.getColor(R.color.mdtrp_date_picker_text_highlighted); } mSelectedDayTextColor = res.getColor(R.color.mdtrp_white); mTodayNumberColor = res.getColor(R.color.mdtrp_accent_color); mMonthTitleColor = res.getColor(R.color.mdtrp_white); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtrp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtrp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtrp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtrp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtrp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtrp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.customdatepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;/* w ww. j av a2 s .c o m*/ Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(mController.getTimeZone()); mCalendar = Calendar.getInstance(mController.getTimeZone()); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled_dark_theme); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal); mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day); mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled); mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted); } mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white); mTodayNumberColor = mController.getAccentColor(); mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white); mStringBuilder = new StringBuilder(50); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }