Build and add the DrawerBuilder to your activity

@return
519208
public Drawer build() {
        if (mUsed) {
            throw new RuntimeException("you must not reuse a DrawerBuilder builder");
        }
        if (mActivity == null) {
            throw new RuntimeException("please pass an activity");
        }

        //set that this builder was used. now you have to create a new one
        mUsed = true;

        // if the user has not set a drawerLayout use the default one :D
        if (mDrawerLayout == null) {
            withDrawerLayout(-1);
        }

        //some new Materialize magic ;)
        mMaterialize = new MaterializeBuilder()
                .withActivity(mActivity)
                .withRootView(mRootView)
                .withFullscreen(mFullscreen)
                .withSystemUIHidden(mSystemUIHidden)
                .withUseScrimInsetsLayout(false)
                .withTransparentStatusBar(mTranslucentStatusBar)
                .withTranslucentNavigationBarProgrammatically(mTranslucentNavigationBarProgrammatically)
                .withContainer(mDrawerLayout)
                .build();

        //handle the navigation stuff of the ActionBarDrawerToggle and the drawer in general
        handleDrawerNavigation(mActivity, false);

        //build the view which will be set to the drawer
        Drawer result = buildView();

        //define id for the sliderLayout
        mSliderLayout.setId(R.id.material_drawer_slider_layout);
        // add the slider to the drawer
        mDrawerLayout.addView(mSliderLayout, 1);

        return result;
    }
749599
@Beta
  public Builder toBuilder() {
    Builder builder = new GoogleCredential.Builder()
        .setServiceAccountPrivateKey(serviceAccountPrivateKey)
        .setServiceAccountPrivateKeyId(serviceAccountPrivateKeyId)
        .setServiceAccountId(serviceAccountId)
        .setServiceAccountProjectId(serviceAccountProjectId)
        .setServiceAccountUser(serviceAccountUser)
        .setServiceAccountScopes(serviceAccountScopes)
        .setTokenServerEncodedUrl(getTokenServerEncodedUrl())
        .setTransport(getTransport())
        .setJsonFactory(getJsonFactory())
        .setClock(getClock());

    builder.setClientAuthentication(getClientAuthentication());

    return builder;
  }
79302
public DrawerBuilder withActivity(@NonNull Activity activity) {
        this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content);
        this.mActivity = activity;
        this.mLayoutManager = new LinearLayoutManager(mActivity);
        return this;
    }
1236464
protected JComponent buildComponent() {
        helperList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        GridBagLayout gbl = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();

        setLayout(gbl);

        editButton = new JButton("Edit...");
        editButton.setIconTextGap(0);
        editButton.setMargin(new Insets(2, 4, 2, 4));

        editButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                togglePanels();
            }
        });

        gbc.fill = GridBagConstraints.NONE;
        gbc.weightx = 0.0;
        gbc.weighty = 0.0;
        gbc.insets = new Insets(0, 0, 0, 3);
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbl.setConstraints(editButton, gbc);
        add(editButton);

        sourceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        sourceList.addKeyListener(new KeyAdapter() {
            public void keyPressed(final KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    moveLeftToRight();
                }
            }
        });

        gbc.fill = GridBagConstraints.BOTH;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        sourcePanel.add(BorderLayout.NORTH, sourceLabel);
        JScrollPane sourceScroller = new JScrollPane(sourceList);
        sourcePanel.add(BorderLayout.CENTER, sourceScroller);
        gbl.setConstraints(sourcePanel, gbc);
        add(sourcePanel);

        // JPanel buttonPanel = new ControlButtonPanel();
        JPanel buttonPanel = buildButtonPanel();
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.weightx = 0;
        gbc.weighty = 1.0;
        gbl.setConstraints(buttonPanel, gbc);
        add(buttonPanel);

        chosenList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        chosenList.addKeyListener(new KeyAdapter() {
            public void keyPressed(final KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_LEFT) {
                    moveRightToLeft();
                }
            }
        });
        gbc.fill = GridBagConstraints.BOTH;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        chosenPanel.add(BorderLayout.NORTH, chosenLabel);
        JScrollPane chosenScroller = new JScrollPane(chosenList);
        chosenPanel.add(BorderLayout.CENTER, chosenScroller);
        gbl.setConstraints(chosenPanel, gbc);
        add(chosenPanel);

        editButton.setVisible(showEditButton);
        this.buttonPanel.setVisible(panelsShowing);
        sourcePanel.setVisible(panelsShowing);

        return this;
    }
1107117
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_sample);
    ButterKnife.inject(this);
    initializeFragments();
    initializeListView();
    initializeDraggablePanel();
    configNavigationDrawer();
  }
637934
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
        mFragmentContainerView = getActivity().findViewById(fragmentId);
        mDrawerLayout = drawerLayout;
        mActionBarToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);

        // set a custom shadow that overlays the main content when the drawer opens
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
        // set up the drawer's list view with items and click listener

        // ActionBarDrawerToggle ties together the the proper interactions
        // between the navigation drawer and the action bar app icon.
        mDrawerToggle = new JToggle(
                getActivity(),                    /* host Activity */
                mDrawerLayout,                    /* DrawerLayout object */
                mActionBarToolbar,             /* nav drawer image to replace 'Up' caret */
                R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
                R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
        ) {
            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                if (!isAdded()) {
                    return;
                }

                getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
            }

            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                if (!isAdded()) {
                    return;
                }

                if (!mUserLearnedDrawer) {
                    // The user manually opened the drawer; store this flag to prevent auto-showing
                    // the navigation drawer automatically in the future.
                    mUserLearnedDrawer = true;
                    SharedPreferences sp = PreferenceManager
                            .getDefaultSharedPreferences(getActivity());
                    sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
                }

                getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
            }
        };

        // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
        // per the navigation drawer design guidelines.
        if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
            mDrawerLayout.openDrawer(mFragmentContainerView);
        }

        // Defer code dependent on restoration of previous instance state.
        mDrawerLayout.post(new Runnable() {
            @Override
            public void run() {
                mDrawerToggle.syncState();
            }
        });

        mDrawerLayout.setDrawerListener(mDrawerToggle);
    }
1176627
protected ImageLoader.Builder getBuilder() {
        // Get memory class of this device, exceeding this amount will throw an
        // OutOfMemory exception.
        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        int memClass = am.getMemoryClass();

        // Use part of the available memory for memory cache.
        final int memoryCacheSize = 1024 * 1024 * memClass / getMemoryDivider();

        int diskCache = getDiskCacheSize();
        if (Logger.DEBUG) Log.d(TAG, "Using memory cache of size: " + humanReadableByteCount(memoryCacheSize, false));
        if (Logger.DEBUG) Log.d(TAG, "Using disk cache of size: " + humanReadableByteCount(diskCache, false));

        File cacheDir = IOUtil.getDiskCacheDir(this, getCacheFolderName());
        return new ImageLoader.Builder(this)
                .enableDiskCache(cacheDir, diskCache)
                .enableMemoryCache(memoryCacheSize);
    }
946374
public static Builder builder() {
    return new AutoValue_OfflineDownloadOptions.Builder()
      .uuid(UUID.randomUUID().getMostSignificantBits())
      .metadata(new byte[] {})
      .progress(0);
    // TODO user must provide a notificationOptions object
  }
95831
protected BindingFactory createIdeaBindings() {
		final BindingFactory factory = new BindingFactory(getClass().getName());
		for (final AbstractSubCodeBuilderFragment subFragment : this.subFragments) {
			subFragment.generateIdeaBindings(factory);
		}
		return factory;
	}
836450
@SuppressWarnings("unchecked")
	@Pure
	public static Iterator<Drawer<?>> getAllDrawers() {
		if (services == null) {
			services = ServiceLoader.load(Drawer.class);
		}
		return services.iterator();
	}
1367333
public MessageMgr build(){
		if(this.messageHandlers.size()==0){
			this.buildErrors.addError("no message handlers set");
			return null;
		}
		return new MessageMgr(this.appID, this.messageHandlers, this.doCollectMessages);
	}
1161112
public MaterializeBuilder withActivity(Activity activity) {
        this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content);
        this.mActivity = activity;
        return this;
    }
1182030
public static void rebuildStickyFooterView(final DrawerBuilder drawer) {
        if (drawer.mSliderLayout != null) {
            if (drawer.mStickyFooterView != null) {
                drawer.mStickyFooterView.removeAllViews();

                //create the divider
                if (drawer.mStickyFooterDivider) {
                    addStickyFooterDivider(drawer.mStickyFooterView.getContext(), drawer.mStickyFooterView);
                }

                //fill the footer with items
                DrawerUtils.fillStickyDrawerItemFooter(drawer, drawer.mStickyFooterView, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        IDrawerItem drawerItem = (IDrawerItem) v.getTag(R.id.material_drawer_item);
                        com.mikepenz.materialdrawer.DrawerUtils.onFooterDrawerItemClick(drawer, drawerItem, v, true);
                    }
                });

                drawer.mStickyFooterView.setVisibility(View.VISIBLE);
            } else {
                //there was no footer yet. now just create one
                DrawerUtils.handleFooterView(drawer, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        IDrawerItem drawerItem = (IDrawerItem) v.getTag(R.id.material_drawer_item);
                        DrawerUtils.onFooterDrawerItemClick(drawer, drawerItem, v, true);
                    }
                });
            }

            setStickyFooterSelection(drawer, drawer.mCurrentStickyFooterSelection, false);
        }
    }
556293
public Builder copyBuilder() {
        return GetJobArgs.builder().noHang(noHang).timeout(timeout).withCounters(withCounters);
    }
447292
public ISarlConstructorBuilder addSarlConstructor() {
		ISarlConstructorBuilder builder = this.iSarlConstructorBuilderProvider.get();
		builder.eInit(getSarlAgent(), getTypeResolutionContext());
		return builder;
	}
1025518
@Override public WebViewMapFragment build() {
    if (options == null) {
      options = new GoogleWebMapType();
    }
    if (options instanceof GoogleWebMapType) {
      return GoogleWebViewMapFragment.newInstance(options);
    }
    if (options instanceof GoogleChinaMapType) {
      return GoogleChinaWebViewMapFragment.newInstance(options);
    }
    if (options instanceof LeafletMapType) {
      return LeafletWebViewMapFragment.newInstance(options);
    }
    return null;
  }
173388
private void setupDrawer(){

        // Setup drawer background color if set
        int backgroundColor = UIUtils.getColorAttr(mActivity, R.attr.drawerBackground);
        if(backgroundColor > 0){
            mDrawerPane.setBackgroundColor(backgroundColor);
        }

        // Set the drawer layout statusbar color
        int statusBarColor = mConfig.getStatusBarColor(mActivity);
        if(statusBarColor != -1) mDrawerLayout.setStatusBarBackgroundColor(statusBarColor);

        // Populate Header View
        populateHeader();

        // Populate Footer View
        populateFooter();

        // Configure the scrim inset pane view
        final int headerHeight = mActivity.getResources().getDimensionPixelSize(
                R.dimen.navdrawer_chosen_account_height);
        mDrawerPane.setOnInsetsCallback(new OnInsetsCallback() {
            @Override
            public void onInsetsChanged(Rect insets) {

                if (mHeaderView != null) {
                    mConfig.onInsetsChanged(mHeaderView, insets);

                    ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams();
                    lp2.height = headerHeight + insets.top;
                    mDrawerHeaderFrame.setLayoutParams(lp2);
                }else{

                    ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams();
                    lp2.height = insets.top;
                    mDrawerHeaderFrame.setLayoutParams(lp2);

                }
            }
        });

        // Setup the drawer toggle
        if(mToolbar != null){
            mDrawerToggle = new ActionBarDrawerToggle(mActivity,
                    mDrawerLayout,
                    mToolbar,
                    R.string.navigation_drawer_open,
                    R.string.navigation_drawer_close){

                @Override
                public void onDrawerClosed(View drawerView) {
                    super.onDrawerClosed(drawerView);
                    if(mCallbacks != null) mCallbacks.onDrawerClosed(drawerView);
                }

                @Override
                public void onDrawerOpened(View drawerView) {
                    super.onDrawerOpened(drawerView);
                    if(mCallbacks != null) mCallbacks.onDrawerOpened(drawerView);
                }

                @Override
                public void onDrawerSlide(View drawerView, float slideOffset) {
                    super.onDrawerSlide(drawerView, mConfig.shouldAnimateIndicator() ? slideOffset : 0);
                    if(mCallbacks != null) mCallbacks.onDrawerSlide(drawerView, slideOffset);
                }
            };

            // Defer code dependent on restoration of previous instance state.

            mDrawerLayout.post(new Runnable() {
                @Override
                public void run() {
                    mDrawerToggle.syncState();
                }
            });
            mDrawerLayout.setDrawerListener(mDrawerToggle);
        }

        // Setup the drawer shadow
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    }