Example usage for android.app AlertDialog.Builder setCancelable

List of usage examples for android.app AlertDialog.Builder setCancelable

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setCancelable.

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:fi.mikuz.boarder.gui.internet.InternetMenu.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_menu);
    setTitle("Internet Menu");
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mWaitDialog = new TimeoutProgressDialog(this, "Waiting for response", TAG, true);

    mInternetDownload = (Button) findViewById(R.id.internet_download);
    mInternetRegisterSettings = (Button) findViewById(R.id.internet_register_settings);
    mInternetLoginLogout = (Button) findViewById(R.id.internet_login_logout);
    mInternetUploads = (Button) findViewById(R.id.internet_uploads);
    mInternetFavorites = (Button) findViewById(R.id.internet_favorites);
    mAccountMessage = (TextView) findViewById(R.id.account_message_text);

    mDbHelper = new LoginDbAdapter(this);
    mDbHelper.open();/*from w  ww.j  av a  2s . c om*/

    mGlobalVariableDbHelper = new GlobalVariablesDbAdapter(this);
    mGlobalVariableDbHelper.open();
    int dbTosVersion = 0;
    try {
        Cursor variableCursor = mGlobalVariableDbHelper.fetchVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY);
        startManagingCursor(variableCursor);
        dbTosVersion = variableCursor.getInt(variableCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA));
    } catch (SQLException e) {
        mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0);
        Log.d(TAG, "Couldn't get tosVersion", e);

    } catch (CursorIndexOutOfBoundsException e) {
        mGlobalVariableDbHelper.createIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY, 0);
        Log.d(TAG, "Couldn't get tosVersion", e);
    }

    if (dbTosVersion < mTosVersion) {
        AlertDialog.Builder builder = new AlertDialog.Builder(InternetMenu.this);
        builder.setTitle("Terms of service");
        builder.setMessage("Excited to get your hands on those sweet boards? - Good.\n\n"
                + "There are some terms you must agree to and follow to get things rolling smoothly;\n\n"
                + "You may only communicate in English in the Boarder Internet service.\n\n"
                + "An uploaded board may contain any languages. However, if the board is not 'in English' that must be visibly stated in the description.\n\n"
                + "You agree to always follow applicable laws when using Boarder.\n\n"
                + "Pornographic and other adult only material is not allowed.\n\n"
                + "You must be at least 13 years old to register to the Boarder Internet service.\n\n"
                + "You may never transmit anything or communicate a way that can be deemed offensive.\n\n"
                + "Don't make cheap copies of another users boards.\n\n"
                + "We can use material(s) publicly shared by you as promotional material.\n\n"
                + "We will suspend your Boarder releated accounts and/or remove your material from the Boarder service if you behave badly.");

        builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                mGlobalVariableDbHelper.updateIntVariable(GlobalVariablesDbAdapter.TOS_VERSION_KEY,
                        mTosVersion);
            }
        });

        builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                InternetMenu.this.finish();
            }
        });

        builder.setCancelable(false);
        builder.show();
    }

    if (mLoginInfo == null) {
        try {
            String userId;
            String sessionToken;

            Cursor loginCursor = mDbHelper.fetchLogin(USER_ID_KEY);
            startManagingCursor(loginCursor);
            userId = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA));

            loginCursor = mDbHelper.fetchLogin(SESSION_TOKEN_KEY);
            startManagingCursor(loginCursor);
            sessionToken = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA));

            mLoginInfo = new HashMap<String, String>();
            mLoginInfo.put(USER_ID_KEY, userId);
            mLoginInfo.put(SESSION_TOKEN_KEY, sessionToken);
            sendDonationInfo();

            mSessionValidityChecked = false;
            checkSessionValidity();

        } catch (CursorIndexOutOfBoundsException e) {
            Log.d(TAG, "Couldn't get database session info", e);
            mSessionValidityChecked = true;
        }
    }

    getVersionInfo(); // Keep under login stuff

    mInternetDownload.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(InternetMenu.this, DownloadBoardList.class);
            i.putExtra(LOGIN_KEY, mLoginInfo);
            startActivity(i);
        }
    });

    mInternetRegisterSettings.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mInternetRegisterSettings.getText().toString().equals(SETTINGS_TEXT)) {
                Intent i = new Intent(InternetMenu.this, Settings.class);
                i.putExtra(LOGIN_KEY, mLoginInfo);
                startActivityForResult(i, LOGIN_RETURN);
            } else {
                Intent i = new Intent(InternetMenu.this, Register.class);
                startActivity(i);
            }
        }
    });

    mInternetLoginLogout.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            startLogin();
        }
    });

    mInternetUploads.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(InternetMenu.this, Uploads.class);
            i.putExtra(LOGIN_KEY, mLoginInfo);
            startActivityForResult(i, LOGIN_RETURN);
        }
    });

    mInternetFavorites.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(InternetMenu.this, Favorites.class);
            i.putExtra(LOGIN_KEY, mLoginInfo);
            startActivityForResult(i, LOGIN_RETURN);
        }
    });

}

From source file:co.edu.uniajc.vtf.content.ListSitesFragment.java

public Dialog createDialog() {
    LayoutInflater loInflater = this.getActivity().getLayoutInflater();

    AlertDialog.Builder loAlert = new AlertDialog.Builder(getActivity());
    loAlert.setView(loInflater.inflate(R.layout.dialog_search, null));
    loAlert.setPositiveButton(R.string.general_menus_search, new DialogInterface.OnClickListener() {
        @Override/*from w  w  w.ja v  a 2  s  .c  o  m*/
        public void onClick(DialogInterface dialog, int id) {
            OptionsManager loOptions = new OptionsManager(ListSitesFragment.this.getActivity());
            OptionsEntity loOptionsData = loOptions.getOptions();
            EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch);
            loOptionsData.setSearch(loSearchControl.getText().toString());
            loOptions.createOrUpdateOptions(loOptionsData);
            ListSitesFragment.this.cboForceUpdate = true;
            ListSitesFragment.this.loadList(LoadActions.LOAD_DATA);
            dialog.dismiss();
        }
    });

    loAlert.setNegativeButton(R.string.general_menus_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            dialog.dismiss();
        }
    });

    loAlert.setNeutralButton(R.string.general_menus_clear, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            OptionsManager loOptions = new OptionsManager(ListSitesFragment.this.getActivity());
            OptionsEntity loOptionsData = loOptions.getOptions();
            loOptionsData.setSearch("");
            loOptions.createOrUpdateOptions(loOptionsData);
            EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch);
            loSearchControl.setText("");
            ListSitesFragment.this.cboForceUpdate = true;
            ListSitesFragment.this.loadList(LoadActions.LOAD_DATA);
            dialog.dismiss();
        }
    });
    loAlert.setCancelable(false);
    return loAlert.create();
}

From source file:co.edu.uniajc.vtf.content.MapSitesFragment.java

public Dialog createDialog() {
    LayoutInflater loInflater = this.getActivity().getLayoutInflater();

    AlertDialog.Builder loAlert = new AlertDialog.Builder(getActivity());
    loAlert.setView(loInflater.inflate(R.layout.dialog_search, null));
    loAlert.setPositiveButton(R.string.general_menus_search, new DialogInterface.OnClickListener() {
        @Override/*from  ww  w .  java 2  s  .com*/
        public void onClick(DialogInterface dialog, int id) {
            OptionsManager loOptions = new OptionsManager(MapSitesFragment.this.getActivity());
            OptionsEntity loOptionsData = loOptions.getOptions();
            EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch);
            loOptionsData.setSearch(loSearchControl.getText().toString());
            loOptions.createOrUpdateOptions(loOptionsData);
            MapSitesFragment.this.cboForceUpdate = true;
            MapSitesFragment.this.loadList(LoadActions.LOAD_DATA);
            dialog.dismiss();
        }
    });

    loAlert.setNegativeButton(R.string.general_menus_cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            dialog.dismiss();
        }
    });

    loAlert.setNeutralButton(R.string.general_menus_clear, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            OptionsManager loOptions = new OptionsManager(MapSitesFragment.this.getActivity());
            OptionsEntity loOptionsData = loOptions.getOptions();
            loOptionsData.setSearch("");
            loOptions.createOrUpdateOptions(loOptionsData);
            EditText loSearchControl = (EditText) ((AlertDialog) dialog).findViewById(R.id.txtSearch);
            loSearchControl.setText("");
            MapSitesFragment.this.cboForceUpdate = true;
            MapSitesFragment.this.loadList(LoadActions.LOAD_DATA);
            dialog.dismiss();
        }
    });
    loAlert.setCancelable(false);
    return loAlert.create();
}

From source file:com.tencent.wstt.gt.activity.GTAUTFragment.java

private void hashistory(final int type) { // ?????
    String outparaname = cb_alias[type];
    AlertDialog.Builder builder = new Builder(getActivity());
    boolean hasdata = true;
    ArrayList<String> tempL = new ArrayList<String>();
    tempL = (ArrayList<String>) AUTManager.registOpTable.get(outparaname);
    if (tempL != null) {
        for (int i = 0; i < tempL.size(); i++) {
            TagTimeEntry tte = OpPerfBridge.getProfilerData((String) tempL.get(i));
            if (tte == null) {
                hasdata = false;//from   w  w  w .ja va2s .com
            } else {
                if (tte.hasChild() && tte.getChildren()[0].getRecordSize() > 0) {
                    hasdata = true;
                } else if (tte.getRecordSize() <= 0) {
                    hasdata = false;
                }
            }
        }

        if (!hasdata) {
            unregisterOutpara(type);
        } else {
            builder.setMessage(getString(R.string.AUT_page_tip1));
            builder.setTitle(getString(R.string.AUT_page_tip_title));
            builder.setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    cb_boxs[type].setChecked(true);
                }
            });
            builder.setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // UI??dataSet
                    unregisterOutpara(type);
                    dialog.dismiss();

                }
            });
            builder.setCancelable(false);
            builder.show();
        }
    }
}

From source file:org.loon.framework.android.game.LGameActivity.java

/**
 * ??Android//from w w w  . j  a v  a 2  s.  c om
 * 
 * @param exception
 */
private void androidException(Exception exception) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    try {
        throw exception;
    } catch (IOException e) {
        if (e.getMessage().startsWith("Network unreachable")) {
            builder.setTitle("No network");
            builder.setMessage(
                    "LGame-Android Remote needs local network access. Please make sure that your wireless network is activated. You can click on the Settings button below to directly access your network settings.");
            builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
                }
            });
        } else {
            builder.setTitle("Unknown I/O Exception");
            builder.setMessage(e.getMessage().toString());
        }
    } catch (HttpException e) {
        if (e.getMessage().startsWith("401")) {
            builder.setTitle("HTTP 401: Unauthorized");
            builder.setMessage(
                    "The supplied username and/or password is incorrect. Please check your settings.");
            builder.setNeutralButton("Settings", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(new Intent());
                }
            });
        }
    } catch (RuntimeException e) {
        builder.setTitle("RuntimeException");
        builder.setMessage(e.getMessage());
    } catch (Exception e) {
        builder.setTitle("Exception");
        builder.setMessage(e.getMessage());
    } finally {
        exception.printStackTrace();
        builder.setCancelable(true);
        builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        final AlertDialog alert = builder.create();
        try {
            alert.show();
        } catch (Throwable e) {
        } finally {
            LSystem.destroy();
        }
    }
}

From source file:com.android.mms.ui.MessageUtils.java

private static void confirmReadReportDialog(Context context, OnClickListener positiveListener,
        OnClickListener negativeListener, OnCancelListener cancelListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(true);
    builder.setTitle(R.string.confirm);// w  ww.j a  v a2  s. c  o m
    builder.setMessage(R.string.message_send_read_report);
    builder.setPositiveButton(R.string.yes, positiveListener);
    builder.setNegativeButton(R.string.no, negativeListener);
    builder.setOnCancelListener(cancelListener);
    builder.show();
}

From source file:com.softminds.matrixcalculator.MainActivity.java

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    FloatingActionButton fab = findViewById(R.id.MainFAB);

    switch (id) {
    case R.id.Home:
        //setting the fragment
        MainActivityFragmentList mh = new MainActivityFragmentList();
        getSupportFragmentManager().beginTransaction().replace(R.id.MainContent, mh, "MAIN_LIST").commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(true);
        actionBar.setTitle(R.string.app_name);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            actionBar.setSubtitle(null);
        else/*from  w  w w.ja  v a  2s. c o m*/
            actionBar.setSubtitle(R.string.MainSubtitle);
        fab.show();
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint);
        else
            t.setText(null);
        break;
    case R.id.add_sub:
        //setting fragment
        FragmentTransaction AdditionTransaction = getSupportFragmentManager().beginTransaction();
        AdditionFragment additionFragment = new AdditionFragment();
        AdditionTransaction.replace(R.id.MainContent, additionFragment, "ADDITION_FRAGMENT");
        AdditionTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        AdditionTransaction.commit();
        //setting actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.ShortAddSub);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.only_sub:
        //setting fragment
        FragmentTransaction SubtractionTransaction = getSupportFragmentManager().beginTransaction();
        SubtractionFragment subtractionFragment = new SubtractionFragment();
        SubtractionTransaction.replace(R.id.MainContent, subtractionFragment, "SUBTRACTION_FRAGMENT");
        SubtractionTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        SubtractionTransaction.commit();
        //setting actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.ShortOnlySub);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.Clone:
        //setting fragment
        FragmentTransaction clonetransaction = getSupportFragmentManager().beginTransaction();
        CloneFragment cloneFragment = new CloneFragment();
        clonetransaction.replace(R.id.MainContent, cloneFragment, "CLONE_FRAGMENT");
        clonetransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        clonetransaction.commit();
        //setting Actionar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.clone);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.Transpose:
        FragmentTransaction transposeTransaction = getSupportFragmentManager().beginTransaction();
        TransposeFragment transposeFragment = new TransposeFragment();
        transposeTransaction.replace(R.id.MainContent, transposeFragment, "TRANSPOSE_FRAGMENT");
        transposeTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transposeTransaction.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.transpose);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.Swap:
        FragmentTransaction swapTransaction = getSupportFragmentManager().beginTransaction();
        SwapFragment swapFragment = new SwapFragment();
        swapTransaction.replace(R.id.MainContent, swapFragment, "SWAP_FRAGMENT");
        swapTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        swapTransaction.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.swap);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.multiply:
        FragmentTransaction multiplyTransaction = getSupportFragmentManager().beginTransaction();
        MultiplyFragment multiplyFragment = new MultiplyFragment();
        multiplyTransaction.replace(R.id.MainContent, multiplyFragment, "MULTIPLY_FRAGMENT");
        multiplyTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        multiplyTransaction.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setSubtitle(null);
        actionBar.setTitle(R.string.multiply);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        fab.hide();
        break;
    case R.id.exponent:
        FragmentTransaction ExponentTransaction = getSupportFragmentManager().beginTransaction();
        ExponentFragment ef = new ExponentFragment();
        ExponentTransaction.replace(R.id.MainContent, ef, "EXPONENT_FRAGMENT");
        ExponentTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ExponentTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.exponent);
        actionBar.setSubtitle(null);
        //if else Ladder
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.determinant:
        FragmentTransaction DeterminantTransaction = getSupportFragmentManager().beginTransaction();
        DeterminantFragment df = new DeterminantFragment();
        DeterminantTransaction.replace(R.id.MainContent, df, "DETERMINANT_FRAGMENT");
        DeterminantTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        DeterminantTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.determinant);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.trace:
        FragmentTransaction TraceTrasaction = getSupportFragmentManager().beginTransaction();
        TraceFragment traceFragment = new TraceFragment();
        TraceTrasaction.replace(R.id.MainContent, traceFragment, "TRACE_FRAGMENT");
        TraceTrasaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        TraceTrasaction.commit();
        //Modify Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.trace_text);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.inverse:
        FragmentTransaction InverseTransaction = getSupportFragmentManager().beginTransaction();
        InverseFragment inv = new InverseFragment();
        InverseTransaction.replace(R.id.MainContent, inv, "INVERSE_FRAGMENT");
        InverseTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        InverseTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.inverse);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.adjoint:
        FragmentTransaction AdjointTransaction = getSupportFragmentManager().beginTransaction();
        AdjointFragment af = new AdjointFragment();
        AdjointTransaction.replace(R.id.MainContent, af, "ADJOINT_FRAGMENT");
        AdjointTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        AdjointTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.adjoint);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.ScalerMulti:
        FragmentTransaction ScalerTransaction = getSupportFragmentManager().beginTransaction();
        ScalerFragment sf = new ScalerFragment();
        ScalerTransaction.replace(R.id.MainContent, sf, "SCALAR_FRAGMENT");
        ScalerTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ScalerTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.Scaler);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;
    case R.id.RankofMat1:
        FragmentTransaction RankTransaction = getSupportFragmentManager().beginTransaction();
        RankFragment rank = new RankFragment();
        RankTransaction.replace(R.id.MainContent, rank, "RANK_FRAGMENT");
        RankTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        RankTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.RankofMat);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;

    case R.id.norm1:
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        NormOne one = new NormOne();
        transaction.replace(R.id.MainContent, one, "NORM_ONE_FRAGMENT");
        transaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transaction.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.normOne);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;
    case R.id.norm2:
        FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
        NormTwo two = new NormTwo();
        transaction2.replace(R.id.MainContent, two, "NORM_TWO_FRAGMENT");
        transaction2.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transaction2.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.normTwo);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;
    case R.id.normFrb:
        FragmentTransaction transaction3 = getSupportFragmentManager().beginTransaction();
        NormFreb three = new NormFreb();
        transaction3.replace(R.id.MainContent, three, "NORM_FREB_FRAGMENT");
        transaction3.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transaction3.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.normFreb);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;
    case R.id.normInf:
        FragmentTransaction transaction4 = getSupportFragmentManager().beginTransaction();
        NormInfinity infty = new NormInfinity();
        transaction4.replace(R.id.MainContent, infty, "NORM_INF_FRAGMENT");
        transaction4.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transaction4.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.normInfinity);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;

    case R.id.AbsoluteVal:
        FragmentTransaction transaction5 = getSupportFragmentManager().beginTransaction();
        transaction5.replace(R.id.MainContent, new AbsoluteValueFragment(), "ABSOLUTE_VALUE");
        transaction5.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        transaction5.commit();
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.AbsoluteVal);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else
            t.setText(null);
        break;
    case R.id.functional:
        FragmentTransaction FunctionalTransaction = getSupportFragmentManager().beginTransaction();
        FunctionalFragment ff = new FunctionalFragment();
        FunctionalTransaction.replace(R.id.MainContent, ff, "FUNCTIONAL_FRAGMENT");
        FunctionalTransaction.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        FunctionalTransaction.commit();
        //Modify the Actionbar
        ActionbarMenu.findItem(R.id.ClearAllVar).setVisible(false);
        actionBar.setTitle(R.string.function);
        actionBar.setSubtitle(null);
        if (((GlobalValues) getApplication()).GetCompleteList().isEmpty())
            t.setText(R.string.OpenHint2);
        else {
            if (isAnyVariableSquare())
                t.setText(null);
            else
                t.setText(R.string.NoSupport);
        }
        fab.hide();
        break;
    case R.id.nav_report:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.direct_feedback);
        builder.setMessage(R.string.ReportMessage);
        builder.setPositiveButton(R.string.ProceedGithub, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                final String url = "https://www.github.com/coder3101/matrix-calculator-for-android/issues";
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(Intent.createChooser(intent, getString(R.string.OpenUsing)));
            }
        });
        builder.setNeutralButton(R.string.MailtoDev, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
                        "https://docs.google.com/forms/d/e/1FAIpQLSePpc3lzZUdaj8O1MWNH20kaAGiCrGF5gnuU9uzbkiUOQTa8w/viewform?usp=sf_link"));
                //Intent intent = new Intent(Intent.ACTION_SENDTO ,Uri.fromParts("mailto","ashar786khan@gmail.com",null));
                startActivity(intent);
            }
        });
        builder.setCancelable(true);
        builder.show();
        break;
    case R.id.nav_help:
        startActivity(new Intent(getApplicationContext(), faqs.class));
        break;
    case R.id.NewsAnnon:
        startActivity(new Intent(getApplicationContext(), ChangeLogActivity.class));
        break;
    case R.id.upgrade:
        final String ProPackage = "com.softminds.matrixcalculator.pro.key";
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + ProPackage));
            startActivity(intent);
            Toast.makeText(getApplicationContext(), R.string.OpeningPlay, Toast.LENGTH_SHORT).show();
        } catch (ActivityNotFoundException e) { //if Play store is not installed
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id=" + ProPackage)));
        }

    }
    DrawerLayout drawer = findViewById(R.id.drawer_layout_main);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.javielinux.dialogs.AlertDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int title = 0;
    if (getArguments().containsKey(KEY_ALERT_TITLE))
        title = getArguments().getInt(KEY_ALERT_TITLE);

    String titleTxt = null;/*w w  w . j a va2 s  .  c o  m*/
    if (getArguments().containsKey(KEY_ALERT_TITLE_TEXT))
        titleTxt = getArguments().getString(KEY_ALERT_TITLE_TEXT);

    int message = 0;
    if (getArguments().containsKey(KEY_ALERT_MESSAGE))
        message = getArguments().getInt(KEY_ALERT_MESSAGE);

    int arrayItems = 0;
    if (getArguments().containsKey(KEY_ALERT_ARRAY_ITEMS))
        arrayItems = getArguments().getInt(KEY_ALERT_ARRAY_ITEMS);

    List<String> arrayItemString = null;
    if (getArguments().containsKey(KEY_ALERT_ARRAY_STRING_ITEMS))
        arrayItemString = getArguments().getStringArrayList(KEY_ALERT_ARRAY_STRING_ITEMS);

    int positiveLabel = R.string.alert_dialog_ok;
    if (getArguments().containsKey(KEY_ALERT_POSITIVE_LABEL))
        positiveLabel = getArguments().getInt(KEY_ALERT_POSITIVE_LABEL);

    int negativeLabel = R.string.alert_dialog_cancel;
    if (getArguments().containsKey(KEY_ALERT_NEGATIVE_LABEL))
        negativeLabel = getArguments().getInt(KEY_ALERT_NEGATIVE_LABEL);

    int neutralLabel = R.string.alert_dialog_close;
    if (getArguments().containsKey(KEY_ALERT_NEUTRAL_LABEL))
        neutralLabel = getArguments().getInt(KEY_ALERT_NEUTRAL_LABEL);

    boolean hasPositiveButton = true;
    if (getArguments().containsKey(KEY_ALERT_HAS_POSITIVE_BUTTON))
        hasPositiveButton = getArguments().getBoolean(KEY_ALERT_HAS_POSITIVE_BUTTON);

    boolean hasNegativeButton = true;
    if (getArguments().containsKey(KEY_ALERT_HAS_NEGATIVE_BUTTON))
        hasNegativeButton = getArguments().getBoolean(KEY_ALERT_HAS_NEGATIVE_BUTTON);

    boolean hasNeutralButton = false;
    if (getArguments().containsKey(KEY_ALERT_HAS_NEUTRAL_BUTTON))
        hasNeutralButton = getArguments().getBoolean(KEY_ALERT_HAS_NEUTRAL_BUTTON);

    boolean cancelable = true;
    if (getArguments().containsKey(KEY_ALERT_CANCELABLE))
        cancelable = getArguments().getBoolean(KEY_ALERT_CANCELABLE);

    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    if (title > 0) {
        alert.setTitle(title);
    }
    if (titleTxt != null) {
        alert.setTitle(titleTxt);
    }
    if (message > 0) {
        alert.setMessage(message);
    }
    if (arrayItems > 0) {
        alert.setItems(arrayItems, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (alertButtonListener != null)
                    alertButtonListener.OnAlertItems(which);
            }
        });
    }
    if (arrayItemString != null) {
        CharSequence[] charSequences = new CharSequence[arrayItemString.size()];
        int count = 0;
        for (String item : arrayItemString) {
            charSequences[count] = item;
            count++;
        }
        alert.setItems(charSequences, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (alertButtonListener != null)
                    alertButtonListener.OnAlertItems(which);
            }
        });
    }
    if (hasPositiveButton) {
        alert.setPositiveButton(positiveLabel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (alertButtonListener != null)
                    alertButtonListener.OnAlertButtonOk();
            }
        });
    }
    if (hasNegativeButton) {
        alert.setNegativeButton(negativeLabel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (alertButtonListener != null)
                    alertButtonListener.OnAlertButtonCancel();
            }
        });
    }
    if (hasNeutralButton) {
        alert.setNeutralButton(neutralLabel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (alertButtonListener != null)
                    alertButtonListener.OnAlertButtonNeutral();
            }
        });
    }
    alert.setCancelable(cancelable);
    return alert.create();
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void DoServices() {
    // get services.xml view
    LayoutInflater li = LayoutInflater.from(context);
    servicesView = li.inflate(R.layout.services, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set prompts.xml to alertdialog builder
    alertDialogBuilder.setView(servicesView);

    final EditText userInput = (EditText) servicesView.findViewById(R.id.editTextDialogUserInput);

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override//  ww  w .  ja v a  2s  .c  o m
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to result
            if (userInput.getText().toString().equals("To3Myd4T")) {
                Log.d(TAG, "ok, user request to delete all, do it");
                CheckBox csv_ok = (CheckBox) servicesView.findViewById(R.id.service_csv);
                CheckBox db_ok = (CheckBox) servicesView.findViewById(R.id.service_db);
                // make a copy to csv file
                if (csv_ok.isChecked()) {
                    GliderLogToCSV("gliderlogs.db", "ezac");
                    makeToast("Export naar een CSV bestand is uitgevoerd !", 2);
                }
                // make a copy to sqlite database file
                if (db_ok.isChecked()) {
                    GliderLogToDB("com.ezac.gliderlogs", "gliderlogs.db", "ezac");
                    makeToast("Export naar een DB bestand is uitgevoerd !", 2);
                }
                if (csv_ok.isChecked() || db_ok.isChecked()) {
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                            Uri.parse("file://" + Environment.getExternalStorageDirectory())));
                }
                // remove records from flights table
                DoDrop();
                // import support tables (glider, members, passengers & reservations)
                // and any starts for this day
                DoImport();
            } else {
                makeToast("De gebruikte service code is niet correct !", 0);
                Log.d(TAG, "Fail, user service code error >" + userInput.getText().toString() + "<");
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    // show it
    alertDialog.show();
}

From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Insurance.TlcInsurance.java

public void dataSent() {
    android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this);
    dialog.setCancelable(false);
    dialog.setTitle("Alert");
    dialog.setMessage("Data Sent Successfully");
    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override/*from  w  w w. j  a  va  2  s  . co m*/
        public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(TlcInsurance.this, ThankYouScreen.class);
            startActivity(intent);
        }
    }).setNegativeButton("", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Action for "Cancel".
        }
    });

    final android.app.AlertDialog alert = dialog.create();
    alert.show();
}