List of usage examples for android.util TypedValue getFloat
public final float getFloat()
From source file:com.microhealthllc.Slide.MultiShrinkScroller.java
/** * Create a new instance of MultiShrinkScroller. * * @param context/*from ww w . j av a 2s . c o m*/ * @param attrs * @param defStyleAttr */ public MultiShrinkScroller(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final ViewConfiguration configuration = ViewConfiguration.get(context); setFocusable(false); setWillNotDraw(false); edgeGlowBottom = new EdgeEffect(context); edgeGlowTop = new EdgeEffect(context); scroller = new Scroller(context, INTERPOLATOR); touchSlop = configuration.getScaledTouchSlop(); minimumVelocity = configuration.getScaledMinimumFlingVelocity(); maximumVelocity = configuration.getScaledMaximumFlingVelocity(); transparentStartHeight = (int) getResources().getDimension(R.dimen.sliding_starting_empty_height); toolbarElevation = getResources().getDimension(R.dimen.sliding_toolbar_elevation); isTwoPanel = getResources().getBoolean(R.bool.sliding_two_panel); paddedLayout = getResources().getBoolean(R.bool.padded_layout); maximumTitleMargin = (int) getResources().getDimension(R.dimen.sliding_title_initial_margin); dismissDistanceOnScroll = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_scroll); dismissDistanceOnRelease = (int) getResources().getDimension(R.dimen.sliding_dismiss_distance_on_release); snapToTopSlopHeight = (int) getResources().getDimension(R.dimen.sliding_snap_to_top_slop_height); final TypedValue photoRatio = new TypedValue(); getResources().getValue(R.dimen.sliding_landscape_photo_ratio, photoRatio, true); landscapePhotoRatio = photoRatio.getFloat(); final TypedArray attributeArray = context .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); actionBarSize = attributeArray.getDimensionPixelSize(0, 0); minimumHeaderHeight = actionBarSize; attributeArray.recycle(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { textSizePathInterpolator = new PathInterpolator(X1, Y1, X2, Y2); } else { textSizePathInterpolator = null; } }
From source file:android.support.v17.leanback.app.GuidedStepFragment.java
/** * {@inheritDoc}//from w w w . jav a2s . co m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we dont need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:android.support.v17.leanback.app.GuidedStepSupportFragment.java
/** * {@inheritDoc}// ww w . j a v a2s . c o m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we dont need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:com.rbware.github.androidcouchpotato.app.GuidedStepFragment.java
/** * {@inheritDoc}/* www . j av a 2s .co m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we don't need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:com.rbware.github.androidcouchpotato.app.GuidedStepSupportFragment.java
/** * {@inheritDoc}//ww w .j av a 2 s .c o m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); root.setFocusOutStart(isFocusOutStartAllowed()); root.setFocusOutEnd(isFocusOutEndAllowed()); ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment); ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment); Guidance guidance = onCreateGuidance(savedInstanceState); View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance); guidanceContainer.addView(guidanceView); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepSupportFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we don't need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = root.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); // Add the background view. View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState); if (backgroundView != null) { FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root); backgroundViewRoot.addView(backgroundView, 0); } return root; }
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
public RadialTimePickerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // Pull disabled alpha from theme. final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true); mDisabledAlpha = (int) (outValue.getFloat() * 255 + 0.5f); // process style attributes final Resources res = getResources(); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TimePicker, defStyleAttr, 0); mTypeface = Typeface.create("sans-serif", Typeface.NORMAL); // Initialize all alpha values to opaque. for (int i = 0; i < mAlpha.length; i++) { mAlpha[i] = new IntHolder(ALPHA_OPAQUE); }/*from www .j av a2 s. com*/ for (int i = 0; i < mAlphaSelector.length; i++) { for (int j = 0; j < mAlphaSelector[i].length; j++) { mAlphaSelector[i][j] = new IntHolder(ALPHA_OPAQUE); } } final int numbersTextColor = a.getColor(R.styleable.TimePicker_numbersTextColor, res.getColor(R.color.timepicker_default_text_color_material)); mPaint[HOURS] = new Paint(); mPaint[HOURS].setAntiAlias(true); mPaint[HOURS].setTextAlign(Paint.Align.CENTER); mColor[HOURS] = numbersTextColor; mPaint[MINUTES] = new Paint(); mPaint[MINUTES].setAntiAlias(true); mPaint[MINUTES].setTextAlign(Paint.Align.CENTER); mColor[MINUTES] = numbersTextColor; mPaintCenter.setColor(numbersTextColor); mPaintCenter.setAntiAlias(true); mPaintCenter.setTextAlign(Paint.Align.CENTER); mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true); mColorSelector[HOURS][SELECTOR_CIRCLE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[HOURS][SELECTOR_DOT] = new Paint(); mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true); mColorSelector[HOURS][SELECTOR_DOT] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[HOURS][SELECTOR_LINE] = new Paint(); mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2); mColorSelector[HOURS][SELECTOR_LINE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true); mColorSelector[MINUTES][SELECTOR_CIRCLE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint(); mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true); mColorSelector[MINUTES][SELECTOR_DOT] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2); mColorSelector[MINUTES][SELECTOR_LINE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintBackground.setColor(a.getColor(R.styleable.TimePicker_numbersBackgroundColor, res.getColor(R.color.timepicker_default_numbers_background_color_material))); mPaintBackground.setAntiAlias(true); if (DEBUG) { mPaintDebug.setColor(DEBUG_COLOR); mPaintDebug.setAntiAlias(true); mPaintDebug.setStrokeWidth(DEBUG_STROKE_WIDTH); mPaintDebug.setStyle(Paint.Style.STROKE); mPaintDebug.setTextAlign(Paint.Align.CENTER); } mShowHours = true; mIs24HourMode = false; mAmOrPm = AM; // Set up accessibility components. mTouchHelper = new RadialPickerTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); if (getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); } initHoursAndMinutesText(); initData(); mTransitionMidRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_transition_mid_radius_multiplier)); mTransitionEndRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_transition_end_radius_multiplier)); mTextGridHeights[HOURS] = new float[7]; mTextGridHeights[MINUTES] = new float[7]; mSelectionRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_selection_radius_multiplier)); a.recycle(); setOnTouchListener(this); setClickable(true); // Initial values final Calendar calendar = Calendar.getInstance(Locale.getDefault()); final int currentHour = calendar.get(Calendar.HOUR_OF_DAY); final int currentMinute = calendar.get(Calendar.MINUTE); setCurrentHourInternal(currentHour, false, false); setCurrentMinuteInternal(currentMinute, false); setHapticFeedbackEnabled(true); }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
private void loadAllPreferences() { SharedPreferences mediaPhoneSettings = PreferenceManager .getDefaultSharedPreferences(MediaPhoneActivity.this); Resources res = getResources(); // bluetooth observer configureBluetoothObserver(mediaPhoneSettings, res); // importing confirmation boolean confirmImporting = res.getBoolean(R.bool.default_confirm_importing); try {/*w w w . j a va 2s .c o m*/ confirmImporting = mediaPhoneSettings.getBoolean(getString(R.string.key_confirm_importing), confirmImporting); } catch (Exception e) { confirmImporting = res.getBoolean(R.bool.default_confirm_importing); } MediaPhone.IMPORT_CONFIRM_IMPORTING = confirmImporting; // delete after import boolean deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); try { deleteAfterImport = mediaPhoneSettings.getBoolean(getString(R.string.key_delete_after_importing), deleteAfterImport); } catch (Exception e) { deleteAfterImport = res.getBoolean(R.bool.default_delete_after_importing); } MediaPhone.IMPORT_DELETE_AFTER_IMPORTING = deleteAfterImport; // minimum frame duration TypedValue resourceValue = new TypedValue(); res.getValue(R.attr.default_minimum_frame_duration, resourceValue, true); float minimumFrameDuration; try { minimumFrameDuration = mediaPhoneSettings.getFloat(getString(R.string.key_minimum_frame_duration), resourceValue.getFloat()); if (minimumFrameDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { minimumFrameDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_MINIMUM_FRAME_DURATION = Math.round(minimumFrameDuration * 1000); // word duration res.getValue(R.attr.default_word_duration, resourceValue, true); float wordDuration; try { wordDuration = mediaPhoneSettings.getFloat(getString(R.string.key_word_duration), resourceValue.getFloat()); if (wordDuration <= 0) { throw new NumberFormatException(); } } catch (Exception e) { wordDuration = resourceValue.getFloat(); } MediaPhone.PLAYBACK_EXPORT_WORD_DURATION = Math.round(wordDuration * 1000); // screen orientation int requestedOrientation = res.getInteger(R.integer.default_screen_orientation); try { String requestedOrientationString = mediaPhoneSettings .getString(getString(R.string.key_screen_orientation), null); requestedOrientation = Integer.valueOf(requestedOrientationString); } catch (Exception e) { requestedOrientation = res.getInteger(R.integer.default_screen_orientation); } setRequestedOrientation(requestedOrientation); // other preferences loadPreferences(mediaPhoneSettings); }
From source file:info.awesomedevelopment.tvgrid.library.TVGridView.java
@SuppressWarnings("deprecation") private void init(AttributeSet attrs) { ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); mCache = new LruCache<>(am.getMemoryClass() * 1024); mYSize = new ValueAnimator(); mXSize = new ValueAnimator(); mYLocation = new ValueAnimator(); mXLocation = new ValueAnimator(); mXSize.addUpdateListener(xSizeListener); mYSize.addUpdateListener(ySizeListener); mYLocation.addUpdateListener(yLocationListener); mXLocation.addUpdateListener(xLocationListener); mSelectorAnimationSet.playTogether(mXLocation, mYLocation, mXSize, mYSize); mSelectorAnimationSet.setInterpolator(new AccelerateDecelerateInterpolator()); mSelectorAnimationSet.setDuration(ANIMATION_DURATION); TypedValue fillAlpha = new TypedValue(); getResources().getValue(R.dimen.tvg_defFillAlpha, fillAlpha, true); TypedValue fillAlphaSelected = new TypedValue(); getResources().getValue(R.dimen.tvg_defFillAlphaSelected, fillAlphaSelected, true); if (attrs != null) { TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.TVGridView, 0, 0); try {//from www . j a va2 s . c om //noinspection ResourceType mStrokePosition = a.getInteger(R.styleable.TVGridView_tvg_strokePosition, OUTSIDE); //noinspection ResourceType mSelectorPosition = a.getInteger(R.styleable.TVGridView_tvg_selectorPosition, OVER); //noinspection ResourceType mSelectorShape = a.getInteger(R.styleable.TVGridView_tvg_selectorShape, RECTANGLE); mAnimateSelectorChanges = a.getBoolean(R.styleable.TVGridView_tvg_animateSelectorChanges, getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1); mIsFilled = a.getBoolean(R.styleable.TVGridView_tvg_filled, getResources().getInteger(R.integer.tvg_defIsFilled) == 1); mFillAlpha = a.getFloat(R.styleable.TVGridView_tvg_fillAlpha, fillAlpha.getFloat()); mFillAlphaSelected = a.getFloat(R.styleable.TVGridView_tvg_fillAlphaSelected, fillAlphaSelected.getFloat()); mFillColor = a.getColor(R.styleable.TVGridView_tvg_fillColor, getResources().getColor(R.color.tvg_defFillColor)); mFillColorSelected = a.getColor(R.styleable.TVGridView_tvg_fillColorSelected, getResources().getColor(R.color.tvg_defFillColorSelected)); mCornerRadiusX = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius, getResources().getDimension(R.dimen.tvg_defCornerRadius)); mCornerRadiusY = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius, getResources().getDimension(R.dimen.tvg_defCornerRadius)); mStrokeWidth = a.getDimension(R.styleable.TVGridView_tvg_strokeWidth, getResources().getDimension(R.dimen.tvg_defStrokeWidth)); mStrokeColor = a.getColor(R.styleable.TVGridView_tvg_strokeColor, getResources().getColor(R.color.tvg_defStrokeColor)); mStrokeColorSelected = a.getColor(R.styleable.TVGridView_tvg_strokeColorSelected, getResources().getColor(R.color.tvg_defStrokeColorSelected)); mStrokeMarginLeft = a.getDimension(R.styleable.TVGridView_tvg_marginLeft, getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft)); mStrokeMarginTop = a.getDimension(R.styleable.TVGridView_tvg_marginTop, getResources().getDimension(R.dimen.tvg_defStrokeMarginTop)); mStrokeMarginRight = a.getDimension(R.styleable.TVGridView_tvg_marginRight, getResources().getDimension(R.dimen.tvg_defStrokeMarginRight)); mStrokeMarginBottom = a.getDimension(R.styleable.TVGridView_tvg_marginBottom, getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom)); mStrokeSpacingLeft = a.getDimension(R.styleable.TVGridView_tvg_spacingLeft, getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft)); mStrokeSpacingTop = a.getDimension(R.styleable.TVGridView_tvg_spacingTop, getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop)); mStrokeSpacingRight = a.getDimension(R.styleable.TVGridView_tvg_spacingRight, getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight)); mStrokeSpacingBottom = a.getDimension(R.styleable.TVGridView_tvg_spacingBottom, getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom)); } finally { a.recycle(); } } else { mStrokePosition = OUTSIDE; mSelectorPosition = OVER; mSelectorShape = RECTANGLE; mAnimateSelectorChanges = getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1; mIsFilled = getResources().getInteger(R.integer.tvg_defIsFilled) == 1; mFillAlpha = fillAlpha.getFloat(); mFillAlphaSelected = fillAlphaSelected.getFloat(); mFillColor = getResources().getColor(R.color.tvg_defFillColor); mFillColorSelected = getResources().getColor(R.color.tvg_defFillColorSelected); mCornerRadiusX = getResources().getDimension(R.dimen.tvg_defCornerRadius); mCornerRadiusY = getResources().getDimension(R.dimen.tvg_defCornerRadius); mStrokeWidth = getResources().getDimension(R.dimen.tvg_defStrokeWidth); mStrokeColor = getResources().getColor(R.color.tvg_defStrokeColor); mStrokeColorSelected = getResources().getColor(R.color.tvg_defStrokeColorSelected); mStrokeMarginLeft = getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft); mStrokeMarginTop = getResources().getDimension(R.dimen.tvg_defStrokeMarginTop); mStrokeMarginRight = getResources().getDimension(R.dimen.tvg_defStrokeMarginRight); mStrokeMarginBottom = getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom); mStrokeSpacingLeft = getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft); mStrokeSpacingTop = getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop); mStrokeSpacingRight = getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight); mStrokeSpacingBottom = getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom); } addOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == SCROLL_STATE_IDLE) { mEdgeChange = false; mHardScrollChange = false; } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); mScrollY = mScrollY + dy; if (mStrokeCellCurrentBounds == null || mStrokeCell == null) return; if (useAnimations()) { mSelectorAnimationSet.cancel(); mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx, mStrokeCellCurrentBounds.top - dy); performSelectorAnimation(); } else if (mHardScrollChange || mEdgeChange) { mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx, mStrokeCellCurrentBounds.top - dy); setPrevBounds(); mStrokeCell.setBounds(mStrokeCellPrevBounds); invalidate(); } } }); setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { clearHighlightedView(); return false; } }); }
From source file:ticwear.design.widget.CoordinatorLayout.java
public CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); if (!isInEditMode()) { ThemeUtils.checkDesignTheme(context); }/*from www . ja v a 2s . c o m*/ final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CoordinatorLayout, defStyleAttr, defStyleRes); final int keylineArrayRes = a.getResourceId(R.styleable.CoordinatorLayout_tic_keylines, 0); if (keylineArrayRes != 0) { final Resources res = context.getResources(); mKeylines = res.getIntArray(keylineArrayRes); final float density = res.getDisplayMetrics().density; final int count = mKeylines.length; for (int i = 0; i < count; i++) { mKeylines[i] *= density; } } mStatusBarBackground = a.getDrawable(R.styleable.CoordinatorLayout_tic_statusBarBackground); int effect = a.getInt(R.styleable.CoordinatorLayout_tic_overScrollEffect, OverScrollEffect.BOUNCE.ordinal()); mOverScrollEffect = OverScrollEffect.values()[effect]; a.recycle(); super.setOnHierarchyChangeListener(new HierarchyChangeListener()); mScrollBarHelper = new ScrollBarHelper(context, attrs, defStyleAttr); mViewScrollingStatusAccessor = new ViewScrollingStatusAccessor(); if (mEdgeGlowTop == null) { mEdgeGlowTop = new ClassicEdgeEffect(context); mEdgeGlowBottom = new ClassicEdgeEffect(context); } ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (mLastInsets == null) { setupForWindowInsets(); } if (isShown()) { setWindowInsets(insets); return insets.consumeSystemWindowInsets(); } else { return insets; } } }); if (isInEditMode()) { mOverScrollOffsetFactor = 0.5f; mOverScrollOffsetLimit = Integer.MAX_VALUE; } else { TypedValue typedValue = new TypedValue(); getResources().getValue(R.integer.design_factor_over_scroll_bounce, typedValue, true); mOverScrollOffsetFactor = typedValue.getFloat(); mOverScrollOffsetLimit = getResources().getDimensionPixelOffset(R.dimen.design_over_scroll_limit); } setWillNotDraw(false); }
From source file:android.content.pm.PackageParser.java
private Bundle parseMetaData(Resources res, XmlPullParser parser, AttributeSet attrs, Bundle data, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestMetaData); if (data == null) { data = new Bundle(); }/*from w w w .j av a 2s . c om*/ String name = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestMetaData_name, 0); if (name == null) { outError[0] = "<meta-data> requires an android:name attribute"; sa.recycle(); return null; } name = name.intern(); TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestMetaData_resource); if (v != null && v.resourceId != 0) { //Slog.i(TAG, "Meta data ref " + name + ": " + v); data.putInt(name, v.resourceId); } else { v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestMetaData_value); //Slog.i(TAG, "Meta data " + name + ": " + v); if (v != null) { if (v.type == TypedValue.TYPE_STRING) { CharSequence cs = v.coerceToString(); data.putString(name, cs != null ? cs.toString().intern() : null); } else if (v.type == TypedValue.TYPE_INT_BOOLEAN) { data.putBoolean(name, v.data != 0); } else if (v.type >= TypedValue.TYPE_FIRST_INT && v.type <= TypedValue.TYPE_LAST_INT) { data.putInt(name, v.data); } else if (v.type == TypedValue.TYPE_FLOAT) { data.putFloat(name, v.getFloat()); } else { if (!RIGID_PARSER) { Slog.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { outError[0] = "<meta-data> only supports string, integer, float, color, boolean, and resource reference types"; data = null; } } } else { outError[0] = "<meta-data> requires an android:value or android:resource attribute"; data = null; } } sa.recycle(); XmlUtils.skipCurrentTag(parser); return data; }