Example usage for android.widget RadioGroup getCheckedRadioButtonId

List of usage examples for android.widget RadioGroup getCheckedRadioButtonId

Introduction

In this page you can find the example usage for android.widget RadioGroup getCheckedRadioButtonId.

Prototype

@IdRes
public int getCheckedRadioButtonId() 

Source Link

Document

Returns the identifier of the selected radio button in this group.

Usage

From source file:dev.ukanth.ufirewall.MainActivity.java

private void selectFilterGroup() {
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.appFilterGroup);
    switch (radioGroup.getCheckedRadioButtonId()) {
    case R.id.rpkg_core:
        showApplications(null, 0, false);
        break;//ww  w .  j  a v  a 2  s .  co  m
    case R.id.rpkg_sys:
        showApplications(null, 1, false);
        break;
    case R.id.rpkg_user:
        showApplications(null, 2, false);
        break;
    default:
        showApplications("", 99, true);
        break;
    }
}

From source file:com.carlrice.reader.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from w w w . ja va 2 s  .  co  m
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());
                            values.put(FilterColumns.IS_ACCEPT_RULE,
                                    ((RadioButton) dialogView.findViewById(R.id.acceptRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    case R.id.menu_search_feed: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
        final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
        if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME)
                && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) {
            searchText.setText(mUrlEditText.getText());
        }
        final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

        new AlertDialog.Builder(EditFeedActivity.this) //
                .setIcon(R.drawable.action_search) //
                .setTitle(R.string.feed_search) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (searchText.getText().length() > 0) {
                            String tmp = searchText.getText().toString();
                            try {
                                tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }
                            final String text = tmp;

                            switch (radioGroup.getCheckedRadioButtonId()) {
                            case R.id.byWebSearch:
                                final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
                                pd.setMessage(getString(R.string.loading));
                                pd.setCancelable(true);
                                pd.setIndeterminate(true);
                                pd.show();

                                getLoaderManager().restartLoader(1, null,
                                        new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                            @Override
                                            public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(
                                                    int id, Bundle args) {
                                                return new GetFeedSearchResultsLoader(EditFeedActivity.this,
                                                        text);
                                            }

                                            @Override
                                            public void onLoadFinished(
                                                    Loader<ArrayList<HashMap<String, String>>> loader,
                                                    final ArrayList<HashMap<String, String>> data) {
                                                pd.cancel();

                                                if (data == null) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.error,
                                                            Toast.LENGTH_SHORT).show();
                                                } else if (data.isEmpty()) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.no_result,
                                                            Toast.LENGTH_SHORT).show();
                                                } else {
                                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                                            EditFeedActivity.this);
                                                    builder.setTitle(R.string.feed_search);

                                                    // create the grid item mapping
                                                    String[] from = new String[] { FEED_SEARCH_TITLE,
                                                            FEED_SEARCH_DESC };
                                                    int[] to = new int[] { android.R.id.text1,
                                                            android.R.id.text2 };

                                                    // fill in the grid_item layout
                                                    SimpleAdapter adapter = new SimpleAdapter(
                                                            EditFeedActivity.this, data,
                                                            R.layout.item_search_result, from, to);
                                                    builder.setAdapter(adapter,
                                                            new DialogInterface.OnClickListener() {
                                                                @Override
                                                                public void onClick(DialogInterface dialog,
                                                                        int which) {
                                                                    mNameEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_TITLE));
                                                                    mUrlEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_URL));
                                                                }
                                                            });
                                                    builder.show();
                                                }
                                            }

                                            @Override
                                            public void onLoaderReset(
                                                    Loader<ArrayList<HashMap<String, String>>> loader) {
                                            }
                                        });
                                break;

                            case R.id.byTopic:
                                mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                        + "&start=1&length=10&l=en&src=news&f=rss");
                                break;

                            case R.id.byYoutube:
                                mUrlEditText.setText("http://www.youtube.com/rss/user/"
                                        + text.replaceAll("\\+", "") + "/videos.rss");
                                break;
                            }
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.autburst.picture.MainActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    final Context mContext = this;

    switch (id) {

    case DIALOG_CREATE_ALBUM_ID:

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle(R.string.new_gallery);

        View view = getLayoutInflater().inflate(R.layout.create_album, null);
        final EditText edit = (EditText) view.findViewById(R.id.albumNameEditText);
        final RadioGroup rg = (RadioGroup) view.findViewById(R.id.formatRadioGroup);

        builder2.setView(view);//from   ww w. ja  v  a 2  s. co  m

        builder2.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {

                String name = edit.getText().toString();
                Log.d(TAG, "Entered name: " + name);

                // base64 encode string
                String encodedName = new String(Base64.encodeBase64(name.getBytes()));
                Log.d(TAG, "base64 encoded name: " + encodedName);

                // check if album with the same name already exist
                if (Utilities.existsAlbumName(encodedName)) {
                    // fehler
                    showDialog(DIALOG_ALBUM_NAME_ALREADY_EXIST);
                    return;
                }

                // create folder
                Utilities.getAlbumDirectory(encodedName);

                // get format
                int checkedRadioButtonId = rg.getCheckedRadioButtonId();
                final Boolean portrait;
                if (checkedRadioButtonId == R.id.portraitRB)
                    portrait = true;
                else
                    portrait = false;

                SharedPreferences settings = getSharedPreferences(Utilities.PIC_STORE, 0);
                Editor edit2 = settings.edit();
                edit2.putBoolean(encodedName + ".portrait", portrait);
                edit2.putFloat(encodedName + ".frameRate", Utilities.MEDIUM_FRAME_RATE);
                edit2.commit();
                Log.d(TAG, "portrait: " + portrait + " settingsname: " + encodedName + ".portrait frameRate: "
                        + Utilities.MEDIUM_FRAME_RATE);

                // reset editView
                edit.setText("");

                // update table
                adapter.add(encodedName);
                adapter.sort(Utilities.getAlbumNameComparator());
                adapter.notifyDataSetChanged();

                dialog.dismiss();

                controller.transformGUI(MainActivityController.CREATED_ALBUM);
            }
        });
        builder2.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
                // reset editView
                edit.setText("");
                // showDialog(DIALOG_CREATE_ALBUM_ID);
            }
        });

        AlertDialog create = builder2.create();
        dialog = create;

        break;
    case DIALOG_ALBUM_NAME_ALREADY_EXIST:
        AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
        builder3.setTitle(R.string.warning);
        builder3.setMessage(R.string.gallery_exists);
        builder3.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // dialog.dismiss();
                showDialog(DIALOG_CREATE_ALBUM_ID);
            }
        });

        dialog = builder3.create();
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:com.app.uafeed.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();/* www  . j  av  a2s. com*/
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    case R.id.menu_search_feed: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
        final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
        if (!mUrlEditText.getText().toString().startsWith(Constants.HTTP_SCHEME)
                && !mUrlEditText.getText().toString().startsWith(Constants.HTTPS_SCHEME)) {
            searchText.setText(mUrlEditText.getText());
        }
        final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

        new AlertDialog.Builder(EditFeedActivity.this) //
                .setIcon(R.drawable.action_search) //
                .setTitle(R.string.feed_search) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (searchText.getText().length() > 0) {
                            String tmp = searchText.getText().toString();
                            try {
                                tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }
                            final String text = tmp;

                            switch (radioGroup.getCheckedRadioButtonId()) {
                            case R.id.byWebSearch:
                                final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
                                pd.setMessage(getString(R.string.loading));
                                pd.setCancelable(true);
                                pd.setIndeterminate(true);
                                pd.show();

                                getLoaderManager().restartLoader(1, null,
                                        new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                            @Override
                                            public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(
                                                    int id, Bundle args) {
                                                return new GetFeedSearchResultsLoader(EditFeedActivity.this,
                                                        text);
                                            }

                                            @Override
                                            public void onLoadFinished(
                                                    Loader<ArrayList<HashMap<String, String>>> loader,
                                                    final ArrayList<HashMap<String, String>> data) {
                                                pd.cancel();

                                                if (data == null) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.error,
                                                            Toast.LENGTH_SHORT).show();
                                                } else if (data.isEmpty()) {
                                                    Toast.makeText(EditFeedActivity.this, R.string.no_result,
                                                            Toast.LENGTH_SHORT).show();
                                                } else {
                                                    AlertDialog.Builder builder = new AlertDialog.Builder(
                                                            EditFeedActivity.this);
                                                    builder.setTitle(R.string.feed_search);

                                                    // create the grid item mapping
                                                    String[] from = new String[] { FEED_SEARCH_TITLE,
                                                            FEED_SEARCH_DESC };
                                                    int[] to = new int[] { android.R.id.text1,
                                                            android.R.id.text2 };

                                                    // fill in the grid_item layout
                                                    SimpleAdapter adapter = new SimpleAdapter(
                                                            EditFeedActivity.this, data,
                                                            R.layout.item_search_result, from, to);
                                                    builder.setAdapter(adapter,
                                                            new DialogInterface.OnClickListener() {
                                                                @Override
                                                                public void onClick(DialogInterface dialog,
                                                                        int which) {
                                                                    mNameEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_TITLE));
                                                                    mUrlEditText.setText(data.get(which)
                                                                            .get(FEED_SEARCH_URL));
                                                                }
                                                            });
                                                    builder.show();
                                                }
                                            }

                                            @Override
                                            public void onLoaderReset(
                                                    Loader<ArrayList<HashMap<String, String>>> loader) {
                                            }
                                        });
                                break;

                            case R.id.byTopic:
                                mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                        + "&start=1&length=10&l=en&src=news&f=rss");
                                break;

                            case R.id.byYoutube:
                                mUrlEditText.setText("http://www.youtube.com/rss/user/"
                                        + text.replaceAll("\\+", "") + "/videos.rss");
                                break;
                            }
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.google.android.gcm.demo.ui.NetworkSchedulerFragment.java

private void showDialog(final int type) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getActivity());
    @SuppressLint("InflateParams") // the layout is used inside a dialog so no parent is needed
    LinearLayout layout = (LinearLayout) getActivity().getLayoutInflater()
            .inflate(R.layout.widget_schedule_task_dialog, null);
    if (type == TYPE_ONE_OFF) {
        alertBuilder.setTitle(R.string.scheduler_add_oneoff);
        alertBuilder.setMessage(R.string.scheduler_add_oneoff_message);
        alertBuilder.setPositiveButton(R.string.scheduler_add_oneoff, null);
        ((TextView) layout.findViewById(R.id.task_param1_title)).setText(R.string.scheduler_run_from);
        ((TextView) layout.findViewById(R.id.task_param2_title)).setText(R.string.scheduler_run_by);
    } else {/* www .j  av a2 s .c  om*/
        alertBuilder.setTitle(R.string.scheduler_add_periodic);
        alertBuilder.setMessage(R.string.scheduler_add_periodic_message);
        alertBuilder.setPositiveButton(R.string.scheduler_add_periodic, null);
        ((TextView) layout.findViewById(R.id.task_param1_title)).setText(R.string.scheduler_period);
        ((TextView) layout.findViewById(R.id.task_param2_title)).setText(R.string.scheduler_flex);
    }
    final EditText param1View = (EditText) layout.findViewById(R.id.task_param1);
    final EditText param2View = (EditText) layout.findViewById(R.id.task_param2);
    final RadioGroup connectivityView = (RadioGroup) layout.findViewById(R.id.task_connectivity_group);
    final CheckBox chargingView = (CheckBox) layout.findViewById(R.id.task_charging_checkbox);
    final CheckBox persistenceView = (CheckBox) layout.findViewById(R.id.task_persistence_checkbox);
    alertBuilder.setView(layout);
    alertBuilder.setNegativeButton(R.string.scheduler_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });
    // Show the dialog
    final AlertDialog dialog = alertBuilder.create();
    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // schedule the task
            final long value1;
            final long value2;
            try {
                value1 = Long.parseLong(param1View.getText().toString());
                value2 = Long.parseLong(param2View.getText().toString());
            } catch (NumberFormatException e) {
                Toast.makeText(getActivity(), getString(R.string.scheduler_error_nan), Toast.LENGTH_SHORT)
                        .show();
                return;
            }
            int connectivity = Task.NETWORK_STATE_CONNECTED;
            switch (connectivityView.getCheckedRadioButtonId()) {
            case R.id.task_connectivity_connected:
                connectivity = Task.NETWORK_STATE_CONNECTED;
                break;
            case R.id.task_connectivity_unmetered:
                connectivity = Task.NETWORK_STATE_UNMETERED;
                break;
            case R.id.task_connectivity_any:
                connectivity = Task.NETWORK_STATE_ANY;
                break;
            }
            boolean charging = chargingView.isChecked();
            boolean persistence = persistenceView.isChecked();
            if (type == TYPE_ONE_OFF) {
                addOneOff(value1, value2, connectivity, charging);
            } else {
                addPeriodic(value1, value2, connectivity, charging, persistence);
            }
            refresh();
            dialog.dismiss();
        }
    });
}

From source file:reportsas.com.formulapp.Formulario.java

public int ObtenerRespuesta(LinearLayout contenedor, Pregunta Pregunta,
        ArrayList<PreguntaRespuesta> respuestaList) {
    PreguntaRespuesta result = new PreguntaRespuesta();
    int numRespuesta = 0;
    result.setIdPregunta(Pregunta.getIdPregunta());
    EditText resp;/*from www .jav a  2  s.  c  o  m*/
    TextView selectio;
    switch (Pregunta.getTipoPregunta()) {
    case 1:
        resp = (EditText) contenedor.findViewById(R.id.edtTexto);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 2:
        resp = (EditText) contenedor.findViewById(R.id.mtxtEdit);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 3:
        selectio = (TextView) contenedor.findViewById(R.id.respuestaGruop);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 4:

        String resp_opcio = "";
        for (int j = 0; j < contenedor.getChildCount(); j++) {
            View child = contenedor.getChildAt(j);
            if (child instanceof CheckBox) {
                CheckBox hijo = (CheckBox) child;
                if (hijo.isChecked()) {
                    if (resp_opcio.length() == 0) {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio = otrosR.getText().toString();
                        } else {
                            resp_opcio = hijo.getText().toString();
                        }
                    } else {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio += " , " + otrosR.getText().toString() + " ";
                        } else {
                            resp_opcio = resp_opcio + " , " + hijo.getText() + " ";
                        }

                    }
                }
            }

        }
        result.setItem(1);
        result.setRespuesta(resp_opcio);
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 5:
        selectio = (TextView) contenedor.findViewById(R.id.seleEscala);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 6:
        Spinner lista = (Spinner) contenedor.findViewById(R.id.opcionesListado);
        result.setItem(1);
        result.setRespuesta(lista.getSelectedItem().toString() + "");
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 7:
        TableLayout tabla = (TableLayout) contenedor.findViewById(R.id.tablaOpciones);
        for (int i = 0; i < tabla.getChildCount(); i++) {
            TableRow registro = (TableRow) tabla.getChildAt(i);
            TextView etiq = (TextView) registro.findViewById(R.id.textoRow);
            RadioGroup selector = (RadioGroup) registro.findViewById(R.id.valoresRow);
            PreguntaRespuesta itemA = new PreguntaRespuesta();
            itemA.setIdPregunta(Pregunta.getIdPregunta());
            itemA.setItem(i + 1);
            itemA.setRespuesta(etiq.getText().toString());
            if (selector.getCheckedRadioButtonId() > 0) {
                RadioButton rb = (RadioButton) selector.findViewById(selector.getCheckedRadioButtonId());
                itemA.setOpcion(rb.getText() + "");
            }

            respuestaList.add(itemA);
            numRespuesta++;
        }

        break;
    case 8:
        DatePicker dp = (DatePicker) contenedor.findViewById(R.id.Fecha_resutl);
        result.setItem(1);
        result.setRespuesta(dp.getYear() + "-" + dp.getMonth() + "-" + dp.getDayOfMonth());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 9:
        TimePicker tp = (TimePicker) contenedor.findViewById(R.id.hora_result);
        result.setItem(1);
        result.setRespuesta(tp.getCurrentHour() + ":" + tp.getCurrentMinute());
        respuestaList.add(result);
        numRespuesta = 1;
        break;

    default:
        result.setItem(1);
        result.setRespuesta("Proceso");
        break;

    }

    return numRespuesta;

}

From source file:com.android.calendar.event.EditEventView.java

private void addFieldsRecursive(StringBuilder b, View v) {
    if (v == null || v.getVisibility() != View.VISIBLE) {
        return;/*from  w w  w.j av a 2s  .  c o m*/
    }
    if (v instanceof TextView) {
        CharSequence tv = ((TextView) v).getText();
        if (!TextUtils.isEmpty(tv.toString().trim())) {
            b.append(tv + PERIOD_SPACE);
        }
    } else if (v instanceof RadioGroup) {
        RadioGroup rg = (RadioGroup) v;
        int id = rg.getCheckedRadioButtonId();
        if (id != View.NO_ID) {
            b.append(((RadioButton) (v.findViewById(id))).getText() + PERIOD_SPACE);
        }
    } else if (v instanceof Spinner) {
        Spinner s = (Spinner) v;
        if (s.getSelectedItem() instanceof String) {
            String str = ((String) (s.getSelectedItem())).trim();
            if (!TextUtils.isEmpty(str)) {
                b.append(str + PERIOD_SPACE);
            }
        }
    } else if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;
        int children = vg.getChildCount();
        for (int i = 0; i < children; i++) {
            addFieldsRecursive(b, vg.getChildAt(i));
        }
    }
}

From source file:org.readium.sdk.android.launcher.ViewerSettingsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();

    final View dialogView = inflater.inflate(R.layout.viewer_settings, null);

    final RadioGroup spreadGroup = (RadioGroup) dialogView.findViewById(R.id.spreadSettings);
    switch (mOriginalSettings.getSyntheticSpreadMode()) {
    case AUTO://w  ww.java2 s  . co  m
        spreadGroup.check(R.id.spreadAuto);
        break;
    case DOUBLE:
        spreadGroup.check(R.id.spreadDouble);
        break;
    case SINGLE:
        spreadGroup.check(R.id.spreadSingle);
        break;
    }

    final RadioGroup scrollGroup = (RadioGroup) dialogView.findViewById(R.id.scrollSettings);
    switch (mOriginalSettings.getScrollMode()) {
    case AUTO:
        scrollGroup.check(R.id.scrollAuto);
        break;
    case DOCUMENT:
        scrollGroup.check(R.id.scrollDocument);
        break;
    case CONTINUOUS:
        scrollGroup.check(R.id.scrollContinuous);
        break;
    }

    final EditText fontSizeText = (EditText) dialogView.findViewById(R.id.fontSize);
    fontSizeText.setText("" + mOriginalSettings.getFontSize());

    final EditText columnGapText = (EditText) dialogView.findViewById(R.id.columnGap);
    columnGapText.setText("" + mOriginalSettings.getColumnGap());

    builder.setView(dialogView).setTitle(R.string.settings)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    if (mListener != null) {
                        int fontSize = parseString(fontSizeText.getText().toString(), 100);
                        int columnGap = parseString(columnGapText.getText().toString(), 20);

                        ViewerSettings.SyntheticSpreadMode syntheticSpreadMode = null;
                        switch (spreadGroup.getCheckedRadioButtonId()) {
                        case R.id.spreadAuto:
                            syntheticSpreadMode = ViewerSettings.SyntheticSpreadMode.AUTO;
                            break;
                        case R.id.spreadSingle:
                            syntheticSpreadMode = ViewerSettings.SyntheticSpreadMode.SINGLE;
                            break;
                        case R.id.spreadDouble:
                            syntheticSpreadMode = ViewerSettings.SyntheticSpreadMode.DOUBLE;
                            break;
                        }

                        ViewerSettings.ScrollMode scrollMode = null;
                        switch (scrollGroup.getCheckedRadioButtonId()) {
                        case R.id.scrollAuto:
                            scrollMode = ViewerSettings.ScrollMode.AUTO;
                            break;
                        case R.id.scrollDocument:
                            scrollMode = ViewerSettings.ScrollMode.DOCUMENT;
                            break;
                        case R.id.scrollContinuous:
                            scrollMode = ViewerSettings.ScrollMode.CONTINUOUS;
                            break;
                        }

                        ViewerSettings settings = new ViewerSettings(syntheticSpreadMode, scrollMode, fontSize,
                                columnGap);
                        mListener.onViewerSettingsChange(settings);
                    }
                    dismiss();
                }

                private int parseString(String s, int defaultValue) {
                    try {
                        return Integer.parseInt(s);
                    } catch (Exception e) {
                        Log.e(TAG, "" + e.getMessage(), e);
                    }
                    return defaultValue;
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dismiss();
                }
            });

    return builder.create();
}

From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java

public void onMotionStateChanged(MotionState oldState, MotionState newState) {

    if (oldState == MotionState.STATIONARY
            || (newState != MotionState.BIGMOVEMENT && newState != MotionState.MICROMOVEMENT)) {
        //LOG IN TABLE
        final String motionStateSwitch = oldState.name() + "=>" + newState.name();

        final String userStateSwitch = "Stationary=" + mMotionManager.isStationary() + "|OnCommute="
                + mMotionManager.isOnCommute();

        new Thread((new Runnable() {

            public void run() {

                //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled
                writeToFusionTable(false, motionStateSwitch);

            }/*from   ww w  . j  a  v  a  2 s .  com*/
        })).start();

        mMainHandler.post(new Runnable() {

            public void run() {
                ((TextView) findViewById(R.id.motion_state)).setText(motionStateSwitch);
                ((TextView) findViewById(R.id.user_state)).setText(userStateSwitch);
            }
        });
    }

    if (mIsStationary && mMotionManager.isStationary() == false)
    //We started to move, enable frequency controls
    {
        findViewById(R.id.frequency0).setEnabled(true);
        findViewById(R.id.frequency1).setEnabled(true);
        findViewById(R.id.frequency2).setEnabled(true);
        findViewById(R.id.frequency3).setEnabled(true);

        RadioGroup pollFrequencyRadioGroup = (RadioGroup) findViewById(R.id.pollFrequencyRadioGroup);
        if (pollFrequencyRadioGroup.getCheckedRadioButtonId() == -1) {
            //check(...) inderictly calls startTaskForId(...)
            ((RadioGroup) findViewById(R.id.pollFrequencyRadioGroup)).check(R.id.frequency2);
        } else {
            //START SCHEDULED THREADED ACTIVTY TO PUSH Location TO FUSION TABLE
            startTaskForId(pollFrequencyRadioGroup.getCheckedRadioButtonId(), false);
        }

        ((TextView) findViewById(R.id.pollFrequencyText)).setText("{Polling frequency}:");
        //((TextView) findViewById(R.id.pollFrequencyText)).setTextColor(R.color.text_blue);
    } else if (mIsStationary == false && mMotionManager.isStationary())
    //We just stopped, disable 
    {
        findViewById(R.id.frequency0).setEnabled(false);
        findViewById(R.id.frequency1).setEnabled(false);
        findViewById(R.id.frequency2).setEnabled(false);
        findViewById(R.id.frequency3).setEnabled(false);

        //((RadioGroup) findViewById(R.id.pollFrequencyRadioGroup)).check(-1);
        cancelActiveTasks();
        mLocationPollThreadExecutor.purge();

        //Should I thread this as the Alohar's guy did by posting a new thread on the main handle ?
        ((TextView) findViewById(R.id.pollFrequencyText)).setText("{N/A when stationary}");

        //((TextView) findViewById(R.id.pollFrequencyText)).setTextColor(R.color.text_violet);

        new Thread((new Runnable() {

            public void run() {

                //Threaded : httpTransport is Thread safe, hence concurrent access to the web should be handled
                writeToFusionTable(false, "Location poll STOP--Purged");

            }
        })).start();

    }

    mIsStationary = mMotionManager.isStationary();
}

From source file:universe.constellation.orion.viewer.OrionViewerActivity.java

public void initRotationScreen() {
    //if (getDevice() instanceof EdgeDevice) {
    if (false) {// www  .  j  a  va 2 s .  com
        final RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup);

        rotationGroup.check(R.id.rotate0);

        if (Device.Info.NOOK2) {
            RadioButton r0 = (RadioButton) rotationGroup.findViewById(R.id.rotate0);
            RadioButton r90 = (RadioButton) rotationGroup.findViewById(R.id.rotate90);
            RadioButton r270 = (RadioButton) rotationGroup.findViewById(R.id.rotate270);
            TextView tv = (TextView) findMyViewById(R.id.navigation_title);
            int color = tv.getTextColors().getDefaultColor();
            r0.setTextColor(color);
            r90.setTextColor(color);
            r270.setTextColor(color);
        }

        getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
            @Override
            public void documentOpened(Controller controller) {
                updateRotation();
            }
        });

        ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply);
        apply.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onApplyAction(true);
                int id = rotationGroup.getCheckedRadioButtonId();
                controller.setRotation(id == R.id.rotate0 ? 0 : id == R.id.rotate90 ? -1 : 1);
            }
        });

        ListView list = (ListView) findMyViewById(R.id.rotationList);
        list.setVisibility(View.GONE);
    } else {
        RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup);
        rotationGroup.setVisibility(View.GONE);

        final ListView list = (ListView) findMyViewById(R.id.rotationList);

        //set choices and replace 0 one with Application Default
        boolean isLevel9 = getOrionContext().getSdkVersion() >= 9;
        CharSequence[] values = getResources().getTextArray(
                isLevel9 ? R.array.screen_orientation_full_desc : R.array.screen_orientation_desc);
        CharSequence[] newValues = new CharSequence[values.length];
        for (int i = 0; i < values.length; i++) {
            newValues[i] = values[i];
        }
        newValues[0] = getResources().getString(R.string.orientation_default_rotation);

        list.setAdapter(Device.Info.NOOK2
                ? new Nook2ListAdapter(this, android.R.layout.simple_list_item_single_choice, newValues,
                        (TextView) findMyViewById(R.id.navigation_title))
                : new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, newValues));

        list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        list.setItemChecked(0, true);

        list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) {
                CheckedTextView check = (CheckedTextView) view;
                check.setChecked(!check.isChecked());
            }
        });

        final CharSequence[] ORIENTATION_ARRAY = getResources().getTextArray(R.array.screen_orientation_full);

        list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) {
                onApplyAction(true);
                String orientation = ORIENTATION_ARRAY[position].toString();
                controller.changeOrinatation(orientation);
            }
        });

        ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply);
        apply.setVisibility(View.GONE);
        //            apply.setOnClickListener(new View.OnClickListener() {
        //                public void onClick(View view) {
        //                    onApplyAction(true);
        //                }
        //            });
    }

    ImageButton cancel = (ImageButton) findMyViewById(R.id.rotation_close);
    cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onAnimatorCancel();
            updateRotation();
        }
    });
}