idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
26,300 | protected void configureDetailedDayView ( DetailedDayView newDetailedDayView , boolean trimTimeBounds ) { newDetailedDayView . getDayView ( ) . setStartTime ( LocalTime . MIN ) ; newDetailedDayView . getDayView ( ) . setEndTime ( LocalTime . MAX ) ; newDetailedDayView . getDayView ( ) . setEarlyLateHoursStrategy ( DayViewBase . EarlyLateHoursStrategy . HIDE ) ; newDetailedDayView . getDayView ( ) . setHoursLayoutStrategy ( DayViewBase . HoursLayoutStrategy . FIXED_HOUR_COUNT ) ; newDetailedDayView . getDayView ( ) . setVisibleHours ( 24 ) ; newDetailedDayView . getDayView ( ) . setTrimTimeBounds ( trimTimeBounds ) ; } | The idea of this method is to be able to change the default configuration of the detailed day view in the preview pane . | 177 | 24 |
26,301 | private DetailedWeekView createDetailedWeekView ( ) { DetailedWeekView newDetailedWeekView = new DetailedWeekView ( ) ; newDetailedWeekView . setShowScrollBar ( false ) ; newDetailedWeekView . layoutProperty ( ) . bind ( layoutProperty ( ) ) ; newDetailedWeekView . setEnableCurrentTimeMarker ( false ) ; newDetailedWeekView . showAllDayViewProperty ( ) . bind ( showAllDayEntriesProperty ( ) ) ; newDetailedWeekView . weekFieldsProperty ( ) . bind ( weekFieldsProperty ( ) ) ; newDetailedWeekView . setStartTime ( LocalTime . MIN ) ; newDetailedWeekView . setEndTime ( LocalTime . MAX ) ; newDetailedWeekView . setEarlyLateHoursStrategy ( DayViewBase . EarlyLateHoursStrategy . HIDE ) ; newDetailedWeekView . setHoursLayoutStrategy ( DayViewBase . HoursLayoutStrategy . FIXED_HOUR_COUNT ) ; newDetailedWeekView . setVisibleHours ( 24 ) ; newDetailedWeekView . addEventFilter ( MouseEvent . ANY , weakMouseHandler ) ; newDetailedWeekView . dateProperty ( ) . bind ( pageStartDateProperty ( ) ) ; configureDetailedWeekView ( newDetailedWeekView , true ) ; return newDetailedWeekView ; } | Default configuration for Detailed Week view in the preview Pane . | 280 | 13 |
26,302 | protected void configureDetailedWeekView ( DetailedWeekView newDetailedWeekView , boolean trimTimeBounds ) { newDetailedWeekView . getWeekView ( ) . setShowToday ( false ) ; newDetailedWeekView . getWeekView ( ) . setTrimTimeBounds ( trimTimeBounds ) ; } | The idea of this method is to be able to change the default configuration of the detailed week view in the preview pane . | 66 | 24 |
26,303 | protected MonthView createMonthView ( ) { MonthView newMonthView = new MonthView ( ) ; newMonthView . setShowToday ( false ) ; newMonthView . setShowCurrentWeek ( false ) ; newMonthView . weekFieldsProperty ( ) . bind ( weekFieldsProperty ( ) ) ; newMonthView . showFullDayEntriesProperty ( ) . bind ( showAllDayEntriesProperty ( ) ) ; newMonthView . showTimedEntriesProperty ( ) . bind ( showTimedEntriesProperty ( ) ) ; newMonthView . addEventFilter ( MouseEvent . ANY , weakMouseHandler ) ; newMonthView . dateProperty ( ) . bind ( pageStartDateProperty ( ) ) ; return newMonthView ; } | Default configuration for Month view in the preview Pane . | 158 | 11 |
26,304 | public final Calendar getCalendar ( ) { Calendar calendar = calendarSelector . getCalendar ( ) ; if ( calendar == null ) { calendar = entry . getCalendar ( ) ; } return calendar ; } | Returns the currently selected calendar . | 44 | 6 |
26,305 | public ZonedDateTime getStartZonedDateTime ( ) { if ( zonedStartDateTime == null ) { zonedStartDateTime = ZonedDateTime . of ( startDate , startTime , zoneId ) ; } return zonedStartDateTime ; } | A convenience method to retrieve a zoned date time based on the start date start time and time zone id . | 57 | 22 |
26,306 | public ZonedDateTime getEndZonedDateTime ( ) { if ( zonedEndDateTime == null ) { zonedEndDateTime = ZonedDateTime . of ( endDate , endTime , zoneId ) ; } return zonedEndDateTime ; } | A convenience method to retrieve a zoned date time based on the end date end time and time zone id . | 57 | 22 |
26,307 | public Interval withTimes ( LocalTime startTime , LocalTime endTime ) { requireNonNull ( startTime ) ; requireNonNull ( endTime ) ; return new Interval ( this . startDate , startTime , this . endDate , endTime , this . zoneId ) ; } | Returns a new interval based on this interval but with a different start and end time . | 61 | 17 |
26,308 | public Interval withStartDate ( LocalDate date ) { requireNonNull ( date ) ; return new Interval ( date , startTime , endDate , endTime , zoneId ) ; } | Returns a new interval based on this interval but with a different start date . | 40 | 15 |
26,309 | public Interval withEndDate ( LocalDate date ) { requireNonNull ( date ) ; return new Interval ( startDate , startTime , date , endTime , zoneId ) ; } | Returns a new interval based on this interval but with a different end date . | 40 | 15 |
26,310 | public Interval withStartTime ( LocalTime time ) { requireNonNull ( time ) ; return new Interval ( startDate , time , endDate , endTime , zoneId ) ; } | Returns a new interval based on this interval but with a different start time . | 40 | 15 |
26,311 | public Interval withStartDateTime ( LocalDateTime dateTime ) { requireNonNull ( dateTime ) ; return new Interval ( dateTime . toLocalDate ( ) , dateTime . toLocalTime ( ) , endDate , endTime ) ; } | Returns a new interval based on this interval but with a different start date and time . | 54 | 17 |
26,312 | public Interval withEndTime ( LocalTime time ) { requireNonNull ( time ) ; return new Interval ( startDate , startTime , endDate , time , zoneId ) ; } | Returns a new interval based on this interval but with a different end time . | 40 | 15 |
26,313 | public Interval withEndDateTime ( LocalDateTime dateTime ) { requireNonNull ( dateTime ) ; return new Interval ( startDate , startTime , dateTime . toLocalDate ( ) , dateTime . toLocalTime ( ) ) ; } | Returns a new interval based on this interval but with a different end date and time . | 54 | 17 |
26,314 | public Interval withZoneId ( ZoneId zone ) { requireNonNull ( zone ) ; return new Interval ( startDate , startTime , endDate , endTime , zone ) ; } | Returns a new interval based on this interval but with a different time zone id . | 40 | 16 |
26,315 | public LocalDateTime getStartDateTime ( ) { if ( startDateTime == null ) { startDateTime = LocalDateTime . of ( getStartDate ( ) , getStartTime ( ) ) ; } return startDateTime ; } | Utility method to get the local start date time . This method combines the start date and the start time to create a date time object . | 50 | 28 |
26,316 | public LocalDateTime getEndDateTime ( ) { if ( endDateTime == null ) { endDateTime = LocalDateTime . of ( getEndDate ( ) , getEndTime ( ) ) ; } return endDateTime ; } | Utility method to get the local end date time . This method combines the end date and the end time to create a date time object . | 50 | 28 |
26,317 | public static < T > Predicate < T > not ( Predicate < ? super T > predicate ) { assert null != predicate ; return new NotPredicate < T > ( predicate ) ; } | Returns a Predicate that evaluates to true iff the given Predicate evaluates to false . | 40 | 18 |
26,318 | protected void parse ( String icalString , IcalSchema schema ) throws ParseException { String paramText ; String content ; { String unfolded = IcalParseUtil . unfoldIcal ( icalString ) ; Matcher m = CONTENT_LINE_RE . matcher ( unfolded ) ; if ( ! m . matches ( ) ) { schema . badContent ( icalString ) ; } setName ( m . group ( 1 ) . toUpperCase ( ) ) ; paramText = m . group ( 2 ) ; if ( null == paramText ) { paramText = "" ; } content = m . group ( 3 ) ; } // parse parameters Map < String , String > params = new HashMap < String , String > ( ) ; String rest = paramText ; while ( ! "" . equals ( rest ) ) { Matcher m = PARAM_RE . matcher ( rest ) ; if ( ! m . find ( ) ) { schema . badPart ( rest , null ) ; } rest = rest . substring ( m . end ( 0 ) ) ; String k = m . group ( 1 ) . toUpperCase ( ) ; String v = m . group ( 2 ) ; if ( null == v ) { v = m . group ( 3 ) ; } if ( params . containsKey ( k ) ) { schema . dupePart ( k ) ; } params . put ( k , v ) ; } // parse the content and individual attribute values schema . applyObjectSchema ( this . name , params , content , this ) ; } | parse the ical object from the given ical content using the given schema . Modifies the current object in place . | 329 | 24 |
26,319 | public Map < String , String > getExtParams ( ) { if ( null == extParams ) { extParams = new LinkedHashMap < String , String > ( ) ; } return extParams ; } | a map of any extension parameters such as the X - FOO = BAR in RRULE ; X - FOO = BAR . Maps the parameter name X - FOO to the parameter value BAR . | 47 | 40 |
26,320 | public DateValue next ( ) { if ( null == this . pendingUtc_ ) { this . fetchNext ( ) ; } DateValue next = this . pendingUtc_ ; this . pendingUtc_ = null ; return next ; } | fetch and return the next date in this recurrence . | 51 | 12 |
26,321 | public DateTimeValue toDateTime ( ) { normalize ( ) ; return new DateTimeValueImpl ( year , month , day , hour , minute , second ) ; } | produces a normalized date time using zero for the time fields if none were provided . | 36 | 17 |
26,322 | public final ObservableMap < Object , Object > getProperties ( ) { if ( properties == null ) { properties = FXCollections . observableMap ( new HashMap <> ( ) ) ; MapChangeListener < ? super Object , ? super Object > changeListener = change -> { if ( change . getKey ( ) . equals ( "com.calendarfx.recurrence.source" ) ) { //$NON-NLS-1$ if ( change . getValueAdded ( ) != null ) { @ SuppressWarnings ( "unchecked" ) Entry < T > source = ( Entry < T > ) change . getValueAdded ( ) ; // lookup of property first to instantiate recurrenceSourceProperty ( ) ; recurrenceSource . set ( source ) ; } } else if ( change . getKey ( ) . equals ( "com.calendarfx.recurrence.id" ) ) { //$NON-NLS-1$ if ( change . getValueAdded ( ) != null ) { setRecurrenceId ( ( String ) change . getValueAdded ( ) ) ; } } } ; properties . addListener ( changeListener ) ; } return properties ; } | Returns an observable map of properties on this entry for use primarily by application developers . | 251 | 16 |
26,323 | public final void changeStartDate ( LocalDate date , boolean keepDuration ) { requireNonNull ( date ) ; Interval interval = getInterval ( ) ; LocalDateTime newStartDateTime = getStartAsLocalDateTime ( ) . with ( date ) ; LocalDateTime endDateTime = getEndAsLocalDateTime ( ) ; if ( keepDuration ) { endDateTime = newStartDateTime . plus ( getDuration ( ) ) ; setInterval ( newStartDateTime , endDateTime , getZoneId ( ) ) ; } else { /* * We might have a problem if the new start time is AFTER the current end time. */ if ( newStartDateTime . isAfter ( endDateTime ) ) { interval = interval . withEndDateTime ( newStartDateTime . plus ( interval . getDuration ( ) ) ) ; } setInterval ( interval . withStartDate ( date ) ) ; } } | Changes the start date of the entry interval . | 195 | 9 |
26,324 | public final void changeStartTime ( LocalTime time , boolean keepDuration ) { requireNonNull ( time ) ; Interval interval = getInterval ( ) ; LocalDateTime newStartDateTime = getStartAsLocalDateTime ( ) . with ( time ) ; LocalDateTime endDateTime = getEndAsLocalDateTime ( ) ; if ( keepDuration ) { endDateTime = newStartDateTime . plus ( getDuration ( ) ) ; setInterval ( newStartDateTime , endDateTime ) ; } else { /* * We might have a problem if the new start time is AFTER the current end time. */ if ( newStartDateTime . isAfter ( endDateTime . minus ( getMinimumDuration ( ) ) ) ) { interval = interval . withEndDateTime ( newStartDateTime . plus ( getMinimumDuration ( ) ) ) ; } setInterval ( interval . withStartTime ( time ) ) ; } } | Changes the start time of the entry interval . | 197 | 9 |
26,325 | public final void changeEndDate ( LocalDate date , boolean keepDuration ) { requireNonNull ( date ) ; Interval interval = getInterval ( ) ; LocalDateTime newEndDateTime = getEndAsLocalDateTime ( ) . with ( date ) ; LocalDateTime startDateTime = getStartAsLocalDateTime ( ) ; if ( keepDuration ) { startDateTime = newEndDateTime . minus ( getDuration ( ) ) ; setInterval ( startDateTime , newEndDateTime , getZoneId ( ) ) ; } else { /* * We might have a problem if the new end time is BEFORE the current start time. */ if ( newEndDateTime . isBefore ( startDateTime ) ) { interval = interval . withStartDateTime ( newEndDateTime . minus ( interval . getDuration ( ) ) ) ; } setInterval ( interval . withEndDate ( date ) ) ; } } | Changes the end date of the entry interval . | 195 | 9 |
26,326 | public final void changeEndTime ( LocalTime time , boolean keepDuration ) { requireNonNull ( time ) ; Interval interval = getInterval ( ) ; LocalDateTime newEndDateTime = getEndAsLocalDateTime ( ) . with ( time ) ; LocalDateTime startDateTime = getStartAsLocalDateTime ( ) ; if ( keepDuration ) { startDateTime = newEndDateTime . minus ( getDuration ( ) ) ; setInterval ( startDateTime , newEndDateTime , getZoneId ( ) ) ; } else { /* * We might have a problem if the new end time is BEFORE the current start time. */ if ( newEndDateTime . isBefore ( startDateTime . plus ( getMinimumDuration ( ) ) ) ) { interval = interval . withStartDateTime ( newEndDateTime . minus ( getMinimumDuration ( ) ) ) ; } setInterval ( interval . withEndTime ( time ) ) ; } } | Changes the end time of the entry interval . | 203 | 9 |
26,327 | public final boolean isRecurring ( ) { return recurrenceRule != null && ! ( recurrenceRule . get ( ) == null ) && ! recurrenceRule . get ( ) . trim ( ) . equals ( "" ) ; //$NON-NLS-1$ } | Determines if the entry describes a recurring event . | 58 | 11 |
26,328 | public final ReadOnlyObjectProperty < LocalDate > recurrenceEndProperty ( ) { if ( recurrenceEnd == null ) { recurrenceEnd = new ReadOnlyObjectWrapper <> ( this , "recurrenceEnd" , _recurrenceEnd ) ; //$NON-NLS-1$ } return recurrenceEnd . getReadOnlyProperty ( ) ; } | The property used to store the end time of the recurrence rule . | 77 | 14 |
26,329 | public final void setId ( String id ) { requireNonNull ( id ) ; if ( MODEL . isLoggable ( FINE ) ) { MODEL . fine ( "setting id to " + id ) ; //$NON-NLS-1$ } this . id = id ; } | Assigns a new ID to the entry . IDs do not have to be unique . If several entries share the same ID it means that they are representing the same real world entry . An entry spanning multiple days will be shown via several entries in the month view . Clicking on one of them will select all of them as they all represent the same thing . | 64 | 72 |
26,330 | public final ObjectProperty < T > userObjectProperty ( ) { if ( userObject == null ) { userObject = new SimpleObjectProperty < T > ( this , "userObject" ) { //$NON-NLS-1$ @ Override public void set ( T newObject ) { T oldUserObject = get ( ) ; // We do not use .equals() here to allow to reset the object even if is "looks" the same e.g. if it // has some .equals() method implemented which just compares an id/business key. if ( oldUserObject != newObject ) { super . set ( newObject ) ; Calendar calendar = getCalendar ( ) ; if ( calendar != null ) { calendar . fireEvent ( new CalendarEvent ( CalendarEvent . ENTRY_USER_OBJECT_CHANGED , calendar , Entry . this , oldUserObject ) ) ; } } } } ; } return userObject ; } | A property used to store a reference to an optional user object . The user object is usually the reason why the entry was created . | 201 | 26 |
26,331 | public final ReadOnlyObjectProperty < ZoneId > zoneIdProperty ( ) { if ( zoneId == null ) { zoneId = new ReadOnlyObjectWrapper <> ( this , "zoneId" , getInterval ( ) . getZoneId ( ) ) ; //$NON-NLS-1$ } return zoneId . getReadOnlyProperty ( ) ; } | A property used to store a time zone for the entry . The time zone is needed for properly interpreting the dates and times of the entry . | 79 | 28 |
26,332 | public final StringProperty locationProperty ( ) { if ( location == null ) { location = new SimpleStringProperty ( null , "location" ) { //$NON-NLS-1$ @ Override public void set ( String newLocation ) { String oldLocation = get ( ) ; if ( ! Util . equals ( oldLocation , newLocation ) ) { super . set ( newLocation ) ; Calendar calendar = getCalendar ( ) ; if ( calendar != null ) { calendar . fireEvent ( new CalendarEvent ( CalendarEvent . ENTRY_LOCATION_CHANGED , calendar , Entry . this , oldLocation ) ) ; } } } } ; } return location ; } | A property used to store a free - text location specification for the given entry . This could be as simple as New York or a full address as in 128 Madison Avenue New York USA . | 143 | 37 |
26,333 | public final boolean isShowing ( LocalDate startDate , LocalDate endDate , ZoneId zoneId ) { return isShowing ( this , startDate , endDate , zoneId ) ; } | Checks whether the entry will be visible within the given start and end dates . This method takes recurrence into consideration and will return true if any recurrence of this entry will be displayed inside the given time interval . | 41 | 43 |
26,334 | public void setSize ( int width , int height ) { final float r = width * 0.75f / SIN ; final float y = COS * r ; final float h = r - y ; final float or = height * 0.75f / SIN ; final float oy = COS * or ; final float oh = or - oy ; mRadius = r ; mBaseGlowScale = h > 0 ? Math . min ( oh / h , 1.f ) : 1.f ; mBounds . set ( mBounds . left , mBounds . top , width , ( int ) Math . min ( height , h ) ) ; } | Set the size of this edge effect in pixels . | 141 | 10 |
26,335 | private MenuItem createNewMenuItem ( int group , int id , int categoryOrder , int ordering , CharSequence title , int defaultShowAsAction ) { return new MenuItem ( group , id , categoryOrder , title ) ; } | Layoutlib overrides this method to return its custom implementation of MenuItem | 49 | 14 |
26,336 | private static int getOrdering ( int categoryOrder ) { final int index = ( categoryOrder & CATEGORY_MASK ) >> CATEGORY_SHIFT ; if ( index < 0 || index >= sCategoryToOrder . length ) { throw new IllegalArgumentException ( "order does not contain a valid category." ) ; } return ( sCategoryToOrder [ index ] << CATEGORY_SHIFT ) | ( categoryOrder & USER_MASK ) ; } | Returns the ordering across all items . This will grab the category from the upper bits find out how to order the category with respect to other categories and combine it with the lower bits . | 103 | 36 |
26,337 | public Drawable createFromStream ( InputStream is , String srcName ) { return createFromResourceStream ( null , is , srcName ) ; } | Create a drawable from an inputstream | 31 | 8 |
26,338 | private void drawShape ( Canvas canvas , Paint paint , Path path , ShapeAppearanceModel shapeAppearanceModel , RectF bounds ) { if ( shapeAppearanceModel . isRoundRect ( ) ) { float cornerSize = shapeAppearanceModel . getTopRightCorner ( ) . getCornerSize ( ) ; canvas . drawRoundRect ( bounds , cornerSize , cornerSize , paint ) ; } else { canvas . drawPath ( path , paint ) ; } } | Draw the path or try to draw a round rect if possible . | 95 | 13 |
26,339 | private void drawCompatShadow ( Canvas canvas ) { // Draw the fake shadow for each of the corners and edges. for ( int index = 0 ; index < 4 ; index ++ ) { cornerShadowOperation [ index ] . draw ( shadowRenderer , drawableState . shadowCompatRadius , canvas ) ; edgeShadowOperation [ index ] . draw ( shadowRenderer , drawableState . shadowCompatRadius , canvas ) ; } } | Draws a shadow using gradients which can be used in the cases where native elevation can t . This draws the shadow in multiple parts . It draws the shadow for each corner and edge separately . Then it fills in the center space with the main shadow colored paint . If there is no shadow offset this will skip the drawing of the center filled shadow since that will be completely covered by the shape . | 93 | 79 |
26,340 | public void setButtonDrawable ( Drawable d ) { if ( drawable != d ) { if ( drawable != null ) { drawable . setCallback ( null ) ; unscheduleDrawable ( drawable ) ; } drawable = d ; if ( d != null ) { d . setCallback ( this ) ; //d.setLayoutDirection(getLayoutDirection()); if ( d . isStateful ( ) ) { d . setState ( getDrawableState ( ) ) ; } d . setVisible ( getVisibility ( ) == VISIBLE , false ) ; setMinHeight ( d . getIntrinsicHeight ( ) ) ; updateButtonTint ( ) ; } } } | Set the button graphic to a given Drawable | 150 | 9 |
26,341 | public void addState ( int [ ] specs , Animator animation , Animator . AnimatorListener listener ) { Tuple tuple = new Tuple ( specs , animation , listener ) ; animation . addListener ( mAnimationListener ) ; mTuples . add ( tuple ) ; } | Associates the given Animation with the provided drawable state specs so that it will be run when the View s drawable state matches the specs . | 58 | 30 |
26,342 | public void setState ( int [ ] state ) { Tuple match = null ; final int count = mTuples . size ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final Tuple tuple = mTuples . get ( i ) ; if ( StateSet . stateSetMatches ( tuple . mSpecs , state ) ) { match = tuple ; break ; } } if ( match == lastMatch ) { return ; } if ( lastMatch != null ) { cancel ( ) ; } lastMatch = match ; View view = ( View ) viewRef . get ( ) ; if ( match != null && view != null && view . getVisibility ( ) == View . VISIBLE ) { start ( match ) ; } } | Called by View | 159 | 4 |
26,343 | public static void applyTheme ( Drawable d , Resources . Theme t ) { IMPL . applyTheme ( d , t ) ; } | Applies the specified theme to this Drawable and its children . | 28 | 13 |
26,344 | public void adjustChildren ( int widthMeasureSpec , int heightMeasureSpec ) { if ( Log . isLoggable ( TAG , Log . DEBUG ) ) { Log . d ( TAG , "adjustChildren: " + mHost + " widthMeasureSpec: " + View . MeasureSpec . toString ( widthMeasureSpec ) + " heightMeasureSpec: " + View . MeasureSpec . toString ( heightMeasureSpec ) ) ; } int widthHint = View . MeasureSpec . getSize ( widthMeasureSpec ) ; int heightHint = View . MeasureSpec . getSize ( heightMeasureSpec ) ; for ( int i = 0 , N = mHost . getChildCount ( ) ; i < N ; i ++ ) { View view = mHost . getChildAt ( i ) ; ViewGroup . LayoutParams params = view . getLayoutParams ( ) ; if ( Log . isLoggable ( TAG , Log . DEBUG ) ) { Log . d ( TAG , "should adjust " + view + " " + params ) ; } if ( params instanceof PercentLayoutParams ) { PercentLayoutInfo info = ( ( PercentLayoutParams ) params ) . getPercentLayoutInfo ( ) ; if ( Log . isLoggable ( TAG , Log . DEBUG ) ) { Log . d ( TAG , "using " + info ) ; } if ( info != null ) { if ( params instanceof ViewGroup . MarginLayoutParams ) { info . fillMarginLayoutParams ( ( ViewGroup . MarginLayoutParams ) params , widthHint , heightHint ) ; } else { info . fillLayoutParams ( params , widthHint , heightHint ) ; } } } } } | Iterates over children and changes their width and height to one calculated from percentage values . | 361 | 17 |
26,345 | public final void enter ( boolean fast ) { cancel ( ) ; mSoftwareAnimator = createSoftwareEnter ( fast ) ; if ( mSoftwareAnimator != null ) { mSoftwareAnimator . start ( ) ; } } | Starts a ripple enter animation . | 46 | 7 |
26,346 | public void lineTo ( float x , float y ) { PathLineOperation operation = new PathLineOperation ( ) ; operation . x = x ; operation . y = y ; operations . add ( operation ) ; LineShadowOperation shadowOperation = new LineShadowOperation ( operation , endX , endY ) ; // The previous endX and endY is the starting point for this shadow operation. addShadowCompatOperation ( shadowOperation , ANGLE_UP + shadowOperation . getAngle ( ) , ANGLE_UP + shadowOperation . getAngle ( ) ) ; endX = x ; endY = y ; } | Add a line to the ShapePath . | 128 | 8 |
26,347 | public void quadToPoint ( float controlX , float controlY , float toX , float toY ) { PathQuadOperation operation = new PathQuadOperation ( ) ; operation . controlX = controlX ; operation . controlY = controlY ; operation . endX = toX ; operation . endY = toY ; operations . add ( operation ) ; endX = toX ; endY = toY ; } | Add a quad to the ShapePath . | 89 | 8 |
26,348 | public void addArc ( float left , float top , float right , float bottom , float startAngle , float sweepAngle ) { PathArcOperation operation = new PathArcOperation ( left , top , right , bottom ) ; operation . startAngle = startAngle ; operation . sweepAngle = sweepAngle ; operations . add ( operation ) ; ArcShadowOperation arcShadowOperation = new ArcShadowOperation ( operation ) ; float endAngle = startAngle + sweepAngle ; // Flip the startAngle and endAngle when drawing the shadow inside the bounds. They represent // the angles from the center of the circle to the start or end of the arc, respectively. When // the shadow is drawn inside the arc, it is going the opposite direction. boolean drawShadowInsideBounds = sweepAngle < 0 ; addShadowCompatOperation ( arcShadowOperation , drawShadowInsideBounds ? ( 180 + startAngle ) % 360 : startAngle , drawShadowInsideBounds ? ( 180 + endAngle ) % 360 : endAngle ) ; endX = ( left + right ) * 0.5f + ( right - left ) / 2 * ( float ) Math . cos ( Math . toRadians ( startAngle + sweepAngle ) ) ; endY = ( top + bottom ) * 0.5f + ( bottom - top ) / 2 * ( float ) Math . sin ( Math . toRadians ( startAngle + sweepAngle ) ) ; } | Add an arc to the ShapePath . | 313 | 8 |
26,349 | ShadowCompatOperation createShadowCompatOperation ( final Matrix transform ) { // If the shadowCompatOperations don't end on the desired endShadowAngle, add an arc to do so. addConnectingShadowIfNecessary ( endShadowAngle ) ; final List < ShadowCompatOperation > operations = new ArrayList <> ( shadowCompatOperations ) ; return new ShadowCompatOperation ( ) { @ Override public void draw ( Matrix matrix , ShadowRenderer shadowRenderer , int shadowElevation , Canvas canvas ) { for ( ShadowCompatOperation op : operations ) { op . draw ( transform , shadowRenderer , shadowElevation , canvas ) ; } } } ; } | Creates a ShadowCompatOperation to draw compatibility shadow under the matrix transform for the whole path defined by this ShapePath . | 147 | 24 |
26,350 | private void setTargetDensity ( DisplayMetrics metrics ) { if ( mDensity != metrics . density ) { mDensity = metrics . density ; invalidateSelf ( false ) ; } } | Set the density at which this drawable will be rendered . | 41 | 12 |
26,351 | private void tryBackgroundEnter ( boolean focused ) { if ( mBackground == null ) { mBackground = new RippleBackground ( this , mHotspotBounds ) ; } mBackground . setup ( mState . mMaxRadius , mDensity ) ; mBackground . enter ( focused ) ; } | Creates an active hotspot at the specified location . | 63 | 11 |
26,352 | private void tryRippleEnter ( ) { if ( mExitingRipplesCount >= MAX_RIPPLES ) { // This should never happen unless the user is tapping like a maniac // or there is a bug that's preventing ripples from being removed. return ; } if ( mRipple == null ) { final float x ; final float y ; if ( mHasPending ) { mHasPending = false ; x = mPendingX ; y = mPendingY ; } else { x = mHotspotBounds . exactCenterX ( ) ; y = mHotspotBounds . exactCenterY ( ) ; } final boolean isBounded = isBounded ( ) ; mRipple = new RippleForeground ( this , mHotspotBounds , x , y , isBounded ) ; } mRipple . setup ( mState . mMaxRadius , mDensity ) ; mRipple . enter ( false ) ; } | Attempts to start an enter animation for the active hotspot . Fails if there are too many animating ripples . | 205 | 24 |
26,353 | private void tryRippleExit ( ) { if ( mRipple != null ) { if ( mExitingRipples == null ) { mExitingRipples = new RippleForeground [ MAX_RIPPLES ] ; } mExitingRipples [ mExitingRipplesCount ++ ] = mRipple ; mRipple . exit ( ) ; mRipple = null ; } } | Attempts to start an exit animation for the active hotspot . Fails if there is no active hotspot . | 83 | 22 |
26,354 | private void clearHotspots ( ) { if ( mRipple != null ) { mRipple . end ( ) ; mRipple = null ; mRippleActive = false ; } if ( mBackground != null ) { mBackground . end ( ) ; mBackground = null ; mBackgroundActive = false ; } cancelExitingRipples ( ) ; } | Cancels and removes the active ripple all exiting ripples and the background . Nothing will be drawn after this method is called . | 76 | 26 |
26,355 | private void onHotspotBoundsChanged ( ) { final int count = mExitingRipplesCount ; final RippleForeground [ ] ripples = mExitingRipples ; for ( int i = 0 ; i < count ; i ++ ) { ripples [ i ] . onHotspotBoundsChanged ( ) ; } if ( mRipple != null ) { mRipple . onHotspotBoundsChanged ( ) ; } if ( mBackground != null ) { mBackground . onHotspotBoundsChanged ( ) ; } } | Notifies all the animating ripples that the hotspot bounds have changed . | 117 | 16 |
26,356 | public void drawEdgeShadow ( Canvas canvas , Matrix transform , RectF bounds , int elevation ) { bounds . bottom += elevation ; bounds . offset ( 0 , - elevation ) ; edgeColors [ 0 ] = shadowEndColor ; edgeColors [ 1 ] = shadowMiddleColor ; edgeColors [ 2 ] = shadowStartColor ; edgeShadowPaint . setShader ( new LinearGradient ( bounds . left , bounds . top , bounds . left , bounds . bottom , edgeColors , edgePositions , Shader . TileMode . CLAMP ) ) ; canvas . save ( ) ; canvas . concat ( transform ) ; canvas . drawRect ( bounds , edgeShadowPaint ) ; canvas . restore ( ) ; } | Draws an edge shadow on the canvas in the current bounds with the matrix transform applied . | 153 | 18 |
26,357 | public void drawCornerShadow ( Canvas canvas , Matrix matrix , RectF bounds , int elevation , float startAngle , float sweepAngle ) { Path arcBounds = scratch ; // Calculate the arc bounds to prevent drawing shadow in the same part of the arc. arcBounds . rewind ( ) ; arcBounds . moveTo ( bounds . centerX ( ) , bounds . centerY ( ) ) ; arcBounds . arcTo ( bounds , startAngle , sweepAngle ) ; arcBounds . close ( ) ; bounds . inset ( - elevation , - elevation ) ; cornerColors [ 0 ] = 0 ; cornerColors [ 1 ] = shadowStartColor ; cornerColors [ 2 ] = shadowMiddleColor ; cornerColors [ 3 ] = shadowEndColor ; float startRatio = 1f - ( elevation / ( bounds . width ( ) / 2f ) ) ; float midRatio = startRatio + ( ( 1f - startRatio ) / 2f ) ; cornerPositions [ 1 ] = startRatio ; cornerPositions [ 2 ] = midRatio ; cornerShadowPaint . setShader ( new RadialGradient ( bounds . centerX ( ) , bounds . centerY ( ) , bounds . width ( ) / 2 , cornerColors , cornerPositions , Shader . TileMode . CLAMP ) ) ; // TODO: handle oval bounds by scaling the canvas. canvas . save ( ) ; canvas . concat ( matrix ) ; cornerShadowPaint . setStyle ( Paint . Style . STROKE ) ; cornerShadowPaint . setStrokeWidth ( elevation * 2 ) ; canvas . drawArc ( bounds , startAngle , sweepAngle , false , cornerShadowPaint ) ; canvas . restore ( ) ; } | Draws a corner shadow on the canvas in the current bounds with the matrix transform applied . | 381 | 18 |
26,358 | public void performCompletion ( String s ) { int selStart = getSelectionStart ( ) ; int selEnd = getSelectionEnd ( ) ; if ( selStart != selEnd ) return ; Editable text = getText ( ) ; HintSpan [ ] spans = text . getSpans ( 0 , length ( ) , HintSpan . class ) ; if ( spans . length > 1 ) throw new IllegalStateException ( "more than one HintSpan" ) ; Word word = getCurrentWord ( ) ; if ( word == null ) throw new IllegalStateException ( "no word to complete" ) ; autoCompleting = true ; //for (HintSpan span : spans) // text.delete(text.getSpanStart(span), text.getSpanEnd(span)); text . delete ( selStart , selStart + word . postCursor . length ( ) ) ; text . delete ( selStart - word . preCursor . length ( ) , selStart ) ; text . insert ( selStart - word . preCursor . length ( ) , s ) ; setSelection ( selStart - word . preCursor . length ( ) + s . length ( ) ) ; fireOnFilterEvent ( null ) ; super . setImeOptions ( prevOptions ) ; autoCompleting = false ; } | Replaces the current word with s . Used by Adapter to set the selected item as text . | 295 | 19 |
26,359 | public Iterator iterator ( ) { // remove garbage collected elements processQueue ( ) ; // get an iterator of the superclass WeakHashSet final Iterator i = super . iterator ( ) ; return new Iterator ( ) { public boolean hasNext ( ) { return i . hasNext ( ) ; } public Object next ( ) { // unwrap the element return getReferenceObject ( ( WeakReference ) i . next ( ) ) ; } public void remove ( ) { // remove the element from the HashSet i . remove ( ) ; } } ; } | Returns an iterator over the elements in this set . The elements are returned in no particular order . | 114 | 19 |
26,360 | public void inflate ( Resources r , XmlPullParser parser , AttributeSet attrs , Resources . Theme theme ) throws XmlPullParserException , IOException { } | Inflate this Drawable from an XML resource optionally styled by a theme . | 36 | 16 |
26,361 | public void getBounds ( Rect bounds ) { final int outerX = ( int ) mTargetX ; final int outerY = ( int ) mTargetY ; final int r = ( int ) mTargetRadius + 1 ; bounds . set ( outerX - r , outerY - r , outerX + r , outerY + r ) ; } | Returns the maximum bounds of the ripple relative to the ripple center . | 74 | 13 |
26,362 | private void computeBoundedTargetValues ( ) { mTargetX = ( mClampedStartingX - mBounds . exactCenterX ( ) ) * .7f ; mTargetY = ( mClampedStartingY - mBounds . exactCenterY ( ) ) * .7f ; mTargetRadius = mBoundedRadius ; } | Compute target values that are dependent on bounding . | 74 | 11 |
26,363 | private void clampStartingPosition ( ) { final float cX = mBounds . exactCenterX ( ) ; final float cY = mBounds . exactCenterY ( ) ; final float dX = mStartingX - cX ; final float dY = mStartingY - cY ; final float r = mTargetRadius ; if ( dX * dX + dY * dY > r * r ) { // Point is outside the circle, clamp to the perimeter. final double angle = Math . atan2 ( dY , dX ) ; mClampedStartingX = cX + ( float ) ( Math . cos ( angle ) * r ) ; mClampedStartingY = cY + ( float ) ( Math . sin ( angle ) * r ) ; } else { mClampedStartingX = mStartingX ; mClampedStartingY = mStartingY ; } } | Clamps the starting position to fit within the ripple bounds . | 190 | 12 |
26,364 | public void setAllCorners ( CornerTreatment cornerTreatment ) { topLeftCorner = cornerTreatment . clone ( ) ; topRightCorner = cornerTreatment . clone ( ) ; bottomRightCorner = cornerTreatment . clone ( ) ; bottomLeftCorner = cornerTreatment . clone ( ) ; } | Sets all corner treatments . | 68 | 6 |
26,365 | public void setAllEdges ( EdgeTreatment edgeTreatment ) { leftEdge = edgeTreatment . clone ( ) ; topEdge = edgeTreatment . clone ( ) ; rightEdge = edgeTreatment . clone ( ) ; bottomEdge = edgeTreatment . clone ( ) ; } | Sets all edge treatments . | 60 | 6 |
26,366 | public void setCornerTreatments ( CornerTreatment topLeftCorner , CornerTreatment topRightCorner , CornerTreatment bottomRightCorner , CornerTreatment bottomLeftCorner ) { this . topLeftCorner = topLeftCorner ; this . topRightCorner = topRightCorner ; this . bottomRightCorner = bottomRightCorner ; this . bottomLeftCorner = bottomLeftCorner ; } | Sets corner treatments . | 91 | 5 |
26,367 | public void setEdgeTreatments ( EdgeTreatment leftEdge , EdgeTreatment topEdge , EdgeTreatment rightEdge , EdgeTreatment bottomEdge ) { this . leftEdge = leftEdge ; this . topEdge = topEdge ; this . rightEdge = rightEdge ; this . bottomEdge = bottomEdge ; } | Sets edge treatments . | 66 | 5 |
26,368 | boolean scrollIfNecessary ( ) { if ( mSelected == null ) { mDragScrollStartTimeInMs = Long . MIN_VALUE ; return false ; } final long now = System . currentTimeMillis ( ) ; final long scrollDuration = mDragScrollStartTimeInMs == Long . MIN_VALUE ? 0 : now - mDragScrollStartTimeInMs ; RecyclerView . LayoutManager lm = mRecyclerView . getLayoutManager ( ) ; if ( mTmpRect == null ) { mTmpRect = new Rect ( ) ; } int scrollX = 0 ; int scrollY = 0 ; lm . calculateItemDecorationsForChild ( mSelected . itemView , mTmpRect ) ; if ( lm . canScrollHorizontally ( ) ) { int curX = ( int ) ( mSelectedStartX + mDx ) ; final int leftDiff = curX - mTmpRect . left - mRecyclerView . getPaddingLeft ( ) ; if ( mDx < 0 && leftDiff < 0 ) { scrollX = leftDiff ; } else if ( mDx > 0 ) { final int rightDiff = curX + mSelected . itemView . getWidth ( ) + mTmpRect . right - ( mRecyclerView . getWidth ( ) - mRecyclerView . getPaddingRight ( ) ) ; if ( rightDiff > 0 ) { scrollX = rightDiff ; } } } if ( lm . canScrollVertically ( ) ) { int curY = ( int ) ( mSelectedStartY + mDy ) ; final int topDiff = curY - mTmpRect . top - mRecyclerView . getPaddingTop ( ) ; if ( mDy < 0 && topDiff < 0 ) { scrollY = topDiff ; } else if ( mDy > 0 ) { final int bottomDiff = curY + mSelected . itemView . getHeight ( ) + mTmpRect . bottom - ( mRecyclerView . getHeight ( ) - mRecyclerView . getPaddingBottom ( ) ) ; if ( bottomDiff > 0 ) { scrollY = bottomDiff ; } } } if ( scrollX != 0 ) { scrollX = mCallback . interpolateOutOfBoundsScroll ( mRecyclerView , mSelected . itemView . getWidth ( ) , scrollX , mRecyclerView . getWidth ( ) , scrollDuration ) ; } if ( scrollY != 0 ) { scrollY = mCallback . interpolateOutOfBoundsScroll ( mRecyclerView , mSelected . itemView . getHeight ( ) , scrollY , mRecyclerView . getHeight ( ) , scrollDuration ) ; } if ( scrollX != 0 || scrollY != 0 ) { if ( mDragScrollStartTimeInMs == Long . MIN_VALUE ) { mDragScrollStartTimeInMs = now ; } mRecyclerView . scrollBy ( scrollX , scrollY ) ; return true ; } mDragScrollStartTimeInMs = Long . MIN_VALUE ; return false ; } | If user drags the view to the edge trigger a scroll if necessary . | 681 | 15 |
26,369 | int endRecoverAnimation ( ViewHolder viewHolder , boolean override ) { final int recoverAnimSize = mRecoverAnimations . size ( ) ; for ( int i = recoverAnimSize - 1 ; i >= 0 ; i -- ) { final RecoverAnimation anim = mRecoverAnimations . get ( i ) ; if ( anim . mViewHolder == viewHolder ) { anim . mOverridden |= override ; if ( ! anim . mEnded ) { anim . cancel ( ) ; } mRecoverAnimations . remove ( i ) ; return anim . mAnimationType ; } } return 0 ; } | Returns the animation type or 0 if cannot be found . | 132 | 11 |
26,370 | boolean checkSelectForSwipe ( int action , MotionEvent motionEvent , int pointerIndex ) { if ( mSelected != null || action != MotionEvent . ACTION_MOVE || mActionState == ACTION_STATE_DRAG || ! mCallback . isItemViewSwipeEnabled ( ) ) { return false ; } if ( mRecyclerView . getScrollState ( ) == RecyclerView . SCROLL_STATE_DRAGGING ) { return false ; } final ViewHolder vh = findSwipedView ( motionEvent ) ; if ( vh == null ) { return false ; } final int movementFlags = mCallback . getAbsoluteMovementFlags ( mRecyclerView , vh ) ; final int swipeFlags = ( movementFlags & ACTION_MODE_SWIPE_MASK ) >> ( DIRECTION_FLAG_COUNT * ACTION_STATE_SWIPE ) ; if ( swipeFlags == 0 ) { return false ; } // mDx and mDy are only set in allowed directions. We use custom x/y here instead of // updateDxDy to avoid swiping if user moves more in the other direction final float x = motionEvent . getX ( pointerIndex ) ; final float y = motionEvent . getY ( pointerIndex ) ; // Calculate the distance moved final float dx = x - mInitialTouchX ; final float dy = y - mInitialTouchY ; // swipe target is chose w/o applying flags so it does not really check if swiping in that // direction is allowed. This why here, we use mDx mDy to check slope value again. final float absDx = Math . abs ( dx ) ; final float absDy = Math . abs ( dy ) ; if ( absDx < mSlop && absDy < mSlop ) { return false ; } if ( absDx > absDy ) { if ( dx < 0 && ( swipeFlags & LEFT ) == 0 ) { return false ; } if ( dx > 0 && ( swipeFlags & RIGHT ) == 0 ) { return false ; } } else { if ( dy < 0 && ( swipeFlags & UP ) == 0 ) { return false ; } if ( dy > 0 && ( swipeFlags & DOWN ) == 0 ) { return false ; } } mDx = mDy = 0f ; mActivePointerId = motionEvent . getPointerId ( 0 ) ; select ( vh , ACTION_STATE_SWIPE ) ; return true ; } | Checks whether we should select a View for swiping . | 540 | 12 |
26,371 | private void inflateLayers ( Resources r , XmlPullParser parser , AttributeSet attrs , Resources . Theme theme ) throws XmlPullParserException , IOException { final LayerState state = mLayerState ; final int innerDepth = parser . getDepth ( ) + 1 ; int type ; int depth ; while ( ( type = parser . next ( ) ) != XmlPullParser . END_DOCUMENT && ( ( depth = parser . getDepth ( ) ) >= innerDepth || type != XmlPullParser . END_TAG ) ) { if ( type != XmlPullParser . START_TAG ) { continue ; } if ( depth > innerDepth || ! parser . getName ( ) . equals ( "item" ) ) { continue ; } final ChildDrawable layer = new ChildDrawable ( ) ; final TypedArray a = obtainAttributes ( r , theme , attrs , R . styleable . LayerDrawableItem ) ; updateLayerFromTypedArray ( layer , a ) ; a . recycle ( ) ; // If the layer doesn't have a drawable or unresolved theme // attribute for a drawable, attempt to parse one from the child // element. if ( layer . mDrawable == null && ( layer . mThemeAttrs == null || layer . mThemeAttrs [ R . styleable . LayerDrawableItem_android_drawable ] == 0 ) ) { while ( ( type = parser . next ( ) ) == XmlPullParser . TEXT ) { } if ( type != XmlPullParser . START_TAG ) { throw new XmlPullParserException ( parser . getPositionDescription ( ) + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable" ) ; } layer . mDrawable = LollipopDrawablesCompat . createFromXmlInner ( r , parser , attrs , theme ) ; } if ( layer . mDrawable != null ) { state . mChildrenChangingConfigurations |= layer . mDrawable . getChangingConfigurations ( ) ; layer . mDrawable . setCallback ( this ) ; } addLayer ( layer ) ; } } | Inflates child layers using the specified parser . | 457 | 10 |
26,372 | int addLayer ( ChildDrawable layer ) { final LayerState st = mLayerState ; final int N = st . mChildren != null ? st . mChildren . length : 0 ; final int i = st . mNum ; if ( i >= N ) { final ChildDrawable [ ] nu = new ChildDrawable [ N + 10 ] ; if ( i > 0 ) { System . arraycopy ( st . mChildren , 0 , nu , 0 , i ) ; } st . mChildren = nu ; } st . mChildren [ i ] = layer ; st . mNum ++ ; st . invalidateCache ( ) ; return i ; } | Adds a new layer at the end of list of layers and returns its index . | 136 | 16 |
26,373 | ChildDrawable addLayer ( Drawable dr , int [ ] themeAttrs , int id , int left , int top , int right , int bottom ) { final ChildDrawable childDrawable = createLayer ( dr ) ; childDrawable . mId = id ; childDrawable . mThemeAttrs = themeAttrs ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . KITKAT ) childDrawable . mDrawable . setAutoMirrored ( isAutoMirrored ( ) ) ; childDrawable . mInsetL = left ; childDrawable . mInsetT = top ; childDrawable . mInsetR = right ; childDrawable . mInsetB = bottom ; addLayer ( childDrawable ) ; mLayerState . mChildrenChangingConfigurations |= dr . getChangingConfigurations ( ) ; dr . setCallback ( this ) ; return childDrawable ; } | Add a new layer to this drawable . The new layer is identified by an id . | 201 | 18 |
26,374 | public int getId ( int index ) { if ( index >= mLayerState . mNum ) { throw new IndexOutOfBoundsException ( ) ; } return mLayerState . mChildren [ index ] . mId ; } | Returns the ID of the specified layer . | 48 | 8 |
26,375 | public void setDrawable ( int index , Drawable drawable ) { if ( index >= mLayerState . mNum ) { throw new IndexOutOfBoundsException ( ) ; } final ChildDrawable [ ] layers = mLayerState . mChildren ; final ChildDrawable childDrawable = layers [ index ] ; if ( childDrawable . mDrawable != null ) { if ( drawable != null ) { final Rect bounds = childDrawable . mDrawable . getBounds ( ) ; drawable . setBounds ( bounds ) ; } childDrawable . mDrawable . setCallback ( null ) ; } if ( drawable != null ) { drawable . setCallback ( this ) ; } childDrawable . mDrawable = drawable ; mLayerState . invalidateCache ( ) ; refreshChildPadding ( index , childDrawable ) ; } | Sets the drawable for the layer at the specified index . | 184 | 13 |
26,376 | public Drawable getDrawable ( int index ) { if ( index >= mLayerState . mNum ) { throw new IndexOutOfBoundsException ( ) ; } return mLayerState . mChildren [ index ] . mDrawable ; } | Returns the drawable for the layer at the specified index . | 51 | 12 |
26,377 | public void setLayerInset ( int index , int l , int t , int r , int b ) { setLayerInsetInternal ( index , l , t , r , b , UNDEFINED_INSET , UNDEFINED_INSET ) ; } | Specifies the insets in pixels for the drawable at the specified index . | 57 | 16 |
26,378 | public void setLayerInsetRelative ( int index , int s , int t , int e , int b ) { setLayerInsetInternal ( index , 0 , t , 0 , b , s , e ) ; } | Specifies the relative insets in pixels for the drawable at the specified index . | 47 | 17 |
26,379 | private boolean refreshChildPadding ( int i , ChildDrawable r ) { if ( r . mDrawable != null ) { final Rect rect = mTmpRect ; r . mDrawable . getPadding ( rect ) ; if ( rect . left != mPaddingL [ i ] || rect . top != mPaddingT [ i ] || rect . right != mPaddingR [ i ] || rect . bottom != mPaddingB [ i ] ) { mPaddingL [ i ] = rect . left ; mPaddingT [ i ] = rect . top ; mPaddingR [ i ] = rect . right ; mPaddingB [ i ] = rect . bottom ; return true ; } } return false ; } | Refreshes the cached padding values for the specified child . | 157 | 12 |
26,380 | void ensurePadding ( ) { final int N = mLayerState . mNum ; if ( mPaddingL != null && mPaddingL . length >= N ) { return ; } mPaddingL = new int [ N ] ; mPaddingT = new int [ N ] ; mPaddingR = new int [ N ] ; mPaddingB = new int [ N ] ; } | Ensures the child padding caches are large enough . | 85 | 11 |
26,381 | public static Properties getResourceAsProperties ( ClassLoader loader , String resource ) throws IOException { Properties props = new Properties ( ) ; InputStream in = null ; String propfile = resource ; in = getResourceAsStream ( loader , propfile ) ; props . load ( in ) ; in . close ( ) ; return props ; } | Returns a resource on the classpath as a Properties object | 70 | 11 |
26,382 | public static Reader getResourceAsReader ( ClassLoader loader , String resource ) throws IOException { return new InputStreamReader ( getResourceAsStream ( loader , resource ) ) ; } | Returns a resource on the classpath as a Reader object | 37 | 11 |
26,383 | public static File getResourceAsFile ( ClassLoader loader , String resource ) throws IOException { return new File ( getResourceURL ( loader , resource ) . getFile ( ) ) ; } | Returns a resource on the classpath as a File object | 39 | 11 |
26,384 | public synchronized String generateId ( ) { final StringBuilder sb = new StringBuilder ( this . length ) ; sb . append ( this . seed ) ; sb . append ( this . sequence . getAndIncrement ( ) ) ; return sb . toString ( ) ; } | Generate a unqiue id | 60 | 7 |
26,385 | public String generateSanitizedId ( ) { String result = this . generateId ( ) ; result = result . replace ( ' ' , ' ' ) ; result = result . replace ( ' ' , ' ' ) ; result = result . replace ( ' ' , ' ' ) ; return result ; } | Generate a unique ID - that is friendly for a URL or file system | 62 | 15 |
26,386 | protected void doResponseHeaders ( final HttpServletResponse response , final String mimeType ) { if ( mimeType != null ) { response . setContentType ( mimeType ) ; } } | Set the response headers . This method is called to set the response headers such as content type and content length . May be extended to add additional headers . | 44 | 30 |
26,387 | public MessageProducer getOrCreateProducer ( final String topic ) { if ( ! this . shareProducer ) { FutureTask < MessageProducer > task = this . producers . get ( topic ) ; if ( task == null ) { task = new FutureTask < MessageProducer > ( new Callable < MessageProducer > ( ) { @ Override public MessageProducer call ( ) throws Exception { MessageProducer producer = MetaqTemplate . this . messageSessionFactory . createProducer ( ) ; producer . publish ( topic ) ; if ( ! StringUtils . isBlank ( MetaqTemplate . this . defaultTopic ) ) { producer . setDefaultTopic ( MetaqTemplate . this . defaultTopic ) ; } return producer ; } } ) ; FutureTask < MessageProducer > oldTask = this . producers . putIfAbsent ( topic , task ) ; if ( oldTask != null ) { task = oldTask ; } else { task . run ( ) ; } } try { MessageProducer producer = task . get ( ) ; return producer ; } catch ( ExecutionException e ) { throw ThreadUtils . launderThrowable ( e . getCause ( ) ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } } else { if ( this . sharedProducer == null ) { synchronized ( this ) { if ( this . sharedProducer == null ) { this . sharedProducer = this . messageSessionFactory . createProducer ( ) ; if ( ! StringUtils . isBlank ( this . defaultTopic ) ) { this . sharedProducer . setDefaultTopic ( this . defaultTopic ) ; } } } } this . sharedProducer . publish ( topic ) ; return this . sharedProducer ; } throw new IllegalStateException ( "Could not create producer for topic '" + topic + "'" ) ; } | Returns or create a message producer for topic . | 398 | 9 |
26,388 | public SendResult send ( MessageBuilder builder , long timeout , TimeUnit unit ) throws InterruptedException { Message msg = builder . build ( this . messageBodyConverter ) ; final String topic = msg . getTopic ( ) ; MessageProducer producer = this . getOrCreateProducer ( topic ) ; try { return producer . sendMessage ( msg , timeout , unit ) ; } catch ( MetaClientException e ) { return new SendResult ( false , null , - 1 , ExceptionUtils . getFullStackTrace ( e ) ) ; } } | Send message built by message builder . Returns the sent result . | 116 | 12 |
26,389 | public void send ( MessageBuilder builder , SendMessageCallback cb , long timeout , TimeUnit unit ) { Message msg = builder . build ( this . messageBodyConverter ) ; final String topic = msg . getTopic ( ) ; MessageProducer producer = this . getOrCreateProducer ( topic ) ; producer . sendMessage ( msg , cb , timeout , unit ) ; } | Send message asynchronously with callback . | 81 | 8 |
26,390 | public < T > Message build ( MessageBodyConverter < T > converter ) { if ( StringUtils . isBlank ( this . topic ) ) { throw new IllegalArgumentException ( "Blank topic" ) ; } if ( this . body == null && this . payload == null ) { throw new IllegalArgumentException ( "Empty payload" ) ; } byte [ ] payload = this . payload ; if ( payload == null && converter != null ) { try { payload = converter . toByteArray ( ( T ) this . body ) ; } catch ( MetaClientException e ) { throw new IllegalStateException ( "Convert message body failed." , e ) ; } } if ( payload == null ) { throw new IllegalArgumentException ( "Empty payload" ) ; } return new Message ( this . topic , payload , this . attribute ) ; } | Build message by message body converter . | 181 | 7 |
26,391 | public boolean acquireProcessLock ( ) throws MongobeeConnectionException , MongobeeLockException { verifyDbConnection ( ) ; boolean acquired = lockDao . acquireLock ( getMongoDatabase ( ) ) ; if ( ! acquired && waitForLock ) { long timeToGiveUp = new Date ( ) . getTime ( ) + ( changeLogLockWaitTime * 1000 * 60 ) ; while ( ! acquired && new Date ( ) . getTime ( ) < timeToGiveUp ) { acquired = lockDao . acquireLock ( getMongoDatabase ( ) ) ; if ( ! acquired ) { logger . info ( "Waiting for changelog lock...." ) ; try { Thread . sleep ( changeLogLockPollRate * 1000 ) ; } catch ( InterruptedException e ) { // nothing } } } } if ( ! acquired && throwExceptionIfCannotObtainLock ) { logger . info ( "Mongobee did not acquire process lock. Throwing exception." ) ; throw new MongobeeLockException ( "Could not acquire process lock" ) ; } return acquired ; } | Try to acquire process lock | 230 | 5 |
26,392 | public boolean waitForCompletion ( long duration , TimeUnit timeUnit ) throws InterruptedException { synchronized ( lock ) { if ( ! isCompleted ( ) ) { lock . wait ( timeUnit . toMillis ( duration ) ) ; } return isCompleted ( ) ; } } | Blocks until the task is complete or times out . | 58 | 10 |
26,393 | @ SuppressWarnings ( "unchecked" ) public static < TResult > Task < TResult > forResult ( TResult value ) { if ( value == null ) { return ( Task < TResult > ) TASK_NULL ; } if ( value instanceof Boolean ) { return ( Task < TResult > ) ( ( Boolean ) value ? TASK_TRUE : TASK_FALSE ) ; } bolts . TaskCompletionSource < TResult > tcs = new bolts . TaskCompletionSource <> ( ) ; tcs . setResult ( value ) ; return tcs . getTask ( ) ; } | Creates a completed task with the given value . | 135 | 10 |
26,394 | public static < TResult > Task < TResult > forError ( Exception error ) { bolts . TaskCompletionSource < TResult > tcs = new bolts . TaskCompletionSource <> ( ) ; tcs . setError ( error ) ; return tcs . getTask ( ) ; } | Creates a faulted task with the given error . | 62 | 11 |
26,395 | public static Task < Void > delay ( long delay , CancellationToken cancellationToken ) { return delay ( delay , BoltsExecutors . scheduled ( ) , cancellationToken ) ; } | Creates a task that completes after a time delay . | 39 | 11 |
26,396 | public < TOut > Task < TOut > cast ( ) { @ SuppressWarnings ( "unchecked" ) Task < TOut > task = ( Task < TOut > ) this ; return task ; } | Makes a fluent cast of a Task s result possible avoiding an extra continuation just to cast the type of the result . | 46 | 24 |
26,397 | public < TContinuationResult > Task < TContinuationResult > continueWith ( Continuation < TResult , TContinuationResult > continuation ) { return continueWith ( continuation , IMMEDIATE_EXECUTOR , null ) ; } | Adds a synchronous continuation to this task returning a new task that completes after the continuation has finished running . | 51 | 21 |
26,398 | public < TContinuationResult > Task < TContinuationResult > continueWithTask ( final Continuation < TResult , Task < TContinuationResult > > continuation , final Executor executor , final CancellationToken ct ) { boolean completed ; final bolts . TaskCompletionSource < TContinuationResult > tcs = new bolts . TaskCompletionSource <> ( ) ; synchronized ( lock ) { completed = this . isCompleted ( ) ; if ( ! completed ) { this . continuations . add ( new Continuation < TResult , Void > ( ) { @ Override public Void then ( Task < TResult > task ) { completeAfterTask ( tcs , continuation , task , executor , ct ) ; return null ; } } ) ; } } if ( completed ) { completeAfterTask ( tcs , continuation , this , executor , ct ) ; } return tcs . getTask ( ) ; } | Adds an Task - based continuation to this task that will be scheduled using the executor returning a new task that completes after the task returned by the continuation has completed . | 196 | 33 |
26,399 | public < TContinuationResult > Task < TContinuationResult > continueWithTask ( Continuation < TResult , Task < TContinuationResult > > continuation ) { return continueWithTask ( continuation , IMMEDIATE_EXECUTOR , null ) ; } | Adds an asynchronous continuation to this task returning a new task that completes after the task returned by the continuation has completed . | 56 | 23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.