idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,600
static void render ( List < AbstractConfigValue > stack , StringBuilder sb , int indent , boolean atRoot , String atKey , ConfigRenderOptions options ) { boolean commentMerge = options . getComments ( ) ; if ( commentMerge ) { sb . append ( "# unresolved merge of " + stack . size ( ) + " values follows (\n" ) ; if ( at...
static method also used by ConfigDelayedMergeObject .
8,601
static ConfigException . NotResolved improveNotResolved ( Path what , ConfigException . NotResolved original ) { String newMessage = what . render ( ) + " has not been resolved, you need to call Config#resolve()," + " see API docs for Config#resolve()" ; if ( newMessage . equals ( original . getMessage ( ) ) ) return o...
further down on the stack .
8,602
public ConfigRenderOptions setFormatted ( boolean value ) { if ( value == formatted ) return this ; else return new ConfigRenderOptions ( originComments , comments , value , json ) ; }
Returns options with formatting toggled . Formatting means indentation and whitespace enabling formatting makes things prettier but larger .
8,603
private AbstractConfigObject rootMustBeObj ( Container value ) { if ( value instanceof AbstractConfigObject ) { return ( AbstractConfigObject ) value ; } else { return SimpleConfigObject . empty ( ) ; } }
object with nothing in it instead .
8,604
static private ResultWithPath findInObject ( AbstractConfigObject obj , ResolveContext context , Path path ) throws NotPossibleToResolve { if ( ConfigImpl . traceSubstitutionsEnabled ( ) ) ConfigImpl . trace ( "*** finding '" + path + "' in " + obj ) ; Path restriction = context . restrictToChild ( ) ; ResolveResult < ...
the ValueWithPath instance itself should not be .
8,605
private static Node < Container > replace ( Node < Container > list , Container old , AbstractConfigValue replacement ) { Container child = list . head ( ) ; if ( child != old ) throw new ConfigException . BugOrBroken ( "Can only replace() the top node we're resolving; had " + child + " on top and tried to replace " + ...
returns null if the replacement results in deleting all the nodes .
8,606
ResolveSource replaceWithinCurrentParent ( AbstractConfigValue old , AbstractConfigValue replacement ) { if ( ConfigImpl . traceSubstitutionsEnabled ( ) ) ConfigImpl . trace ( "replaceWithinCurrentParent old " + old + "@" + System . identityHashCode ( old ) + " replacement " + replacement + "@" + System . identityHashC...
replacement may be null to delete
8,607
static Iterator < Token > tokenize ( ConfigOrigin origin , Reader input , ConfigSyntax flavor ) { return new TokenIterator ( origin , input , flavor != ConfigSyntax . JSON ) ; }
Tokenizes a Reader . Does not close the reader ; you have to arrange to do that after you re done with the returned iterator .
8,608
private static SimpleConfigOrigin mergeThree ( SimpleConfigOrigin a , SimpleConfigOrigin b , SimpleConfigOrigin c ) { if ( similarity ( a , b ) >= similarity ( b , c ) ) { return mergeTwo ( mergeTwo ( a , b ) , c ) ; } else { return mergeTwo ( a , mergeTwo ( b , c ) ) ; } }
better consolidated .
8,609
static Map < SerializedField , Object > fieldsDelta ( Map < SerializedField , Object > base , Map < SerializedField , Object > child ) { Map < SerializedField , Object > m = new EnumMap < SerializedField , Object > ( child ) ; for ( Map . Entry < SerializedField , Object > baseEntry : base . entrySet ( ) ) { Serialized...
filename with every single value .
8,610
public DrawerBuilder withDrawerWidthDp ( int drawerWidthDp ) { if ( mActivity == null ) { throw new RuntimeException ( "please pass an activity first to use this call" ) ; } this . mDrawerWidth = Utils . convertDpToPx ( mActivity , drawerWidthDp ) ; return this ; }
Set the DrawerBuilder width with a dp value
8,611
private void addMenuItems ( Menu mMenu , boolean subMenu ) { int groupId = R . id . material_drawer_menu_default_group ; for ( int i = 0 ; i < mMenu . size ( ) ; i ++ ) { MenuItem mMenuItem = mMenu . getItem ( i ) ; IDrawerItem iDrawerItem ; if ( ! subMenu && mMenuItem . getGroupId ( ) != groupId && mMenuItem . getGrou...
helper method to init the drawerItems from a menu
8,612
private void handleShowOnLaunch ( ) { if ( mActivity != null && mDrawerLayout != null ) { if ( mShowDrawerOnFirstLaunch || mShowDrawerUntilDraggedOpened ) { final SharedPreferences preferences = mSharedPreferences != null ? mSharedPreferences : PreferenceManager . getDefaultSharedPreferences ( mActivity ) ; if ( mShowD...
helper method to handle when the drawer should be shown on launch
8,613
public Drawer buildView ( ) { mSliderLayout = ( ScrimInsetsRelativeLayout ) mActivity . getLayoutInflater ( ) . inflate ( R . layout . material_drawer_slider , mDrawerLayout , false ) ; mSliderLayout . setBackgroundColor ( UIUtils . getThemeColorFromAttrOrRes ( mActivity , R . attr . material_drawer_background , R . co...
build the drawers content only . This will still return a Result object but only with the content set . No inflating of a DrawerLayout .
8,614
protected void closeDrawerDelayed ( ) { if ( mCloseOnClick && mDrawerLayout != null ) { if ( mDelayOnDrawerClose > - 1 ) { new Handler ( ) . postDelayed ( new Runnable ( ) { public void run ( ) { mDrawerLayout . closeDrawers ( ) ; if ( mScrollToTopAfterClick ) { mRecyclerView . smoothScrollToPosition ( 0 ) ; } } } , mD...
helper method to close the drawer delayed
8,615
protected void resetStickyFooterSelection ( ) { if ( mStickyFooterView instanceof LinearLayout ) { for ( int i = 0 ; i < ( mStickyFooterView ) . getChildCount ( ) ; i ++ ) { ( mStickyFooterView ) . getChildAt ( i ) . setActivated ( false ) ; ( mStickyFooterView ) . getChildAt ( i ) . setSelected ( false ) ; } } }
simple helper method to reset the selection of the sticky footer
8,616
public void setActiveProfile ( IProfile profile , boolean fireOnProfileChanged ) { final boolean isCurrentSelectedProfile = mAccountHeaderBuilder . switchProfiles ( profile ) ; if ( mAccountHeaderBuilder . mDrawer != null && isSelectionListShown ( ) ) { mAccountHeaderBuilder . mDrawer . setSelection ( profile . getIden...
Selects the given profile and sets it to the new active profile
8,617
public void setActiveProfile ( long identifier , boolean fireOnProfileChanged ) { if ( mAccountHeaderBuilder . mProfiles != null ) { for ( IProfile profile : mAccountHeaderBuilder . mProfiles ) { if ( profile != null ) { if ( profile . getIdentifier ( ) == identifier ) { setActiveProfile ( profile , fireOnProfileChange...
Selects a profile by its identifier
8,618
public void removeProfile ( int position ) { if ( mAccountHeaderBuilder . mProfiles != null && mAccountHeaderBuilder . mProfiles . size ( ) > position ) { mAccountHeaderBuilder . mProfiles . remove ( position ) ; } mAccountHeaderBuilder . updateHeaderAndList ( ) ; }
remove a profile from the given position
8,619
public void removeProfileByIdentifier ( long identifier ) { int found = getPositionByIdentifier ( identifier ) ; if ( found > - 1 ) { mAccountHeaderBuilder . mProfiles . remove ( found ) ; } mAccountHeaderBuilder . updateHeaderAndList ( ) ; }
remove the profile with the given identifier
8,620
private int getPositionByIdentifier ( long identifier ) { int found = - 1 ; if ( mAccountHeaderBuilder . mProfiles != null && identifier != - 1 ) { for ( int i = 0 ; i < mAccountHeaderBuilder . mProfiles . size ( ) ; i ++ ) { if ( mAccountHeaderBuilder . mProfiles . get ( i ) != null ) { if ( mAccountHeaderBuilder . mP...
gets the position of a profile by it s identifier
8,621
public void setSelectorColor ( int selectorColor ) { this . mSelectorColor = selectorColor ; this . mSelectorFilter = new PorterDuffColorFilter ( Color . argb ( mSelectorAlpha , Color . red ( mSelectorColor ) , Color . green ( mSelectorColor ) , Color . blue ( mSelectorColor ) ) , PorterDuff . Mode . SRC_ATOP ) ; this ...
Sets the color of the selector to be draw over the CircularImageView . Be sure to provide some opacity .
8,622
public IDrawerItem generateMiniDrawerItem ( IDrawerItem drawerItem ) { if ( drawerItem instanceof SecondaryDrawerItem ) { return mIncludeSecondaryDrawerItems ? new MiniDrawerItem ( ( SecondaryDrawerItem ) drawerItem ) . withEnableSelectedBackground ( mEnableSelectedMiniDrawerItemBackground ) . withSelectedBackgroundAni...
generates a MiniDrawerItem from a IDrawerItem
8,623
public View build ( Context ctx ) { mContainer = new LinearLayout ( ctx ) ; if ( mInnerShadow ) { if ( ! mInRTL ) { mContainer . setBackgroundResource ( R . drawable . material_drawer_shadow_left ) ; } else { mContainer . setBackgroundResource ( R . drawable . material_drawer_shadow_right ) ; } } mRecyclerView = new Re...
build the MiniDrawer
8,624
public void onProfileClick ( ) { if ( mCrossFader != null ) { if ( mCrossFader . isCrossfaded ( ) ) { mCrossFader . crossfade ( ) ; } } if ( mAccountHeader != null ) { IProfile profile = mAccountHeader . getActiveProfile ( ) ; if ( profile instanceof IDrawerItem ) { mItemAdapter . set ( 0 , generateMiniDrawerItem ( ( I...
call this method to trigger the onProfileClick on the MiniDrawer
8,625
public boolean onItemClick ( IDrawerItem selectedDrawerItem ) { if ( selectedDrawerItem . isSelectable ( ) ) { if ( mCrossFader != null ) { if ( mCrossFader . isCrossfaded ( ) ) { mCrossFader . crossfade ( ) ; } } setSelection ( selectedDrawerItem . getIdentifier ( ) ) ; return false ; } else { return true ; } }
call this method to trigger the onItemClick on the MiniDrawer
8,626
public void setSelection ( long identifier ) { if ( identifier == - 1 ) { mAdapter . deselect ( ) ; } int count = mAdapter . getItemCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { IDrawerItem item = mAdapter . getItem ( i ) ; if ( item . getIdentifier ( ) == identifier && ! item . isSelected ( ) ) { mAdapter . desel...
set the selection of the MiniDrawer
8,627
public void createItems ( ) { mItemAdapter . clear ( ) ; int profileOffset = 0 ; if ( mAccountHeader != null && mAccountHeader . getAccountHeaderBuilder ( ) . mProfileImagesVisible ) { IProfile profile = mAccountHeader . getActiveProfile ( ) ; if ( profile instanceof IDrawerItem ) { mItemAdapter . add ( generateMiniDra...
creates the items for the MiniDrawer
8,628
private List < IDrawerItem > getDrawerItems ( ) { return mDrawer . getOriginalDrawerItems ( ) != null ? mDrawer . getOriginalDrawerItems ( ) : mDrawer . getDrawerItems ( ) ; }
returns always the original drawerItems and not the switched content
8,629
private void setHeaderHeight ( int height ) { if ( mAccountHeaderContainer != null ) { ViewGroup . LayoutParams params = mAccountHeaderContainer . getLayoutParams ( ) ; if ( params != null ) { params . height = height ; mAccountHeaderContainer . setLayoutParams ( params ) ; } View accountHeader = mAccountHeaderContaine...
helper method to set the height for the header!
8,630
private void handleSelectionView ( IProfile profile , boolean on ) { if ( on ) { if ( Build . VERSION . SDK_INT >= 23 ) { mAccountHeaderContainer . setForeground ( AppCompatResources . getDrawable ( mAccountHeaderContainer . getContext ( ) , mAccountHeaderTextSectionBackgroundResource ) ) ; } else { } mAccountHeaderCon...
a small helper to handle the selectionView
8,631
protected boolean switchProfiles ( IProfile newSelection ) { if ( newSelection == null ) { return false ; } if ( mCurrentProfile == newSelection ) { return true ; } if ( mAlternativeProfileHeaderSwitching ) { int prevSelection = - 1 ; if ( mProfileFirst == newSelection ) { prevSelection = 1 ; } else if ( mProfileSecond...
helper method to switch the profiles
8,632
private void setImageOrPlaceholder ( ImageView iv , ImageHolder imageHolder ) { DrawerImageLoader . getInstance ( ) . cancelImage ( iv ) ; iv . setImageDrawable ( DrawerImageLoader . getInstance ( ) . getImageLoader ( ) . placeholder ( iv . getContext ( ) , DrawerImageLoader . Tags . PROFILE . name ( ) ) ) ; ImageHolde...
small helper method to set an profile image or a placeholder
8,633
private void onProfileImageClick ( View v , boolean current ) { IProfile profile = ( IProfile ) v . getTag ( R . id . material_drawer_profile_header ) ; boolean consumed = false ; if ( mOnAccountHeaderProfileImageListener != null ) { consumed = mOnAccountHeaderProfileImageListener . onProfileImageClick ( v , profile , ...
calls the mOnAccountHEaderProfileImageListener and continues with the actions afterwards
8,634
protected int getCurrentSelection ( ) { if ( mCurrentProfile != null && mProfiles != null ) { int i = 0 ; for ( IProfile profile : mProfiles ) { if ( profile == mCurrentProfile ) { return i ; } i ++ ; } } return - 1 ; }
get the current selection
8,635
protected void toggleSelectionList ( Context ctx ) { if ( mDrawer != null ) { if ( mDrawer . switchedDrawerContent ( ) ) { resetDrawerContent ( ctx ) ; mSelectionListShown = false ; } else { buildDrawerSelectionList ( ) ; mAccountSwitcherArrow . clearAnimation ( ) ; ViewCompat . animate ( mAccountSwitcherArrow ) . rota...
helper method to toggle the collection
8,636
protected void buildDrawerSelectionList ( ) { int selectedPosition = - 1 ; int position = 0 ; ArrayList < IDrawerItem > profileDrawerItems = new ArrayList < > ( ) ; if ( mProfiles != null ) { for ( IProfile profile : mProfiles ) { if ( profile == mCurrentProfile ) { if ( mCurrentHiddenInList ) { continue ; } else { sel...
helper method to build and set the drawer selection list
8,637
private void resetDrawerContent ( Context ctx ) { if ( mDrawer != null ) { mDrawer . resetDrawerContent ( ) ; } mAccountSwitcherArrow . clearAnimation ( ) ; ViewCompat . animate ( mAccountSwitcherArrow ) . rotation ( 0 ) . start ( ) ; }
helper method to reset the drawer content
8,638
public boolean isDrawerOpen ( ) { if ( mDrawerBuilder . mDrawerLayout != null && mDrawerBuilder . mSliderLayout != null ) { return mDrawerBuilder . mDrawerLayout . isDrawerOpen ( mDrawerBuilder . mDrawerGravity ) ; } return false ; }
Get the current state of the drawer . True if the drawer is currently open .
8,639
public MiniDrawer getMiniDrawer ( ) { if ( mDrawerBuilder . mMiniDrawer == null ) { mDrawerBuilder . mMiniDrawer = new MiniDrawer ( ) . withDrawer ( this ) . withAccountHeader ( mDrawerBuilder . mAccountHeader ) ; } return mDrawerBuilder . mMiniDrawer ; }
gets the already generated MiniDrawer or creates a new one
8,640
public FrameLayout getContent ( ) { if ( mContentView == null && this . mDrawerBuilder . mDrawerLayout != null ) { mContentView = ( FrameLayout ) this . mDrawerBuilder . mDrawerLayout . findViewById ( R . id . content_layout ) ; } return mContentView ; }
get the container frameLayout of the current drawer
8,641
public void setGravity ( int gravity ) { DrawerLayout . LayoutParams params = ( DrawerLayout . LayoutParams ) getSlider ( ) . getLayoutParams ( ) ; params . gravity = gravity ; getSlider ( ) . setLayoutParams ( params ) ; mDrawerBuilder . mDrawerGravity = gravity ; }
sets the gravity for this drawer .
8,642
public IDrawerItem getDrawerItem ( long identifier ) { Pair < IDrawerItem , Integer > res = getAdapter ( ) . getItemById ( identifier ) ; if ( res != null ) { return res . first ; } else { return null ; } }
returns the DrawerItem by the given identifier
8,643
public int getCurrentSelectedPosition ( ) { return mDrawerBuilder . mAdapter . getSelections ( ) . size ( ) == 0 ? - 1 : mDrawerBuilder . mAdapter . getSelections ( ) . iterator ( ) . next ( ) ; }
get the current position of the selected drawer element
8,644
public long getCurrentSelection ( ) { IDrawerItem drawerItem = mDrawerBuilder . getDrawerItem ( getCurrentSelectedPosition ( ) ) ; if ( drawerItem != null ) { return drawerItem . getIdentifier ( ) ; } return - 1 ; }
get the current selected item identifier
8,645
public void updateBadge ( long identifier , StringHolder badge ) { IDrawerItem drawerItem = getDrawerItem ( identifier ) ; if ( drawerItem instanceof Badgeable ) { Badgeable badgeable = ( Badgeable ) drawerItem ; badgeable . withBadge ( badge ) ; updateItem ( ( IDrawerItem ) badgeable ) ; } }
update the badge for a specific drawerItem identified by its id
8,646
public void removeItemByPosition ( int position ) { if ( mDrawerBuilder . checkDrawerItem ( position , false ) ) { mDrawerBuilder . getItemAdapter ( ) . remove ( position ) ; } }
Remove a drawerItem at a specific position
8,647
public void removeStickyFooterItemAtPosition ( int position ) { if ( mDrawerBuilder . mStickyDrawerItems != null && mDrawerBuilder . mStickyDrawerItems . size ( ) > position ) { mDrawerBuilder . mStickyDrawerItems . remove ( position ) ; } DrawerUtils . rebuildStickyFooterView ( mDrawerBuilder ) ; }
Remove a footerDrawerItem at a specific position
8,648
public void removeAllStickyFooterItems ( ) { if ( mDrawerBuilder . mStickyDrawerItems != null ) { mDrawerBuilder . mStickyDrawerItems . clear ( ) ; } if ( mDrawerBuilder . mStickyFooterView != null ) { mDrawerBuilder . mStickyFooterView . setVisibility ( View . GONE ) ; } }
Removes all footerItems from drawer
8,649
public void resetDrawerContent ( ) { if ( switchedDrawerContent ( ) ) { setOnDrawerItemClickListener ( originalOnDrawerItemClickListener ) ; setOnDrawerItemLongClickListener ( originalOnDrawerItemLongClickListener ) ; setItems ( originalDrawerItems , true ) ; getAdapter ( ) . withSavedInstanceState ( originalDrawerStat...
helper method to reset to the original drawerContent
8,650
public static ColorStateList getTextColorStateList ( int text_color , int selected_text_color ) { return new ColorStateList ( new int [ ] [ ] { new int [ ] { android . R . attr . state_selected } , new int [ ] { } } , new int [ ] { selected_text_color , text_color } ) ; }
helper to create a colorStateList for the text
8,651
public static StateListDrawable getIconStateList ( Drawable icon , Drawable selectedIcon ) { StateListDrawable iconStateListDrawable = new StateListDrawable ( ) ; iconStateListDrawable . addState ( new int [ ] { android . R . attr . state_selected } , selectedIcon ) ; iconStateListDrawable . addState ( new int [ ] { } ...
helper to create a stateListDrawable for the icon
8,652
public static StateListDrawable getDrawerItemBackground ( int selected_color ) { ColorDrawable clrActive = new ColorDrawable ( selected_color ) ; StateListDrawable states = new StateListDrawable ( ) ; states . addState ( new int [ ] { android . R . attr . state_selected } , clrActive ) ; return states ; }
helper to create a StateListDrawable for the drawer item background
8,653
public static int getOptimalDrawerWidth ( Context context ) { int possibleMinDrawerWidth = UIUtils . getScreenWidth ( context ) - UIUtils . getActionBarHeight ( context ) ; int maxDrawerWidth = context . getResources ( ) . getDimensionPixelSize ( R . dimen . material_drawer_width ) ; return Math . min ( possibleMinDraw...
helper to calculate the optimal drawer width
8,654
public static Drawable getPlaceHolder ( Context ctx ) { return new IconicsDrawable ( ctx , MaterialDrawerFont . Icon . mdf_person ) . colorRes ( R . color . accent ) . backgroundColorRes ( R . color . primary ) . sizeDp ( 56 ) . paddingDp ( 16 ) ; }
helper method to get a person placeHolder drawable
8,655
public static void setDrawerVerticalPadding ( View v ) { int verticalPadding = v . getContext ( ) . getResources ( ) . getDimensionPixelSize ( R . dimen . material_drawer_vertical_padding ) ; v . setPadding ( verticalPadding , 0 , verticalPadding , 0 ) ; }
helper to set the vertical padding to the DrawerItems this is required because on API Level 17 the padding is ignored which is set via the XML
8,656
public static void setDrawerVerticalPadding ( View v , int level ) { int verticalPadding = v . getContext ( ) . getResources ( ) . getDimensionPixelSize ( R . dimen . material_drawer_vertical_padding ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ) { v . setPaddingRelative ( verticalPaddin...
helper to set the vertical padding including the extra padding for deeper item hirachy level to the DrawerItems this is required because on API Level 17 the padding is ignored which is set via the XML
8,657
public static boolean isSystemBarOnBottom ( Context ctx ) { WindowManager wm = ( WindowManager ) ctx . getSystemService ( Context . WINDOW_SERVICE ) ; DisplayMetrics metrics = new DisplayMetrics ( ) ; wm . getDefaultDisplay ( ) . getMetrics ( metrics ) ; Configuration cfg = ctx . getResources ( ) . getConfiguration ( )...
helper to check if the system bar is on the bottom of the screen
8,658
public void onPostBindView ( IDrawerItem drawerItem , View view ) { if ( mOnPostBindViewListener != null ) { mOnPostBindViewListener . onBindView ( drawerItem , view ) ; } }
is called after bindView to allow some post creation setps
8,659
public VH getViewHolder ( ViewGroup parent ) { return getViewHolder ( LayoutInflater . from ( parent . getContext ( ) ) . inflate ( getLayoutRes ( ) , parent , false ) ) ; }
This method returns the ViewHolder for our item using the provided View .
8,660
protected int getColor ( Context ctx ) { int color ; if ( this . isEnabled ( ) ) { color = ColorHolder . color ( getTextColor ( ) , ctx , R . attr . material_drawer_secondary_text , R . color . material_drawer_secondary_text ) ; } else { color = ColorHolder . color ( getDisabledTextColor ( ) , ctx , R . attr . material...
helper method to decide for the correct color OVERWRITE to get the correct secondary color
8,661
public static void onFooterDrawerItemClick ( DrawerBuilder drawer , IDrawerItem drawerItem , View v , Boolean fireOnClick ) { boolean checkable = ! ( drawerItem != null && drawerItem instanceof Selectable && ! drawerItem . isSelectable ( ) ) ; if ( checkable ) { drawer . resetStickyFooterSelection ( ) ; v . setActivate...
helper method to handle the onClick of the footer
8,662
public static void setStickyFooterSelection ( DrawerBuilder drawer , int position , Boolean fireOnClick ) { if ( position > - 1 ) { if ( drawer . mStickyFooterView != null && drawer . mStickyFooterView instanceof LinearLayout ) { LinearLayout footer = ( LinearLayout ) drawer . mStickyFooterView ; if ( drawer . mStickyF...
helper method to set the selection of the footer
8,663
public static int getPositionByIdentifier ( DrawerBuilder drawer , long identifier ) { if ( identifier != - 1 ) { for ( int i = 0 ; i < drawer . getAdapter ( ) . getItemCount ( ) ; i ++ ) { if ( drawer . getAdapter ( ) . getItem ( i ) . getIdentifier ( ) == identifier ) { return i ; } } } return - 1 ; }
calculates the position of an drawerItem . searching by it s identifier
8,664
public static IDrawerItem getDrawerItem ( List < IDrawerItem > drawerItems , long identifier ) { if ( identifier != - 1 ) { for ( IDrawerItem drawerItem : drawerItems ) { if ( drawerItem . getIdentifier ( ) == identifier ) { return drawerItem ; } } } return null ; }
gets the drawerItem with the specific identifier from a drawerItem list
8,665
public static IDrawerItem getDrawerItem ( List < IDrawerItem > drawerItems , Object tag ) { if ( tag != null ) { for ( IDrawerItem drawerItem : drawerItems ) { if ( tag . equals ( drawerItem . getTag ( ) ) ) { return drawerItem ; } } } return null ; }
gets the drawerItem by a defined tag from a drawerItem list
8,666
public static int getStickyFooterPositionByIdentifier ( DrawerBuilder drawer , long identifier ) { if ( identifier != - 1 ) { if ( drawer . mStickyFooterView != null && drawer . mStickyFooterView instanceof LinearLayout ) { LinearLayout footer = ( LinearLayout ) drawer . mStickyFooterView ; int shadowOffset = 0 ; for (...
calculates the position of an drawerItem inside the footer . searching by it s identifier
8,667
public static void rebuildStickyFooterView ( final DrawerBuilder drawer ) { if ( drawer . mSliderLayout != null ) { if ( drawer . mStickyFooterView != null ) { drawer . mStickyFooterView . removeAllViews ( ) ; if ( drawer . mStickyFooterDivider ) { addStickyFooterDivider ( drawer . mStickyFooterView . getContext ( ) , ...
small helper to rebuild the FooterView
8,668
public static void handleFooterView ( DrawerBuilder drawer , View . OnClickListener onClickListener ) { Context ctx = drawer . mSliderLayout . getContext ( ) ; if ( drawer . mStickyDrawerItems != null && drawer . mStickyDrawerItems . size ( ) > 0 ) { drawer . mStickyFooterView = DrawerUtils . buildStickyDrawerItemFoote...
helper method to handle the footerView
8,669
public static ViewGroup buildStickyDrawerItemFooter ( Context ctx , DrawerBuilder drawer , View . OnClickListener onClickListener ) { final LinearLayout linearLayout = new LinearLayout ( ctx ) ; linearLayout . setLayoutParams ( new LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . Layo...
build the sticky footer item view
8,670
private static void addStickyFooterDivider ( Context ctx , ViewGroup footerView ) { LinearLayout divider = new LinearLayout ( ctx ) ; LinearLayout . LayoutParams dividerParams = new LinearLayout . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ; divider . setMinimumHe...
adds the shadow to the stickyFooter
8,671
public static void fillStickyDrawerItemFooter ( DrawerBuilder drawer , ViewGroup container , View . OnClickListener onClickListener ) { for ( IDrawerItem drawerItem : drawer . mStickyDrawerItems ) { View view = drawerItem . generateView ( container . getContext ( ) , container ) ; view . setTag ( drawerItem ) ; if ( dr...
helper method to fill the sticky footer with it s elements
8,672
public static DrawerLayout . LayoutParams processDrawerLayoutParams ( DrawerBuilder drawer , DrawerLayout . LayoutParams params ) { if ( params != null ) { if ( drawer . mDrawerGravity != null && ( drawer . mDrawerGravity == Gravity . RIGHT || drawer . mDrawerGravity == Gravity . END ) ) { params . rightMargin = 0 ; if...
helper to extend the layoutParams of the drawer
8,673
public static void hideKeyboard ( Activity act ) { if ( act != null && act . getCurrentFocus ( ) != null ) { InputMethodManager inputMethodManager = ( InputMethodManager ) act . getSystemService ( Activity . INPUT_METHOD_SERVICE ) ; inputMethodManager . hideSoftInputFromWindow ( act . getCurrentFocus ( ) . getWindowTok...
Helper to hide the keyboard
8,674
public static byte run ( String [ ] argv , ClassLoader classLoader ) { final Runtime runtime = Runtime . builder ( ) . withArgs ( argv ) . withClassLoader ( classLoader ) . build ( ) ; runtime . run ( ) ; return runtime . exitStatus ( ) ; }
Launches the Cucumber - JVM command line .
8,675
private < T > T pluginProxy ( final Class < T > type ) { Object proxy = Proxy . newProxyInstance ( classLoader , new Class < ? > [ ] { type } , new InvocationHandler ( ) { public Object invoke ( Object target , Method method , Object [ ] args ) throws Throwable { for ( Object plugin : getPlugins ( ) ) { if ( type . isI...
Creates a dynamic proxy that multiplexes method invocations to all plugins of the same type .
8,676
public static BackportedJsonStringEncoder getInstance ( ) { SoftReference < BackportedJsonStringEncoder > ref = _threadEncoder . get ( ) ; BackportedJsonStringEncoder enc = ( ref == null ) ? null : ref . get ( ) ; if ( enc == null ) { enc = new BackportedJsonStringEncoder ( ) ; _threadEncoder . set ( new SoftReference ...
Factory method for getting an instance ; this is either recycled per - thread instance or a newly constructed one .
8,677
public char [ ] quoteAsString ( String input ) { TextBuffer textBuffer = _textBuffer ; if ( textBuffer == null ) { _textBuffer = textBuffer = new TextBuffer ( null ) ; } char [ ] outputBuffer = textBuffer . emptyAndGetCurrentSegment ( ) ; final int [ ] escCodes = sOutputEscapes128 ; final int escCodeCount = escCodes . ...
Method that will quote text contents using JSON standard quoting and return results as a character array
8,678
private String authenticate ( Credentials credentials ) throws AuthenticationException { if ( ! ( credentials instanceof EsApiKeyCredentials ) ) { throw new AuthenticationException ( "Incorrect credentials type provided. Expected [" + EsApiKeyCredentials . class . getName ( ) + "] but got [" + credentials . getClass ( ...
Implementation method for authentication
8,679
private void assertCorrectJobId ( Settings settings ) { SettingsUtils . ensureJobTransportPoolingKey ( settings ) ; String requestingJobKey = SettingsUtils . getJobTransportPoolingKey ( settings ) ; if ( ! jobKey . equals ( requestingJobKey ) ) { throw new EsHadoopIllegalArgumentException ( "Settings object passed does...
Checks to ensure that the caller is using a settings object with the same job id that this pool is responsible for .
8,680
private TransportPool getOrCreateTransportPool ( String hostInfo , Settings settings , SecureSettings secureSettings ) { TransportPool pool ; pool = hostPools . get ( hostInfo ) ; if ( pool == null ) { pool = new TransportPool ( jobKey , hostInfo , settings , secureSettings ) ; hostPools . put ( hostInfo , pool ) ; if ...
Gets the transport pool for the given host info or creates one if it is absent .
8,681
private Transport borrowFrom ( TransportPool pool , String hostInfo ) { if ( ! pool . getJobPoolingKey ( ) . equals ( jobKey ) ) { throw new EsHadoopIllegalArgumentException ( "PooledTransportFactory found a pool with a different owner than this job. " + "This could be a different job incorrectly polluting the Transpor...
Creates a Transport using the given TransportPool .
8,682
synchronized int cleanPools ( ) { int totalConnectionsRemaining = 0 ; List < String > hostsToRemove = new ArrayList < String > ( ) ; for ( Map . Entry < String , TransportPool > hostPool : hostPools . entrySet ( ) ) { String host = hostPool . getKey ( ) ; TransportPool pool = hostPool . getValue ( ) ; int connectionsRe...
Iterates over the available host pools and asks each one to purge transports older than a certain age .
8,683
private void doExecute ( HttpMethod method ) throws IOException { long start = System . currentTimeMillis ( ) ; try { client . executeMethod ( method ) ; afterExecute ( method ) ; } finally { stats . netTotalTime += ( System . currentTimeMillis ( ) - start ) ; closeAuthSchemeQuietly ( method ) ; } }
Actually perform the request
8,684
private void afterExecute ( HttpMethod method ) throws IOException { AuthState hostAuthState = method . getHostAuthState ( ) ; if ( hostAuthState . isPreemptive ( ) || hostAuthState . isAuthAttempted ( ) ) { AuthScheme authScheme = hostAuthState . getAuthScheme ( ) ; if ( authScheme instanceof SpnegoAuthScheme && setti...
Close any authentication resources that we may still have open and perform any after - response duties that we need to perform .
8,685
private void closeAuthSchemeQuietly ( HttpMethod method ) { AuthScheme scheme = method . getHostAuthState ( ) . getAuthScheme ( ) ; if ( scheme instanceof Closeable ) { try { ( ( Closeable ) scheme ) . close ( ) ; } catch ( IOException e ) { log . error ( "Could not close [" + scheme . getSchemeName ( ) + "] auth schem...
Close the underlying authscheme if it is a Closeable object .
8,686
static List [ ] findTypos ( Collection < String > fields , Mapping mapping ) { Set < String > keys = mapping . flatten ( ) . keySet ( ) ; List < String > missing = new ArrayList < String > ( fields . size ( ) ) ; for ( String field : fields ) { if ( ! keys . contains ( field ) && ! isBuiltIn ( field ) ) { missing . add...
return a tuple for proper messages
8,687
public static String joinParentField ( Settings settings ) { if ( StringUtils . hasText ( settings . getMappingJoin ( ) ) ) { return settings . getMappingJoin ( ) . concat ( ".parent" ) ; } return null ; }
If es . mapping . join is set this returns the field name for the join field s parent sub - field .
8,688
protected JsonDeserializer < Object > _findRootDeserializer ( DeserializationConfig cfg , JavaType valueType ) throws JsonMappingException { if ( valueType == null ) { throw new JsonMappingException ( "No value type configured for ObjectReader" ) ; } JsonDeserializer < Object > deser = _rootDeserializers . get ( valueT...
Method called to locate deserializer for the passed root - level value .
8,689
static Collection < String > columnToAlias ( Settings settings ) { FieldAlias fa = alias ( settings ) ; List < String > columnNames = StringUtils . tokenize ( settings . getProperty ( HiveConstants . COLUMNS ) , "," ) ; for ( String vc : HiveConstants . VIRTUAL_COLUMNS ) { columnNames . remove ( vc ) ; } for ( int i = ...
Renders the full collection of field names needed from ES by combining the names of the hive table fields with the user provided name mappings .
8,690
static String discoverJsonFieldName ( Settings settings , FieldAlias alias ) { Set < String > virtualColumnsToBeRemoved = new HashSet < String > ( HiveConstants . VIRTUAL_COLUMNS . length ) ; Collections . addAll ( virtualColumnsToBeRemoved , HiveConstants . VIRTUAL_COLUMNS ) ; List < String > columnNames = StringUtils...
Selects an appropriate field from the given Hive table schema to insert JSON data into if the feature is enabled
8,691
private static EsToken obtainEsToken ( final RestClient client , User user ) { KerberosPrincipal principal = user . getKerberosPrincipal ( ) ; if ( user . isProxyUser ( ) ) { principal = user . getRealUserProvider ( ) . getUser ( ) . getKerberosPrincipal ( ) ; } Assert . isTrue ( principal != null , "Kerberos credentia...
Obtain the given user s authentication token from Elasticsearch by performing the getAuthToken operation as the given user thus ensuring the subject s private credentials available on the thread s access control context for the life of the operation .
8,692
public static Token < EsTokenIdentifier > obtainToken ( RestClient client , User user ) { EsToken esToken = obtainEsToken ( client , user ) ; return EsTokenIdentifier . createTokenFrom ( esToken ) ; }
Obtain and return an authentication token for the current user .
8,693
public static void obtainAndCache ( RestClient client , User user ) throws IOException { EsToken token = obtainEsToken ( client , user ) ; if ( token == null ) { throw new IOException ( "No token returned for user " + user . getKerberosPrincipal ( ) . getName ( ) ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "O...
Obtain an authentication token for the given user and add it to the user s credentials .
8,694
public static void obtainTokenForJob ( final RestClient client , User user , Job job ) { Token < EsTokenIdentifier > token = obtainToken ( client , user ) ; if ( token == null ) { throw new EsHadoopException ( "No token returned for user " + user . getKerberosPrincipal ( ) . getName ( ) ) ; } Text clusterName = token ....
Obtain an authentication token on behalf of the given user and add it to the credentials for the given map reduce job . This version always obtains a fresh authentication token instead of checking for existing ones on the current user .
8,695
public static void addTokenForJob ( final RestClient client , ClusterName clusterName , User user , Job job ) { Token < EsTokenIdentifier > token = getAuthToken ( clusterName , user ) ; if ( token == null ) { token = obtainToken ( client , user ) ; } job . getCredentials ( ) . addToken ( token . getService ( ) , token ...
Retrieves an authentication token from the given user obtaining a new token if necessary and adds it to the credentials for the given map reduce job .
8,696
private static Token < EsTokenIdentifier > getAuthToken ( ClusterName clusterName , User user ) { EsToken esToken = getEsAuthToken ( clusterName , user ) ; if ( esToken == null ) { return null ; } else { return EsTokenIdentifier . createTokenFrom ( esToken ) ; } }
Get the authentication token of the user for the provided cluster name in its Hadoop Token form .
8,697
private static EsToken getEsAuthToken ( ClusterName clusterName , User user ) { return user . getEsToken ( clusterName . getName ( ) ) ; }
Get the authentication token of the user for the provided cluster name in its ES - Hadoop specific form .
8,698
public static ClusterInfo discoverClusterInfo ( Settings settings , Log log ) { ClusterName remoteClusterName = null ; EsMajorVersion remoteVersion = null ; String clusterName = settings . getProperty ( InternalConfigurationOptions . INTERNAL_ES_CLUSTER_NAME ) ; String clusterUUID = settings . getProperty ( InternalCon...
Retrieves the Elasticsearch cluster name and version from the settings or if they should be missing creates a bootstrap client and obtains their values .
8,699
private void lazyInitWriting ( ) { if ( ! writeInitialized ) { this . writeInitialized = true ; this . bulkProcessor = new BulkProcessor ( client , resources . getResourceWrite ( ) , settings ) ; this . trivialBytesRef = new BytesRef ( ) ; this . bulkEntryWriter = new BulkEntryWriter ( settings , BulkCommands . create ...
postpone writing initialization since we can do only reading so there s no need to allocate buffers