Example usage for android.text Editable toString

List of usage examples for android.text Editable toString

Introduction

In this page you can find the example usage for android.text Editable toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:nz.ac.auckland.lablet.script.components.ScriptComponentPotentialEnergy1View.java

public ScriptComponentPotentialEnergy1View(Context context, PotentialEnergy1 component) {
    super(context);
    this.component = component;

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.script_component_potential_energy_1, null, true);
    assert view != null;
    addView(view);/*from ww w .j  a v  a 2  s  . c o m*/

    TextView massQuestionTextView = (TextView) view.findViewById(R.id.massQuestionTextView);
    assert massQuestionTextView != null;
    TextView heightQuestionTextView = (TextView) view.findViewById(R.id.heightQuestionTextView);
    assert heightQuestionTextView != null;
    TextView energyQuestionTextView = (TextView) view.findViewById(R.id.energyQuestionTextView);
    assert energyQuestionTextView != null;
    TextView pbjSandwichQuestionTextView = (TextView) view.findViewById(R.id.pbjSandwichQuestionTextView);
    assert pbjSandwichQuestionTextView != null;

    EditText massEditText = (EditText) view.findViewById(R.id.massEditText);
    assert massEditText != null;
    EditText heightEditText = (EditText) view.findViewById(R.id.heightEditText);
    assert heightEditText != null;
    EditText energyEditText = (EditText) view.findViewById(R.id.energyEditText);
    assert energyEditText != null;
    EditText pbjEditText = (EditText) view.findViewById(R.id.pbjEditText);
    assert pbjEditText != null;

    doneCheckBox = (CheckBox) view.findViewById(R.id.doneCheckBox);
    assert doneCheckBox != null;

    massQuestionTextView.setText(component.getMassQuestionText());
    heightQuestionTextView.setText(component.getHeightQuestionText());
    energyQuestionTextView.setText(component.getEnergyQuestionText());
    pbjSandwichQuestionTextView.setText(component.getPbjSandwichQuestionText());

    massEditText.setText(Float.toString(getMass()));
    heightEditText.setText(Float.toString(component.getHeight()));
    energyEditText.setText(Float.toString(component.getEnergy()));
    pbjEditText.setText(Float.toString(component.getPbjValue()));

    massEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            float value = 0;
            try {
                value = Float.parseFloat(editable.toString());
            } catch (NumberFormatException e) {
                System.out.println(e.getMessage());
            }
            setMass(value);
        }
    });
    heightEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            float value = 0;
            try {
                value = Float.parseFloat(editable.toString());
            } catch (NumberFormatException e) {
                System.out.println(e.getMessage());
            }
            setHeight(value);
        }
    });
    energyEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            float value = 0;
            try {
                value = Float.parseFloat(editable.toString());
            } catch (NumberFormatException e) {
                System.out.println(e.getMessage());
            }
            setEnergy(value);
        }
    });
    pbjEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            float value = 0;
            try {
                value = Float.parseFloat(editable.toString());
            } catch (NumberFormatException e) {
                System.out.println(e.getMessage());
            }
            setPbjValue(value);
        }
    });

    update();
}

From source file:com.justplay1.shoppist.features.lists.items.add.AddListItemFragment.java

protected void init(View view) {
    super.init(view);

    autoCompleteTextAdapter = new AutoCompleteTextAdapter(getContext());
    autoCompleteTextAdapter.setListener(this::showNewGoodsDialog);
    nameEdit.setAdapter(autoCompleteTextAdapter);
    nameEdit.setOnItemClickListener((parent, view1, position, id) -> {
        ProductViewModel product = autoCompleteTextAdapter.getProduct(nameEdit.getText().toString());
        mPresenter.onProductClick(product);
    });//from  w w  w .ja va  2 s  .  com
    nameEdit.addTextChangedListener(new AbstractTextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            mPresenter.selectName(ShoppistUtils.filterSpace(s.toString()));
            ProductViewModel product = autoCompleteTextAdapter.getProduct(s.toString());
            mPresenter.setProduct(product);
        }
    });

    priceEdit.setFloatingLabelTextSize(getResources().getDimensionPixelSize(R.dimen.edit_label_text_size));
    quantityEdit.setFloatingLabelTextSize(getResources().getDimensionPixelSize(R.dimen.edit_label_text_size));
    note.setFloatingLabelTextSize(getResources().getDimensionPixelSize(R.dimen.edit_label_text_size));

    note.addTextChangedListener(new AbstractTextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            mPresenter.setNote(ShoppistUtils.filterSpace(s.toString()));
        }
    });
    priceEdit.addTextChangedListener(new AbstractTextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            mPresenter.setPrice(s.toString());
        }
    });
    quantityEdit.addTextChangedListener(new AbstractTextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            mPresenter.setQuantity(s.toString());
        }
    });

    ImageButton incrementPriceBtn = (ImageButton) view.findViewById(R.id.increment_price_button);
    ImageButton decrementPriceBtn = (ImageButton) view.findViewById(R.id.decrement_price_button);
    ImageButton incrementUnitBtn = (ImageButton) view.findViewById(R.id.increment_quantity_button);
    ImageButton decrementUnitBtn = (ImageButton) view.findViewById(R.id.decrement_quantity_button);

    incrementPriceBtn.setOnClickListener(this);
    decrementPriceBtn.setOnClickListener(this);
    incrementUnitBtn.setOnClickListener(this);
    decrementUnitBtn.setOnClickListener(this);

    TextView categoryLabel = (TextView) view.findViewById(R.id.category_label);
    TextView priorityLabel = (TextView) view.findViewById(R.id.priority_label);
    TextView unitLabel = (TextView) view.findViewById(R.id.unit_label);
    TextView currencyLabel = (TextView) view.findViewById(R.id.currency_label);

    currencyLabel.setTextColor(preferences.getColorPrimary());
    categoryLabel.setTextColor(preferences.getColorPrimary());
    priorityLabel.setTextColor(preferences.getColorPrimary());
    unitLabel.setTextColor(preferences.getColorPrimary());

    priceEdit.setPrimaryColor(preferences.getColorPrimary());
    quantityEdit.setPrimaryColor(preferences.getColorPrimary());
    note.setPrimaryColor(preferences.getColorPrimary());

    initializePriorityList();
    initializeCategoryList();
    initializeUnitList();
    initializeCurrencyList();
}

From source file:com.example.android.wizardpager.wizard.ui.CustomerAddressFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    OCR();//from   ww w  .  ja  v a2 s .  c o m

    mAddress1View.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(CustomerAddressPage.ADDRESS1_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    /*        mEmailView.addTextChangedListener(new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1,
            int i2) {
    }
            
    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
    }
            
    @Override
    public void afterTextChanged(Editable editable) {
        mPage.getData().putString(CustomerInfoPage.EMAIL_DATA_KEY,
                (editable != null) ? editable.toString() : null);
        mPage.notifyDataChanged();
    }
            });*/

    mAddress2View.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(CustomerAddressPage.ADDRESS2_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    mAddress3View.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(CustomerAddressPage.ADDRESS3_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

    mAddress4View.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mPage.getData().putString(CustomerAddressPage.ADDRESS4_DATA_KEY,
                    (editable != null) ? editable.toString() : null);
            mPage.notifyDataChanged();
        }
    });

}

From source file:com.z299studio.pb.EditFragment.java

@Override
public void afterTextChanged(Editable s) {
    mNameOk = !s.toString().isEmpty();
    changeSaveStatus();
}

From source file:org.mariotaku.twidere.fragment.support.DirectMessagesConversationFragment.java

private void sendDirectMessage() {
    final Editable text = mEditText.getText();
    if (isEmpty(text) || mAccountId <= 0 || mRecipientId <= 0)
        return;/*from  www  .  j  ava  2  s  .co  m*/
    final String message = text.toString();
    if (mValidator.isValidTweet(message)) {
        mTwitterWrapper.sendDirectMessageAsync(mAccountId, mRecipientId, message);
        text.clear();
    }
}

From source file:org.microsoftdx.netherclientsample.fragments.NetherClientApiFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_nether_client_api, container, false);

    mSettings = Settings.getInstance(view.getContext());
    mSettings.load();//from w  ww.j av a  2s  . c  o  m

    mNetherBaseUrldEditText = (EditText) view.findViewById(R.id.netherBaseUrlEditText);
    mNetherBaseUrldEditText.setText(mSettings.getNetherBaseUrl());
    mNetherBaseUrldEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setNetherBaseUrl(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mNetherBaseUrldEditText.setText(mSettings.getNetherBaseUrl());
            }
        }
    });

    mNetherClientIdEditText = (EditText) view.findViewById(R.id.netherClientIdEditText);
    mNetherClientIdEditText.setText(mSettings.getNetherClientId());
    mNetherClientIdEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setNetherClientId(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mNetherClientIdEditText.setText(mSettings.getNetherClientId());
            }
        }
    });

    mNetherClientSecretEditText = (EditText) view.findViewById(R.id.netherClientSecretEditText);
    mNetherClientSecretEditText.setText(mSettings.getNetherClientSecret());
    mNetherClientSecretEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setNetherClientSecret(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mNetherClientSecretEditText.setText(mSettings.getNetherClientSecret());
            }
        }
    });

    mUserIdEditText = (EditText) view.findViewById(R.id.userIdEditText);
    mUserIdEditText.setText(mSettings.getUserId());
    mUserIdEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setUserId(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mUserIdEditText.setText(mSettings.getUserId());
            }
        }
    });

    mPasswordEditText = (EditText) view.findViewById(R.id.passwordEditText);
    mPasswordEditText.setText(mSettings.getPassword());
    mPasswordEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setPassword(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mPasswordEditText.setText(mSettings.getPassword());
            }
        }
    });

    mCountryEditText = (EditText) view.findViewById(R.id.countryEditText);
    mCountryEditText.setText(mSettings.getCountry());
    mCountryEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setCountry(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mCountryEditText.setText(mSettings.getCountry());
            }
        }
    });

    mScoreEditText = (EditText) view.findViewById(R.id.scoreEditText);
    mScoreEditText.setText(String.valueOf(mSettings.getScore()));
    mScoreEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                try {
                    mSettings.setScore(Long.parseLong(editable.toString()));
                } catch (NumberFormatException e) {
                    Log.e(TAG, e.getMessage(), e);
                    mScoreEditText.setText(String.valueOf(mSettings.getScore()));
                }
            }
        }
    });

    mLeaderboardNameEditText = (EditText) view.findViewById(R.id.leaderboardNameEditText);
    mLeaderboardNameEditText.setText(mSettings.getLeaderboardName());
    mLeaderboardNameEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mSettings.setLeaderboardName(editable.toString());
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage(), e);
                mLeaderboardNameEditText.setText(mSettings.getLeaderboardName());
            }
        }
    });

    mAuthenticateButton = (Button) view.findViewById(R.id.authenticateButton);
    mAuthenticateButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NetherClient netherClient = MainActivity.getNetherClient();

            if (netherClient != null) {
                netherClient.login(mSettings.getUserId(), mSettings.getPassword());
            } else {
                logAndDisplayNoNetherClientError();
                ;
            }
        }
    });

    mPostScoreButton = (Button) view.findViewById(R.id.postScoreButton);
    mPostScoreButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NetherClient netherClient = MainActivity.getNetherClient();

            if (netherClient != null) {
                netherClient.postScoreForCurrentPlayer(mSettings.getCountry(), mSettings.getScore());
            } else {
                logAndDisplayNoNetherClientError();
                ;
            }
        }
    });

    mGetLeaderboardButton = (Button) view.findViewById(R.id.getLeaderboardButton);
    mGetLeaderboardButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NetherClient netherClient = MainActivity.getNetherClient();

            if (netherClient != null) {
                netherClient.getLeaderboard(mSettings.getLeaderboardName());
            } else {
                logAndDisplayNoNetherClientError();
                ;
            }
        }
    });

    return view;
}

From source file:com.jins_meme.bridge.OSCConfigFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    handler = new Handler();

    layout = (LinearLayout) view.findViewById(R.id.osc_layout);
    layout.setOnTouchListener(new OnTouchListener() {
        @Override/*from w  w  w  .  j  a v  a  2s  .com*/
        public boolean onTouch(View view, MotionEvent motionEvent) {
            Log.d("DEBUG", "view touch.");

            layout.requestFocus();

            return false;
        }
    });

    InputFilter[] filters = new InputFilter[1];
    filters[0] = new InputFilter() {
        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            if (end > start) {
                String destTxt = dest.toString();
                String resultingTxt = destTxt.substring(0, dstart) + source.subSequence(start, end)
                        + destTxt.substring(dend);
                if (!resultingTxt
                        .matches("^\\d{1,3}(\\." + "(\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3})?)?)?)?)?)?")) {
                    return "";
                } else {
                    String[] splits = resultingTxt.split("\\.");
                    for (String split : splits) {
                        if (Integer.valueOf(split) > 255) {
                            return "";
                        }
                    }
                }
            }
            return null;
        }
    };

    etRemoteIP = (EditText) view.findViewById(R.id.remote_ip);
    String savedRemoteIP = ((MainActivity) getActivity()).getSavedValue("REMOTE_IP", "255.255.255.255");
    if (savedRemoteIP.equals("255.255.255.255")) {
        etRemoteIP.setText(MemeOSC.getRemoteIPv4Address());
    } else {
        etRemoteIP.setText(savedRemoteIP);
    }
    etRemoteIP.setFilters(filters);
    etRemoteIP.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    });
    etRemoteIP.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            Log.d("DEBUG", "after text changed " + editable.toString());

            ((MainActivity) getActivity()).autoSaveValue("REMOTE_IP", editable.toString());

            testOSC.setRemoteIP(etRemoteIP.getText().toString());
            testOSC.initSocket();
        }
    });

    etRemotePort = (EditText) view.findViewById(R.id.remote_port);
    etRemotePort.setText(String.valueOf(((MainActivity) getActivity()).getSavedValue("REMOTE_PORT", 10316)));
    etRemotePort.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    });
    etRemotePort.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            Log.d("DEBUG", "after text changed " + editable.toString());

            if (editable.toString().length() > 0) {
                ((MainActivity) getActivity()).autoSaveValue("REMOTE_PORT",
                        Integer.valueOf(editable.toString()));

                testOSC.setRemotePort(Integer.parseInt(editable.toString()));
                testOSC.initSocket();
            }
        }
    });

    etHostIP = (EditText) view.findViewById(R.id.host_ip);
    etHostIP.setText(MemeOSC.getHostIPv4Address());
    etHostIP.setEnabled(false);

    etHostPort = (EditText) view.findViewById(R.id.host_port);
    etHostPort.setText(String.valueOf(((MainActivity) getActivity()).getSavedValue("HOST_PORT", 11316)));
    etHostPort.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    });
    etHostPort.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            Log.d("DEBUG", "after text changed " + editable.toString());

            if (editable.toString().length() > 0) {
                ((MainActivity) getActivity()).autoSaveValue("HOST_PORT", Integer.valueOf(editable.toString()));
                testOSC.setHostPort(Integer.parseInt(editable.toString()));
                testOSC.initSocket();
            }
        }
    });

    btnTest = (Button) view.findViewById(R.id.remote_test);
    btnTest.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            layout.requestFocus();

            testOSC.setAddress("/meme/bridge", "/test");
            testOSC.setTypeTag("si");
            testOSC.addArgument(etRemoteIP.getText().toString());
            testOSC.addArgument(Integer.parseInt(etRemotePort.getText().toString()));
            testOSC.flushMessage();
        }
    });

    testOSC = new MemeOSC();
    testOSC.setRemoteIP(etRemoteIP.getText().toString());
    testOSC.setRemotePort(Integer.parseInt(etRemotePort.getText().toString()));
    testOSC.setHostPort(Integer.parseInt(etHostPort.getText().toString()));
    testOSC.initSocket();

    isShown = true;
    Thread rcvTestThread = new Thread(new ReceiveTestTRunnable());
    rcvTestThread.start();
}

From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java

private void promptUsername() {
    final EditText input = new EditText(this);
    new AlertDialog.Builder(this).setTitle(R.string.namePrompt).setMessage(R.string.highScoreAchieved)
            .setView(input).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    Editable value = input.getText();
                    String valueString = value.toString().trim();
                    if (valueString.isEmpty()) {
                        valueString = "Unknown";
                    }/*w w  w.  j  av  a2  s  . c  o  m*/
                    scores.addScore(valueString, gameManager.getCurrGameState().getPlayer(playerId).getScore());
                    showTopScores();
                }
            }).show();
}

From source file:com.xperia64.timidityae.TrackFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    reset();//  w  w w . j a v  a  2 s  . co m

    fileList = new ArrayAdapter<String>(getActivity(), R.layout.row);
    for (int i = 0; i < JNIHandler.MAX_CHANNELS; i++) {
        fileList.add(String.format(getActivity().getResources().getString(R.string.trk_form),
                (getActivity().getResources()
                        .getString(JNIHandler.drums.get(i) ? R.string.trk_drum : R.string.trk_inst2)),
                (i + 1), JNIHandler.drums.get(i) ? 0 : localInst.get(i) + 1, localVol.get(i)));
    }
    channelList.setAdapter(fileList);
    channelList.setOnItemClickListener(new OnItemClickListener() {

        @SuppressLint("InflateParams")
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
            AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
            View v = getActivity().getLayoutInflater().inflate(R.layout.track_dialog, null);
            final Spinner instSpin = (Spinner) v.findViewById(R.id.instSpin);
            instSpin.setClickable(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2));
            instSpin.setOnLongClickListener(null);
            instSpin.setEnabled(JNIHandler.custInst.get(arg2) && !JNIHandler.drums.get(arg2));
            List<String> arrayAdapter = new ArrayList<String>();
            final int offset = (!JNIHandler.drums.get(arg2)) ? 0 : 34;
            if (!JNIHandler.drums.get(arg2)) {
                for (String inst : getActivity().getResources().getStringArray(R.array.midi_instruments))
                    arrayAdapter.add(inst);
            } else {
                for (String inst : getActivity().getResources().getStringArray(R.array.midi_drums))
                    arrayAdapter.add(inst);
            }
            ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, arrayAdapter);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
            } else {
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            }

            dataAdapter.setNotifyOnChange(false);
            if (!JNIHandler.drums.get(arg2)) {
                instSpin.setAdapter(dataAdapter);
                instSpin.setSelection(localInst.get(arg2) - offset);
            }
            final EditText txtVol = (EditText) v.findViewById(R.id.txtVol);
            txtVol.setText(Integer.toString(localVol.get(arg2)));
            txtVol.setClickable(JNIHandler.custVol.get(arg2));
            txtVol.setEnabled(JNIHandler.custVol.get(arg2));

            final SeekBar volSeek = (SeekBar) v.findViewById(R.id.volSeek);
            volSeek.setClickable(JNIHandler.custVol.get(arg2));
            volSeek.setEnabled(JNIHandler.custVol.get(arg2));
            volSeek.setMax(127);
            volSeek.setProgress(localVol.get(arg2));
            volSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

                @Override
                public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
                    if (arg2 && !fromUser) {
                        fromUser = true;
                        txtVol.setText(Integer.toString(arg0.getProgress()));
                    } else {
                        fromUser = false;
                    }
                }

                @Override
                public void onStartTrackingTouch(SeekBar arg0) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar arg0) {
                }

            });

            txtVol.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    if (!fromUser) {
                        if (s.length() > 0) {
                            int numm = Integer.parseInt(s.toString());
                            if (numm > 127) {
                                fromUser = true;
                                numm = 127;
                            }
                            if (numm < 0) {
                                fromUser = true;
                                numm = 0;
                            }
                            if (fromUser) {
                                txtVol.setText(Integer.toString(numm));
                            }
                            fromUser = true;
                            volSeek.setProgress(numm);
                            fromUser = false;
                        }
                    } else {
                        fromUser = false;
                    }
                }

                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });
            final CheckBox inst = (CheckBox) v.findViewById(R.id.defInstr);
            inst.setEnabled(!JNIHandler.drums.get(arg2));
            inst.setChecked(!JNIHandler.custInst.get(arg2));
            inst.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {

                    instSpin.setClickable(!arg1);
                    instSpin.setEnabled(!arg1);
                }

            });
            final CheckBox vol = (CheckBox) v.findViewById(R.id.defVol);
            vol.setChecked(!JNIHandler.custVol.get(arg2));
            //System.out.println("Def inst: "+(!JNIHandler.custInst.get(arg2)?"true":"false")+" def vol: "+(!JNIHandler.custVol.get(arg2)?"true":"false"));
            vol.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton arg0, boolean arg1) {

                    volSeek.setClickable(!arg1);
                    volSeek.setEnabled(!arg1);
                    txtVol.setClickable(!arg1);
                    txtVol.setEnabled(!arg1);
                }

            });
            if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                v.setBackgroundColor(Globals.theme == 1 ? Color.WHITE : Color.BLACK);
            b.setView(v);
            b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

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

                    JNIHandler.custInst.set(arg2, !inst.isChecked());
                    JNIHandler.custVol.set(arg2, !vol.isChecked());
                    JNIHandler.setChannelVolumeTimidity(arg2 | (JNIHandler.custVol.get(arg2) ? 0x800 : 0x8000),
                            volSeek.getProgress());
                    JNIHandler.setChannelTimidity(arg2 | (JNIHandler.custInst.get(arg2) ? 0x800 : 0x8000),
                            instSpin.getSelectedItemPosition());
                    if (!JNIHandler.paused && Globals.isPlaying == 0)
                        JNIHandler.seekTo(JNIHandler.currTime);
                    //bigCounter=12;
                    updateList();
                }
            });

            b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            b.setTitle(String.format((getActivity().getResources().getString(R.string.trk_form2)), (arg2 + 1)));
            ddd = b.create();
            ddd.show();
        }

    });
}

From source file:com.digi.android.wva.fragments.EndpointOptionsDialog.java

/**
 * @param subInterval EditText holding user input for interval
 * @return true if subscription was valid (and probably worked), false
 * if the interval is invalid// w  w w .j a v a 2  s  . c o  m
 */
protected boolean handleMakingSubscription(EditText subInterval) {
    // Shouldn't need to worry about NumberFormatException -
    // the EditText is set to type numeric
    Editable intervalText = subInterval.getText();
    String interval;
    if (intervalText == null)
        interval = "";
    else
        interval = intervalText.toString();
    if (TextUtils.isEmpty(interval) || !TextUtils.isDigitsOnly(interval)) {
        return false;
    }

    int iinterval;
    try {
        iinterval = Integer.valueOf(interval);
    } catch (NumberFormatException e) {
        return false;
    }

    if (isSubscribing() || subscriptionIntervalChanged(iinterval)) {
        subscribe(mConfig.getEndpoint(), iinterval);
    }
    return true;
}