Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

In this page you can find the example usage for android.view Gravity LEFT.

Prototype

int LEFT

To view the source code for android.view Gravity LEFT.

Click Source Link

Document

Push object to the left of its container, not changing its size.

Usage

From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java

/**
 * Check the lock mode of the given drawer view.
 *
 * @param drawerView Drawer view to check lock mode
 * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 *//* ww  w. j a  v a 2  s  .c  o m*/
public int getDrawerLockMode(View drawerView) {
    final int gravity = getDrawerViewGravity(drawerView);
    if (gravity == Gravity.LEFT) {
        return mLockModeLeft;
    } else if (gravity == Gravity.RIGHT) {
        return mLockModeRight;
    }

    return LOCK_MODE_UNLOCKED;
}

From source file:com.cpic.taylor.logistics.activity.HomeActivity.java

@Override
protected void registerListener() {
    ivMine.setOnClickListener(new View.OnClickListener() {
        @Override//from   www  .  java  2  s .c  o  m
        public void onClick(View view) {
            layout.openDrawer(Gravity.LEFT);
        }
    });
    tvChat.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(HomeActivity.this, MainActivity.class);
            startActivity(intent);
        }
    });

    rgroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            // ?radioButton
            RadioButton selectRbtn = (RadioButton) findViewById(checkedId);

            int index = Integer.parseInt(selectRbtn.getTag().toString());
            int lastIndex = Integer.parseInt(lastButton.getTag().toString());

            Fragment mFragment = mManager.findFragmentByTag(index + "");

            mTrans = mManager.beginTransaction();

            if (mFragment == null) {
                mTrans.add(R.id.activity_home_framelayout, mFragList.get(index), "" + index);
            }

            // ??????
            mTrans.show(mFragList.get(index));
            mTrans.hide(mFragList.get(lastIndex));
            mTrans.commit();

            lastButton = selectRbtn;
        }
    });

    /**
     * 
     */
    etName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {

            if (!b && !etName.getText().toString().equals(sp.getString("name", ""))) {
                changeInfo(NAME);
            }
        }
    });
    etCarNum.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b && !etCarNum.getText().toString().equals(sp.getString("plate_number", ""))) {
                changeInfo(CAR_NUM);
            }
        }
    });
    etCarType.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b && !etCarType.getText().toString().equals(sp.getString("car_models", ""))) {
                changeInfo(CAR_TYPE);
            }
        }
    });
    linIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showPopupWindow(view, CAMERA, PHOTO, true);
        }
    });
    ivCarInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //                showPopupWindow(view, INFO_CAMERA, INFO_PHOTO, false);
            LoadImgPop pop = new LoadImgPop(pw, screenWidth, HomeActivity.this,
                    sp.getString("driving_license", ""));
            pop.showLookCameraPop();

        }
    });

    ivAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showPopupWindow(view, INFO_CAMERA, INFO_PHOTO, false);
        }
    });

    btnLoginOut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AlertDialog.Builder builder = new AlertDialog.Builder(HomeActivity.this);
            builder.setTitle("??");
            builder.setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (RongIM.getInstance() != null) {
                        if (RongYunContext.getInstance() != null) {
                            SharedPreferences.Editor edit = RongYunContext.getInstance().getSharedPreferences()
                                    .edit();
                            edit.putString(Constants.APP_TOKEN, Constants.DEFAULT);
                            edit.apply();
                        }
                        RongIM.getInstance().logout();
                    }
                    sp = PreferenceManager.getDefaultSharedPreferences(HomeActivity.this);
                    SharedPreferences.Editor editor = sp.edit();
                    editor.putBoolean("isLogin", true);
                    editor.putString("start", "");
                    editor.putString("end", "");
                    editor.putString("startLat", "");
                    editor.putString("startLng", "");
                    editor.putString("endLat", "");
                    editor.putString("endLng", "");
                    editor.commit();
                    finish();
                    dialogInterface.dismiss();
                }
            });
            builder.setNegativeButton("?", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
            builder.show();
        }
    });

    /**
     * ?
     */
    cboxVoice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                isSpeakVoice = true;
            } else {
                isSpeakVoice = false;
            }
        }
    });
    /**
     * ?
     */
    llCbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (cboxVoice.isChecked()) {
                cboxVoice.setChecked(false);
            } else {
                cboxVoice.setChecked(true);
            }
        }
    });

}

From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java

/**
 * Check the lock mode of the drawer with the given gravity.
 * //from w  ww. j a  va2s .com
 * @param edgeGravity
 *            Gravity of the drawer to check
 * @return one of {@link #LOCK_MODE_UNLOCKED},
 *         {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 */
public int getDrawerLockMode(int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.LEFT) {
        return mLockModeLeft;
    } else if (absGravity == Gravity.RIGHT) {
        return mLockModeRight;
    }
    return LOCK_MODE_UNLOCKED;
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED/* ww  w.  j av a 2  s. c o  m*/
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(@LockMode int lockMode, @EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.LEFT) {
        mLockModeLeft = lockMode;
    } else if (absGravity == Gravity.RIGHT) {
        mLockModeRight = lockMode;
    }
    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGravity == Gravity.LEFT ? mLeftDragger : mRightDragger;
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:com.google.blockly.android.ToolboxFragment.java

/**
 * Updates the padding used to calculate the margins of the scrollable blocks, based on the size
 * and placement of the tabs.//from   w  w  w.ja  va2s  .co m
 */
private void updateScrollablePadding() {
    int buttonHeight = mActionButton.getVisibility() == View.GONE ? 0 : mActionButton.getMeasuredHeight();
    int buttonWidth = mActionButton.getVisibility() == View.GONE ? 0 : mActionButton.getMeasuredWidth();
    int buttonVerticalPadding = 0, buttonHorizontalPadding = 0;
    if (mScrollOrientation == SCROLL_VERTICAL) {
        buttonVerticalPadding = buttonHeight;
    } else {
        buttonHorizontalPadding = buttonWidth;
    }
    int layoutDir = ViewCompat.getLayoutDirection(mRootView);
    int spacingForTabs;
    switch (GravityCompat.getAbsoluteGravity(mTabEdge, layoutDir)) {
    case Gravity.LEFT:
        spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredWidth() : 0; // Horizontal
        mScrollablePadding.set(spacingForTabs + buttonHorizontalPadding, buttonVerticalPadding, 0, 0);
        break;
    case Gravity.TOP:
        spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredHeight() : 0; // Vertical
        if (layoutDir == ViewCompat.LAYOUT_DIRECTION_LTR) {
            mScrollablePadding.set(buttonHorizontalPadding, spacingForTabs + buttonVerticalPadding, 0, 0);
        } else {
            mScrollablePadding.set(0, spacingForTabs + buttonVerticalPadding, buttonHorizontalPadding, 0);
        }
        break;
    case Gravity.RIGHT:
        spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredWidth() : 0; // Horizontal
        mScrollablePadding.set(0, buttonVerticalPadding, spacingForTabs + buttonHorizontalPadding, 0);
        break;
    case Gravity.BOTTOM:
        spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredHeight() : 0; // Vertical
        if (layoutDir == ViewCompat.LAYOUT_DIRECTION_LTR) {
            mScrollablePadding.set(buttonHorizontalPadding, 0, 0, spacingForTabs + buttonVerticalPadding);
        } else {
            mScrollablePadding.set(0, 0, buttonHorizontalPadding, spacingForTabs + buttonVerticalPadding);
        }
        break;
    }
}

From source file:com.gdpi.app.UpdateManager.java

/**
 * ?//from w  w w .jav a2  s  . co m
 */
private void showNoticeDialog() {

    updateinfo = updateinfo.replaceAll("#", "<br/>");
    final TextView text = new TextView(mContext);//
    text.setGravity(Gravity.LEFT | Gravity.CENTER);
    text.setTextSize(16);
    text.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (noticeDialog != null) {
                noticeDialog.dismiss();
                noticeDialog = null;
            }
            Intent intent = new Intent();
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(Url));

            mContext.startActivity(intent);
        }
    });
    text.setText(Html.fromHtml("<a href=" + Url + ">" + updateinfo + "</a>"));
    noticeDialog = AlertUtils.showAlertBtn(mContext, text, "APP???", "?", "??",
            new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    showDownloadDialog();
                    noticeDialog.dismiss();
                    noticeDialog = null;
                }
            }, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    noticeDialog.dismiss();
                    noticeDialog = null;
                }
            });
}

From source file:com.actionbarsherlock.internal.widget.IcsProgressBar.java

/**
 * Converts a drawable to a tiled version of itself. It will recursively
 * traverse layer and state list drawables.
 *//*from w w  w  .j av a2 s  . c o  m*/
private Drawable tileify(Drawable drawable, boolean clip) {

    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];

        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i),
                    (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }

        LayerDrawable newBg = new LayerDrawable(outDrawables);

        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }

        return newBg;

    } /* else if (drawable instanceof StateListDrawable) {
      StateListDrawable in = (StateListDrawable) drawable;
      StateListDrawable out = new StateListDrawable();
      int numStates = in.getStateCount();
      for (int i = 0; i < numStates; i++) {
          out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
      }
      return out;
              
      }*/ else if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }

        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());

        final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT,
                Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);

        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
    }

    return drawable;
}

From source file:com.crearo.gpslogger.GpsMainActivity.java

public void setUpNavigationDrawer(Bundle savedInstanceState) {

    final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, getToolbar(), R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {

        public void onDrawerClosed(View view) {
            invalidateOptionsMenu();/*from  www.java  2 s  .com*/
        }

        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu();
        }
    };

    drawerHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withAccountHeader(R.layout.smaller_header).withSavedInstance(savedInstanceState)
            .withProfileImagesVisible(false)
            .withHeaderBackground(new ColorDrawable(getResources().getColor(R.color.accentColor)))
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {

                    //Add new profile
                    if (profile.getIdentifier() == 101) {
                        new MaterialDialog.Builder(GpsMainActivity.this)
                                .title(getString(R.string.profile_create_new))
                                .inputType(InputType.TYPE_CLASS_TEXT).negativeText(R.string.cancel)
                                .input("", "", false, new MaterialDialog.InputCallback() {
                                    @Override
                                    public void onInput(@NonNull MaterialDialog materialDialog,
                                            CharSequence charSequence) {
                                        String profileName = charSequence.toString().trim();
                                        if (!Strings.isNullOrEmpty(profileName)) {
                                            final String[] ReservedChars = { "|", "\\", "?", "*", "<", "\"",
                                                    ":", ">", ".", "/", "'", ";" };

                                            for (String c : ReservedChars) {
                                                profileName = profileName.replace(c, "");
                                            }

                                            EventBus.getDefault()
                                                    .post(new ProfileEvents.CreateNewProfile(profileName));
                                        }
                                    }
                                }).show();
                        return true;
                    }

                    //Clicked on profile name
                    String newProfileName = profile.getName().getText();
                    EventBus.getDefault().post(new ProfileEvents.SwitchToProfile(newProfileName));

                    refreshProfileIcon(profile.getName().getText());
                    return true;
                }
            })
            .withOnAccountHeaderItemLongClickListener(new AccountHeader.OnAccountHeaderItemLongClickListener() {
                @Override
                public boolean onProfileLongClick(View view, final IProfile iProfile, boolean b) {
                    if (iProfile.getIdentifier() > 150) {

                        if (preferenceHelper.getCurrentProfileName().equals(iProfile.getName().getText())) {
                            Dialogs.alert(getString(R.string.sorry),
                                    getString(R.string.profile_switch_before_delete), GpsMainActivity.this);
                        } else {
                            new MaterialDialog.Builder(GpsMainActivity.this)
                                    .title(getString(R.string.profile_delete))
                                    .content(iProfile.getName().getText()).positiveText(R.string.ok)
                                    .negativeText(R.string.cancel)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            EventBus.getDefault().post(new ProfileEvents.DeleteProfile(
                                                    iProfile.getName().getText()));
                                        }
                                    }).show();
                        }
                    }
                    return false;
                }
            }).build();

    populateProfilesList();

    materialDrawer = new DrawerBuilder().withActivity(this).withSavedInstance(savedInstanceState)
            .withToolbar(getToolbar()).withActionBarDrawerToggle(drawerToggle).withDrawerGravity(Gravity.LEFT)
            .withAccountHeader(drawerHeader).withSelectedItem(-1).build();

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_general_title,
            R.string.pref_general_summary, R.drawable.settings, 1000));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_logging_title,
            R.string.pref_logging_summary, R.drawable.loggingsettings, 1001));
    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_performance_title,
            R.string.pref_performance_summary, R.drawable.performance, 1002));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer.addItem(GpsLoggerDrawerItem.newPrimary(R.string.pref_autosend_title,
            R.string.pref_autosend_summary, R.drawable.autosend, 1003));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.gdocs_setup_title, R.drawable.googledrive, 1004));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.dropbox_setup_title, R.drawable.dropbox, 1005));
    materialDrawer.addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoemail_title, R.drawable.email, 1006));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.autoftp_setup_title, R.drawable.ftp, 1007));
    materialDrawer
            .addItem(GpsLoggerDrawerItem.newSecondary(R.string.opengts_setup_title, R.drawable.opengts, 1008));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.osm_setup_title, R.drawable.openstreetmap, 1009));
    materialDrawer.addItem(
            GpsLoggerDrawerItem.newSecondary(R.string.owncloud_setup_title, R.drawable.owncloud, 1010));
    materialDrawer.addItem(new DividerDrawerItem());

    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_faq, R.drawable.helpfaq, 1011));
    materialDrawer
            .addStickyFooterItem(GpsLoggerDrawerItem.newSecondary(R.string.menu_exit, R.drawable.exit, 1012));

    materialDrawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
        @Override
        public boolean onItemClick(View view, int i, IDrawerItem iDrawerItem) {

            switch (iDrawerItem.getIdentifier()) {
            case 1000:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GENERAL);
                break;
            case 1001:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.LOGGING);
                break;
            case 1002:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.PERFORMANCE);
                break;
            case 1003:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.UPLOAD);
                break;
            case 1004:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.GDOCS);
                break;
            case 1005:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.DROPBOX);
                break;
            case 1006:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.EMAIL);
                break;
            case 1007:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.FTP);
                break;
            case 1008:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OPENGTS);
                break;
            case 1009:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OSM);
                break;
            case 1010:
                launchPreferenceScreen(MainPreferenceActivity.PREFERENCE_FRAGMENTS.OWNCLOUD);
                break;
            case 1011:
                Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
                startActivity(faqtivity);
                break;
            case 1012:
                EventBus.getDefault().post(new CommandEvents.RequestStartStop(false));
                finish();
                break;

            }
            return false;
        }
    });

    ImageButton helpButton = (ImageButton) findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:com.esri.android.mapsapp.MapFragment.java

/**
 * Takes a MapView that has already been instantiated to show a WebMap,
 * completes its setup by setting various listeners and attributes, and sets
 * it as the activity's content view./* www.  j av a 2 s  .  c  om*/
 * 
 * @param mapView
 */
private void setMapView(final MapView mapView) {

    mMapView = mapView;
    mMapView.setEsriLogoVisible(true);
    mMapView.enableWrapAround(true);
    mapView.setAllowRotationByPinch(true);

    // Creating an inflater
    mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Setting up the layout params for the searchview and searchresult
    // layout
    mlayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
            Gravity.LEFT | Gravity.TOP);
    int LEFT_MARGIN_SEARCH = 15;
    int RIGHT_MARGIN_SEARCH = 15;
    int BOTTOM_MARGIN_SEARCH = 0;
    mlayoutParams.setMargins(LEFT_MARGIN_SEARCH, TOP_MARGIN_SEARCH, RIGHT_MARGIN_SEARCH, BOTTOM_MARGIN_SEARCH);

    // Add the map to the layout
    mMapContainer.addView(mMapView, 0);

    // Set up floating action button
    setClickListenerForFloatingActionButton();

    // Displaying the searchbox layout
    showSearchBoxLayout();

    mMapView.setOnPinchListener(new OnPinchListener() {

        /**
         * Default value
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void postPointersDown(float x1, float y1, float x2, float y2, double factor) {
        }

        @Override
        public void postPointersMove(float x1, float y1, float x2, float y2, double factor) {
        }

        @Override
        public void postPointersUp(float x1, float y1, float x2, float y2, double factor) {
        }

        @Override
        public void prePointersDown(float x1, float y1, float x2, float y2, double factor) {
        }

        @Override
        public void prePointersMove(float x1, float y1, float x2, float y2, double factor) {
            if (mMapView.getRotationAngle() > 5 || mMapView.getRotationAngle() < -5) {
                mCompass.setVisibility(View.VISIBLE);
                mCompass.sensorManager.unregisterListener(mCompass.sensorEventListener);
                mCompass.setRotationAngle(mMapView.getRotationAngle());
            }
        }

        @Override
        public void prePointersUp(float x1, float y1, float x2, float y2, double factor) {
        }

    });

    // Setup listener for map initialized
    mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onStatusChanged(Object source, STATUS status) {

            if (source == mMapView && status == STATUS.INITIALIZED) {

                mapSpatialReference = mMapView.getSpatialReference();

                if (mMapViewState == null) {
                    // Starting location tracking will cause zoom to My
                    // Location
                    startLocationTracking();
                } else {
                    mMapView.restoreState(mMapViewState);
                }
                // add search and routing layers
                addGraphicLayers();
            }
        }
    });

    // Setup use of magnifier on a long press on the map
    mMapView.setShowMagnifierOnLongPress(true);
    mLongPressEvent = null;

    // Setup OnTouchListener to detect and act on long-press
    mMapView.setOnTouchListener(new MapOnTouchListener(getActivity(), mMapView) {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                // Start of a new gesture. Make sure mLongPressEvent is
                // cleared.
                mLongPressEvent = null;
            }
            return super.onTouch(v, event);
        }

        @Override
        public void onLongPress(MotionEvent point) {
            // Set mLongPressEvent to indicate we are processing a
            // long-press
            mLongPressEvent = point;
            super.onLongPress(point);

        }

        @Override
        public boolean onDragPointerUp(MotionEvent from, final MotionEvent to) {
            if (mLongPressEvent != null) {
                // This is the end of a long-press that will have displayed
                // the
                // magnifier.
                // Perform reverse-geocoding of the point that was pressed
                Point mapPoint = mMapView.toMapPoint(to.getX(), to.getY());
                ReverseGeocodingAsyncTask reverseGeocodeTask = new ReverseGeocodingAsyncTask();
                reverseGeocodeTask.execute(mapPoint);
                mPendingTask = reverseGeocodeTask;

                mLongPressEvent = null;
                // Remove any previous graphics
                resetGraphicsLayers();
            }
            return super.onDragPointerUp(from, to);
        }

    });

}

From source file:android.car.ui.provider.CarDrawerLayout.java

/**
 * Check the lock mode of the given drawer view.
 *
 * @param drawerView Drawer view to check lock mode
 * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 *//*from   w w w  . ja va 2s .c o m*/
public int getDrawerLockMode(View drawerView) {
    final int absGravity = getDrawerViewAbsoluteGravity(drawerView);
    if (absGravity == Gravity.LEFT) {
        return mLockModeLeft;
    } else if (absGravity == Gravity.RIGHT) {
        return mLockModeRight;
    }
    return LOCK_MODE_UNLOCKED;
}