Example usage for android.widget ToggleButton isChecked

List of usage examples for android.widget ToggleButton isChecked

Introduction

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

Prototype

@ViewDebug.ExportedProperty
    @Override
    public boolean isChecked() 

Source Link

Usage

From source file:com.towson.wavyleaf.Sighting.java

public boolean isToggleSelected() {
    boolean result = false;

    for (int i = 0; i < rg.getChildCount(); i++) {
        View child = rg.getChildAt(i);
        if (child instanceof LinearLayout) {
            for (int j = 0; j < ((ViewGroup) child).getChildCount(); j++) {
                final ToggleButton tog = (ToggleButton) ((ViewGroup) child).getChildAt(j);
                if (tog.isChecked())
                    result = true;//from  ww  w.j av  a 2 s .  c  o  m
            }
        }
    }
    return result;
}

From source file:com.philliphsu.clock2.alarms.ui.ExpandedAlarmViewHolder.java

@OnClick({ R.id.day0, R.id.day1, R.id.day2, R.id.day3, R.id.day4, R.id.day5, R.id.day6 })
void onDayToggled(ToggleButton view) {
    final Alarm oldAlarm = getAlarm();
    Alarm newAlarm = oldAlarm.toBuilder().build();
    oldAlarm.copyMutableFieldsTo(newAlarm);
    // ---------------------------------------------------------------------------------
    // TOneverDO: precede copyMutableFieldsTo()
    int position = ((ViewGroup) view.getParent()).indexOfChild(view);
    int weekDayAtPosition = DaysOfWeek.getInstance(getContext()).weekDayAt(position);
    Log.d(TAG, "Day toggle #" + position + " checked changed. This is weekday #" + weekDayAtPosition
            + " relative to a week starting on Sunday");
    newAlarm.setRecurring(weekDayAtPosition, view.isChecked());
    // ---------------------------------------------------------------------------------
    persistUpdatedAlarm(newAlarm, true);
}

From source file:com.finchuk.clock2.alarms.ui.ExpandedAlarmViewHolder.java

@OnClick({ com.finchuk.clock2.R.id.day0, com.finchuk.clock2.R.id.day1, com.finchuk.clock2.R.id.day2,
        com.finchuk.clock2.R.id.day3, com.finchuk.clock2.R.id.day4, com.finchuk.clock2.R.id.day5,
        com.finchuk.clock2.R.id.day6 })/*  ww w .  j  ava 2 s  . co m*/
void onDayToggled(ToggleButton view) {
    final Alarm oldAlarm = getAlarm();
    Alarm newAlarm = oldAlarm.toBuilder().build();
    oldAlarm.copyMutableFieldsTo(newAlarm);
    // ---------------------------------------------------------------------------------
    // TOneverDO: precede copyMutableFieldsTo()
    int position = ((ViewGroup) view.getParent()).indexOfChild(view);
    int weekDayAtPosition = DaysOfWeek.getInstance(getContext()).weekDayAt(position);
    Log.d(TAG, "Day toggle #" + position + " checked changed. This is weekday #" + weekDayAtPosition
            + " relative to a week starting on Sunday");
    newAlarm.setRecurring(weekDayAtPosition, view.isChecked());
    // ---------------------------------------------------------------------------------
    persistUpdatedAlarm(newAlarm, true);
}

From source file:eu.trentorise.smartcampus.jp.MonitorJourneyFragment.java

@Override
protected void setUpMainOperation() {
    // if (params.getClientId() == null) {
    // getView().findViewById(R.id.recurr_delete).setVisibility(View.GONE);
    // } else {/*from   ww  w.j  a  v a  2 s.  c  o m*/
    // ((Button)
    // getView().findViewById(R.id.recurr_delete)).setOnClickListener(new
    // View.OnClickListener() {
    //
    // @Override
    // public void onClick(View v) {
    // SCAsyncTask<String, Void, Void> task = new SCAsyncTask<String, Void,
    // Void>(getSherlockActivity(),
    // new DeleteMyRecurItineraryProcessor(getSherlockActivity()));
    // task.execute(params.getName(), params.getClientId());
    // }
    // });
    // }
    Button nextButton = (Button) getView().findViewById(R.id.recurr_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // user preferences
            View userPrefsLayout = (View) getView().findViewById(R.id.plannew_userprefs);
            alwaysCheckbox = (CheckBox) getView().findViewById(R.id.always_checkbox);
            if (userPrefsLayout.isShown()) {
                TableLayout tTypesTableLayout = (TableLayout) userPrefsLayout
                        .findViewById(R.id.transporttypes_table);
                RadioGroup rTypesRadioGroup = (RadioGroup) userPrefsLayout
                        .findViewById(R.id.routetypes_radioGroup);
                userPrefsHolder = PrefsHelper.userPrefsViews2Holder(tTypesTableLayout, rTypesRadioGroup,
                        userPrefs);
            } else {
                userPrefsHolder = PrefsHelper.sharedPreferences2Holder(userPrefs);
            }

            // EditText name = (EditText) getView().findViewById(R.id.name);
            // if (name.getText() == null ||
            // name.getText().toString().length() == 0) {
            // Toast.makeText(getActivity(), R.string.name_field_empty,
            // Toast.LENGTH_SHORT).show();
            // return;
            // }
            // params.setName(name.getText().toString().trim());
            // params.setMonitor(((CheckBox)
            // getView().findViewById(R.id.recur_monitor)).isChecked());

            RecurrentJourneyParameters rj = params.getData().getParameters();
            if (fromPosition == null) {
                // Toast.makeText(getActivity(), R.string.from_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromEditText,
                        getResources().getString(R.string.from_field_empty));
                return;
            }
            if (toPosition == null) {
                // Toast.makeText(getActivity(), R.string.to_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toEditText,
                        getResources().getString(R.string.to_field_empty));
                return;
            }

            rj.setFrom(fromPosition);
            rj.setTo(toPosition);

            Date fromDateD;
            Date fromTimeD;
            Date toDateD;
            Date toTimeD;

            CharSequence timeString = fromDate.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.from_date_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromDate,
                        getResources().getString(R.string.from_date_field_empty));
                return;
            } else {
                try {
                    fromDateD = Config.FORMAT_DATE_UI.parse(timeString.toString());
                    rj.setFromDate(fromDateD.getTime());
                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.from_date_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), fromDate,
                            getResources().getString(R.string.from_date_field_empty));
                    return;
                }
            }

            timeString = fromTime.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.from_time_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromTime,
                        getResources().getString(R.string.from_time_field_empty));
                return;
            } else {
                try {
                    fromTimeD = Config.FORMAT_TIME_UI.parse(timeString.toString());
                    rj.setTime(Config.FORMAT_TIME_SMARTPLANNER.format(fromTimeD));
                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.from_time_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), fromTime,
                            getResources().getString(R.string.from_time_field_empty));
                    return;
                }
            }

            // if
            // (!eu.trentorise.smartcampus.jp.helper.Utils.validFromDateTime(fromDateD,
            // fromTimeD)) {
            // Toast.makeText(getActivity(), R.string.datetime_before_now,
            // Toast.LENGTH_SHORT).show();
            // return;
            // }
            if (alwaysCheckbox.isChecked()) {
                rj.setToDate(Config.ALWAYS_DATE);
            }

            timeString = toDate.getText();
            if (!alwaysCheckbox.isChecked())

                if (timeString == null) {
                    // Toast.makeText(getActivity(),
                    // R.string.to_date_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), toDate,
                            getResources().getString(R.string.to_date_field_empty));
                    return;
                } else {
                    try {
                        toDateD = Config.FORMAT_DATE_UI.parse(timeString.toString());
                        rj.setToDate(toDateD.getTime());
                        if (rj.getFromDate() == rj.getToDate())
                            rj.setToDate(rj.getToDate() + (24 * 60 * 60 * 1000));
                        if ((rj.getToDate() < rj.getFromDate()) && !alwaysCheckbox.isChecked()) {
                            // Toast.makeText(getActivity(),
                            // R.string.to_date_before_from_date,
                            // Toast.LENGTH_SHORT).show();
                            ValidatorHelper.highlight(getSherlockActivity(), toDate,
                                    getResources().getString(R.string.to_date_before_from_date));
                            return;
                        }

                    } catch (ParseException e) {
                        // Toast.makeText(getActivity(),
                        // R.string.to_date_field_empty,
                        // Toast.LENGTH_SHORT).show();
                        ValidatorHelper.highlight(getSherlockActivity(), toDate,
                                getResources().getString(R.string.to_date_field_empty));
                        return;
                    }
                }
            else
                toDateD = new Date(Config.ALWAYS_DATE);

            timeString = toTime.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.to_time_field_empty, Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toTime,
                        getResources().getString(R.string.to_time_field_empty));
                return;
            } else {
                try {
                    // if the interval is negative, add an entire day
                    toTimeD = Config.FORMAT_TIME_UI.parse(timeString.toString());
                    rj.setInterval(toTimeD.getTime() - fromTimeD.getTime());
                    if (rj.getInterval() < 0)
                        rj.setInterval(rj.getInterval() + 24 * 60 * 60 * 1000);
                    if (rj.getInterval() > Config.MAX_RECUR_INTERVAL) {
                        // Toast.makeText(getActivity(),
                        // R.string.interval_too_large,
                        // Toast.LENGTH_SHORT).show();
                        ValidatorHelper.highlight(getSherlockActivity(), toTime,
                                getResources().getString(R.string.interval_too_large));
                        return;
                    }

                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.to_time_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), toTime,
                            getResources().getString(R.string.to_time_field_empty));
                    return;
                }
            }

            if (!eu.trentorise.smartcampus.jp.helper.Utils.validFromDateTimeToDateTime(fromDateD, fromTimeD,
                    toDateD, toTimeD) && !alwaysCheckbox.isChecked()) {
                // Toast.makeText(getActivity(),
                // R.string.datetime_to_before_from,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toTime,
                        getResources().getString(R.string.datetime_to_before_from));
                return;
            }

            rj.setTransportTypes((TType[]) userPrefsHolder.getTransportTypes());
            rj.setRouteType(userPrefsHolder.getRouteType());

            /* set recurrence on the ui */
            rj.setRecurrence(new ArrayList<Integer>());
            ToggleButton tmpToggle = (ToggleButton) getView().findViewById(R.id.monday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(2);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.tuesday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(3);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.wednesday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(4);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.thursday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(5);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.friday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(6);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.saturday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(7);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.sunday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(1);

            if (rj.getRecurrence().isEmpty()) {
                ValidatorHelper.highlight(getSherlockActivity(), getView().findViewById(R.id.monday_toggle),
                        getResources().getString(R.string.no_days_selected));
                //               Toast.makeText(getActivity(), R.string.no_days_selected, Toast.LENGTH_SHORT).show();
                return;
            }

            FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager()
                    .beginTransaction();
            Fragment fragment = new MyRecurItineraryFragment();
            Bundle b = new Bundle();
            b.putSerializable(MyRecurItineraryFragment.PARAMS, params);
            b.putBoolean(MyRecurItineraryFragment.PARAM_EDITING, true);

            fragment.setArguments(b);
            fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            fragmentTransaction.replace(Config.mainlayout, fragment, MonitorJourneyFragment.this.getTag());
            fragmentTransaction.addToBackStack(fragment.getTag());
            fragmentTransaction.commit();
            // SCAsyncTask<BasicRecurrentJourneyParameters, Void,
            // RecurrentJourney> task = new
            // SCAsyncTask<BasicRecurrentJourneyParameters, Void,
            // RecurrentJourney>(
            // getSherlockActivity(), new
            // PlanRecurJourneyProcessor(getSherlockActivity()));
            // /*creare i parametri per la chiamata*/
            // BasicRecurrentJourneyParameters parameters = new
            // BasicRecurrentJourneyParameters();
            // /*fill the params*/
            // parameters.setClientId(params.getClientId());
            // parameters.setData(rj);
            // parameters.setMonitor(monitorToggleBtn.isChecked());
            // parameters.setName(params.getName());
            // task.execute(parameters);
        }

    });

    // add listener on alwayscheck
    alwaysCheckbox = (CheckBox) getView().findViewById(R.id.always_checkbox);
    alwaysCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                // disable the toDate
                toDate.setEnabled(false);
            } else {
                // enable the toDate
                toDate.setEnabled(true);

            }
        }
    });

    monitorLayout = (LinearLayout) getView().findViewById(R.id.myitinerary_toggle_layout);
    if (params.getClientId() != null) {
        monitorLayout.setVisibility(View.VISIBLE);
        monitorToggleBtn = (ToggleButton) getView().findViewById(R.id.myitinerary_toggle);
        TextView monitorLabel = (TextView) getView().findViewById(R.id.myitinerary_monitor_label);

        // monitorToggleBtn.setChecked(myItinerary.isMonitor());

        monitorToggleBtn.setOnCheckedChangeListener(null);
        monitorToggleBtn.setChecked(params.isMonitor());

        if (params.isMonitor()) {
            monitorToggleBtn.setBackgroundResource(R.drawable.ic_monitor_on);
            monitorLabel.setText(getString(R.string.monitor_on));
            monitorLabel.setTextAppearance(getSherlockActivity(), R.style.label_jp);

        } else {
            monitorToggleBtn.setBackgroundResource(R.drawable.ic_monitor_off);
            monitorLabel.setText(getString(R.string.monitor_off));
            monitorLabel.setTextAppearance(getSherlockActivity(), R.style.label_black_jp);

        }

        monitorToggleBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                SCAsyncTask<String, Void, Boolean> task = new SCAsyncTask<String, Void, Boolean>(
                        getSherlockActivity(), new MonitorMyRecItineraryProcessor(getSherlockActivity()));
                task.execute(Boolean.toString(isChecked), params.getClientId());
            }
        });
    } else
        monitorLayout.setVisibility(View.GONE);
}

From source file:com.murrayc.galaxyzoo.app.QuestionFragment.java

private void storeAnswer(final String questionId, final String answerId) {
    List<String> checkboxes = null;

    //Get the selected checkboxes too:
    final DecisionTree tree = getDecisionTree();
    final DecisionTree.Question question = tree.getQuestion(questionId);
    if ((question != null) && question.hasCheckboxes()) {
        checkboxes = new ArrayList<>();
        for (final DecisionTree.Checkbox checkbox : question.getCheckboxes()) {
            final String checkboxId = checkbox.getId();
            final ToggleButton button = mCheckboxButtons.get(checkboxId);
            if ((button != null) && button.isChecked()) {
                checkboxes.add(checkboxId);
            }/*from www. j a va  2  s  .  c o m*/
        }
    }

    //Remember the answer:
    mClassificationInProgress.add(questionId, answerId, checkboxes);
}

From source file:com.sorin.cloudcog.car.obd2.RubyBluetoothChatActivity.java

private void setupChat() {
    Log.d(TAG, "setupChat()");

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
    mConversationView = (ListView) findViewById(R.id.in);
    mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    // mOutEditText = (EditText) findViewById(R.id.edit_text_out);
    // mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events
    /*/*from w  ww  .  j a v a2 s  . co m*/
     * mSendButton = (Button) findViewById(R.id.button_send);
     * mSendButton.setOnClickListener(new OnClickListener() { public void
     * onClick(View v) { // Send a message using content of the edit text
     * widget TextView view = (TextView) findViewById(R.id.edit_text_out);
     * String message = view.getText().toString(); sendMessage(message +
     * '\r'); } });
     */

    // Initialize the BluetoothChatService to perform bluetooth connections
    mChatService = new BluetoothChatService(this, mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");

    // ---Get Vehicle Data Button---
    final ToggleButton getDataButton = (ToggleButton) findViewById(R.id.toggleButton1);
    getDataButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (getDataButton.isChecked()) {
                startTransmission();
            } else {
                message_number = 0;
            }

        }
    });

    // ---Clear Trouble Codes Button---
    Button getCodesButton = (Button) findViewById(R.id.button2);
    getCodesButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            clearCodes();
        }
    });

}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    default:/*w  w w  . j a v  a  2  s  .c o  m*/
        return super.onCreateDialog(id);
    case MAP_DLG:
        final View sharedMapView = LayoutInflater.from(this).inflate(R.layout.sharedmap, null);
        final FrameLayout map = (FrameLayout) sharedMapView.findViewById(R.id.sharedmap);
        map.addView(this.sharedMap);
        final CheckBox latlonAddress = (CheckBox) sharedMapView.findViewById(R.id.add_lat_lon_location);
        final CheckBox geocodeAddress = (CheckBox) sharedMapView.findViewById(R.id.add_address_location);
        final RadioButton nourl = (RadioButton) sharedMapView.findViewById(R.id.add_no_url_location);
        final RadioButton url = (RadioButton) sharedMapView.findViewById(R.id.add_url_location);
        final RadioButton gmap = (RadioButton) sharedMapView.findViewById(R.id.add_native_location);
        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
        final ToggleButton track = (ToggleButton) sharedMapView.findViewById(R.id.add_track_location);

        latlonAddress.setChecked(pref.getBoolean(PREF_LAT_LON_CHECKED, true));
        geocodeAddress.setChecked(pref.getBoolean(PREF_ADDRESS_CHECKED, true));
        final boolean isUrl = pref.getBoolean(PREF_URL_CHECKED, true);
        final boolean isGmap = pref.getBoolean(PREF_GMAP_CHECKED, false);
        url.setChecked(isUrl);
        gmap.setChecked(isGmap);
        nourl.setChecked(!isUrl && !isGmap);
        body.setText(pref.getString(PREF_BODY_DEFAULT, getString(R.string.body)));
        track.setChecked(pref.getBoolean(PREF_TRACK_CHECKED, false));

        if (track.isChecked()) {
            latlonAddress.setEnabled(false);
            latlonAddress.setChecked(false);
            geocodeAddress.setEnabled(false);
            geocodeAddress.setChecked(false);
            url.setEnabled(false);
            url.setChecked(true);
            gmap.setEnabled(false);
            gmap.setChecked(false);
            nourl.setEnabled(false);
            nourl.setChecked(false);
        }

        track.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                latlonAddress.setEnabled(!isChecked);
                latlonAddress.setChecked(!isChecked);
                geocodeAddress.setEnabled(!isChecked);
                geocodeAddress.setChecked(!isChecked);
                url.setEnabled(!isChecked);
                url.setChecked(true);
                gmap.setEnabled(!isChecked);
                gmap.setChecked(!isChecked);
                nourl.setEnabled(!isChecked);
                nourl.setChecked(!isChecked);
            }
        });

        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setView(sharedMapView)
                .setOnCancelListener(new OnCancelListener() {

                    @Override
                    public void onCancel(DialogInterface arg0) {
                        finish();
                    }
                }).setNeutralButton(R.string.options, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        /* needed to display neutral button */
                    }
                }).setPositiveButton(R.string.share_it, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        final boolean isLatLong = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_lat_lon_location)).isChecked();
                        final boolean isGeocodeAddress = ((CheckBox) sharedMapView
                                .findViewById(R.id.add_address_location)).isChecked();
                        final boolean isUrl = ((RadioButton) sharedMapView.findViewById(R.id.add_url_location))
                                .isChecked();
                        final boolean isGmap = ((RadioButton) sharedMapView
                                .findViewById(R.id.add_native_location)).isChecked();
                        final EditText body = (EditText) sharedMapView.findViewById(R.id.body);
                        final boolean isTracked = ((ToggleButton) sharedMapView
                                .findViewById(R.id.add_track_location)).isChecked();
                        final String uuid = UUID.randomUUID().toString();

                        pref.edit().putBoolean(PREF_LAT_LON_CHECKED, isLatLong)
                                .putBoolean(PREF_ADDRESS_CHECKED, isGeocodeAddress)
                                .putBoolean(PREF_URL_CHECKED, isUrl).putBoolean(PREF_GMAP_CHECKED, isGmap)
                                .putString(PREF_BODY_DEFAULT, body.getText().toString())
                                .putBoolean(PREF_TRACK_CHECKED, isTracked).commit();

                        final Intent t = new Intent(Intent.ACTION_SEND);
                        t.setType("text/plain");
                        t.addCategory(Intent.CATEGORY_DEFAULT);
                        final Intent share = Intent.createChooser(t, getString(R.string.app_name));
                        final GeoPoint p = sharedMap.getMapCenter();

                        final String text = body.getText().toString();
                        share(p.getLatitude(), p.getLongitude(), t, share, text, isGeocodeAddress, isUrl,
                                isGmap, isLatLong, isTracked, uuid);
                    }
                }).create();
    case PROGRESS_DLG:
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setTitle(getText(R.string.app_name));
        dlg.setMessage(getText(R.string.progression_desc));
        dlg.setIndeterminate(true);
        dlg.setCancelable(true);
        dlg.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        return dlg;
    case PROVIDERS_DLG:
        return new AlertDialog.Builder(this).setTitle(R.string.app_name).setCancelable(false)
                .setIcon(android.R.drawable.ic_menu_help).setMessage(R.string.providers_needed)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }

                }).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent gpsProperty = new Intent(
                                android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(gpsProperty);
                    }
                }).create();
    }
}

From source file:com.esri.squadleader.view.SquadLeaderActivity.java

private boolean isFollowMe() {
    ToggleButton followMeButton = (ToggleButton) findViewById(R.id.toggleButton_followMe);
    if (null != followMeButton) {
        return followMeButton.isChecked();
    } else {// ww  w  .j a  va2s.  c o m
        return false;
    }
}

From source file:com.esri.squadleader.view.SquadLeaderActivity.java

private void setFollowMe(boolean isFollowMe) {
    ToggleButton followMeButton = (ToggleButton) findViewById(R.id.toggleButton_followMe);
    if (null != followMeButton) {
        if (isFollowMe != followMeButton.isChecked()) {
            followMeButton.performClick();
        }/*from w ww.ja  v  a2s .  c o  m*/
    }
}

From source file:ru.valle.safetrade.SellActivity.java

private void takeFunds() {
    String finalAddress = "";
    String errorMessage = null;/*from  ww  w .  j a v a2 s.  com*/
    if (tradeInfo == null) {
        errorMessage = getString(R.string.state_not_loaded_yet);
    } else if (TextUtils.isEmpty(tradeInfo.privateKey)) {
        errorMessage = getString(R.string.no_private_key_from_buyer);
    } else if (addressState == null) {
        errorMessage = getString(R.string.alert_checking_balance);//TODO it may be not true because of networking errors, add retry
    }
    //        } else if (addressState.getBalance() == 0) {
    //            errorMessage = getString(R.string.zero_balance, addressState.address);
    //        }
    else {
        CharSequence enteredAddress = finalAddressView.getText();
        if (enteredAddress != null) {
            finalAddress = enteredAddress.toString();
        }
        if (TextUtils.isEmpty(finalAddress)) {
            errorMessage = getString(R.string.enter_your_final_address);
        }
    }
    if (errorMessage != null) {
        showAlert(errorMessage);
    } else {
        View feesSelectorView = LayoutInflater.from(this).inflate(R.layout.fees_selector, null);
        assert feesSelectorView != null;
        TextView descView = (TextView) feesSelectorView.findViewById(R.id.tx_desc);

        final AddressState addressStateArg;
        final BTCUtils.PrivateKeyInfo privateKeyInfo;

        //args
        //            addressStateArg = addressState;
        //            privateKeyInfo = BTCUtils.decodePrivateKey(tradeInfo.privateKey);
        //
        try {
            addressStateArg = new AddressState("1933phfhK3ZgFQNLGSDXvqCn32k2buXY8a",
                    MainActivity.parseUnspentOutputsFromBlockchainInfo(new String(
                            QRCodesProvider.readStream(getResources().openRawResource(R.raw.fakeoutputs)))));
            privateKeyInfo = BTCUtils.decodePrivateKey(tradeInfo.privateKey);
        } catch (Exception e) {
            throw new RuntimeException();
        }
        //

        final long balance = addressStateArg.getBalance();
        descView.setText(
                getString(R.string.confirm_tx_x_btc_to_addr, BTCUtils.formatValue(balance), finalAddress));

        final ToggleButton minFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.min_miner_fee);
        final ToggleButton safeFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.safe_miner_fee);
        final ToggleButton maxFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.max_miner_fee);

        final TextView minersFeeView = (TextView) feesSelectorView.findViewById(R.id.miners_fee);

        final ToggleButton noDevFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.no_dev_fee);
        final ToggleButton medDevFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.med_dev_fee);
        final ToggleButton maxDevFeeButton = (ToggleButton) feesSelectorView.findViewById(R.id.max_dev_fee);

        final TextView devFeeView = (TextView) feesSelectorView.findViewById(R.id.developer_fee);

        final TextView txDescFinalView = (TextView) feesSelectorView.findViewById(R.id.tx_desc_after_fees);

        CompoundButton.OnCheckedChangeListener feesSelectorListener = new CompoundButton.OnCheckedChangeListener() {
            long fee;
            long devFee;
            public int feeLevel;

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                switch (buttonView.getId()) {
                case R.id.min_miner_fee: {
                    if (isChecked) {
                        safeFeeButton.setChecked(false);
                        maxFeeButton.setChecked(false);
                        updateFee(0);
                    } else if (!safeFeeButton.isChecked() && !maxFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                case R.id.safe_miner_fee: {
                    if (isChecked) {
                        minFeeButton.setChecked(false);
                        maxFeeButton.setChecked(false);
                        updateFee(1);
                    } else if (!minFeeButton.isChecked() && !maxFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                case R.id.max_miner_fee: {
                    if (isChecked) {
                        minFeeButton.setChecked(false);
                        safeFeeButton.setChecked(false);
                        updateFee(2);
                    } else if (!minFeeButton.isChecked() && !safeFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                case R.id.no_dev_fee: {
                    if (isChecked) {
                        medDevFeeButton.setChecked(false);
                        maxDevFeeButton.setChecked(false);
                        updateDevFee(0);
                    } else if (!medDevFeeButton.isChecked() && !maxDevFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                case R.id.med_dev_fee: {
                    if (isChecked) {
                        noDevFeeButton.setChecked(false);
                        maxDevFeeButton.setChecked(false);
                        updateDevFee(1);
                    } else if (!noDevFeeButton.isChecked() && !maxDevFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                case R.id.max_dev_fee: {
                    if (isChecked) {
                        noDevFeeButton.setChecked(false);
                        medDevFeeButton.setChecked(false);
                        updateDevFee(2);
                    } else if (!noDevFeeButton.isChecked() && !medDevFeeButton.isChecked()) {
                        buttonView.setChecked(true);
                    }
                }
                    break;
                }
            }

            private void updateDevFee(int level) {
                devFee = getDevFee(level, balance);
                devFeeView.setText(getString(R.string.tips_for_dev, BTCUtils.formatValue(devFee)));
                updateFee(feeLevel);
            }

            private void updateFee(int level) {
                feeLevel = level;
                fee = getMinerFee(level, devFee, balance, addressStateArg.getUnspentOutputs(),
                        privateKeyInfo.isPublicKeyCompressed);
                minersFeeView.setText(getString(R.string.miners_fee, BTCUtils.formatValue(fee)));
                txDescFinalView.setText(
                        getString(R.string.final_tx_desc, BTCUtils.formatValue(balance - fee - devFee)));
            }

        };

        minFeeButton.setOnCheckedChangeListener(feesSelectorListener);
        safeFeeButton.setOnCheckedChangeListener(feesSelectorListener);
        maxFeeButton.setOnCheckedChangeListener(feesSelectorListener);
        ((ToggleButton) feesSelectorView.findViewById(R.id.no_dev_fee))
                .setOnCheckedChangeListener(feesSelectorListener);
        ((ToggleButton) feesSelectorView.findViewById(R.id.med_dev_fee))
                .setOnCheckedChangeListener(feesSelectorListener);
        ((ToggleButton) feesSelectorView.findViewById(R.id.max_dev_fee))
                .setOnCheckedChangeListener(feesSelectorListener);

        safeFeeButton.setChecked(true);

        if (getDevFee(1, balance) == 0) {
            medDevFeeButton.setEnabled(false);
            maxDevFeeButton.setEnabled(getDevFee(2, balance) > 0);
            noDevFeeButton.setChecked(true);
        } else {
            medDevFeeButton.setChecked(true);
        }

        long minDevFee = getDevFee(0, balance);
        if (getMinerFee(2, minDevFee, balance, addressStateArg.getUnspentOutputs(),
                privateKeyInfo.isPublicKeyCompressed) == balance - minDevFee) {
            maxFeeButton.setEnabled(false);
        }

        if (getMinerFee(1, minDevFee, balance, addressStateArg.getUnspentOutputs(),
                privateKeyInfo.isPublicKeyCompressed) == balance - minDevFee) {
            safeFeeButton.setEnabled(false);
            minFeeButton.setChecked(true);
        }

        new AlertDialog.Builder(SellActivity.this).setView(feesSelectorView)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
    }
}