idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
100
public final void setNavigationWidth ( final int width ) { Condition . INSTANCE . ensureGreater ( width , 0 , "The width must be greater than 0" ) ; this . navigationWidth = width ; adaptNavigationWidth ( ) ; }
Sets the width of the navigation when using the split screen layout .
101
public final void setNextButtonText ( final CharSequence text ) { Condition . INSTANCE . ensureNotNull ( text , "The text may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( text , "The text may not be empty" ) ; this . nextButtonText = text ; adaptNextButtonText ( ) ; }
Sets the text of the next button which is shown when the activity is used as a wizard .
102
public final void setBackButtonText ( final CharSequence text ) { Condition . INSTANCE . ensureNotNull ( text , "The text may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( text , "The text may not be empty" ) ; this . backButtonText = text ; adaptBackButtonText ( ) ; }
Sets the text of the back button which is shown when the activity is used as a wizard .
103
public final void setFinishButtonText ( final CharSequence text ) { Condition . INSTANCE . ensureNotNull ( text , "The text may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( text , "The text may not be empty" ) ; this . finishButtonText = text ; adaptFinishButtonText ( ) ; }
Sets the text of the next button which is shown when the activity is used as a wizard and the last navigation preference is currently selected .
104
public final void setProgressFormat ( final String progressFormat ) { Condition . INSTANCE . ensureNotNull ( progressFormat , "The progress format may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( progressFormat , "The progress format may not be empty" ) ; this . progressFormat = progressFormat ; adaptProgress ( ) ; }
Sets the string which should be used to format the progress which is shown when the activity is used as a wizard .
105
public final void setToolbarElevation ( final int elevation ) { Condition . INSTANCE . ensureAtLeast ( elevation , 0 , "The elevation must be at least 0" ) ; Condition . INSTANCE . ensureAtMaximum ( elevation , ElevationUtil . MAX_ELEVATION , "The elevation must at maximum " + ElevationUtil . MAX_ELEVATION ) ; this . toolbarElevation = elevation ; adaptToolbarElevation ( ) ; }
Sets the elevation of the activity s toolbar .
106
public final void setBreadCrumbElevation ( final int elevation ) { Condition . INSTANCE . ensureAtLeast ( elevation , 0 , "The elevation must be at least 0" ) ; Condition . INSTANCE . ensureAtMaximum ( elevation , ElevationUtil . MAX_ELEVATION , "The elevation must at maximum " + ElevationUtil . MAX_ELEVATION ) ; this . breadCrumbElevation = elevation ; adaptBreadCrumbElevation ( ) ; }
Sets the elevation of the toolbar which is used to show the bread crumb of the currently selected navigation preference when using the split screen layout .
107
public final void setCardViewElevation ( final int elevation ) { Condition . INSTANCE . ensureAtLeast ( elevation , 0 , "The elevation must be at least 0" ) ; Condition . INSTANCE . ensureAtMaximum ( elevation , ElevationUtil . MAX_ELEVATION , "The elevation must be at maximum " + ElevationUtil . MAX_ELEVATION ) ; this . cardViewElevation = elevation ; adaptCardViewElevation ( ) ; }
Sets the elevation of the card view which contains the currently shown prefernce fragment when using the split screen layout .
108
public final void setButtonBarElevation ( final int elevation ) { Condition . INSTANCE . ensureAtLeast ( elevation , 0 , "The elevation must be at least 0" ) ; Condition . INSTANCE . ensureAtMaximum ( elevation , ElevationUtil . MAX_ELEVATION , "The elevation must be at maximum " + ElevationUtil . MAX_ELEVATION ) ; this . buttonBarElevation = elevation ; adaptButtonBarElevation ( ) ; }
Sets the elevation of the button bar which is shown when using the activity as a wizard .
109
public final List < NavigationPreference > getAllNavigationPreferences ( ) { return navigationFragment != null ? navigationFragment . getAllNavigationPreferences ( ) : Collections . < NavigationPreference > emptyList ( ) ; }
Returns a list which contains all navigation preferences which are contained by the activity .
110
private void addNavigationPreference ( ) { NavigationPreference navigationPreference = new NavigationPreference ( this ) ; navigationPreference . setTitle ( getPreferenceHeaderTitle ( ) ) ; navigationPreference . setFragment ( NewPreferenceHeaderFragment . class . getName ( ) ) ; getNavigationFragment ( ) . getPreferenceScreen ( ) . addPreference ( navigationPreference ) ; invalidateOptionsMenu ( ) ; }
Dynamically adds a new navigation preference to the activity .
111
private CharSequence getPreferenceHeaderTitle ( ) { CharSequence originalTitle = getText ( R . string . new_navigation_preference_title ) ; CharSequence title = originalTitle ; int counter = 1 ; while ( isTitleAlreadyUsed ( title ) ) { title = originalTitle + " (" + counter + ")" ; counter ++ ; } return title ; }
Returns an unique title which can be used for a new preference header .
112
private boolean isTitleAlreadyUsed ( final CharSequence title ) { for ( NavigationPreference navigationPreference : getAllNavigationPreferences ( ) ) { if ( title . equals ( navigationPreference . getTitle ( ) ) ) { return true ; } } return false ; }
Returns whether a preference header which has a specific title has already been added to the activity or not .
113
private void obtainShowRestoreDefaultsButton ( ) { boolean show = ThemeUtil . getBoolean ( getActivity ( ) , R . attr . showRestoreDefaultsButton , false ) ; showRestoreDefaultsButton ( show ) ; }
Obtains whether the button which allows to restore the preferences default values should be shown or not from the activity s current theme .
114
private void obtainRestoreDefaultsButtonText ( ) { CharSequence text ; try { text = ThemeUtil . getText ( getActivity ( ) , R . attr . restoreDefaultsButtonText ) ; } catch ( NotFoundException e ) { text = getText ( R . string . restore_defaults_button_text ) ; } setRestoreDefaultsButtonText ( text ) ; }
Obtains the text of the button which allows to restore the preferences default values from the activity s current theme .
115
private void obtainButtonBarBackground ( ) { try { int color = ThemeUtil . getColor ( getActivity ( ) , R . attr . restoreDefaultsButtonBarBackground ) ; setButtonBarBackgroundColor ( color ) ; } catch ( NotFoundException e ) { int resourceId = ThemeUtil . getResId ( getActivity ( ) , R . attr . restoreDefaultsButtonBarBackground , - 1 ) ; if ( resourceId != - 1 ) { setButtonBarBackground ( resourceId ) ; } else { setButtonBarBackgroundColor ( ContextCompat . getColor ( getActivity ( ) , R . color . button_bar_background_light ) ) ; } } }
Obtains the background of the button bar from the activity s current theme .
116
private void handleArguments ( ) { Bundle arguments = getArguments ( ) ; if ( arguments != null ) { handleShowRestoreDefaultsButtonArgument ( arguments ) ; handleRestoreDefaultsButtonTextArgument ( arguments ) ; } }
Handles the arguments which have been passed to the fragment .
117
private void handleShowRestoreDefaultsButtonArgument ( final Bundle arguments ) { boolean showButton = arguments . getBoolean ( EXTRA_SHOW_RESTORE_DEFAULTS_BUTTON , false ) ; showRestoreDefaultsButton ( showButton ) ; }
Handles the extra of the arguments which have been passed to the fragment that allows to show the button which allows to restore the preferences default values .
118
private void handleRestoreDefaultsButtonTextArgument ( final Bundle arguments ) { CharSequence buttonText = getCharSequenceFromArguments ( arguments , EXTRA_RESTORE_DEFAULTS_BUTTON_TEXT ) ; if ( ! TextUtils . isEmpty ( buttonText ) ) { setRestoreDefaultsButtonText ( buttonText ) ; } }
Handles the extra of the arguments which have been passed to the fragment that allows to specify a custom text for the button which allows to restore the preferences default values .
119
private CharSequence getCharSequenceFromArguments ( final Bundle arguments , final String name ) { CharSequence charSequence = arguments . getCharSequence ( name ) ; if ( charSequence == null ) { int resourceId = arguments . getInt ( name , - 1 ) ; if ( resourceId != - 1 ) { charSequence = getText ( resourceId ) ; } } return charSequence ; }
Returns the char sequence which is specified by a specific extra of the arguments which have been passed to the fragment . The char sequence can either be specified as a string or as a resource id .
120
private void restoreDefaults ( final PreferenceGroup preferenceGroup , final SharedPreferences sharedPreferences ) { for ( int i = 0 ; i < preferenceGroup . getPreferenceCount ( ) ; i ++ ) { Preference preference = preferenceGroup . getPreference ( i ) ; if ( preference instanceof PreferenceGroup ) { restoreDefaults ( ( PreferenceGroup ) preference , sharedPreferences ) ; } else if ( preference . getKey ( ) != null && ! preference . getKey ( ) . isEmpty ( ) ) { Object oldValue = sharedPreferences . getAll ( ) . get ( preference . getKey ( ) ) ; if ( notifyOnRestoreDefaultValueRequested ( preference , oldValue ) ) { sharedPreferences . edit ( ) . remove ( preference . getKey ( ) ) . apply ( ) ; preferenceGroup . removePreference ( preference ) ; preferenceGroup . addPreference ( preference ) ; Object newValue = sharedPreferences . getAll ( ) . get ( preference . getKey ( ) ) ; notifyOnRestoredDefaultValue ( preference , oldValue , newValue ) ; } else { preferenceGroup . removePreference ( preference ) ; preferenceGroup . addPreference ( preference ) ; } } } }
Restores the default preferences which are contained by a specific preference group .
121
private boolean notifyOnRestoreDefaultValuesRequested ( ) { boolean result = true ; for ( RestoreDefaultsListener listener : restoreDefaultsListeners ) { result &= listener . onRestoreDefaultValuesRequested ( this ) ; } return result ; }
Notifies all registered listeners that the preferences default values should be restored .
122
private boolean notifyOnRestoreDefaultValueRequested ( final Preference preference , final Object currentValue ) { boolean result = true ; for ( RestoreDefaultsListener listener : restoreDefaultsListeners ) { result &= listener . onRestoreDefaultValueRequested ( this , preference , currentValue ) ; } return result ; }
Notifies all registered listeners that the default value of a specific preference should be restored .
123
private void notifyOnRestoredDefaultValue ( final Preference preference , final Object oldValue , final Object newValue ) { for ( RestoreDefaultsListener listener : restoreDefaultsListeners ) { listener . onRestoredDefaultValue ( this , preference , oldValue , newValue != null ? newValue : oldValue ) ; } }
Notifies all registered listeners that the default value of a specific preference has been be restored .
124
private void adaptButtonBarVisibility ( ) { if ( buttonBarParent != null ) { buttonBarParent . setVisibility ( showRestoreDefaultsButton ? View . VISIBLE : View . GONE ) ; } }
Adapts the visibility of the button bar .
125
public final void addRestoreDefaultsListener ( final RestoreDefaultsListener listener ) { Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; this . restoreDefaultsListeners . add ( listener ) ; }
Adds a new listener which should be notified when the preferences default values should be restored to the fragment .
126
public final void removeRestoreDefaultsListener ( final RestoreDefaultsListener listener ) { Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; this . restoreDefaultsListeners . remove ( listener ) ; }
Removes a specific listener which should not be notified anymore when the preferences default values should be restored from the fragment .
127
public final void restoreDefaults ( ) { SharedPreferences sharedPreferences = getPreferenceManager ( ) . getSharedPreferences ( ) ; if ( getPreferenceScreen ( ) != null ) { restoreDefaults ( getPreferenceScreen ( ) , sharedPreferences ) ; } }
Restores the default values of all preferences which are contained by the fragment .
128
public final void setRestoreDefaultsButtonText ( final CharSequence text ) { Condition . INSTANCE . ensureNotNull ( text , "The text may not be null" ) ; Condition . INSTANCE . ensureNotEmpty ( text , "The text may not be empty" ) ; this . restoreDefaultsButtonText = text ; adaptRestoreDefaultsButtonText ( ) ; }
Sets the text of the button which allows to restore the preferences default values . The text is only set if the button is shown .
129
protected boolean fail ( Throwable e ) { if ( done . compareAndSet ( false , true ) ) { onErrorCore ( e ) ; return true ; } return false ; }
Try to move into an error state .
130
private OnPreferenceChangeListener createToolbarElevationChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( Preference preference , Object newValue ) { int elevation = Integer . valueOf ( ( String ) newValue ) ; ( ( PreferenceActivity ) getActivity ( ) ) . setToolbarElevation ( elevation ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the elevation of the toolbar when the value of the corresponding preference has been changed .
131
private OnPreferenceChangeListener createNavigationWidthChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( final Preference preference , final Object newValue ) { int width = Integer . valueOf ( ( String ) newValue ) ; ( ( PreferenceActivity ) getActivity ( ) ) . setNavigationWidth ( dpToPixels ( getActivity ( ) , width ) ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the width of the navigation when the value of the corresponding preference has been changed .
132
private OnPreferenceChangeListener createPreferenceScreenElevationChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( final Preference preference , final Object newValue ) { int elevation = Integer . valueOf ( ( String ) newValue ) ; ( ( PreferenceActivity ) getActivity ( ) ) . setCardViewElevation ( elevation ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the elevation of the preference screen when the value of the corresponding preference has been changed .
133
private OnPreferenceChangeListener createBreadCrumbElevationChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( Preference preference , Object newValue ) { int elevation = Integer . valueOf ( ( String ) newValue ) ; ( ( PreferenceActivity ) getActivity ( ) ) . setBreadCrumbElevation ( elevation ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the elevation of the bread crumbs when the value of the corresponding preference has been changed .
134
private OnPreferenceChangeListener createWizardButtonBarElevationChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( final Preference preference , final Object newValue ) { int elevation = Integer . valueOf ( ( String ) newValue ) ; ( ( PreferenceActivity ) getActivity ( ) ) . setButtonBarElevation ( elevation ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the elevation of a wizard s button bar when the value of the corresponding preference has been changed .
135
private OnPreferenceChangeListener createPreferenceFragmentButtonBarElevationChangeListener ( ) { return new OnPreferenceChangeListener ( ) { public boolean onPreferenceChange ( final Preference preference , final Object newValue ) { int elevation = Integer . valueOf ( ( String ) newValue ) ; setButtonBarElevation ( elevation ) ; return true ; } } ; }
Creates and returns a listener which allows to adapt the elevation of a preference fragment s button bar when the value of the corresponding preference has been changed .
136
private void obtainDividerDecoration ( ) { int dividerColor ; try { dividerColor = ThemeUtil . getColor ( getActivity ( ) , R . attr . dividerColor ) ; } catch ( NotFoundException e ) { dividerColor = ContextCompat . getColor ( getActivity ( ) , R . color . preference_divider_color_light ) ; } this . dividerDecoration . setDividerColor ( dividerColor ) ; this . dividerDecoration . setDividerHeight ( DisplayUtil . dpToPixels ( getActivity ( ) , 1 ) ) ; }
Obtains the appearance of the dividers which are shown above preference categories from the activity s theme .
137
private void initializeAppearanceNavigationPreference ( final PreferenceFragmentCompat fragment ) { String key = getString ( R . string . appearance_navigation_preference_key ) ; NavigationPreference navigationPreference = ( NavigationPreference ) fragment . findPreference ( key ) ; Bundle extras = new Bundle ( ) ; extras . putBoolean ( PreferenceFragment . EXTRA_SHOW_RESTORE_DEFAULTS_BUTTON , true ) ; navigationPreference . setExtras ( extras ) ; }
Initializes the navigation preference which allows to navigate to the appearance settings .
138
public static < R > OnSubscribe < R > fromAction ( Action0 action , R result ) { return new InvokeAsync < R > ( Actions . toFunc ( action , result ) ) ; }
Subscriber function that invokes an action and returns the given result .
139
public static < R > OnSubscribe < R > fromCallable ( Callable < ? extends R > callable ) { return new InvokeAsync < R > ( callable ) ; }
Subscriber function that invokes the callable and returns its value or propagates its checked exception .
140
public static < R > OnSubscribe < R > fromRunnable ( final Runnable run , final R result ) { return new InvokeAsync < R > ( new Func0 < R > ( ) { public R call ( ) { run . run ( ) ; return result ; } } ) ; }
Subscriber function that invokes a runnable and returns the given result .
141
private void notifyOnScrollingDown ( final View animatedView , final int scrollPosition ) { for ( HideViewOnScrollAnimationListener listener : listeners ) { listener . onScrollingDown ( this , animatedView , scrollPosition ) ; } }
Notifies all listeners which have been registered to be notified about the animation s internal state when the observed list view is scrolling downwards .
142
private void notifyOnScrollingUp ( final View animatedView , final int scrollPosition ) { for ( HideViewOnScrollAnimationListener listener : listeners ) { listener . onScrollingUp ( this , animatedView , scrollPosition ) ; } }
Notifies all listeners which have been registered to be notified about the animation s internal state when the observed list view is scrolling upwards .
143
private void onScrollingUp ( ) { if ( hidden ) { hidden = false ; if ( animatedView . getAnimation ( ) == null ) { ObjectAnimator animator = createAnimator ( false ) ; animator . start ( ) ; } } }
The method which is invoked when the observed list view is scrolling upwards .
144
private void onScrollingDown ( ) { if ( ! hidden ) { hidden = true ; if ( animatedView . getAnimation ( ) == null ) { ObjectAnimator animator = createAnimator ( true ) ; animator . start ( ) ; } } }
The method which is invoked when the observed list view is scrolling downwards .
145
private ObjectAnimator createAnimator ( final boolean hide ) { if ( initialPosition == - 1.0f ) { initialPosition = animatedView . getY ( ) ; } float targetPosition = hide ? initialPosition - animatedView . getHeight ( ) : initialPosition ; if ( direction == Direction . DOWN ) { targetPosition = hide ? initialPosition + animatedView . getHeight ( ) : initialPosition ; } ObjectAnimator animation = ObjectAnimator . ofFloat ( animatedView , "y" , animatedView . getY ( ) , targetPosition ) ; animation . setInterpolator ( new AccelerateDecelerateInterpolator ( ) ) ; animation . setDuration ( animationDuration ) ; return animation ; }
Creates and returns an animator which allows to translate the animated view to become shown or hidden .
146
public final void showView ( ) { if ( animatedView . getAnimation ( ) != null ) { animatedView . getAnimation ( ) . cancel ( ) ; } ObjectAnimator animator = createAnimator ( false ) ; animator . start ( ) ; }
Shows the view .
147
public final void hideView ( ) { if ( animatedView . getAnimation ( ) != null ) { animatedView . getAnimation ( ) . cancel ( ) ; } ObjectAnimator animator = createAnimator ( true ) ; animator . start ( ) ; }
Hides the view .
148
public final void addListener ( final HideViewOnScrollAnimationListener listener ) { Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; listeners . add ( listener ) ; }
Adds a new listener which should be notified about the animation s internal state to the animation .
149
public final void removeListener ( final HideViewOnScrollAnimationListener listener ) { Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; listeners . remove ( listener ) ; }
Removes a specific listener which should not be notified about the animation s internal state from the animation .
150
protected void onVisualizePreference ( final Preference preference , final PreferenceViewHolder viewHolder ) { if ( preference instanceof PreferenceCategory ) { RecyclerView . LayoutParams layoutParams = ( RecyclerView . LayoutParams ) viewHolder . itemView . getLayoutParams ( ) ; layoutParams . height = TextUtils . isEmpty ( preference . getTitle ( ) ) ? 0 : RecyclerView . LayoutParams . WRAP_CONTENT ; } }
The method which is invoked when a specific preference is visualized . This method may be overridden by subclasses in order to modify the appearance of the preference .
151
private void updateNavigationPreferences ( ) { List < NavigationPreference > oldNavigationPreferences = new ArrayList < > ( navigationPreferences ) ; navigationPreferences . clear ( ) ; boolean selectedNavigationPreferenceFound = selectedNavigationPreference == null ; for ( int i = 0 ; i < getItemCount ( ) ; i ++ ) { Preference item = getItem ( i ) ; if ( item instanceof NavigationPreference ) { NavigationPreference navigationPreference = ( NavigationPreference ) item ; navigationPreferences . add ( navigationPreference ) ; if ( selectedNavigationPreference == navigationPreference ) { selectedNavigationPreferenceFound = true ; } if ( ! oldNavigationPreferences . contains ( navigationPreference ) ) { notifyOnNavigationPreferenceAdded ( navigationPreference ) ; oldNavigationPreferences . remove ( navigationPreference ) ; } } } for ( NavigationPreference removedNavigationPreference : oldNavigationPreferences ) { notifyOnNavigationPreferenceRemoved ( removedNavigationPreference ) ; } if ( ! selectedNavigationPreferenceFound ) { if ( getNavigationPreferenceCount ( ) > 0 ) { selectNavigationPreference ( Math . min ( selectedNavigationPreferenceIndex , getNavigationPreferenceCount ( ) - 1 ) , null ) ; } else { selectNavigationPreference ( null , null ) ; } } }
Updates the navigation preferences which are contained by the adapter .
152
private void notifyOnNavigationPreferenceSelected ( final NavigationPreference navigationPreference , final Bundle arguments ) { if ( callback != null ) { callback . onNavigationPreferenceSelected ( navigationPreference , arguments ) ; } }
Notifies te callback that a navigation preference has been selected .
153
private RecyclerView . AdapterDataObserver createAdapterDataObserver ( ) { return new RecyclerView . AdapterDataObserver ( ) { public void onChanged ( ) { super . onChanged ( ) ; updateNavigationPreferences ( ) ; } public void onItemRangeChanged ( final int positionStart , final int itemCount ) { super . onItemRangeChanged ( positionStart , itemCount ) ; updateNavigationPreferences ( ) ; } public void onItemRangeChanged ( final int positionStart , final int itemCount , final Object payload ) { super . onItemRangeChanged ( positionStart , itemCount , payload ) ; updateNavigationPreferences ( ) ; } public void onItemRangeInserted ( final int positionStart , final int itemCount ) { super . onItemRangeInserted ( positionStart , itemCount ) ; updateNavigationPreferences ( ) ; } public void onItemRangeRemoved ( final int positionStart , final int itemCount ) { super . onItemRangeRemoved ( positionStart , itemCount ) ; updateNavigationPreferences ( ) ; } public void onItemRangeMoved ( final int fromPosition , final int toPosition , final int itemCount ) { super . onItemRangeMoved ( fromPosition , toPosition , itemCount ) ; updateNavigationPreferences ( ) ; } } ; }
Creates and returns a data observer which allows to adapt the navigation preferences when the adapter s underlying data has been changed .
154
public final int indexOfNavigationPreference ( final NavigationPreference navigationPreference ) { Condition . INSTANCE . ensureNotNull ( navigationPreference , "The navigation preference may not be null" ) ; return navigationPreferences . indexOf ( navigationPreference ) ; }
Returns the index of a specific navigation preference among all navigation preferences which are contained by the adapter .
155
private void initializeButtonBarElevation ( final SharedPreferences sharedPreferences ) { String key = getString ( R . string . preference_fragment_button_bar_elevation_preference_key ) ; String defaultValue = getString ( R . string . preference_fragment_button_bar_elevation_preference_default_value ) ; int elevation = Integer . valueOf ( sharedPreferences . getString ( key , defaultValue ) ) ; setButtonBarElevation ( elevation ) ; }
Initializes the elevation of the button bar .
156
private DialogInterface . OnClickListener createRestoreDefaultsListener ( ) { return new DialogInterface . OnClickListener ( ) { public void onClick ( final DialogInterface dialog , final int which ) { restoreDefaults ( ) ; } } ; }
Creates and returns a listener which allows to restore the default values of the fragment s preferences .
157
private void inflate ( ) { inflate ( getContext ( ) , R . layout . toolbar_large , this ) ; this . backgroundView = findViewById ( R . id . toolbar_background_view ) ; this . toolbar = findViewById ( R . id . navigation_toolbar ) ; RelativeLayout . LayoutParams layoutParams = ( RelativeLayout . LayoutParams ) toolbar . getLayoutParams ( ) ; this . navigationWidth = layoutParams . width ; }
Inflates the view s layout .
158
private int obtainTheme ( ) { TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( new int [ ] { R . attr . toolbarTheme } ) ; return typedArray . getResourceId ( 0 , 0 ) ; }
Obtains the resource id of the theme which should be applied on the toolbar .
159
private void obtainBackgroundColor ( final int theme ) { TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( theme , new int [ ] { R . attr . colorPrimary } ) ; int colorPrimary = typedArray . getColor ( 0 , 0 ) ; typedArray . recycle ( ) ; if ( colorPrimary != 0 ) { backgroundView . setBackgroundColor ( colorPrimary ) ; } }
Obtains the color of the toolbar s background from a specific typed array .
160
private void obtainTitleColor ( final int theme ) { TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( theme , new int [ ] { android . R . attr . textColorPrimary } ) ; int textColorPrimary = typedArray . getResourceId ( 0 , 0 ) ; typedArray . recycle ( ) ; if ( textColorPrimary != 0 ) { int titleColor = ContextCompat . getColor ( getContext ( ) , textColorPrimary ) ; toolbar . setTitleTextColor ( titleColor ) ; } }
Obtains the color of the toolbar s title from a specific typed array .
161
public final void setNavigationWidth ( final int width ) { Condition . INSTANCE . ensureGreater ( width , 0 , "The width must be greater than 0" ) ; this . navigationWidth = width ; if ( ! isNavigationHidden ( ) ) { RelativeLayout . LayoutParams layoutParams = ( RelativeLayout . LayoutParams ) toolbar . getLayoutParams ( ) ; layoutParams . width = width ; toolbar . requestLayout ( ) ; } }
Sets the width of the navigation .
162
public final void hideNavigation ( final boolean navigationHidden ) { toolbar . setVisibility ( navigationHidden ? View . INVISIBLE : View . VISIBLE ) ; if ( ! navigationHidden ) { setNavigationWidth ( navigationWidth ) ; } }
Hides or shows the navigation .
163
public List < TypeMirror > interfaceTypesOf ( TypeMirror type ) { com . sun . tools . javac . util . List < com . sun . tools . javac . code . Type > interfaces = ( ( DocEnvImpl ) configuration . docEnv ) . toolEnv . getTypes ( ) . interfaces ( ( com . sun . tools . javac . code . Type ) type ) ; if ( interfaces . isEmpty ( ) ) { return Collections . emptyList ( ) ; } List < TypeMirror > list = new ArrayList < > ( interfaces . size ( ) ) ; for ( com . sun . tools . javac . code . Type t : interfaces ) { list . add ( ( TypeMirror ) t ) ; } return list ; }
so we use javac directly investigate why jx . l . m is not cutting it .
164
PackageElement getUnnamedPackage ( ) { return ( toolEnv . source . allowModules ( ) ) ? toolEnv . syms . unnamedModule . unnamedPackage : toolEnv . syms . noModule . unnamedPackage ; }
to return the proper unnamedPackage for all supported releases .
165
public PackageElement getAbbreviatedPackageElement ( PackageElement pkg ) { String parsedPackageName = utils . parsePackageName ( pkg ) ; ModuleElement encl = ( ModuleElement ) pkg . getEnclosingElement ( ) ; PackageElement abbrevPkg = encl == null ? utils . elementUtils . getPackageElement ( parsedPackageName ) : ( ( JavacElements ) utils . elementUtils ) . getPackageElement ( encl , parsedPackageName ) ; return abbrevPkg ; }
Returns a representation of the package truncated to two levels . For instance if the given package represents foo . bar . baz will return a representation of foo . bar
166
private void copy ( ) { if ( elems . nonEmpty ( ) ) { List < A > orig = elems ; elems = last = List . of ( orig . head ) ; while ( ( orig = orig . tail ) . nonEmpty ( ) ) { last . tail = List . of ( orig . head ) ; last = last . tail ; } } }
Copy list and sets last .
167
public ListBuffer < A > prepend ( A x ) { elems = elems . prepend ( x ) ; if ( last == null ) last = elems ; count ++ ; return this ; }
Prepend an element to buffer .
168
public ListBuffer < A > append ( A x ) { Assert . checkNonNull ( x ) ; if ( shared ) copy ( ) ; List < A > newLast = List . of ( x ) ; if ( last != null ) { last . tail = newLast ; last = newLast ; } else { elems = last = newLast ; } count ++ ; return this ; }
Append an element to buffer .
169
public ListBuffer < A > appendList ( List < A > xs ) { while ( xs . nonEmpty ( ) ) { append ( xs . head ) ; xs = xs . tail ; } return this ; }
Append all elements in a list to buffer .
170
public A next ( ) { A x = elems . head ; if ( ! elems . isEmpty ( ) ) { elems = elems . tail ; if ( elems . isEmpty ( ) ) last = null ; count -- ; } return x ; }
Return first element in this buffer and remove
171
public Iterator < A > iterator ( ) { return new Iterator < A > ( ) { List < A > elems = ListBuffer . this . elems ; public boolean hasNext ( ) { return ! elems . isEmpty ( ) ; } public A next ( ) { if ( elems . isEmpty ( ) ) throw new NoSuchElementException ( ) ; A elem = elems . head ; elems = elems . tail ; return elem ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }
An enumeration of all elements in this buffer .
172
void addVar ( TypeVar t ) { this . undetvars = this . undetvars . prepend ( infer . fromTypeVarFun . apply ( t ) ) ; this . inferencevars = this . inferencevars . prepend ( t ) ; }
add a new inference var to this inference context
173
final List < Type > freeVarsIn ( Type t ) { ListBuffer < Type > buf = new ListBuffer < > ( ) ; for ( Type iv : inferenceVars ( ) ) { if ( t . contains ( iv ) ) { buf . add ( iv ) ; } } return buf . toList ( ) ; }
Returns a list of free variables in a given type
174
void addFreeTypeListener ( List < Type > types , FreeTypeListener ftl ) { freeTypeListeners . put ( ftl , freeVarsIn ( types ) ) ; }
Add custom hook for performing post - inference action
175
public List < Type > save ( ) { ListBuffer < Type > buf = new ListBuffer < > ( ) ; for ( Type t : undetvars ) { buf . add ( ( ( UndetVar ) t ) . dup ( infer . types ) ) ; } return buf . toList ( ) ; }
Save the state of this inference context
176
public void rollback ( List < Type > saved_undet ) { Assert . check ( saved_undet != null ) ; ListBuffer < Type > newUndetVars = new ListBuffer < > ( ) ; ListBuffer < Type > newInferenceVars = new ListBuffer < > ( ) ; while ( saved_undet . nonEmpty ( ) && undetvars . nonEmpty ( ) ) { UndetVar uv = ( UndetVar ) undetvars . head ; UndetVar uv_saved = ( UndetVar ) saved_undet . head ; if ( uv . qtype == uv_saved . qtype ) { uv_saved . dupTo ( uv , types ) ; undetvars = undetvars . tail ; saved_undet = saved_undet . tail ; newUndetVars . add ( uv ) ; newInferenceVars . add ( uv . qtype ) ; } else { undetvars = undetvars . tail ; } } undetvars = newUndetVars . toList ( ) ; inferencevars = newInferenceVars . toList ( ) ; }
Restore the state of this inference context to the previous known checkpoint . Consider that the number of saved undetermined variables can be different to the current amount . This is because new captured variables could have been added .
177
public static void generate ( ConfigurationImpl configuration , ModuleElement moduleElement ) throws DocFileIOException { ModuleFrameWriter mdlgen = new ModuleFrameWriter ( configuration , moduleElement ) ; String mdlName = moduleElement . getQualifiedName ( ) . toString ( ) ; Content mdlLabel = new StringContent ( mdlName ) ; HtmlTree body = mdlgen . getBody ( false , mdlgen . getWindowTitle ( mdlName ) ) ; HtmlTree htmlTree = ( configuration . allowTag ( HtmlTag . MAIN ) ) ? HtmlTree . MAIN ( ) : body ; Content heading = HtmlTree . HEADING ( HtmlConstants . TITLE_HEADING , HtmlStyle . bar , mdlgen . getHyperLink ( DocPaths . moduleSummary ( moduleElement ) , mdlLabel , "" , "classFrame" ) ) ; htmlTree . addContent ( heading ) ; HtmlTree div = new HtmlTree ( HtmlTag . DIV ) ; div . addStyle ( HtmlStyle . indexContainer ) ; mdlgen . addClassListing ( div ) ; htmlTree . addContent ( div ) ; if ( configuration . allowTag ( HtmlTag . MAIN ) ) { body . addContent ( htmlTree ) ; } mdlgen . printHtmlDocument ( configuration . metakeywords . getMetaKeywordsForModule ( moduleElement ) , false , body ) ; }
Generate a module type summary page for the left - hand bottom frame .
178
protected void addClassListing ( HtmlTree contentTree ) { List < PackageElement > packagesIn = ElementFilter . packagesIn ( mdle . getEnclosedElements ( ) ) ; SortedSet < TypeElement > interfaces = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; SortedSet < TypeElement > classes = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; SortedSet < TypeElement > enums = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; SortedSet < TypeElement > exceptions = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; SortedSet < TypeElement > errors = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; SortedSet < TypeElement > annotationTypes = new TreeSet < > ( utils . makeGeneralPurposeComparator ( ) ) ; for ( PackageElement pkg : packagesIn ) { if ( utils . isIncluded ( pkg ) ) { interfaces . addAll ( utils . getInterfaces ( pkg ) ) ; classes . addAll ( utils . getOrdinaryClasses ( pkg ) ) ; enums . addAll ( utils . getEnums ( pkg ) ) ; exceptions . addAll ( utils . getExceptions ( pkg ) ) ; errors . addAll ( utils . getErrors ( pkg ) ) ; annotationTypes . addAll ( utils . getAnnotationTypes ( pkg ) ) ; } } addClassKindListing ( interfaces , contents . interfaces , contentTree ) ; addClassKindListing ( classes , contents . classes , contentTree ) ; addClassKindListing ( enums , contents . enums , contentTree ) ; addClassKindListing ( exceptions , contents . exceptions , contentTree ) ; addClassKindListing ( errors , contents . errors , contentTree ) ; addClassKindListing ( annotationTypes , contents . annotationTypes , contentTree ) ; }
Add class listing for all the classes in this module . Divide class listing as per the class kind and generate separate listing for Classes Interfaces Exceptions and Errors .
179
public ClassDoc asClassDoc ( ) { return env . getClassDoc ( ( ClassSymbol ) env . types . erasure ( type ) . tsym ) ; }
Return the ClassDoc of the erasure of this wildcard type .
180
protected void addOverview ( Content body ) { if ( configuration . allowTag ( HtmlTag . MAIN ) ) { body . addContent ( htmlTree ) ; } }
For HTML 5 add the htmlTree to the body . For HTML 4 do nothing .
181
LocalItem makeLocalItem ( VarSymbol v ) { return new LocalItem ( v . erasure ( types ) , v . adr ) ; }
Make an item representing a local variable .
182
CondItem makeCondItem ( int opcode , Chain trueJumps , Chain falseJumps ) { return new CondItem ( opcode , trueJumps , falseJumps ) ; }
Make an item representing a conditional or unconditional jump .
183
Set < String > dependences ( Archive source ) { if ( ! results . containsKey ( source ) ) { return Collections . emptySet ( ) ; } return results . get ( source ) . dependencies ( ) . stream ( ) . map ( Dep :: target ) . collect ( Collectors . toSet ( ) ) ; }
Returns the dependences either class name or package name as specified in the given verbose level from the given source .
184
Stream < Archive > requires ( Archive source ) { if ( ! results . containsKey ( source ) ) { return Stream . empty ( ) ; } return results . get ( source ) . requires ( ) . stream ( ) ; }
Returns the direct dependences of the given source
185
public void stop ( ) throws EngineTerminationException , InternalException { synchronized ( STOP_LOCK ) { if ( ! userCodeRunning ) { return ; } vm ( ) . suspend ( ) ; try { OUTER : for ( ThreadReference thread : vm ( ) . allThreads ( ) ) { for ( StackFrame frame : thread . frames ( ) ) { if ( remoteAgent . equals ( frame . location ( ) . declaringType ( ) . name ( ) ) && ( "invoke" . equals ( frame . location ( ) . method ( ) . name ( ) ) || "varValue" . equals ( frame . location ( ) . method ( ) . name ( ) ) ) ) { ObjectReference thiz = frame . thisObject ( ) ; Field inClientCode = thiz . referenceType ( ) . fieldByName ( "inClientCode" ) ; Field expectingStop = thiz . referenceType ( ) . fieldByName ( "expectingStop" ) ; Field stopException = thiz . referenceType ( ) . fieldByName ( "stopException" ) ; if ( ( ( BooleanValue ) thiz . getValue ( inClientCode ) ) . value ( ) ) { thiz . setValue ( expectingStop , vm ( ) . mirrorOf ( true ) ) ; ObjectReference stopInstance = ( ObjectReference ) thiz . getValue ( stopException ) ; vm ( ) . resume ( ) ; debug ( "Attempting to stop the client code...\n" ) ; thread . stop ( stopInstance ) ; thiz . setValue ( expectingStop , vm ( ) . mirrorOf ( false ) ) ; } break OUTER ; } } } } catch ( ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException ex ) { throw new InternalException ( "Exception on remote stop: " + ex ) ; } finally { vm ( ) . resume ( ) ; } } }
Interrupts a running remote invoke by manipulating remote variables and sending a stop via JDI .
186
public static ModuleFinder instance ( Context context ) { ModuleFinder instance = context . get ( moduleFinderKey ) ; if ( instance == null ) instance = new ModuleFinder ( context ) ; return instance ; }
Get the ModuleFinder instance for this invocation .
187
static PathFileObject forDirectoryPath ( BaseFileManager fileManager , Path path , Path userPackageRootDir , RelativePath relativePath ) { return new DirectoryFileObject ( fileManager , path , userPackageRootDir , relativePath ) ; }
Create a PathFileObject for a file within a directory such that the binary name can be inferred from the relationship to an enclosing directory .
188
public static PathFileObject forJarPath ( BaseFileManager fileManager , Path path , Path userJarPath ) { return new JarFileObject ( fileManager , path , userJarPath ) ; }
Create a PathFileObject for a file in a file system such as a jar file such that the binary name can be inferred from its position within the file system .
189
static PathFileObject forSimplePath ( BaseFileManager fileManager , Path path , Path userPath ) { return new SimpleFileObject ( fileManager , path , userPath ) ; }
Create a PathFileObject for a file whose binary name must be inferred from its position on a search path .
190
public static void generate ( ConfigurationImpl configuration ) throws DocFileIOException { DocPath filename = DocPaths . overviewSummary ( configuration . frames ) ; ModuleIndexWriter mdlgen = new ModuleIndexWriter ( configuration , filename ) ; mdlgen . buildModuleIndexFile ( "doclet.Window_Overview_Summary" , true ) ; }
Generate the module index page for the right - hand frame .
191
protected void addIndex ( Content body ) { for ( String groupname : groupList ) { SortedSet < ModuleElement > list = groupModuleMap . get ( groupname ) ; if ( list != null && ! list . isEmpty ( ) ) { addIndexContents ( list , groupname , configuration . getText ( "doclet.Member_Table_Summary" , groupname , configuration . getText ( "doclet.modules" ) ) , body ) ; } } }
Add the module index .
192
protected void addIndexContents ( Collection < ModuleElement > modules , String title , String tableSummary , Content body ) { HtmlTree htmltree = ( configuration . allowTag ( HtmlTag . NAV ) ) ? HtmlTree . NAV ( ) : new HtmlTree ( HtmlTag . DIV ) ; htmltree . addStyle ( HtmlStyle . indexNav ) ; HtmlTree ul = new HtmlTree ( HtmlTag . UL ) ; addAllClassesLink ( ul ) ; if ( configuration . showModules ) { addAllModulesLink ( ul ) ; } htmltree . addContent ( ul ) ; body . addContent ( htmltree ) ; addModulesList ( modules , title , tableSummary , body ) ; }
Adds module index contents .
193
protected void addModulesList ( Collection < ModuleElement > modules , String text , String tableSummary , Content body ) { Content table = ( configuration . isOutputHtml5 ( ) ) ? HtmlTree . TABLE ( HtmlStyle . overviewSummary , getTableCaption ( new RawHtml ( text ) ) ) : HtmlTree . TABLE ( HtmlStyle . overviewSummary , tableSummary , getTableCaption ( new RawHtml ( text ) ) ) ; table . addContent ( getSummaryTableHeader ( moduleTableHeader , "col" ) ) ; Content tbody = new HtmlTree ( HtmlTag . TBODY ) ; addModulesList ( modules , tbody ) ; table . addContent ( tbody ) ; Content anchor = getMarkerAnchor ( text ) ; Content div = HtmlTree . DIV ( HtmlStyle . contentContainer , anchor ) ; div . addContent ( table ) ; if ( configuration . allowTag ( HtmlTag . MAIN ) ) { htmlTree . addContent ( div ) ; } else { body . addContent ( div ) ; } }
Add the list of modules .
194
protected void addModulesList ( Collection < ModuleElement > modules , Content tbody ) { boolean altColor = true ; for ( ModuleElement mdle : modules ) { if ( ! mdle . isUnnamed ( ) ) { Content moduleLinkContent = getModuleLink ( mdle , new StringContent ( mdle . getQualifiedName ( ) . toString ( ) ) ) ; Content thModule = HtmlTree . TH_ROW_SCOPE ( HtmlStyle . colFirst , moduleLinkContent ) ; HtmlTree tdSummary = new HtmlTree ( HtmlTag . TD ) ; tdSummary . addStyle ( HtmlStyle . colLast ) ; addSummaryComment ( mdle , tdSummary ) ; HtmlTree tr = HtmlTree . TR ( thModule ) ; tr . addContent ( tdSummary ) ; tr . addStyle ( altColor ? HtmlStyle . altColor : HtmlStyle . rowColor ) ; tbody . addContent ( tr ) ; } altColor = ! altColor ; } }
Adds list of modules in the index table . Generate link to each module .
195
public static void convertRoot ( ConfigurationImpl configuration , RootDoc rd , DocPath outputdir ) { new SourceToHTMLConverter ( configuration , rd , outputdir ) . generate ( ) ; }
Convert the Classes in the given RootDoc to an HTML .
196
private static void addLineNo ( Content pre , int lineno ) { HtmlTree span = new HtmlTree ( HtmlTag . SPAN ) ; span . addStyle ( HtmlStyle . sourceLineNo ) ; if ( lineno < 10 ) { span . addContent ( "00" + Integer . toString ( lineno ) ) ; } else if ( lineno < 100 ) { span . addContent ( "0" + Integer . toString ( lineno ) ) ; } else { span . addContent ( Integer . toString ( lineno ) ) ; } pre . addContent ( span ) ; }
Add the line numbers for the source code .
197
private static void addBlankLines ( Content pre ) { for ( int i = 0 ; i < NUM_BLANK_LINES ; i ++ ) { pre . addContent ( NEW_LINE ) ; } }
Add trailing blank lines at the end of the page .
198
public Content getSerializedSummariesHeader ( ) { HtmlTree ul = new HtmlTree ( HtmlTag . UL ) ; ul . addStyle ( HtmlStyle . blockList ) ; return ul ; }
Get the serialized form summaries header .
199
public Content getSerialUIDInfoHeader ( ) { HtmlTree dl = new HtmlTree ( HtmlTag . DL ) ; dl . addStyle ( HtmlStyle . nameValue ) ; return dl ; }
Get the serial UID info header .