Example usage for android.content Context ACCESSIBILITY_SERVICE

List of usage examples for android.content Context ACCESSIBILITY_SERVICE

Introduction

In this page you can find the example usage for android.content Context ACCESSIBILITY_SERVICE.

Prototype

String ACCESSIBILITY_SERVICE

To view the source code for android.content Context ACCESSIBILITY_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.accessibility.AccessibilityManager for giving the user feedback for UI events through the registered event listeners.

Usage

From source file:connect.app.com.connect.calendar.DayPickerView.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    //        final TypedArray a = context.obtainStyledAttributes(attrs,
    //                R.styleable.CalendarView, defStyleAttr, defStyleRes);
    ///* w w  w  . j  a  v  a 2 s  . co m*/
    //        final int firstDayOfWeek = a.getInt(R.styleable.CalendarView_firstDayOfWeek,
    //                LocaleData.get(Locale.getDefault()).firstDayOfWeek);
    final int firstDayOfWeek = 1;
    //
    //        final String minDate = a.getString(R.styleable.CalendarView_minDate);
    final String minDate = null;
    //        final String maxDate = a.getString(R.styleable.CalendarView_maxDate);
    final String maxDate = null;
    //
    //        final int monthTextAppearanceResId = a.getResourceId(
    //                R.styleable.CalendarView_monthTextAppearance,
    //                R.style.TextAppearance_Material_Widget_Calendar_Month);
    //        final int dayOfWeekTextAppearanceResId = a.getResourceId(
    //                R.styleable.CalendarView_weekDayTextAppearance,
    //                R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek);
    //        final int dayTextAppearanceResId = a.getResourceId(
    //                R.styleable.CalendarView_dateTextAppearance,
    //                R.style.TextAppearance_Material_Widget_Calendar_Day);
    //
    //        final ColorStateList daySelectorColor = a.getColorStateList(
    //                R.styleable.CalendarView_daySelectorColor);
    //
    //        a.recycle();

    // Set up adapter.
    mAdapter = new DayPickerPagerAdapter(context, R.layout.layout_test, com.retrofit.R.id.scrollView);
    //        mAdapter.setMonthTextAppearance(monthTextAppearanceResId);
    //        mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId);
    //        mAdapter.setDayTextAppearance(dayTextAppearanceResId);
    //        mAdapter.setDaySelectorColor(daySelectorColor);

    final LayoutInflater inflater = LayoutInflater.from(context);
    final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false);

    // Transfer all children from content to here.
    while (content.getChildCount() > 0) {
        final View child = content.getChildAt(0);
        content.removeViewAt(0);
        addView(child);
    }

    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mOnClickListener);

    mNextButton = (ImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mOnClickListener);

    mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(mOnPageChangedListener);

    // Proxy the month text color into the previous and next buttons.
    //        if (monthTextAppearanceResId != 0) {
    //            final TypedArray ta = mContext.obtainStyledAttributes(null,
    //                    ATTRS_TEXT_COLOR, 0, monthTextAppearanceResId);
    //            final ColorStateList monthColor = ta.getColorStateList(0);
    //            if (monthColor != null) {
    //                mPrevButton.setImageTintList(monthColor);
    //                mNextButton.setImageTintList(monthColor);
    //            }
    //            ta.recycle();
    //        }

    // Set up min and max dates.
    final Calendar tempDate = Calendar.getInstance();
    if (!CalendarView.parseDate(minDate, tempDate)) {
        tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1);
    }
    final long minDateMillis = tempDate.getTimeInMillis();

    if (!CalendarView.parseDate(maxDate, tempDate)) {
        tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31);
    }
    final long maxDateMillis = tempDate.getTimeInMillis();

    if (maxDateMillis < minDateMillis) {
        throw new IllegalArgumentException("maxDate must be >= minDate");
    }

    final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis);

    setFirstDayOfWeek(firstDayOfWeek);
    setMinDate(minDateMillis);
    setMaxDate(maxDateMillis);
    setDate(setDateMillis, false);

    // Proxy selection callbacks to our own listener.
    mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() {
        @Override
        public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) {
            if (mOnDaySelectedListener != null) {
                mOnDaySelectedListener.onDaySelected(DayPickerView.this, day);
            }
        }
    });
}

From source file:com.android.inputmethod.accessibility.AccessibilityUtils.java

private void initInternal(final Context context) {
    mContext = context;//from w  ww .  jav a2s  .c  om
    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerView.java

public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, R.style.SublimePickerStyleLight,
            defStyleAttr, R.style.DayPickerViewStyle), attrs);

    context = getContext();//from w w w.  j av a 2s  . c om

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DayPickerView, defStyleAttr,
            R.style.DayPickerViewStyle);

    final int monthTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spMonthTextAppearance,
            R.style.SPMonthLabelTextAppearance);
    // verified
    final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spWeekDayTextAppearance,
            R.style.SPWeekDayLabelTextAppearance);
    // verified
    final int dayTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spDateTextAppearance,
            R.style.SPDayTextAppearance);

    final ColorStateList daySelectorColor = a.getColorStateList(R.styleable.DayPickerView_spDaySelectorColor);

    a.recycle();

    if (Config.DEBUG) {
        Log.i(TAG, "MDayPickerView_spmMonthTextAppearance: " + monthTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmWeekDayTextAppearance: " + dayOfWeekTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmDateTextAppearance: " + dayTextAppearanceResId);
    }

    // Set up adapter.
    mAdapter = new DayPickerPagerAdapter(context, R.layout.date_picker_month_item, R.id.month_view);
    mAdapter.setMonthTextAppearance(monthTextAppearanceResId);
    mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId);
    mAdapter.setDayTextAppearance(dayTextAppearanceResId);
    mAdapter.setDaySelectorColor(daySelectorColor);

    final LayoutInflater inflater = LayoutInflater.from(context);

    int layoutIdToUse, viewPagerIdToUse;

    if (getTag() != null && getTag() instanceof String
            && getResources().getString(R.string.recurrence_end_date_picker_tag).equals(getTag())) {
        layoutIdToUse = R.layout.day_picker_content_redp;
        viewPagerIdToUse = R.id.redp_view_pager;
    } else {
        layoutIdToUse = R.layout.day_picker_content_sdp;
        viewPagerIdToUse = R.id.sdp_view_pager;
    }

    inflater.inflate(layoutIdToUse, this, true);

    OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            final int direction;
            if (v == mPrevButton) {
                direction = -1;
            } else if (v == mNextButton) {
                direction = 1;
            } else {
                return;
            }

            // Animation is expensive for accessibility services since it sends
            // lots of scroll and content change events.
            final boolean animate = !mAccessibilityManager.isEnabled();

            // ViewPager clamps input values, so we don't need to worry
            // about passing invalid indices.
            final int nextItem = mViewPager.getCurrentItem() + direction;
            mViewPager.setCurrentItem(nextItem, animate);
        }
    };

    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(onClickListener);

    mNextButton = (ImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(onClickListener);

    ViewPager.OnPageChangeListener onPageChangedListener = new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            final float alpha = Math.abs(0.5f - positionOffset) * 2.0f;
            mPrevButton.setAlpha(alpha);
            mNextButton.setAlpha(alpha);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageSelected(int position) {
            updateButtonVisibility(position);
        }
    };

    mViewPager = (DayPickerViewPager) findViewById(viewPagerIdToUse);
    mViewPager.setAdapter(mAdapter);
    mViewPager.addOnPageChangeListener(onPageChangedListener);

    // Proxy the month text color into the previous and next buttons.
    if (monthTextAppearanceResId != 0) {
        final TypedArray ta = context.obtainStyledAttributes(null, ATTRS_TEXT_COLOR, 0,
                monthTextAppearanceResId);
        final ColorStateList monthColor = ta.getColorStateList(0);
        if (monthColor != null) {
            SUtils.setImageTintList(mPrevButton, monthColor);
            SUtils.setImageTintList(mNextButton, monthColor);
        }
        ta.recycle();
    }

    // Proxy selection callbacks to our own listener.
    mAdapter.setDaySelectionEventListener(new DayPickerPagerAdapter.DaySelectionEventListener() {
        @Override
        public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDaySelected(DayPickerView.this, day);
            }
        }

        @Override
        public void onDateRangeSelectionStarted(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionStarted(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionEnded(@Nullable SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionEnded(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionUpdated(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionUpdated(selectedDate);
            }
        }
    });
}

From source file:com.tr4android.support.extension.picker.date.DayPickerView.java

public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePickerDialog, defStyleAttr, 0); //TODO: add default style res

    final int firstDayOfWeek = a.getInt(R.styleable.DatePickerDialog_firstDayOfWeek,
            Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek());

    final String minDate = a.getString(R.styleable.DatePickerDialog_minDate);
    final String maxDate = a.getString(R.styleable.DatePickerDialog_maxDate);

    final int monthTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_monthTextAppearance,
            R.style.TextAppearance_Material_Widget_Calendar_Month);
    final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_weekDayTextAppearance,
            R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek);
    final int dayTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_dateTextAppearance,
            R.style.TextAppearance_Material_Widget_Calendar_Day);

    // Set up day selected color, if available.
    final ColorStateList daySelectorColor;
    if (a.hasValue(R.styleable.DatePickerDialog_daySelectorColor)) {
        daySelectorColor = a.getColorStateList(R.styleable.DatePickerDialog_daySelectorColor);
    } else {/*from  w  ww .j  av a 2 s  .  c  o  m*/
        final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated });
        daySelectorColor = ta.getColorStateList(0);
        ta.recycle();
    }

    // Set up day highlight color, if available.
    final ColorStateList dayHighlightColor;
    if (a.hasValue(R.styleable.DatePickerDialog_dayHighlightColor)) {
        dayHighlightColor = a.getColorStateList(R.styleable.DatePickerDialog_dayHighlightColor);
    } else {
        final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlHighlight });
        dayHighlightColor = ta.getColorStateList(0);
        ta.recycle();
    }

    a.recycle();

    // Set up adapter.
    mAdapter = new DayPickerPagerAdapter(context, R.layout.day_picker_month_item_material, R.id.month_view);
    mAdapter.setMonthTextAppearance(monthTextAppearanceResId);
    mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId);
    mAdapter.setDayTextAppearance(dayTextAppearanceResId);
    mAdapter.setDaySelectorColor(daySelectorColor);
    mAdapter.setDayHighlightColor(dayHighlightColor);

    final LayoutInflater inflater = LayoutInflater.from(context);
    final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false);

    // Transfer all children from content to here.
    while (content.getChildCount() > 0) {
        final View child = content.getChildAt(0);
        content.removeViewAt(0);
        addView(child);
    }

    mPrevButton = (ImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(mOnClickListener);

    mNextButton = (ImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(mOnClickListener);

    mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager);
    mViewPager.setAdapter(mAdapter);
    mViewPager.addOnPageChangeListener(mOnPageChangedListener);

    // Set up background of the previous and next buttons.
    ViewCompatUtils.setBackground(mPrevButton, PickerThemeUtils.getNavButtonBackground(context));
    ViewCompatUtils.setBackground(mNextButton, PickerThemeUtils.getNavButtonBackground(context));

    // Set up min and max dates.
    final Calendar tempDate = Calendar.getInstance();
    if (!parseDate(minDate, tempDate)) {
        tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1);
    }
    final long minDateMillis = tempDate.getTimeInMillis();

    if (!parseDate(maxDate, tempDate)) {
        tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31);
    }
    final long maxDateMillis = tempDate.getTimeInMillis();

    if (maxDateMillis < minDateMillis) {
        throw new IllegalArgumentException("maxDate must be >= minDate");
    }

    final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis);

    setFirstDayOfWeek(firstDayOfWeek);
    setMinDate(minDateMillis);
    setMaxDate(maxDateMillis);
    setDate(setDateMillis, false);

    // Proxy selection callbacks to our own listener.
    mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() {
        @Override
        public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) {
            if (mOnDaySelectedListener != null) {
                mOnDaySelectedListener.onDaySelected(DayPickerView.this, day);
            }
        }
    });
}

From source file:com.android.utils.ExploreByTouchHelper.java

/**
 * Constructs a new Explore by Touch helper.
 *
 * @param host The view whose virtual hierarchy is exposed by this
 *            helper.//from w w  w . ja va 2s  .c  o m
 */
ExploreByTouchHelper(View host) {
    mHost = host;
    mManager = (AccessibilityManager) host.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:android.support.v7.preference.CheckBoxPreference.java

private void syncViewIfAccessibilityEnabled(View view) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!accessibilityManager.isEnabled()) {
        return;/* w  ww.j av  a 2s  .  c o  m*/
    }

    View checkboxView = view.findViewById(android.R.id.checkbox);
    syncCheckboxView(checkboxView);

    View summaryView = view.findViewById(android.R.id.summary);
    syncSummaryView(summaryView);
}

From source file:com.googlecode.eyesfree.utils.ExploreByTouchHelper.java

/**
 * Constructs a new Explore by Touch helper.
 *
 * @param host The view whose virtual hierarchy is exposed by this
 *            helper./*from www  .ja  va  2s .c  o  m*/
 */
public ExploreByTouchHelper(View host) {
    mHost = host;
    mManager = (AccessibilityManager) host.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:rikka.materialpreference.CheckBoxPreference.java

private void syncViewIfAccessibilityEnabled(View view) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (!accessibilityManager.isEnabled()) {
        return;/*from www. j a  va 2s  .c om*/
    }

    View checkboxView = view.findViewById(R.id.checkbox);
    syncCheckboxView(checkboxView);

    View summaryView = view.findViewById(android.R.id.summary);
    syncSummaryView(summaryView);
}

From source file:com.miuhouse.yourcompany.student.view.widget.date.datepicker.DayPickerView.java

public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(SUtils.createThemeWrapper(context, R.attr.sublimePickerStyle, R.style.SublimePickerStyleLight,
            defStyleAttr, R.style.DayPickerViewStyle), attrs);

    context = getContext();// w ww  .j a v a  2s.c o  m

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DayPickerView, defStyleAttr,
            R.style.DayPickerViewStyle);

    final int monthTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spMonthTextAppearance,
            R.style.SPMonthLabelTextAppearance);
    // verified
    final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spWeekDayTextAppearance,
            R.style.SPWeekDayLabelTextAppearance);
    // verified
    final int dayTextAppearanceResId = a.getResourceId(R.styleable.DayPickerView_spDateTextAppearance,
            R.style.SPDayTextAppearance);

    final ColorStateList daySelectorColor = a.getColorStateList(R.styleable.DayPickerView_spDaySelectorColor);

    a.recycle();

    if (Config.DEBUG) {
        Log.i(TAG, "MDayPickerView_spmMonthTextAppearance: " + monthTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmWeekDayTextAppearance: " + dayOfWeekTextAppearanceResId);
        Log.i(TAG, "MDayPickerView_spmDateTextAppearance: " + dayTextAppearanceResId);
    }

    String titleFormat;
    final Resources res = getContext().getResources();

    final Locale locale = res.getConfiguration().locale;
    if (SUtils.isApi_18_OrHigher()) {
        titleFormat = DateFormat.getBestDateTimePattern(locale, "MM");
    } else {
        titleFormat = DateTimePatternHelper.getBestDateTimePattern(locale, DateTimePatternHelper.PATTERN_MMMMy);
    }

    mTitleFormatter = new SimpleDateFormat(titleFormat, locale);

    // Set up adapter.
    mAdapter = new DayPickerPagerAdapter(context, R.layout.date_picker_month_item, R.id.month_view, this);
    mAdapter.setMonthTextAppearance(monthTextAppearanceResId);
    mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId);
    mAdapter.setDayTextAppearance(dayTextAppearanceResId);
    mAdapter.setDaySelectorColor(daySelectorColor);

    final LayoutInflater inflater = LayoutInflater.from(context);

    int layoutIdToUse, viewPagerIdToUse;

    if (getTag() != null && getTag() instanceof String
            && getResources().getString(R.string.recurrence_end_date_picker_tag).equals(getTag())) {
        layoutIdToUse = R.layout.day_picker_content_redp;
        viewPagerIdToUse = R.id.redp_view_pager;
    } else {
        layoutIdToUse = R.layout.day_picker_content_sdp;
        viewPagerIdToUse = R.id.sdp_view_pager;
    }

    inflater.inflate(layoutIdToUse, this, true);

    OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            int direction = -1;
            if (v == mPrevButton) {
                direction = -1;
            } else if (v == mNextButton) {
                direction = 1;
            } else if (v == tvReset) {
                if (mOnResetClickListener != null)
                    mOnResetClickListener.onResetClick();
                //                    return;
            }

            // Animation is expensive for accessibility services since it sends
            // lots of scroll and content change events.
            final boolean animate = !mAccessibilityManager.isEnabled();

            // ViewPager clamps input values, so we don't need to worry
            // about passing invalid indices.
            final int nextItem = mViewPager.getCurrentItem() + direction;
            mViewPager.setCurrentItem(nextItem, animate);
        }
    };

    mPrevButton = (TextView) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(onClickListener);

    mNextButton = (TextView) findViewById(R.id.next);
    mNextButton.setOnClickListener(onClickListener);
    mPrevButton.setText(getTitle());
    mNextButton.setText(getNextTitle());
    tvReset = (TextView) findViewById(R.id.tv_reset);
    tvReset.setOnClickListener(onClickListener);
    ViewPager.OnPageChangeListener onPageChangedListener = new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            final float alpha = Math.abs(0.5f - positionOffset) * 2.0f;
            //                mPrevButton.setAlpha(alpha);
            //                mNextButton.setAlpha(alpha);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageSelected(int position) {
            Log.i("TAG", "position=" + position);
            mOnPageClickListener.onPageSelected(position);
            updateButtonVisibility(position);
        }
    };

    mViewPager = (DayPickerViewPager) findViewById(viewPagerIdToUse);
    mViewPager.setAdapter(mAdapter);

    mViewPager.addOnPageChangeListener(onPageChangedListener);

    // Proxy the month text color into the previous and next buttons.
    if (monthTextAppearanceResId != 0) {
        final TypedArray ta = context.obtainStyledAttributes(null, ATTRS_TEXT_COLOR, 0,
                monthTextAppearanceResId);
        final ColorStateList monthColor = ta.getColorStateList(0);

        ta.recycle();
    }

    // Proxy selection callbacks to our own listener.
    mAdapter.setDaySelectionEventListener(new DayPickerPagerAdapter.DaySelectionEventListener() {
        @Override
        public boolean onDaySelected(SimpleMonthView view, Calendar day) {
            if (mProxyDaySelectionEventListener != null) {
                return mProxyDaySelectionEventListener.onDaySelected(view, day);
            }
            return true;
        }

        @Override
        public void onDateRangeSelectionStarted(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionStarted(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionEnded(@Nullable SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionEnded(selectedDate);
            }
        }

        @Override
        public void onDateRangeSelectionUpdated(@NonNull SelectedDate selectedDate) {
            if (mProxyDaySelectionEventListener != null) {
                mProxyDaySelectionEventListener.onDateRangeSelectionUpdated(selectedDate);
            }
        }
    });
}

From source file:android.support.v7.widget.TooltipCompatHandler.java

@Override
public boolean onHover(View v, MotionEvent event) {
    if (mPopup != null && mFromTouch) {
        return false;
    }//from ww w.  j a v a2  s . c o  m
    AccessibilityManager manager = (AccessibilityManager) mAnchor.getContext()
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (manager.isEnabled() && manager.isTouchExplorationEnabled()) {
        return false;
    }
    switch (event.getAction()) {
    case MotionEvent.ACTION_HOVER_MOVE:
        if (mAnchor.isEnabled() && mPopup == null) {
            mAnchorX = (int) event.getX();
            mAnchorY = (int) event.getY();
            setPendingHandler(this);
        }
        break;
    case MotionEvent.ACTION_HOVER_EXIT:
        hide();
        break;
    }

    return false;
}