Example usage for android.widget RadioButton isChecked

List of usage examples for android.widget RadioButton isChecked

Introduction

In this page you can find the example usage for android.widget RadioButton isChecked.

Prototype

@ViewDebug.ExportedProperty
    @Override
    public boolean isChecked() 

Source Link

Usage

From source file:com.nextgis.maplibui.dialog.LocalResourcesListAdapter.java

protected void setRadioButton(final RadioButton radioButton, final File file) {
    radioButton.setOnCheckedChangeListener(null);

    if (mCheckState.contains(file.getAbsolutePath())) {

        mUncheckBtn = radioButton;/*from w  w w  .  j  a v a  2s .co m*/
        if (!radioButton.isChecked()) {
            radioButton.setChecked(true);
        }
    } else {
        if (radioButton.isChecked()) {
            radioButton.setChecked(false);
        }
    }

    radioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                if (mCheckState.isEmpty()) {
                    mCheckState.add(file.getAbsolutePath());
                } else {
                    mCheckState.set(0, file.getAbsolutePath());
                }

                if (null != mUncheckBtn && mUncheckBtn != radioButton) {
                    mUncheckBtn.setChecked(false);
                }
                mUncheckBtn = radioButton;
            }

            mDialog.updateButtons();
        }
    });
}

From source file:com.odoo.base.login_signup.SyncWizard.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection

    switch (item.getItemId()) {
    case R.id.menu_start_application:
        for (CheckBox chkBox : checkbox) {
            if (chkBox != null) {
                String authority = authorities.get(chkBox.getId() + "").toString();
                scope.main().setAutoSync(authority, chkBox.isChecked());
                scope.main().cancelSync(authority);
            }/*from   w  w w  .  ja  va  2  s .  co  m*/
        }
        for (RadioGroup rdoGrp : rdoGroups) {
            if (rdoGrp != null) {
                for (int i = 0; i < rdoGrp.getChildCount(); i++) {
                    RadioButton rdoBtn = (RadioButton) rdoGrp.getChildAt(i);
                    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(scope.context());
                    Editor editor = settings.edit();
                    // TODO: store preference setting for your options.
                    editor.commit();
                    String authority = authorities.get(rdoBtn.getId() + "");
                    scope.main().setAutoSync(authority, rdoBtn.isChecked());
                    scope.main().cancelSync(authority);
                }
            }
        }
        getActivity().finish();
        getActivity().startActivity(getActivity().getIntent());
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.openerp.base.login.SyncWizard.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection

    int itemId = item.getItemId();
    if (itemId == R.id.menu_start_application) {
        for (CheckBox chkBox : checkbox) {
            if (chkBox != null) {
                String authority = authorities.get(chkBox.getId() + "").toString();
                scope.main().setAutoSync(authority, chkBox.isChecked());
                scope.main().cancelSync(authority);
            }//w w  w . ja  v  a  2s  .co  m
        }
        for (RadioGroup rdoGrp : rdoGroups) {
            if (rdoGrp != null) {
                for (int i = 0; i < rdoGrp.getChildCount(); i++) {
                    RadioButton rdoBtn = (RadioButton) rdoGrp.getChildAt(i);
                    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(scope.context());
                    Editor editor = settings.edit();
                    //TODO: store preference setting for your options.
                    editor.commit();
                    String authority = authorities.get(rdoBtn.getId() + "");
                    scope.main().setAutoSync(authority, rdoBtn.isChecked());
                    scope.main().cancelSync(authority);
                }
            }
        }
        getActivity().finish();
        getActivity().startActivity(getActivity().getIntent());
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.duy.pascal.ui.file.fragment.FragmentFileManager.java

/**
 * show dialog create new file/*from   w  w  w  .  j a v a2 s  . co  m*/
 */
@Override
public void createNewFile() {
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setTitle(R.string.new_file);
    builder.setView(R.layout.dialog_new_file);
    final AlertDialog alertDialog = builder.create();
    alertDialog.show();
    final EditText editText = alertDialog.findViewById(R.id.edit_input);
    Button btnOK = alertDialog.findViewById(R.id.btn_ok);
    Button btnCancel = alertDialog.findViewById(R.id.btn_cancel);

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.cancel();
        }
    });

    btnOK.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //get string path of in edit text
            String fileName = editText.getText().toString();
            if (fileName.isEmpty()) {
                editText.setError(getString(R.string.enter_new_file_name));
                return;
            }

            RadioButton checkBoxPas = alertDialog.findViewById(R.id.rad_program);
            RadioButton checkBoxInp = alertDialog.findViewById(R.id.rad_inp);

            if (checkBoxInp != null && checkBoxInp.isChecked())
                fileName += ".inp";
            else if (checkBoxPas.isChecked())
                fileName += ".pas";

            //create new file
            File file = new File(mCurrentFolder, fileName);
            try {
                file.createNewFile();
                new UpdateList(mCurrentFolder).execute();
            } catch (IOException e) {
                Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
            }
            alertDialog.cancel();
        }
    });

}

From source file:org.cryptocall.ui.WizardActivity.java

public void nextOnClick(View view) {
    switch (mCurrentScreen) {
    case SCREEN_MAIN:
        RadioButton generateKeyringRadio = (RadioButton) findViewById(
                R.id.wizard_activity_generate_keyring_radio);
        RadioButton selectKeyringRadio = (RadioButton) findViewById(R.id.wizard_activity_select_keyring_radio);

        if (generateKeyringRadio.isChecked()) {
            mGenerateKeyRingFragment = new GenerateKeyringFragment();
            loadFragment(mGenerateKeyRingFragment);
            mCurrentScreen = SCREEN_GENERATE_KEYRING_INPUT;
        } else if (selectKeyringRadio.isChecked()) {
            mSelectKeyringFragment = new SelectKeyringFragment();
            loadFragment(mSelectKeyringFragment);
            mCurrentScreen = SCREEN_SELECT_KEYRING;
        }// ww w. ja v a2 s . c o  m

        break;

    case SCREEN_GENERATE_KEYRING_INPUT:
        EditText generateNicknameEdit = (EditText) findViewById(R.id.wizard_generate_keyring_nickname);
        EditText generateTelephoneNumberEdit = (EditText) findViewById(
                R.id.wizard_generate_keyring_telephone_number);

        if (isEditTextNotEmpty(this, generateNicknameEdit)
                && isEditTextValidTelephoneNumber(this, generateTelephoneNumberEdit)) {
            String nickname = generateNicknameEdit.getText().toString();
            String number = generateTelephoneNumberEdit.getText().toString();
            Log.d(Constants.TAG, "nickname: " + nickname);
            Log.d(Constants.TAG, "number: " + number);

            String protectedEmail = ProtectedEmailUtils.generateProtectedEmail(number);
            Log.d(Constants.TAG, "protectedEmail: " + protectedEmail);

            String id = nickname + " (CryptoCall) <" + protectedEmail + ">";

            Log.d(Constants.TAG, "id: " + id);

            mKeychainIntentHelper.createNewKey(id, true, true);
        }
        break;

    case SCREEN_SELECT_KEYRING:
        EditText selectTelephoneNumberEdit = (EditText) findViewById(
                R.id.wizard_select_keyring_telephone_number);

        if (isEditTextValidTelephoneNumber(this, selectTelephoneNumberEdit)) {
            mKeychainIntentHelper.selectSecretKey();
        }
        break;

    case SCREEN_SUCCESS:
        // save into prefs
        PreferencesHelper.setPgpEmail(this, mProtectedEmail);
        PreferencesHelper.setPgpMasterKeyId(this, mMasterKeyId);
        PreferencesHelper.setTelephoneNumber(this, mTelephoneNumber);

        PreferencesHelper.setFirstStart(this, false);

        // go to base activity
        Intent baseIntent = new Intent(this, BaseActivity.class);
        startActivity(baseIntent);
        finish();

        break;

    default:
        break;
    }

    // set button to "back"
    mBackButton.setText(R.string.button_back);
}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * Returns active command for controls selected in view .
 * Returns null for wrong command/* w  w w  . j  av a 2 s  .  c o m*/
 * 
 * @param v
 * @return
 */
private IFeedbackCubeCommnads getCommnand(View v) {

    LinearLayout llButtons = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llButtons.getParent();

    String sTag = v.getTag().toString();
    if (sTag.compareTo(getString(R.string.tab_vi)) == 0) {

        TextView tvRed = (TextView) llRoot.findViewById(R.id.textViewRedValue);
        TextView tvGreen = (TextView) llRoot.findViewById(R.id.textViewGreenValue);
        TextView tvBlue = (TextView) llRoot.findViewById(R.id.textViewBlueValue);

        RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
        RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

        if (rbP.isChecked()) {

            NumberPicker npStart = (NumberPicker) llRoot.findViewById(R.id.npLedStart);
            NumberPicker npStop = (NumberPicker) llRoot.findViewById(R.id.npLedStop);

            FCPieChart c = new FCPieChart(FeedbackCubeConfig.getSingleInstance().getIp(),
                    npStart.getValue() + "", npStop.getValue() + "", tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else {
            FCColor c = new FCColor(FeedbackCubeConfig.getSingleInstance().getIp(), tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_au)) == 0) {

        //         CheckBox cb = (CheckBox) llRoot.findViewById(R.id.cbBeep);
        //         if (cb.isChecked()) {
        //            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance()
        //                  .getIp());
        ////            Toast.makeText(this, "Launch cube " + c.toString(),
        ////                  Toast.LENGTH_SHORT).show();
        //
        //            return c;
        //         } else {
        //            Toast.makeText(this,
        //                  "Check off the Beep! to launch the action.",
        //                  Toast.LENGTH_SHORT).show();
        //         }

        RadioButton rbBeep = (RadioButton) llRoot.findViewById(R.id.rbBeep);
        RadioButton rbMelody = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

        if (rbBeep.isChecked()) {

            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbMelody.isChecked()) {

            FCMelody1 c = new FCMelody1(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_ef)) == 0) {

        RadioButton rbRainbow = (RadioButton) llRoot.findViewById(R.id.rbRainbow);
        RadioButton rbRainbowC = (RadioButton) llRoot.findViewById(R.id.rbRainbowCircle);
        RadioButton rbFade = (RadioButton) llRoot.findViewById(R.id.rbFade);

        if (rbRainbow.isChecked()) {

            FCRainbow c = new FCRainbow(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbRainbowC.isChecked()) {

            FCRainbowCircle c = new FCRainbowCircle(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbFade.isChecked()) {

            NumberPicker npD = (NumberPicker) llRoot.findViewById(R.id.npDelay);
            NumberPicker npN = (NumberPicker) llRoot.findViewById(R.id.npNumber);

            FCFade c = new FCFade(FeedbackCubeConfig.getSingleInstance().getIp(), "" + npN.getValue(),
                    "" + npD.getValue());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;
        }

    }
    return null;

}

From source file:com.vkassin.mtrade.Common.java

public static void login(final Context ctx) {

    // ctx = Common.app_ctx;
    Common.connected = false;//w  w  w  .  ja va 2s  . co m

    if (inLogin)
        return;

    inLogin = true;

    if (Common.mainActivity != null)
        Common.mainActivity.handler.sendMessage(
                Message.obtain(Common.mainActivity.handler, Common.mainActivity.DISMISS_PROGRESS_DIALOG));

    // while(true) {

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.login_dialog);
    dialog.setTitle(R.string.LoginDialogTitle);
    dialog.setCancelable(false);

    final EditText nametxt = (EditText) dialog.findViewById(R.id.loginnameedit);
    final EditText passtxt = (EditText) dialog.findViewById(R.id.passwordedit);
    final EditText passtxt1 = (EditText) dialog.findViewById(R.id.passwordedit1);
    final EditText passtxt2 = (EditText) dialog.findViewById(R.id.passwordedit2);
    final EditText mailtxt = (EditText) dialog.findViewById(R.id.emailedit2);

    String nam = myaccount.get("name");
    Common.oldName = nam;

    if (nam != null) {

        nametxt.setText(nam);
        passtxt.requestFocus();
    }

    Button customDialog_Register = (Button) dialog.findViewById(R.id.goregister);
    customDialog_Register.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.setTitle(R.string.LoginDialogTitle1);
            final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354);
            layreg.setVisibility(View.VISIBLE);
            final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543);
            laylog.setVisibility(View.GONE);
        }

    });

    Button customDialog_Register1 = (Button) dialog.findViewById(R.id.goregister1);
    customDialog_Register1.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            if (mailtxt.getText().length() < 1) {

                Toast toast = Toast.makeText(mainActivity, R.string.CorrectEmail, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();

                return;
            }

            if (passtxt1.getText().length() < 1) {

                Toast toast = Toast.makeText(mainActivity, R.string.CorrectPassword, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();
                return;
            }

            if (!passtxt2.getText().toString().equals(passtxt1.getText().toString())) {

                Toast toast = Toast.makeText(mainActivity, R.string.CorrectPassword1, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();
                return;
            }

            try {

                Socket sock = new Socket(ip_addr, port_register);

                JSONObject msg = new JSONObject();
                msg.put("objType", Common.MSG_REGISTER);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("user", mailtxt.getText().toString());
                msg.put("passwd", passtxt1.getText().toString());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("sign", sign(mailtxt.getText().toString(), passtxt1.getText().toString()));

                byte[] array = msg.toString().getBytes();
                ByteBuffer buff = ByteBuffer.allocate(array.length + 4);
                buff.putInt(array.length);
                buff.put(array);
                sock.getOutputStream().write(buff.array());

                ByteBuffer buff1 = ByteBuffer.allocate(4);
                buff1.put(readMsg(sock.getInputStream(), 4));
                buff1.position(0);
                int pkgSize = buff1.getInt();
                // Log.i(TAG, "size = "+pkgSize);
                String s = new String(readMsg(sock.getInputStream(), pkgSize));

                sock.close();

                JSONObject jo = new JSONObject(s);

                Log.i(TAG, "register answer = " + jo);

                int t = jo.getInt("status");
                switch (t) {

                case 1:
                    Toast toast = Toast.makeText(mainActivity, R.string.RegisterStatus1, Toast.LENGTH_LONG);
                    toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                    toast.show();

                    dialog.setTitle(R.string.LoginDialogTitle);
                    final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354);
                    layreg.setVisibility(View.GONE);
                    final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543);
                    laylog.setVisibility(View.VISIBLE);

                    nametxt.setText(mailtxt.getText());
                    break;

                case -2:
                    Toast toast1 = Toast.makeText(mainActivity, R.string.RegisterStatus3, Toast.LENGTH_LONG);
                    toast1.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                    toast1.show();
                    break;

                default:
                    Toast toast2 = Toast.makeText(mainActivity, R.string.RegisterStatus2, Toast.LENGTH_LONG);
                    toast2.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                    toast2.show();
                    break;

                }

            } catch (Exception e) {

                e.printStackTrace();
                Log.e(TAG, "Error in registration process!!", e);

                Toast toast = Toast.makeText(mainActivity, R.string.ConnectError, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();

            }

        }

    });

    Button customDialog_CancelReg = (Button) dialog.findViewById(R.id.cancelreg);
    customDialog_CancelReg.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.setTitle(R.string.LoginDialogTitle);
            final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354);
            layreg.setVisibility(View.GONE);
            final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543);
            laylog.setVisibility(View.VISIBLE);

        }

    });

    Button customDialog_Dismiss = (Button) dialog.findViewById(R.id.gologin);
    customDialog_Dismiss.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.lradio0);
            Common.isSSL = bu0.isChecked();

            inLogin = false;

            JSONObject msg = new JSONObject();
            try {

                msg.put("objType", Common.LOGOUT);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("status", 1);
                mainActivity.writeJSONMsg(msg);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e(TAG, "Error! Cannot create JSON logout object", e);
            }

            myaccount.put("name", nametxt.getText().toString());
            myaccount.put("password", passtxt.getText().toString());

            Log.i(TAG,
                    "myaccount username: " + myaccount.get("name") + " password: " + myaccount.get("password"));

            dialog.dismiss();
            mainActivity.stop();
            // saveAccountDetails();
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            loginFromDialog = true;
            //            mainActivity.refresh();

            Common.keypassword(ctx);
        }

    });

    dialog.show();
    // Common.confChanged = false;
    // }//while(true);

}

From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java

private void initRadioButtons(View fragmentView) {
    final LinearLayout rowSelectOws = (LinearLayout) fragmentView.findViewById(R.id.row_service_ows);
    final LinearLayout rowSelectOther = (LinearLayout) fragmentView.findViewById(R.id.row_service_other);
    final RadioButton radioButtonOws = (RadioButton) fragmentView.findViewById(R.id.radio_button_service_ows);
    final RadioButton radioButtonOther = (RadioButton) fragmentView
            .findViewById(R.id.radio_button_service_other);
    final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description);
    final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd);

    rowSelectOws.setOnClickListener(new View.OnClickListener() {

        @Override/*  www  . j  ava2 s  .  c om*/
        public void onClick(View view) {
            if (!radioButtonOws.isChecked()) {
                radioButtonOws.setChecked(true);
                radioButtonOther.setChecked(false);
                serviceDescription.setText(Html.fromHtml(
                        getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available,
                                costPerYearUsd)));
                serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
            }
        }

    });

    rowSelectOther.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!radioButtonOther.isChecked()) {
                radioButtonOther.setChecked(true);
                radioButtonOws.setChecked(false);
                serviceDescription
                        .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server);
            }
        }

    });

    radioButtonOws.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                radioButtonOws.setChecked(true);
                radioButtonOther.setChecked(false);
                serviceDescription.setText(Html.fromHtml(
                        getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available,
                                costPerYearUsd)));
                serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
            }
        }

    });

    radioButtonOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
            if (isChecked) {
                radioButtonOther.setChecked(true);
                radioButtonOws.setChecked(false);
                serviceDescription
                        .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server);
            }
        }

    });
}

From source file:com.vkassin.mtrade.Common.java

public static void putArcDeal(final Context ctx) {

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.arcdeal_dialog);
    dialog.setTitle(R.string.ArcDealDialogTitle);

    datetxt = (EditText) dialog.findViewById(R.id.expdateedit);
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date dat1 = new Date();
    datetxt.setText(sdf.format(dat1));/*  w ww  .j av a  2 s  . c  o  m*/
    mYear = dat1.getYear() + 1900;
    mMonth = dat1.getMonth();
    mDay = dat1.getDate();
    final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime();

    datetxt.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "Show DatePickerDialog");
            DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay);
            dpd.show();
        }
    });

    TextView itext = (TextView) dialog.findViewById(R.id.instrtext);
    itext.setText(Common.arcfilter);

    Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt);
    customDialog_Cancel.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.dismiss();
        }

    });

    Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder);
    customDialog_Put.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            Double price = new Double(0);
            Long qval = new Long(0);
            final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit);
            final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit);

            try {

                price = Double.valueOf(pricetxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
                return;
            }
            try {

                qval = Long.valueOf(quanttxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
                return;
            }

            //            if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay)
            //            .getTime()) > 0) {
            //
            //               Toast.makeText(ctx, R.string.CorrectDate,
            //               Toast.LENGTH_SHORT).show();
            //
            //            return;
            //            }

            long maxkey = 0;
            Iterator<String> itr2 = arcdealMap.keySet().iterator();
            while (itr2.hasNext()) {
                String key1 = itr2.next();
                long k = Long.parseLong(key1);
                if (k > maxkey)
                    maxkey = k;
            }

            Deal adeal = new Deal();
            Iterator<String> itr1 = instrMap.keySet().iterator();
            while (itr1.hasNext()) {
                String key1 = itr1.next();
                Instrument in = instrMap.get(key1);
                if (in.symbol.equals(Common.arcfilter)) {

                    adeal.instrId = Long.valueOf(in.id);
                    break;
                }
            }

            final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0);

            adeal.price = price;
            adeal.qty = qval;
            adeal.dtime = new GregorianCalendar(mYear, mMonth, mDay).getTimeInMillis();
            adeal.direct = bu0.isChecked() ? Long.valueOf(0) : Long.valueOf(1);
            Collection<String> lacc = Common.getAccountList();
            adeal.account = (lacc == null) ? "" : lacc.iterator().next();
            arcdealMap.put(String.valueOf(maxkey + 1), adeal);
            Common.saveArcDeals();
            Common.arcActivity.refresh();
            dialog.dismiss();
        }
    });

    dialog.show();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    dialog.getWindow().setAttributes(lp);

}

From source file:com.speed.traquer.app.Feedback_rate_taxi.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feedback_rate_taxi);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    inputTaxi = (EditText) findViewById(R.id.taxi_id);
    taxiDriver = (EditText) findViewById(R.id.taxi_driver);
    taxiLic = (EditText) findViewById(R.id.taxi_license);
    feedback_remarks = (EditText) findViewById(R.id.feedback_remarks);
    rgSafety = (RadioGroup) findViewById(R.id.radioSafety);
    rgDriver = (RadioGroup) findViewById(R.id.radioDriver);
    rgClean = (RadioGroup) findViewById(R.id.radioClean);
    rgComfort = (RadioGroup) findViewById(R.id.radioComfort);
    rgPunctual = (RadioGroup) findViewById(R.id.radioPunctual);
    rgIntegrity = (RadioGroup) findViewById(R.id.radioIntegrity);
    rateBtnBus = (ImageButton) findViewById(R.id.btn_rate_bus);
    editCurrDate = (EditText) findViewById(R.id.editCurrDate);
    editCurrTime = (EditText) findViewById(R.id.editCurrTime);
    ProgressBar barProgress = (ProgressBar) findViewById(R.id.progressLoading);

    rateBtnBus.setOnClickListener(new View.OnClickListener() {
        @Override// www.j  a v  a  2 s  . com
        public void onClick(View view) {
            Intent intent = new Intent(getApplicationContext(), Feedback_rate.class);
            startActivity(intent);
        }
    });

    //Auto Complete Database
    if (isNetworkConnected()) {
        actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp);
        SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl,
                "compcode");
        sa.setLoadingIndicator(barProgress);
        actv_comp_taxi.setAdapter(sa);
    } else {
        Toast.makeText(getApplicationContext(), "Looks like there's a problem with your network connection.",
                Toast.LENGTH_SHORT).show();
    }

    actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp);
    SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl,
            "compcode");
    sa.setLoadingIndicator(barProgress);
    actv_comp_taxi.setAdapter(sa);

    getCurrentDate();
    getCurrentTime();

    String fontPath = "fonts/segoeuil.ttf";
    Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
    actv_comp_taxi.setTypeface(tf);
    actv_comp_taxi.setTypeface(tf);
    feedback_remarks.setTypeface(tf);
    inputTaxi.setTypeface(tf);
    taxiDriver.setTypeface(tf);
    taxiLic.setTypeface(tf);

    TextView txtTaxiDriver = (TextView) findViewById(R.id.txt_taxi_driver);
    txtTaxiDriver.setTypeface(tf);

    TextView txtTaxiLic = (TextView) findViewById(R.id.txt_taxi_license);
    txtTaxiLic.setTypeface(tf);

    TextView txtComp = (TextView) findViewById(R.id.taxi_comp);
    txtComp.setTypeface(tf);

    TextView txtNumber = (TextView) findViewById(R.id.taxi_number);
    txtNumber.setTypeface(tf);

    TextView txtSafety = (TextView) findViewById(R.id.txtSafety);
    txtSafety.setTypeface(tf);

    TextView txtDriver = (TextView) findViewById(R.id.txtDriver);
    txtDriver.setTypeface(tf);

    TextView txtClean = (TextView) findViewById(R.id.txtClean);
    txtClean.setTypeface(tf);

    TextView txtComfort = (TextView) findViewById(R.id.txtComfort);
    txtComfort.setTypeface(tf);

    TextView txtPunctual = (TextView) findViewById(R.id.txtPunctual);
    txtPunctual.setTypeface(tf);

    TextView txtIntegrity = (TextView) findViewById(R.id.txtIntegrity);
    txtIntegrity.setTypeface(tf);

    rgSafety.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatSafety = (RadioButton) findViewById(R.id.ibGreatSafety);
            RadioButton ibGoodSafety = (RadioButton) findViewById(R.id.ibGoodSafety);
            RadioButton ibBadSafety = (RadioButton) findViewById(R.id.ibBadSafety);
            if (ibGreatSafety.isChecked()) {
                re1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Safety",Toast.LENGTH_SHORT).show();
            } else if (ibGoodSafety.isChecked()) {
                rg1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Safety",Toast.LENGTH_SHORT).show();
            } else if (ibBadSafety.isChecked()) {
                rb1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Safety",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgDriver.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatDriver = (RadioButton) findViewById(R.id.ibGreatDriver);
            RadioButton ibGoodDriver = (RadioButton) findViewById(R.id.ibGoodDriver);
            RadioButton ibBadDriver = (RadioButton) findViewById(R.id.ibBadDriver);
            if (ibGreatDriver.isChecked()) {
                re2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Driver",Toast.LENGTH_SHORT).show();
            } else if (ibGoodDriver.isChecked()) {
                rg2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Driver",Toast.LENGTH_SHORT).show();
            } else if (ibBadDriver.isChecked()) {
                rb2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Driver",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgClean.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatClean = (RadioButton) findViewById(R.id.ibGreatClean);
            RadioButton ibGoodClean = (RadioButton) findViewById(R.id.ibGoodClean);
            RadioButton ibBadClean = (RadioButton) findViewById(R.id.ibBadClean);
            if (ibGreatClean.isChecked()) {
                re3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Cleanliness",Toast.LENGTH_SHORT).show();
            } else if (ibGoodClean.isChecked()) {
                rg3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Cleanliness",Toast.LENGTH_SHORT).show();
            } else if (ibBadClean.isChecked()) {
                rb3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Cleanliness",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgComfort.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatComfort = (RadioButton) findViewById(R.id.ibGreatComfort);
            RadioButton ibGoodComfort = (RadioButton) findViewById(R.id.ibGoodComfort);
            RadioButton ibBadComfort = (RadioButton) findViewById(R.id.ibBadComfort);
            if (ibGreatComfort.isChecked()) {
                re4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Super Comfort",Toast.LENGTH_SHORT).show();
            } else if (ibGoodComfort.isChecked()) {
                rg4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Comfort",Toast.LENGTH_SHORT).show();
            } else if (ibBadComfort.isChecked()) {
                rb4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Not Comfort at all",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgPunctual.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatPunctual = (RadioButton) findViewById(R.id.ibGreatPunctual);
            RadioButton ibGoodPunctual = (RadioButton) findViewById(R.id.ibGoodPunctual);
            RadioButton ibBadPunctual = (RadioButton) findViewById(R.id.ibBadPunctual);
            if (ibGreatPunctual.isChecked()) {
                re5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Very Punctual",Toast.LENGTH_SHORT).show();
            } else if (ibGoodPunctual.isChecked()) {
                rg5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Delay Abit",Toast.LENGTH_SHORT).show();
            } else if (ibBadPunctual.isChecked()) {
                rb5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Not Punctual at all",Toast.LENGTH_SHORT).show();
            }
        }
    });

    rgIntegrity.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatDriver = (RadioButton) findViewById(R.id.ibGreatIntegrity);
            RadioButton ibGoodDriver = (RadioButton) findViewById(R.id.ibGoodIntegrity);
            RadioButton ibBadDriver = (RadioButton) findViewById(R.id.ibBadIntegrity);
            if (ibGreatDriver.isChecked()) {
                re6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Driver",Toast.LENGTH_SHORT).show();
            } else if (ibGoodDriver.isChecked()) {
                rg6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Driver",Toast.LENGTH_SHORT).show();
            } else if (ibBadDriver.isChecked()) {
                rb6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Driver",Toast.LENGTH_SHORT).show();
            }
        }
    });

    easyTracker = EasyTracker.getInstance(Feedback_rate_taxi.this);
}