Search in sources :

Example 46 with RadioButton

use of android.widget.RadioButton in project PhoneProfiles by henrichg.

the class ConnectToSSIDPreferenceAdapter method getView.

public View getView(final int position, View convertView, ViewGroup parent) {
    // SSID to display
    WifiSSIDData wifiSSID = preference.ssidList.get(position);
    // System.out.println(String.valueOf(position));
    ViewHolder holder;
    View vi = convertView;
    if (convertView == null) {
        vi = inflater.inflate(R.layout.connect_to_ssid_preference_list_item, parent, false);
        holder = new ViewHolder();
        holder.SSIDName = vi.findViewById(R.id.connect_to_ssid_pref_dlg_item_label);
        holder.radioButton = vi.findViewById(R.id.connect_to_ssid_pref_dlg_item_radiobutton);
        vi.setTag(holder);
    } else {
        holder = (ViewHolder) vi.getTag();
    }
    if (wifiSSID.ssid.equals(Profile.CONNECTTOSSID_JUSTANY))
        holder.SSIDName.setText(R.string.connect_to_ssid_pref_dlg_summary_text_just_any);
    else if (wifiSSID.ssid.equals(Profile.CONNECTTOSSID_SHAREDPROFILE))
        holder.SSIDName.setText(R.string.array_pref_default_profile);
    else
        holder.SSIDName.setText(wifiSSID.ssid);
    holder.radioButton.setTag(position);
    holder.radioButton.setChecked(preference.value.equals(wifiSSID.ssid));
    holder.radioButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            RadioButton rb = (RadioButton) v;
            preference.value = preference.ssidList.get((Integer) rb.getTag()).ssid;
            notifyDataSetChanged();
        }
    });
    return vi;
}
Also used : RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View)

Example 47 with RadioButton

use of android.widget.RadioButton in project PhoneProfiles by henrichg.

the class ProfilePreferenceAdapter method getView.

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    View vi = convertView;
    if (convertView == null) {
        if (ApplicationPreferences.applicationEditorPrefIndicator(context))
            vi = inflater.inflate(R.layout.profile_preference_list_item, parent, false);
        else
            vi = inflater.inflate(R.layout.profile_preference_list_item_no_indicator, parent, false);
        holder = new ViewHolder();
        holder.profileIcon = vi.findViewById(R.id.profile_pref_dlg_item_icon);
        holder.profileLabel = vi.findViewById(R.id.profile_pref_dlg_item_label);
        if (ApplicationPreferences.applicationEditorPrefIndicator(context))
            holder.profileIndicator = vi.findViewById(R.id.profile_pref_dlg_item_indicator);
        holder.radioBtn = vi.findViewById(R.id.profile_pref_dlg_item_radiobtn);
        vi.setTag(holder);
    } else {
        holder = (ViewHolder) vi.getTag();
    }
    Profile profile;
    if (preference.addNoActivateItem == 1) {
        if (position == 0)
            profile = null;
        else
            profile = profileList.get(position - 1);
    } else
        profile = profileList.get(position);
    holder.radioBtn.setTag(position);
    holder.radioBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            RadioButton rb = (RadioButton) v;
            preference.doOnItemSelected((Integer) rb.getTag());
        }
    });
    if (profile != null) {
        holder.radioBtn.setChecked(profileId == profile._id);
        if (preference.showDuration == 1)
            holder.profileLabel.setText(profile.getProfileNameWithDuration(false, context));
        else
            holder.profileLabel.setText(profile._name);
        holder.profileIcon.setVisibility(View.VISIBLE);
        if (profile.getIsIconResourceID()) {
            if (profile._iconBitmap != null)
                holder.profileIcon.setImageBitmap(profile._iconBitmap);
            else {
                // holder.profileIcon.setImageBitmap(null);
                int res = vi.getResources().getIdentifier(profile.getIconIdentifier(), "drawable", vi.getContext().getPackageName());
                holder.profileIcon.setImageResource(res);
            }
        } else
            holder.profileIcon.setImageBitmap(profile._iconBitmap);
        if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
            holder.profileIndicator.setVisibility(View.VISIBLE);
            if (profile._preferencesIndicator != null)
                holder.profileIndicator.setImageBitmap(profile._preferencesIndicator);
            else
                holder.profileIndicator.setImageResource(R.drawable.ic_empty);
        }
    } else {
        if ((preference.addNoActivateItem == 1) && (position == 0)) {
            holder.radioBtn.setChecked((profileId == Profile.PROFILE_NO_ACTIVATE));
            if (preference.noActivateAsDoNotApply == 1)
                holder.profileLabel.setText(vi.getResources().getString(R.string.profile_preference_do_not_apply));
            else
                holder.profileLabel.setText(vi.getResources().getString(R.string.profile_preference_profile_end_no_activate));
            // holder.profileIcon.setImageResource(R.drawable.ic_empty);
            holder.profileIcon.setVisibility(View.GONE);
            if (ApplicationPreferences.applicationEditorPrefIndicator(context))
                // holder.profileIndicator.setImageResource(R.drawable.ic_empty);
                holder.profileIndicator.setVisibility(View.GONE);
        } else {
            holder.radioBtn.setChecked(false);
            holder.profileLabel.setText("");
            holder.profileIcon.setVisibility(View.VISIBLE);
            holder.profileIcon.setImageResource(R.drawable.ic_empty);
            if (ApplicationPreferences.applicationEditorPrefIndicator(context)) {
                holder.profileIndicator.setVisibility(View.VISIBLE);
                holder.profileIndicator.setImageResource(R.drawable.ic_empty);
            }
        }
    }
    return vi;
}
Also used : RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 48 with RadioButton

use of android.widget.RadioButton in project PhoneProfiles by henrichg.

the class RingtonePreferenceAdapter method getView.

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    String ringtone = (new ArrayList<>(toneList.keySet())).get(position);
    String ringtoneTitle = (new ArrayList<>(toneList.values())).get(position);
    View vi = convertView;
    if (convertView == null) {
        vi = inflater.inflate(R.layout.ringtone_preference_list_item, parent, false);
        holder = new ViewHolder();
        holder.ringtoneLabel = vi.findViewById(R.id.ringtone_pref_dlg_item_label);
        holder.radioBtn = vi.findViewById(R.id.ringtone_pref_dlg_item_radiobtn);
        vi.setTag(holder);
    } else {
        holder = (ViewHolder) vi.getTag();
    }
    holder.radioBtn.setTag(ringtone);
    if (preference.ringtone.equals(ringtone))
        holder.radioBtn.setChecked(true);
    else
        holder.radioBtn.setChecked(false);
    holder.radioBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            RadioButton rb = (RadioButton) v;
            preference.setRingtone((String) rb.getTag());
            preference.playRingtone(true);
        }
    });
    holder.ringtoneLabel.setText(ringtoneTitle);
    return vi;
}
Also used : ArrayList(java.util.ArrayList) RadioButton(android.widget.RadioButton) TextView(android.widget.TextView) View(android.view.View)

Example 49 with RadioButton

use of android.widget.RadioButton in project osm-contributor by jawg.

the class RadioChoiceViewBinder method onBindViewHolder.

@Override
public void onBindViewHolder(TagRadioChoiceHolder holder, final TagItem tagItem) {
    // Save holder
    this.content = holder.getContent();
    holder.setCheckBoxListener(new TagRadioChoiceHolder.CheckBoxListener() {

        @Override
        public void onCheckBoxSelected(String value) {
            tagItem.setValue(value);
            if (onTagItemChange != null) {
                onTagItemChange.onTagItemUpdated(tagItem);
            }
        }
    });
    // Set key text view
    holder.getTextViewKey().setText(ParserManager.parseTagName(tagItem.getKey(), holder.getContent().getContext()));
    // if Tag is show=false, hide it
    if (!tagItem.isShow()) {
        ((RelativeLayout) holder.getContent().getParent()).setVisibility(View.GONE);
    }
    // Check if size of possible values are 3, means special action to organize layout
    Map<String, String> values = tagItem.getValues();
    boolean isFourElements = values.size() == 3;
    // List of radio buttons without undefined. Undefined is always showing
    RadioButton[] radioButtons = holder.getRadioButtons();
    RadioButton undefinedRadioButton = holder.getUndefinedRadioButton();
    // If the tag is mandatory, the undefined button is disabled and unchecked
    if (tagItem.isMandatory()) {
        undefinedRadioButton.setEnabled(false);
        undefinedRadioButton.setChecked(false);
    } else {
        undefinedRadioButton.setChecked(true);
    }
    // Access element for values
    int pos = 0;
    for (int i = 0; i < radioButtons.length; i++) {
        if (!values.isEmpty()) {
            // If values is not empty...
            if (isFourElements && i == 1) {
                // ... and list contains four values, skip one radio to have a 2/2 side by side printing
                radioButtons[i].setVisibility(View.INVISIBLE);
                i++;
                isFourElements = false;
            }
            if (pos < values.size()) {
                // Set value of radio button and show it
                String value = (new ArrayList<>(values.values())).get(pos);
                radioButtons[i].setText(value);
                radioButtons[i].setVisibility(View.VISIBLE);
                // Select radio if value is not undefined
                String key = (new ArrayList<>(values.keySet())).get(pos);
                if (tagItem.getValue() != null && tagItem.getValue().equals(key)) {
                    holder.getUndefinedRadioButton().setChecked(false);
                    radioButtons[i].setChecked(true);
                }
                pos++;
            } else {
                // If all values are set, hide radio button not used
                radioButtons[i].setVisibility(View.INVISIBLE);
            }
        }
    }
    // run validation process
    showInvalidityMessage(tagItem);
}
Also used : TagRadioChoiceHolder(io.jawg.osmcontributor.ui.utils.views.holders.TagRadioChoiceHolder) RelativeLayout(android.widget.RelativeLayout) ArrayList(java.util.ArrayList) RadioButton(android.widget.RadioButton)

Example 50 with RadioButton

use of android.widget.RadioButton in project MPW by shineangelic.

the class MainActivity method issueRefresh.

private void issueRefresh(final PoolDbHelper mDbHelper, final GsonBuilder builder) {
    Log.i(Constants.TAG, "JsonObjectRequest for: " + Utils.getHomeStatsURL(PreferenceManager.getDefaultSharedPreferences(MainActivity.this)));
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getHomeStatsURL(PreferenceManager.getDefaultSharedPreferences(MainActivity.this)), null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(final JSONObject response) {
            Log.d(Constants.TAG, response.toString());
            hashText.post(new Runnable() {

                @Override
                public void run() {
                    Gson gson = builder.create();
                    // Register an adapter to manage the date types as long values
                    HomeStats retrieved = gson.fromJson(response.toString(), HomeStats.class);
                    mDbHelper.logHomeStats(retrieved);
                    // dati semi grezzi
                    int radioButtonID = radioGroupBackTo.getCheckedRadioButtonId();
                    View radioButton = findViewById(radioButtonID);
                    storia = mDbHelper.getHistoryData(BackToEnum.valueOf((String) radioButton.getTag()));
                    updateCurrentStats();
                    final RadioButton radioDay = findViewById(R.id.radioButtonDay);
                    final RadioButton radioMin = findViewById(R.id.radioButtonMinutes);
                    GranularityEnum granoEnum = GranularityEnum.HOUR;
                    if (radioDay.isChecked())
                        granoEnum = GranularityEnum.DAY;
                    else if (radioMin.isChecked())
                        granoEnum = GranularityEnum.MINUTE;
                    ChartUtils.drawDifficultyHistory(textViewNetDiffTitle, PoolQueryGrouper.groupAvgQueryResult(storia, granoEnum), (LineView) findViewById(R.id.line_view_difficulty), granoEnum);
                    ChartUtils.drawHashrateHistory(hashText, PoolQueryGrouper.groupAvgQueryResult(storia, granoEnum), (LineView) findViewById(R.id.line_view_hashrate), granoEnum);
                }
            });
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d(Constants.TAG, "Error: " + error.getMessage());
            Snackbar.make(findViewById(android.R.id.content), "Network Error", Snackbar.LENGTH_SHORT).show();
            // prevent stale data appear
            updateCurrentStats();
        }
    });
    /*
        JsonArrayRequest jsonArrayCurrenciesReq = new JsonArrayRequest(Request.Method.GET,
                Constants.ETHER_STATS_URL, null,
                new Response.Listener<JSONArray>() {

                    @Override
                    public void onResponse(final JSONArray response) {
                        Log.d(Constants.TAG, response.toString());
                        hashText.post(new Runnable() {
                            @Override
                            public void run() {
                                Gson gson = builder.create();
                                Log.d(Constants.TAG, response.toString());
                                Type listType = new TypeToken<List<Ticker>>() {}.getType();
                                List<Ticker> posts = gson.fromJson(response.toString(), listType);
                                Ticker fnd = null;
                                for (Ticker currency : posts) {
                                    if (mCur.name().equalsIgnoreCase(currency.getSymbol()) || mCur.toString().equalsIgnoreCase(currency.getName())) {
                                        fnd = currency;
                                    }
                                    //always save ETH
                                    if (CurrencyEnum.ETH.name().equalsIgnoreCase(currency.getSymbol())) {
                                        CryptoSharedPreferencesUtils.saveEthereumValues(currency, MainActivity.this);
                                    }
                                    //always save BTC
                                    if (CurrencyEnum.BTC.name().equalsIgnoreCase(currency.getSymbol())) {
                                        CryptoSharedPreferencesUtils.saveBtcValues(currency, MainActivity.this);
                                    }
                                }
                                //eventually resets  when fnd = null
                                CryptoSharedPreferencesUtils.saveEtherValues(fnd, MainActivity.this);
                            }
                        });
                    }
                }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(Constants.TAG, "Error: " + error.getMessage());
                Crashlytics.logException(error);
            }
        });*/
    // Adding request to request queue
    JSONClientSingleton.getInstance(this).addToRequestQueue(jsonObjReq);
// JSONClientSingleton.getInstance(this).addToRequestQueue(jsonArrayCurrenciesReq);
}
Also used : VolleyError(com.android.volley.VolleyError) Gson(com.google.gson.Gson) HomeStats(it.angelic.mpw.model.jsonpojos.home.HomeStats) RadioButton(android.widget.RadioButton) NavigationView(android.support.design.widget.NavigationView) LineView(im.dacer.androidcharts.LineView) View(android.view.View) AdView(com.google.android.gms.ads.AdView) TextView(android.widget.TextView) Response(com.android.volley.Response) JSONObject(org.json.JSONObject) GranularityEnum(it.angelic.mpw.model.db.GranularityEnum) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest)

Aggregations

RadioButton (android.widget.RadioButton)198 View (android.view.View)100 TextView (android.widget.TextView)69 RadioGroup (android.widget.RadioGroup)43 Button (android.widget.Button)38 Intent (android.content.Intent)36 CheckBox (android.widget.CheckBox)28 EditText (android.widget.EditText)26 ImageView (android.widget.ImageView)21 CompoundButton (android.widget.CompoundButton)19 LayoutInflater (android.view.LayoutInflater)18 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)17 Bundle (android.os.Bundle)16 AdapterView (android.widget.AdapterView)15 DialogInterface (android.content.DialogInterface)14 Context (android.content.Context)10 ScrollView (android.widget.ScrollView)10 ArrayList (java.util.ArrayList)10 SharedPreferences (android.content.SharedPreferences)9