Example usage for android.support.v4.view GravityCompat START

List of usage examples for android.support.v4.view GravityCompat START

Introduction

In this page you can find the example usage for android.support.v4.view GravityCompat START.

Prototype

int START

To view the source code for android.support.v4.view GravityCompat START.

Click Source Link

Usage

From source file:com.dosse.bwentrain.androidPlayer.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.nav_presets) {
        startActivity(/*w w  w  .  ja va  2s  . co  m*/
                new Intent(this, BrowserActivity.class).putExtra("path", getString(R.string.presets_url)));
    }
    if (id == R.id.nav_community) {
        startActivity(
                new Intent(this, CommunityActivity.class).putExtra("path", getString(R.string.forum_url)));
    }
    if (id == R.id.nav_settings) {
        startActivity(new Intent(this, SettingsActivity.class));
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.EditText.java

@Override
protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super.applyStyle(context, attrs, defStyleAttr, defStyleRes);

    CharSequence text = mInputView == null ? null : mInputView.getText();
    removeAllViews();/*from   ww  w  .j a v a2 s.c  o  m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EditText, defStyleAttr, defStyleRes);

    int labelPadding = -1;
    int labelTextSize = -1;
    ColorStateList labelTextColor = null;
    int supportPadding = -1;
    int supportTextSize = -1;
    ColorStateList supportColors = null;
    ColorStateList supportErrorColors = null;
    String supportHelper = null;
    String supportError = null;
    ColorStateList dividerColors = null;
    ColorStateList dividerErrorColors = null;
    int dividerHeight = -1;
    int dividerPadding = -1;
    int dividerAnimDuration = -1;

    mAutoCompleteMode = a.getInteger(R.styleable.EditText_et_autoCompleteMode, mAutoCompleteMode);
    if (needCreateInputView(mAutoCompleteMode)) {
        switch (mAutoCompleteMode) {
        case AUTOCOMPLETE_MODE_SINGLE:
            mInputView = new InternalAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        case AUTOCOMPLETE_MODE_MULTI:
            mInputView = new InternalMultiAutoCompleteTextView(context, attrs, defStyleAttr);
            break;
        default:
            mInputView = new InternalEditText(context, attrs, defStyleAttr);
            break;
        }
        ViewUtil.applyFont(mInputView, attrs, defStyleAttr, defStyleRes);
        if (text != null)
            mInputView.setText(text);

        mInputView.addTextChangedListener(new InputTextWatcher());

        if (mDivider != null) {
            mDivider.setAnimEnable(false);
            ViewUtil.setBackground(mInputView, mDivider);
            mDivider.setAnimEnable(true);
        }
    } else
        ViewUtil.applyStyle(mInputView, attrs, defStyleAttr, defStyleRes);
    mInputView.setVisibility(View.VISIBLE);
    mInputView.setFocusableInTouchMode(true);

    for (int i = 0, count = a.getIndexCount(); i < count; i++) {
        int attr = a.getIndex(i);

        if (attr == R.styleable.EditText_et_labelEnable)
            mLabelEnable = a.getBoolean(attr, false);
        else if (attr == R.styleable.EditText_et_labelPadding)
            labelPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextSize)
            labelTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_labelTextColor)
            labelTextColor = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_labelTextAppearance)
            getLabelView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_labelEllipsize) {
            int labelEllipsize = a.getInteger(attr, 0);
            switch (labelEllipsize) {
            case 1:
                getLabelView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getLabelView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getLabelView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getLabelView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_labelInAnim)
            mLabelInAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_labelOutAnim)
            mLabelOutAnimId = a.getResourceId(attr, 0);
        else if (attr == R.styleable.EditText_et_supportMode)
            mSupportMode = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_supportPadding)
            supportPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextSize)
            supportTextSize = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_supportTextColor)
            supportColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextErrorColor)
            supportErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_supportTextAppearance)
            getSupportView().setTextAppearance(context, a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_supportEllipsize) {
            int supportEllipsize = a.getInteger(attr, 0);
            switch (supportEllipsize) {
            case 1:
                getSupportView().setEllipsize(TruncateAt.START);
                break;
            case 2:
                getSupportView().setEllipsize(TruncateAt.MIDDLE);
                break;
            case 3:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            case 4:
                getSupportView().setEllipsize(TruncateAt.MARQUEE);
                break;
            default:
                getSupportView().setEllipsize(TruncateAt.END);
                break;
            }
        } else if (attr == R.styleable.EditText_et_supportMaxLines)
            getSupportView().setMaxLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportLines)
            getSupportView().setLines(a.getInteger(attr, 0));
        else if (attr == R.styleable.EditText_et_supportSingleLine)
            getSupportView().setSingleLine(a.getBoolean(attr, false));
        else if (attr == R.styleable.EditText_et_supportMaxChars)
            mSupportMaxChars = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_helper)
            supportHelper = a.getString(attr);
        else if (attr == R.styleable.EditText_et_error)
            supportError = a.getString(attr);
        else if (attr == R.styleable.EditText_et_inputId)
            mInputView.setId(a.getResourceId(attr, 0));
        else if (attr == R.styleable.EditText_et_dividerColor)
            dividerColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerErrorColor)
            dividerErrorColors = a.getColorStateList(attr);
        else if (attr == R.styleable.EditText_et_dividerHeight)
            dividerHeight = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerPadding)
            dividerPadding = a.getDimensionPixelSize(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerAnimDuration)
            dividerAnimDuration = a.getInteger(attr, 0);
        else if (attr == R.styleable.EditText_et_dividerCompoundPadding)
            mDividerCompoundPadding = a.getBoolean(attr, true);
    }

    a.recycle();

    if (mInputView.getId() == 0)
        mInputView.setId(ViewUtil.generateViewId());

    if (mDivider == null) {
        mDividerColors = dividerColors;
        mDividerErrorColors = dividerErrorColors;

        if (mDividerColors == null) {
            int[][] states = new int[][] { new int[] { -android.R.attr.state_focused },
                    new int[] { android.R.attr.state_focused, android.R.attr.state_enabled }, };
            int[] colors = new int[] { ThemeUtil.colorControlNormal(context, 0xFF000000),
                    ThemeUtil.colorControlActivated(context, 0xFF000000), };

            mDividerColors = new ColorStateList(states, colors);
        }

        if (mDividerErrorColors == null)
            mDividerErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

        if (dividerHeight < 0)
            dividerHeight = 0;

        if (dividerPadding < 0)
            dividerPadding = 0;

        if (dividerAnimDuration < 0)
            dividerAnimDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime);

        mDividerPadding = dividerPadding;
        mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);

        mDivider = new DividerDrawable(dividerHeight,
                mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0, mDividerColors,
                dividerAnimDuration);
        mDivider.setInEditMode(isInEditMode());
        mDivider.setAnimEnable(false);
        ViewUtil.setBackground(mInputView, mDivider);
        mDivider.setAnimEnable(true);
    } else {
        if (dividerHeight >= 0 || dividerPadding >= 0) {
            if (dividerHeight < 0)
                dividerHeight = mDivider.getDividerHeight();

            if (dividerPadding >= 0)
                mDividerPadding = dividerPadding;

            mInputView.setPadding(0, 0, 0, mDividerPadding + dividerHeight);
            mDivider.setDividerHeight(dividerHeight);
            mDivider.setPadding(mDividerCompoundPadding ? mInputView.getTotalPaddingLeft() : 0,
                    mDividerCompoundPadding ? mInputView.getTotalPaddingRight() : 0);
        }

        if (dividerColors != null)
            mDividerColors = dividerColors;

        if (dividerErrorColors != null)
            mDividerErrorColors = dividerErrorColors;

        mDivider.setColor(getError() == null ? mDividerColors : mDividerErrorColors);

        if (dividerAnimDuration >= 0)
            mDivider.setAnimationDuration(dividerAnimDuration);
    }

    if (labelPadding >= 0)
        getLabelView().setPadding(mDivider.getPaddingLeft(), 0, mDivider.getPaddingRight(), labelPadding);

    if (labelTextSize >= 0)
        getLabelView().setTextSize(TypedValue.COMPLEX_UNIT_PX, labelTextSize);

    if (labelTextColor != null)
        getLabelView().setTextColor(labelTextColor);

    if (mLabelEnable) {
        mLabelVisible = true;
        getLabelView().setText(mInputView.getHint());
        addView(getLabelView(), 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        setLabelVisible(!TextUtils.isEmpty(mInputView.getText().toString()), false);
    }

    if (supportTextSize >= 0)
        getSupportView().setTextSize(TypedValue.COMPLEX_UNIT_PX, supportTextSize);

    if (supportColors != null)
        mSupportColors = supportColors;
    else if (mSupportColors == null)
        mSupportColors = context.getResources().getColorStateList(R.color.abc_secondary_text_material_light);

    if (supportErrorColors != null)
        mSupportErrorColors = supportErrorColors;
    else if (mSupportErrorColors == null)
        mSupportErrorColors = ColorStateList.valueOf(ThemeUtil.colorAccent(context, 0xFFFF0000));

    if (supportPadding >= 0)
        getSupportView().setPadding(mDivider.getPaddingLeft(), supportPadding, mDivider.getPaddingRight(), 0);

    if (supportHelper == null && supportError == null)
        getSupportView().setTextColor(getError() == null ? mSupportColors : mSupportErrorColors);
    else if (supportHelper != null)
        setHelper(supportHelper);
    else
        setError(supportError);

    if (mSupportMode != SUPPORT_MODE_NONE) {
        switch (mSupportMode) {
        case SUPPORT_MODE_CHAR_COUNTER:
            getSupportView().setGravity(Gravity.END);
            updateCharCounter(mInputView.getText().length());
            break;
        case SUPPORT_MODE_HELPER:
        case SUPPORT_MODE_HELPER_WITH_ERROR:
            getSupportView().setGravity(GravityCompat.START);
            break;
        }
        addView(getSupportView(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }

    addView(mInputView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    requestLayout();
}

From source file:augsburg.se.alltagsguide.overview.OverviewActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(OTHER_LANGUAGES_KEY, new ArrayList<>(mOtherLanguages));
    outState.putBoolean(SAVE_INSTANCE_STATE_NAVIGATION_DRAWER_OPEN,
            drawerLayout.isDrawerOpen(GravityCompat.START));
    super.onSaveInstanceState(outState);
}

From source file:com.example.customview.DynamicListView.java

/**
 * To lock DrawerLayout when user modify panel
 *//*from  w  w  w.  jav a 2s.c  om*/
private void drawLayoutSetLock() {
    if (mDrawerLayout == null) {
        mDrawerLayout = (DrawerLayout) slideMenuActivity.findViewById(R.id.drawer_layout);
    }
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, GravityCompat.END);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.START);
}

From source file:com.example.customview.DynamicListView.java

/**
 * To unlock DrawerLayout when user finish modify
 *///  w w w . j  a v a  2 s .  c o  m
private void drawLayoutSetUnlock() {
    if (mDrawerLayout == null) {
        mDrawerLayout = (DrawerLayout) slideMenuActivity.findViewById(R.id.drawer_layout);
    }
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.START);
}

From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean retval = true;
    switch (item.getItemId()) {
    case R.id.action_sync_account: {
        startSynchronization();//from w w w  .  java2  s . c  o  m
        break;
    }
    case android.R.id.home: {
        FileFragment second = getSecondFragment();
        OCFile currentDir = getCurrentDir();
        if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
            mDrawerLayout.closeDrawer(GravityCompat.START);
        } else if ((currentDir != null && currentDir.getParentId() != 0)
                || (second != null && second.getFile() != null)) {
            onBackPressed();

        } else {
            mDrawerLayout.openDrawer(GravityCompat.START);
        }
        break;
    }
    case R.id.action_sort: {
        SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this);

        // Read sorting order, default to sort by name ascending
        Integer sortOrder = appPreferences.getInt("sortOrder", FileStorageUtils.SORT_NAME);

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.actionbar_sort_title).setSingleChoiceItems(R.array.actionbar_sortby,
                sortOrder, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                        case 0:
                            sortByName(true);
                            break;
                        case 1:
                            sortByDate(false);
                            break;
                        }

                        dialog.dismiss();
                    }
                });
        builder.create().show();
        break;
    }
    case R.id.action_switch_view: {
        if (isGridView()) {
            item.setTitle(getString(R.string.action_switch_grid_view));
            item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_module));
            getListOfFilesFragment().setListAsPreferred();
        } else {
            item.setTitle(getApplicationContext().getString(R.string.action_switch_list_view));
            item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_list));
            getListOfFilesFragment().setGridAsPreferred();
        }
        return true;
    }
    default:
        retval = super.onOptionsItemSelected(item);
    }
    return retval;
}

From source file:com.example.angel.parkpanda.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    showhideFootWindow(0);/*  w  w w .ja va2  s. com*/
    if (id == R.id.nav_menu_findparking) {
        Intent intent = new Intent(getApplicationContext(), Find_Park.class);
        startActivityForResult(intent, 2);// Activity is started with requestCode 2
        // finish();
    }
    if (id == R.id.nav_menu_account) {
        initViewSetting(false);
        if (LOGININFO.flag == 10) {
            Fragment fragment = new my_account();
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction FT = fragmentManager.beginTransaction();
            FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
            FT.replace(R.id.flContent, fragment).commit();
        } else {
            Fragment fragment = new log_in();
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction FT = fragmentManager.beginTransaction();
            FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
            FT.replace(R.id.flContent, fragment).commit();
        }

    }
    if (id == R.id.nav_menu_help) {
        int currentapiVersion = android.os.Build.VERSION.SDK_INT;

        if (currentapiVersion > 21) {
            showhideFootWindow(0);
            initViewSetting(true);

            LayoutInflater inflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.ly_my_help, null);
            layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popupanim));
            PopupWindow optionspu = new PopupWindow(layout, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);

            optionspu.setFocusable(true);
            optionspu.showAtLocation(layout, Gravity.CENTER, 0, 0);
            optionspu.update(0, 0, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);
            optionspu.setAnimationStyle(R.anim.popupanim);
        } else {

            // initViewSetting(false);

            /*                Fragment fragment = new help_dialog();
                            FragmentManager fragmentManager = getSupportFragmentManager();
                            FragmentTransaction FT = fragmentManager.beginTransaction();
                            FT.setCustomAnimations(R.anim.enter_from_right,
                R.anim.exit_to_left);
                            FT.replace(R.id.flContent, fragment).commit();*/

            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.fragment_help_dialog, null);
            final PopupWindow optionspu = new PopupWindow(popupView, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);

            optionspu.setFocusable(true);
            optionspu.showAtLocation(popupView, Gravity.CENTER, 0, 0);
            Button btnDismiss = (Button) popupView.findViewById(R.id.btn_help_close);

            btnDismiss.setOnClickListener(new Button.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // Toast.makeText(getApplicationContext(), "dsdsa", Toast.LENGTH_SHORT).show();
                    optionspu.dismiss();
                    plotMarkers(mMyMarkersArray);
                    initViewSetting(true);
                }

            });
        }

    }
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.hangulo.powercontact.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem menuItem) { //Navigation? ?? ?? ? 

    // update the main content by replacing fragments
    // ?  ?? ?   ?? .
    //Intent intent;
    int mSelectedId;
    menuItem.setChecked(true);/*from   w w  w . j a  v  a  2  s  .  c  o  m*/
    mSelectedId = menuItem.getItemId();
    switch (mSelectedId) {

    case R.id.drawer_menu_header:
        mDrawerLayout.closeDrawer(GravityCompat.START); //Drawer ?
        return true;

    case R.id.main_drawer_item_01: { // ?
        mDrawerLayout.closeDrawer(GravityCompat.START); //Drawer ?
        selectAccount(true); // start sync
        return true;
    }
    case R.id.main_drawer_item_02: // ??
    // Toast.makeText(this, "Menu item selected -> " + position, Toast.LENGTH_SHORT).show();
    {
        mDrawerLayout.closeDrawer(GravityCompat.START); //Drawer ?

        Intent intentNext = new Intent(this, ErrorContactsListActivity.class);
        startActivity(intentNext);
        return true;
    }

    case R.id.main_drawer_item_04: { //  Settings
        mDrawerLayout.closeDrawer(GravityCompat.START);
        Intent SettingActivity = new Intent(this, SettingsActivity.class);
        startActivityForResult(SettingActivity, Constants.SETTINGS_REQUEST); // when settings changed then apply it immediately
        return true;
    }

    case R.id.main_drawer_item_05: // about
        mDrawerLayout.closeDrawer(GravityCompat.START); //Drawer ?
        OpensourceFragment.displayLicensesFragment(getSupportFragmentManager());
        return true;
    }
    return false;
}

From source file:com.fvd.nimbus.PaintActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_DOWN) {
            drawView.zoom(1.25f);//  w w  w.ja v  a 2s .  co m
        }
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            drawView.zoom(0.75f);
        }
        return true;
    case KeyEvent.KEYCODE_BACK:
        if (action == KeyEvent.ACTION_DOWN) {
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
                return true;
            } else if (findViewById(R.id.text_field).getVisibility() != View.GONE) {
                findViewById(R.id.text_field).setVisibility(View.GONE);
                drawView.hideCrop();
                drawView.startEdit();
                setSelectedFoot(0);
                return true;
            } else if (findViewById(R.id.color_menu).getVisibility() != View.GONE) {
                findViewById(R.id.color_menu).setVisibility(View.GONE);
                drawView.hideCrop();
                drawView.startEdit();
                setSelectedFoot(0);
                return true;
            } else if (findViewById(R.id.draw_tools).getVisibility() != View.GONE) {
                findViewById(R.id.draw_tools).setVisibility(View.GONE);
                drawView.hideCrop();
                drawView.startEdit();
                setSelectedFoot(0);
                return false;
            } else if (!drawView.hideCrop()) {
                if (!saved && storePath.length() == 0)
                    showDialog(0);
                else {
                    drawView.recycle();
                    finish();
                    return true;
                }
            } else {
                ((ImageButton) findViewById(R.id.bToolCrop)).setSelected(false);
                drawView.startEdit();
                setSelectedFoot(0);
                return true;
            }

        }
    default:
        return super.dispatchKeyEvent(event);
    }
}

From source file:com.grarak.kerneladiutor.activities.NavigationActivity.java

private void onItemSelected(final int res, boolean delay, boolean saveOpened) {
    mDrawer.closeDrawer(GravityCompat.START);
    getSupportActionBar().setTitle(getString(res));
    mNavigationView.setCheckedItem(res);
    mSelection = res;/*from w ww  .  j  a va 2  s.  c om*/
    Fragment fragment = getFragment(res);
    if (fragment instanceof RecyclerViewFragment) {
        ((RecyclerViewFragment) fragment).mDelay = delay;
    } else if (fragment instanceof SettingsFragment) {
        ((SettingsFragment) fragment).mDelay = delay;
    }
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, res + "_key").commit();

    if (saveOpened) {
        String openedName = fragment.getClass().getSimpleName() + "_opened";
        Prefs.saveInt(openedName, Prefs.getInt(openedName, 0, this) + 1, this);
    }
    setShortcuts();
}