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:org.odk.collect.android.activities.GeoTraceGoogleMapActivity.java

private void startGeoTrace() {
    RadioGroup rb = (RadioGroup) traceSettingsView.findViewById(R.id.radio_group);
    int radioButtonID = rb.getCheckedRadioButtonId();
    View radioButton = rb.findViewById(radioButtonID);
    int idx = rb.indexOfChild(radioButton);
    beenPaused = true;/*from w  ww  . jav a2s  .  c  o m*/
    TRACE_MODE = idx;
    if (TRACE_MODE == 0) {
        setupManualMode();
    } else if (TRACE_MODE == 1) {
        setupAutomaticMode();
    } else {

    }
    play_button.setVisibility(View.GONE);
    pause_button.setVisibility(View.VISIBLE);

}

From source file:edu.csh.coursebrowser.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    this.setTitle("Settings");
    final SharedPreferences sp = SchoolActivity.sp;
    LinearLayout ll = (LinearLayout) this.findViewById(R.id.settings_layout);
    ll.setGravity(Gravity.CENTER);//from w  ww .  j a va  2 s.  c  o  m
    final TextView tv = new TextView(this);
    if (!sp.contains("quarter")) {
        SharedPreferences.Editor e = sp.edit();
        e.putString("quarter", "20122");
        e.commit();
    }
    tv.setText("Current Quarter: " + sp.getString("quarter", "20122"));
    Button b = new Button(this);
    b.setText("Change Quarter");
    ll.addView(tv);
    ll.addView(b);
    ll.setPadding(10, 10, 10, 10);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            AlertDialog.Builder changeQuarter = new AlertDialog.Builder(SettingsActivity.this);
            changeQuarter.setTitle("Change Quarter");
            changeQuarter.setMessage("Select New Quarter");
            final RadioButton ld = new RadioButton(SettingsActivity.this);
            ld.setText("20121");
            ld.setId(1);
            final RadioButton s = new RadioButton(SettingsActivity.this);
            s.setText("20122 (Current)");
            s.setId(2);
            final RadioButton d = new RadioButton(SettingsActivity.this);
            d.setText("20123");
            d.setId(3);
            final RadioGroup rg = new RadioGroup(SettingsActivity.this);
            rg.addView(ld);
            rg.addView(s);
            rg.addView(d);
            changeQuarter.setView(rg);

            changeQuarter.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }

            });
            changeQuarter.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String q;
                    int n = rg.getCheckedRadioButtonId();
                    if (n == 1)
                        q = "20121";
                    else if (n == 2)
                        q = "20122";
                    else
                        q = "20123";
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("quarter", q);
                    edit.commit();
                    SettingsActivity.this.finish();
                }
            });

            changeQuarter.show();
        }

    });

}

From source file:com.metinkale.prayerapp.vakit.PrefsView.java

@Override
public void onClick(View v) {
    Object o = getValue();//from w  w  w. ja  va  2s  .co  m
    if ((mPref == Pref.Sound) || (mPref == Pref.Dua) || (mPref == Pref.Sela)) {
        new SoundChooser().showExpanded(((Activity) getContext()).getFragmentManager(), new Callback() {

            @Override
            public String getCurrent() {
                return (String) getValue();
            }

            @Override
            public void setCurrent(String current) {
                setValue(current);

            }

            @Override
            public Vakit getVakit() {
                return mVakit;
            }

            @Override
            public List<Sound> getSounds() {
                if (mPref == Pref.Sound) {
                    return Sounds.getSounds(mVakit);
                } else if (mPref == Pref.Dua) {
                    return Sounds.getSounds("dua", "extra");
                } else if (mPref == Pref.Sela) {
                    return Sounds.getSounds("sela", "extra");
                }

                return Sounds.getSounds(mVakit);
            }

        });

    } else if (mPref == Pref.SabahTime) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        LayoutInflater inflater = LayoutInflater.from(getContext());
        View view = inflater.inflate(R.layout.sabahtime_dialog, null);
        final NumberPicker np = (NumberPicker) view.findViewById(R.id.number_picker);
        final RadioGroup rg = (RadioGroup) view.findViewById(R.id.rg);

        int val = (Integer) getValue();
        np.setMinValue(0);
        np.setMaxValue(300);
        np.setValue(Math.abs(val));

        rg.check((val < 0) ? R.id.afterImsak : R.id.beforeGunes);
        builder.setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                setValue(np.getValue() * ((rg.getCheckedRadioButtonId() == R.id.beforeGunes) ? 1 : -1));
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
            }
        });
        builder.show();
    } else if (mPref == Pref.Vibration2) {
        int i = (Integer) o;
        i++;
        if ((i < -1) || (i > 1)) {
            i = -1;
        }
        setValue(i);
        performHapticFeedback(HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING
                | HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
    } else if (o instanceof Boolean) {
        setValue(!(Boolean) o);
        performHapticFeedback(HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING
                | HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
    } else if (o instanceof Integer) {
        int titleId = 0;
        switch (mPref) {
        case Silenter:
            PermissionUtils.get(getContext()).needNotificationPolicy((Activity) getContext());
            titleId = R.string.silenterDuration;
            break;
        case Time:
            titleId = R.string.time;
            break;
        default:
            break;
        }
        NumberPickerDialog npd = new NumberPickerDialog(getContext(), new OnNumberSetListener() {

            @Override
            public void onNumberSet(int dialogId, int number) {
                setValue(number);

            }
        }, (Integer) o, 0, 300, titleId, 0, 0);
        npd.show();
    }

}

From source file:org.odk.collect.android.activities.GeoTraceOsmMapActivity.java

private void startGeoTrace() {
    RadioGroup rb = (RadioGroup) traceSettingsView.findViewById(R.id.radio_group);
    int radioButtonID = rb.getCheckedRadioButtonId();
    View radioButton = rb.findViewById(radioButtonID);
    int idx = rb.indexOfChild(radioButton);
    beenPaused = true;/*from w  w w. j a v a2 s.  c  om*/
    traceMode = idx;
    if (traceMode == 0) {
        setupManualMode();
    } else if (traceMode == 1) {
        setupAutomaticMode();
    } else {
        reset_trace_settings();
    }
    playButton.setVisibility(View.GONE);
    clearButton.setEnabled(false);
    pauseButton.setVisibility(View.VISIBLE);

}

From source file:course1778.mobileapp.safeMedicare.Main.FamMemFrag.java

public void onClick(DialogInterface di, int whichButton) {
    // get strings from edittext boxes, then insert them into database
    ContentValues values = new ContentValues(DatabaseHelper.CONTENT_VALUE_COUNT);
    ContentValues drugInteractionValues = new ContentValues(4);
    Dialog dlg = (Dialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    TimePicker tp = (TimePicker) dlg.findViewById(R.id.timePicker);
    Spinner mySpinner = (Spinner) dlg.findViewById(R.id.spinner);
    String fre = mySpinner.getSelectedItem().toString();
    EditText dosage = (EditText) dlg.findViewById(R.id.dosage);
    EditText instruction = (EditText) dlg.findViewById(R.id.instruction);
    RadioGroup radioButtonGroup = (RadioGroup) dlg.findViewById(R.id.radioGroup);
    int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
    View radioButton = radioButtonGroup.findViewById(radioButtonID);
    int shape = radioButtonGroup.indexOfChild(radioButton) / 2;
    int Fre;//  w w w  .j  a  v  a 2  s . c om
    //int day = 0;
    int monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0, sunday = 0;

    // clear array list
    drug_interaction_list.clear();
    curr_drug_interaction_list.clear();

    // loop through database
    crsInteractions.moveToPosition(-1);
    while (crsInteractions.moveToNext()) {
        // drug names
        drugName = crsInteractions.getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_NAMES));

        // corresponding interacted drugs/foods
        interactionName = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_DRUG_INTERACTIONS));

        // interaction result
        interactionResult = crsInteractions
                .getString(crsInteractions.getColumnIndex(DatabaseHelper.SHEET_1_INTERACTION_RESULT));

        // medication name entered by user
        medNameFieldTxt = textView.getText().toString();

        // check if newly entered medication name matches current drug name
        if (drugName.equals(medNameFieldTxt)) {
            /**if found, check if the corresponding interaction
             * drug in the list of all added drugs by user
             */
            if (db.isNameExitOnDB(interactionName)) {
                // interaction found
                Log.d("myinteraction", "Found Interaction");

                String interaction_result = medNameFieldTxt + "/" + interactionName + "\n";

                // only insert new drug interactions if they have not yet exist
                if (!dbInteraction.isDrugInteractionExist(medNameFieldTxt, interactionName)) {
                    // insert the drug interaction into our new dynamic drug interaction db
                    drugInteractionValues.put(DatabaseInteractionHelper.USR_NAME,
                            ParseUser.getCurrentUser().getUsername());
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_NAME, medNameFieldTxt);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION, interactionName);
                    drugInteractionValues.put(DatabaseInteractionHelper.DRUG_INTERACTION_SHOW,
                            DatabaseInteractionHelper.DRUG_INTERACTION_SHOW_TRUE);

                    dbInteraction.getWritableDatabase().insert(DatabaseInteractionHelper.TABLE,
                            DatabaseInteractionHelper.DRUG_NAME, drugInteractionValues);
                }

                drug_interaction_list.add(interaction_result);
                curr_drug_interaction_list.add(interactionName);
            }
        }
    }

    Log.d("mydatabase3", DatabaseUtils.dumpCursorToString(dbInteraction.getCursor()));

    // display all iteractions in pop window if there is any
    String interaction_results = "\n";
    for (int i = 0; i < curr_drug_interaction_list.size(); i++) {
        String interaction = medNameFieldTxt + " & " + curr_drug_interaction_list.get(i) + "\n\n";
        interaction_results = interaction_results.concat(interaction);
    }

    if (drug_interaction_list.size() != 0) {
        // inflate a dialog to display the drug interactions warning
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View resultView = inflater.inflate(R.layout.drug_interaction_result, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        builder.setTitle(R.string.drug_interaction_result_title).setView(resultView)
                // go to drug interaction list button
                .setNegativeButton(R.string.drug_interaction_list, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // drug interaction page
                        DrugInteractions drugInterac = new DrugInteractions();
                        FragmentTransaction transaction;
                        transaction = getFragmentManager().beginTransaction();
                        transaction.replace(R.id.fragmentContainer, drugInterac);
                        transaction.addToBackStack(null);
                        // Commit the transaction
                        transaction.commit();
                    }
                })

                // ok button
                .setPositiveButton(R.string.dismiss, null).show();

        TextView interactionResultView = (TextView) resultView.findViewById(R.id.resultView);

        // add warning message into the pop up window
        interaction_results = interaction_results.concat(getString(R.string.interaction_warning));

        // display on pop up window
        interactionResultView.setText(interaction_results);
    }

    // write the list of drug interactions into file
    Helpers.writeToFile(getContext(), drug_interaction_list, "drug_interaction_list");

    Log.d("mydatabase", DatabaseUtils.dumpCursorToString(db.getCursor()));

    if (fre == "Ten Times a Day") {
        Fre = 10;
    } else if (fre == "Twice a Day") {
        Fre = 2;
    } else if (fre == "Three Times a Day") {
        Fre = 3;
    } else if (fre == "Four Times a Day") {
        Fre = 4;
    } else if (fre == "Five Times a Day") {
        Fre = 5;
    } else if (fre == "Six Times a Day") {
        Fre = 6;
    } else if (fre == "Seven Times a Day") {
        Fre = 7;
    } else if (fre == "Eight Times a Day") {
        Fre = 8;
    } else if (fre == "Nine Times a Day") {
        Fre = 9;
    } else {
        Fre = 1;
    }

    if (((CheckBox) dlg.findViewById(R.id.MonCheck)).isChecked()) {
        monday = monday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.TueCheck)).isChecked()) {
        tuesday = tuesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.WedCheck)).isChecked()) {
        wednesday = wednesday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.ThuCheck)).isChecked()) {
        thursday = thursday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.FriCheck)).isChecked()) {
        friday = friday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SatCheck)).isChecked()) {
        saturday = saturday + 1;
    }
    if (((CheckBox) dlg.findViewById(R.id.SunCheck)).isChecked()) {
        sunday = sunday + 1;
    }

    // clear focus before retrieving the min and hr
    tp.clearFocus();

    int tpMinute = tp.getCurrentMinute();
    int tpHour = tp.getCurrentHour();
    // an order number to order the list view items
    int orderNum = tpHour * 60 + tpMinute;
    tp.setIs24HourView(true);

    String titleStr = title.getText().toString();
    String timeHStr = Helpers.StringFormatter(tpHour, "00");
    String timeMStr = Helpers.StringFormatter(tpMinute, "00");
    String dosageStr = dosage.getText().toString();
    String instructionStr = instruction.getText().toString();

    Log.d("mytime", Integer.toString(tpHour));
    Log.d("mytime", Integer.toString(tpMinute));

    values.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    values.put(DatabaseHelper.TITLE, titleStr);
    values.put(DatabaseHelper.TIME_H, timeHStr);
    values.put(DatabaseHelper.TIME_M, timeMStr);
    values.put(DatabaseHelper.FREQUENCY, Fre);
    //values.put(DatabaseHelper.DAY, day);

    values.put(DatabaseHelper.MONDAY, monday);
    values.put(DatabaseHelper.TUESDAY, tuesday);
    values.put(DatabaseHelper.WEDNESDAY, wednesday);
    values.put(DatabaseHelper.THURSDAY, thursday);
    values.put(DatabaseHelper.FRIDAY, friday);
    values.put(DatabaseHelper.SATURDAY, saturday);
    values.put(DatabaseHelper.SUNDAY, sunday);

    values.put(DatabaseHelper.DOSAGE, dosageStr);
    values.put(DatabaseHelper.INSTRUCTION, instructionStr);
    values.put(DatabaseHelper.SHAPE, shape);
    values.put(DatabaseHelper.ORDER_NUM, orderNum);

    Bundle bundle = new Bundle();
    // add extras here..
    bundle.putString(DatabaseHelper.TITLE, title.getText().toString());
    bundle.putString(DatabaseHelper.TIME_H, timeHStr);
    bundle.putString(DatabaseHelper.TIME_M, timeMStr);
    bundle.putInt(DatabaseHelper.FREQUENCY, Fre);
    //bundle.putInt(DatabaseHelper.DAY, day);

    bundle.putInt(DatabaseHelper.MONDAY, monday);
    bundle.putInt(DatabaseHelper.TUESDAY, tuesday);
    bundle.putInt(DatabaseHelper.WEDNESDAY, wednesday);
    bundle.putInt(DatabaseHelper.THURSDAY, thursday);
    bundle.putInt(DatabaseHelper.FRIDAY, friday);
    bundle.putInt(DatabaseHelper.SATURDAY, saturday);
    bundle.putInt(DatabaseHelper.SUNDAY, sunday);

    bundle.putString(DatabaseHelper.DOSAGE, dosageStr);
    bundle.putString(DatabaseHelper.INSTRUCTION, instructionStr);
    bundle.putInt(DatabaseHelper.SHAPE, shape);
    bundle.putInt(DatabaseHelper.ORDER_NUM, orderNum);
    //Alarm alarm = new Alarm(getActivity().getApplicationContext(), bundle);

    // get unique notifyId for each alarm
    int length = title.length();
    for (int i = 0; i < length; i++) {
        notifyId = (int) titleStr.charAt(i) + notifyId;
    }
    notifyId = Integer.parseInt(timeHStr + timeMStr);

    // saving it into parse.com
    ParseObject parseObject = new ParseObject(Helpers.PARSE_OBJECT);
    parseObject.put(DatabaseHelper.USRNAME, ParseUser.getCurrentUser().getUsername());
    parseObject.put(DatabaseHelper.TITLE, titleStr);
    parseObject.put(DatabaseHelper.TIME_H, timeHStr);
    parseObject.put(DatabaseHelper.TIME_M, timeMStr);
    parseObject.put(DatabaseHelper.FREQUENCY, Fre);
    //parseObject.put(DatabaseHelper.DAY, day);

    parseObject.put(DatabaseHelper.MONDAY, monday);
    parseObject.put(DatabaseHelper.TUESDAY, tuesday);
    parseObject.put(DatabaseHelper.WEDNESDAY, wednesday);
    parseObject.put(DatabaseHelper.THURSDAY, thursday);
    parseObject.put(DatabaseHelper.FRIDAY, friday);
    parseObject.put(DatabaseHelper.SATURDAY, saturday);
    parseObject.put(DatabaseHelper.SUNDAY, sunday);

    parseObject.put(DatabaseHelper.DOSAGE, dosageStr);
    parseObject.put(DatabaseHelper.INSTRUCTION, instructionStr);
    parseObject.put(DatabaseHelper.SHAPE, shape);
    parseObject.put(DatabaseHelper.NOFITY_ID, notifyId);
    parseObject.put(DatabaseHelper.ORDER_NUM, orderNum);
    parseObject.saveInBackground();

    task = new InsertTask().execute(values);
}

From source file:com.mycodehurts.rapidmath.app.TestActivity.java

public void onBtnClicked(View v) {
    if (v.getId() == R.id.btnNextQuestion) {

        //Store User's answer first
        RadioGroup chkSex = (RadioGroup) findViewById(R.id.groupAnswers);
        Question q = lstQuestions.get(iQuestion);

        q.iUserAnswer = chkSex.indexOfChild(findViewById(chkSex.getCheckedRadioButtonId()));
        Log.i("JS: ", "Answer: " + q.iAnswer + " Selection: " + q.iUserAnswer);

        //Increase counter and check if results can be displayed.
        iQuestion++;//w w w  . j  av  a 2  s  .  c  om
        if (iQuestion >= 10) {

            timer.cancel();
            timer.purge();

            int iPass = 0;
            String strFailedQ = new String();
            for (int i = 0; i < 10; i++) {
                //Log.i("JS: "," "+lstQuestions.get(i).iUserAnswer + " "+lstQuestions.get(i).iAnswer);
                if (lstQuestions.get(i).iUserAnswer == lstQuestions.get(i).iAnswer) {
                    iPass++;
                } else {
                    if (lstQuestions.get(i).iUserAnswer < 0) {
                        strFailedQ += "\n\n Q" + (i + 1) + ". " + lstQuestions.get(i).strQuestion
                                + "\n Your Answer: " + " " + "\n Correct Answer"
                                + lstQuestions.get(i).strChoices[lstQuestions.get(i).iAnswer];
                    } else {
                        strFailedQ += "\n\n Q" + (i + 1) + ". " + lstQuestions.get(i).strQuestion
                                + "\n Your Answer: "
                                + lstQuestions.get(i).strChoices[lstQuestions.get(i).iUserAnswer]
                                + "\n Correct Answer"
                                + lstQuestions.get(i).strChoices[lstQuestions.get(i).iAnswer];
                    }
                }
            }
            int iPercent = iPass * 100 / 10;
            //Load next activity.
            Intent intent = new Intent(this, ShowResult.class);
            intent.putExtra("iPercent", iPercent);
            intent.putExtra("strFailedQ", strFailedQ);

            //String strTestType = new String();
            /*if(iLevel==0)
            strTestType = "Easy";
            else if(iLevel ==1)
            strTestType = "Medium";
            else
            strTestType = "Hard";
            */
            intent.putExtra("TestType", strTestType);
            startActivity(intent);
            return;
        }

        //Fetch next question.
        NextQuestion();

        //Update UI
        ((TextView) findViewById(R.id.textView2)).setText("Question " + (iQuestion + 1) + " of 10");
        chkSex.clearCheck();

    }
}

From source file:org.odk.collect.android.activities.GeoTraceGoogleMapActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geotrace_google_layout);

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.gmap)).getMap();
    mHelper = new MapHelper(this, mMap);
    mMap.setMyLocationEnabled(true);/*from w  w w.  ja  v a2 s  . com*/
    mMap.setOnMapLongClickListener(this);
    mMap.setOnMarkerDragListener(this);
    mMap.getUiSettings().setZoomControlsEnabled(true);
    mMap.getUiSettings().setMyLocationButtonEnabled(false);
    mMap.getUiSettings().setZoomControlsEnabled(false);

    polylineOptions = new PolylineOptions();
    polylineOptions.color(Color.RED);

    clear_button = (Button) findViewById(R.id.clear);
    clear_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (markerArray.size() != 0) {
                showClearDialog();
            }
        }
    });

    inflater = this.getLayoutInflater();
    traceSettingsView = inflater.inflate(R.layout.geotrace_dialog, null);
    polygonPolylineView = inflater.inflate(R.layout.polygon_polyline_dialog, null);
    resource_proxy = new DefaultResourceProxyImpl(getApplicationContext());
    time_delay = (Spinner) traceSettingsView.findViewById(R.id.trace_delay);
    time_delay.setSelection(3);
    time_units = (Spinner) traceSettingsView.findViewById(R.id.trace_scale);
    pause_button = (Button) findViewById(R.id.pause);
    pause_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            play_button.setVisibility(View.VISIBLE);
            if (markerArray != null && markerArray.size() > 0) {
                clear_button.setEnabled(true);
            }
            pause_button.setVisibility(View.GONE);
            manual_button.setVisibility(View.GONE);
            play_check = true;
            mode_active = false;
            try {
                schedulerHandler.cancel(true);
            } catch (Exception e) {
                // Do nothing
            }

        }
    });
    layers_button = (Button) findViewById(R.id.layers);

    save_button = (Button) findViewById(R.id.geotrace_save);
    save_button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (markerArray.size() != 0) {
                p_alert.show();
            } else {
                saveGeoTrace();
            }

        }
    });
    play_button = (Button) findViewById(R.id.play);
    play_button.setEnabled(false);
    play_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (!play_check) {
                if (!beenPaused) {
                    alert.show();
                } else {
                    RadioGroup rb = (RadioGroup) traceSettingsView.findViewById(R.id.radio_group);
                    int radioButtonID = rb.getCheckedRadioButtonId();
                    View radioButton = rb.findViewById(radioButtonID);
                    int idx = rb.indexOfChild(radioButton);
                    TRACE_MODE = idx;
                    if (TRACE_MODE == 0) {
                        setupManualMode();
                    } else if (TRACE_MODE == 1) {
                        setupAutomaticMode();
                    } else {
                        //Do nothing
                    }
                }
                play_check = true;
            } else {
                play_check = false;
                startGeoTrace();
            }
        }
    });

    if (markerArray == null || markerArray.size() == 0) {
        clear_button.setEnabled(false);
    }

    manual_button = (Button) findViewById(R.id.manual_button);
    manual_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addLocationMarker();

        }
    });

    polygon_save = (Button) polygonPolylineView.findViewById(R.id.polygon_save);
    polygon_save.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (markerArray.size() > 2) {
                createPolygon();
                p_alert.dismiss();
                saveGeoTrace();
            } else {
                p_alert.dismiss();
                showPolyonErrorDialog();
            }

        }
    });
    polyline_save = (Button) polygonPolylineView.findViewById(R.id.polyline_save);
    polyline_save.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            p_alert.dismiss();
            saveGeoTrace();

        }
    });

    buildDialogs();

    layers = (Button) findViewById(R.id.layers);
    layers.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mHelper.showLayersDialog();
        }
    });

    location_button = (Button) findViewById(R.id.show_location);
    location_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showZoomDialog();
        }
    });

    zoomDialogView = getLayoutInflater().inflate(R.layout.geoshape_zoom_dialog, null);

    zoomLocationButton = (Button) zoomDialogView.findViewById(R.id.zoom_location);
    zoomLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomToMyLocation();
            zoomDialog.dismiss();
        }
    });

    zoomPointButton = (Button) zoomDialogView.findViewById(R.id.zoom_shape);
    zoomPointButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            zoomtoBounds();
            zoomDialog.dismiss();
        }
    });
    List<String> providers = mLocationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
            curLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
            curLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
    }

    if (mGPSOn) {
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
                GeoTraceGoogleMapActivity.this);
    }
    if (mNetworkOn) {
        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
                GeoTraceGoogleMapActivity.this);
    }

    if (!mGPSOn & !mNetworkOn) {
        showGPSDisabledAlertToUser();
    }
    Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoTraceWidget.TRACE_LOCATION)) {
            String s = intent.getStringExtra(GeoTraceWidget.TRACE_LOCATION);
            play_button.setEnabled(false);
            clear_button.setEnabled(true);
            firstLocationFound = true;
            location_button.setEnabled(true);
            overlayIntentTrace(s);
            zoomtoBounds();
        }
    } else {
        if (curLocation != null) {
            curlatLng = new LatLng(curLocation.getLatitude(), curLocation.getLongitude());
            initZoom = true;
        }
    }

}

From source file:com.freeme.filemanager.FileExplorerTabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //*/ add by xueweili for after Switch the language, file manager  stop running on 20160518
    if (savedInstanceState != null) {
        savedInstanceState.remove("android:fragments");
    }//  w w  w  .j av a2  s . c o m
    //*/
    Log.i("liuhaoran", "oncreate");
    super.onCreate(savedInstanceState);

    mContext = this;

    MobclickAgent.setDebugMode(true);
    MobclickAgent.openActivityDurationTrack(false);
    MobclickAgent.startWithConfigure(new UMAnalyticsConfig(mContext, "57dfa18e67e58e7d2b003625", "hwdroi",
            EScenarioType.E_UM_ANALYTICS_OEM, false));

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    StorageHelper.getInstance(this).setCurrentMountPoint(Environment.getExternalStorageDirectory().getPath());
    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES);

    //*/ test
    if (FileManagerApplication.mIsTest.equals("true")) {
        final TextView test = (TextView) findViewById(R.id.tv_test);
        test.setVisibility(View.VISIBLE);
        test.getBackground().setAlpha(100);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                test.setVisibility(View.GONE);
            }
        }, 3000);
    }
    //*/

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(null, FileCategoryContainerFragment.class, null);
    mTabsAdapter.addTab(null, FileViewFragment.class, null);
    mTabsAdapter.addTab(null, ServerControlFragment.class, null);
    mViewPager.setAdapter(mTabsAdapter);
    //*/ modified by tyd wulianghuan 2013-07-15 for: make the second tab be selected when usbStorge mounted
    //*/add by droi mingjun for updateself on 20151221
    mSharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    editor = mSharedPref.edit();

    //*/end
    mTabHost = (RadioGroup) findViewById(R.id.home_group);
    mTabBtnOne = (RadioButton) findViewById(R.id.home_radio_one);
    mTabBtnTwo = (RadioButton) findViewById(R.id.home_radio_two);
    mTabBtnThree = (RadioButton) findViewById(R.id.home_radio_three);

    if (FileManagerApplication.mIsHideFTP.equals("false")) {
        mTabBtnThree.setVisibility(View.GONE);
    }

    mTabHost.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup arg0, int arg1) {
            // TODO Auto-generated method stub
            switch (arg0.getCheckedRadioButtonId()) {
            case R.id.home_radio_one:
                Log.i("home_radio_one", "home_radio_one");
                // hometype = 1;
                if ((FileViewFragment) mTabsAdapter.getItem(1) != null
                        && ((FileViewFragment) mTabsAdapter.getItem(1)).mFileViewInteractionHub != null) {
                    ((FileViewFragment) mTabsAdapter.getItem(1)).mFileViewInteractionHub.exitActionMode();
                    //((FileCategoryContainerFragment)mTabsAdapter.getItem(0)).setStorageDeviceInfo();
                }
                mViewPager.setCurrentItem(0, false);
                break;

            case R.id.home_radio_two:
                // hometype = 2;
                if ((FileCategoryContainerFragment) mTabsAdapter.getItem(0) != null
                        && ((FileCategoryContainerFragment) mTabsAdapter
                                .getItem(0)).mFileViewInteractionHub != null) {

                    ((FileCategoryContainerFragment) mTabsAdapter.getItem(0)).mFileViewInteractionHub
                            .exitActionMode();
                }
                mViewPager.setCurrentItem(1, false);
                break;

            case R.id.home_radio_three:
                // hometype = 3;
                if ((FileViewFragment) mTabsAdapter.getItem(1) != null
                        && ((FileViewFragment) mTabsAdapter.getItem(1)).mFileViewInteractionHub != null) {
                    ((FileViewFragment) mTabsAdapter.getItem(1)).mFileViewInteractionHub.exitActionMode();
                }
                mViewPager.setCurrentItem(2, false);
                break;
            default:
                break;
            }
        }
    });
    int tabindex = getIntent().getIntExtra("TAB", Util.CATEGORY_TAB_INDEX);
    if (tabindex != 2) {
        int index = getIntent().getIntExtra("tab_index", Util.CATEGORY_TAB_INDEX);
    }
    //*/ modify end

    initButtonReceiver();

    UpdateMonitor.Builder
            //*/ init UpdateMonitor
            .getInstance(this)
            //*/ register you Application to obsever
            .registerApplication(getApplication())
            //*/ register you Application is Service or hasEnrtyActivity
            .setApplicationIsServices(true)
            //*/ default notify small icon, ifnot set use updateself_ic_notify_small
            .setDefaultNotifyIcon(R.drawable.updateself_ic_notify_small).complete();

    checkSecurityPermissions();
    //        requestPermissionsMonery();
}

From source file:org.odk.collect.android.activities.GeoTraceOsmMapActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.geotrace_osm_layout);
    setTitle(getString(R.string.geotrace_title)); // Setting title of the action

    mapView = (MapView) findViewById(R.id.geotrace_mapview);
    helper = new MapHelper(this, mapView, GeoTraceOsmMapActivity.this);
    mapView.setMultiTouchControls(true);
    mapView.setBuiltInZoomControls(true);
    mapView.getController().setZoom(zoomLevel);
    myLocationOverlay = new MyLocationNewOverlay(mapView);

    inflater = this.getLayoutInflater();
    traceSettingsView = inflater.inflate(R.layout.geotrace_dialog, null);
    polygonPolylineView = inflater.inflate(R.layout.polygon_polyline_dialog, null);
    timeDelay = (Spinner) traceSettingsView.findViewById(R.id.trace_delay);
    timeDelay.setSelection(3);/*from  ww  w  .j a v  a2s  .  c  om*/
    timeUnits = (Spinner) traceSettingsView.findViewById(R.id.trace_scale);
    layersButton = (ImageButton) findViewById(R.id.layers);
    layersButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            helper.showLayersDialog(GeoTraceOsmMapActivity.this);

        }
    });

    locationButton = (ImageButton) findViewById(R.id.show_location);
    locationButton.setEnabled(false);
    locationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            reset_trace_settings();
            showZoomDialog();
        }

    });

    clearButton = (ImageButton) findViewById(R.id.clear);
    clearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showClearDialog();

        }

    });

    ImageButton saveButton = (ImageButton) findViewById(R.id.geotrace_save);
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (mapMarkers.size() != 0) {
                alertDialog.show();
            } else {
                saveGeoTrace();
            }
        }
    });
    if (mapMarkers == null || mapMarkers.size() == 0) {
        clearButton.setEnabled(false);
    }
    manualCaptureButton = (Button) findViewById(R.id.manual_button);
    manualCaptureButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addLocationMarker();
        }
    });
    pauseButton = (ImageButton) findViewById(R.id.pause);
    playButton = (ImageButton) findViewById(R.id.play);
    playButton.setEnabled(false);
    beenPaused = false;
    traceMode = 1;

    playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (!playCheck) {
                if (!beenPaused) {
                    alert.show();
                } else {
                    RadioGroup rb = (RadioGroup) traceSettingsView.findViewById(R.id.radio_group);
                    int radioButtonID = rb.getCheckedRadioButtonId();
                    View radioButton = rb.findViewById(radioButtonID);
                    traceMode = rb.indexOfChild(radioButton);
                    if (traceMode == 0) {
                        setupManualMode();
                    } else if (traceMode == 1) {
                        setupAutomaticMode();
                    } else {
                        reset_trace_settings();
                    }
                }
                playCheck = true;
            } else {
                playCheck = false;
                startGeoTrace();
            }
        }
    });

    pauseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            playButton.setVisibility(View.VISIBLE);
            if (mapMarkers != null && mapMarkers.size() > 0) {
                clearButton.setEnabled(true);
            }
            pauseButton.setVisibility(View.GONE);
            manualCaptureButton.setVisibility(View.GONE);
            playCheck = true;
            modeActive = false;
            myLocationOverlay.disableFollowLocation();

            try {
                schedulerHandler.cancel(true);
            } catch (Exception e) {
                // Do nothing
            }
        }
    });

    overlayMapLayerListener();
    buildDialogs();
    Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
        if (intent.hasExtra(GeoTraceWidget.TRACE_LOCATION)) {
            String s = intent.getStringExtra(GeoTraceWidget.TRACE_LOCATION);
            playButton.setEnabled(false);
            clearButton.setEnabled(true);
            overlayIntentTrace(s);
            locationButton.setEnabled(true);
            //zoomToCentroid();
            zoomToBounds();

        }
    } else {
        myLocationOverlay.runOnFirstFix(centerAroundFix);
    }

    Button polygonSaveButton = (Button) polygonPolylineView.findViewById(R.id.polygon_save);
    polygonSaveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mapMarkers.size() > 2) {
                createPolygon();
                alertDialog.dismiss();
                saveGeoTrace();
            } else {
                alertDialog.dismiss();
                showPolygonErrorDialog();
            }

        }
    });
    Button polylineSaveButton = (Button) polygonPolylineView.findViewById(R.id.polyline_save);
    polylineSaveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            alertDialog.dismiss();
            saveGeoTrace();

        }
    });

    zoomDialogView = getLayoutInflater().inflate(R.layout.geoshape_zoom_dialog, null);

    zoomLocationButton = (Button) zoomDialogView.findViewById(R.id.zoom_location);
    zoomLocationButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomToMyLocation();
            mapView.invalidate();
            zoomDialog.dismiss();
        }
    });

    zoomPointButton = (Button) zoomDialogView.findViewById(R.id.zoom_shape);
    zoomPointButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //zoomToCentroid();
            zoomToBounds();
            mapView.invalidate();
            zoomDialog.dismiss();
        }
    });

    mapView.invalidate();
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    List<String> providers = locationManager.getProviders(true);
    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            gpsOn = true;
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            networkOn = true;
        }
    }
    if (gpsOn) {
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    }
    if (networkOn) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    }
}

From source file:sliding_tab.SlidingTabs.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public View getView(final int position, View convertView, ViewGroup viewGroup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.event_attending_list_item, null);

    TextView name = (TextView) convertView.findViewById(R.id.tv_ea_list_item);
    final RadioGroup radioGroup = (RadioGroup) convertView.findViewById(R.id.radioGroup);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            ArrayList<String>[] dbResult = Helper.getFriends_From_Event(Event_ID);
            switch (radioGroup.getCheckedRadioButtonId()) {
            case R.id.rb_ea_list_yes: {
                Update_Attending(dbResult, Constants.Yes, position);
                break;
            }//  w  w  w. ja  v a 2s . c o  m
            case R.id.rb_ea_list_maybe: {
                Update_Attending(dbResult, Constants.Maybe, position);
                break;
            }
            case R.id.rb_ea_list_no: {
                Update_Attending(dbResult, Constants.No, position);
                break;
            }
            }
        }
    });
    ArrayList<String>[] dbResult = Helper.getFriends_From_Event(Event_ID);
    //name.setText(dbResult[1].get(position));
    name.setText(Helper.getNickname(dbResult[1].get(position)));
    switch (dbResult[2].get(position)) {
    case Constants.Yes: {
        radioGroup.check(R.id.rb_ea_list_yes);
        break;
    }
    case Constants.Maybe: {
        radioGroup.check(R.id.rb_ea_list_maybe);
        break;
    }
    case Constants.No: {
        radioGroup.check(R.id.rb_ea_list_no);
        break;
    }
    default: {
        break;
    }
    }
    if (!dbResult[1].get(position).equals(Constants.MY_User_ID)) {
        for (int i = 0; i < radioGroup.getChildCount(); i++) {
            radioGroup.getChildAt(i).setEnabled(false);
        }
    }

    return convertView;
}