Example usage for android.text InputType TYPE_CLASS_NUMBER

List of usage examples for android.text InputType TYPE_CLASS_NUMBER

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_NUMBER.

Prototype

int TYPE_CLASS_NUMBER

To view the source code for android.text InputType TYPE_CLASS_NUMBER.

Click Source Link

Document

Class for numeric text.

Usage

From source file:com.dirkgassen.wator.ui.view.RangeSlider.java

/**
 * Allows the user to click on the thumb. Clicking shows an alert that allows the user to enter a value. The
 * entered value is adjusted to the minimum/maximum (or to be one of the value set if one is active).
 *
 * @return {@code true} to indicate that the click was handled.
 *///from  w w  w . j  a  v  a2  s .  c  o  m
@Override
public boolean performClick() {
    super.performClick();

    final Context c = this.getContext();
    final AlertDialog.Builder alert = new AlertDialog.Builder(c);
    final EditText input = new EditText(c);
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    input.setEms(getMaxDigits());
    alert.setView(input).setTitle(getContext().getString(R.string.enter_new_value_title))
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    try {
                        int enteredValue = Integer.valueOf(input.getText().toString().trim());
                        int newValue;
                        if (valueSet != null) {
                            newValue = valueSet[valueSet.length - 1];
                            for (int searchValue : valueSet) {
                                if (enteredValue <= searchValue) {
                                    newValue = searchValue;
                                    break;
                                }
                            }
                        } else {
                            newValue = enteredValue < minValue ? minValue
                                    : enteredValue > maxValue ? maxValue : enteredValue;
                        }
                        if (newValue != enteredValue) {
                            Toast.makeText(c, c.getString(R.string.entered_value_adjusted, newValue),
                                    Toast.LENGTH_LONG).show();
                        }
                        if (newValue != value) {
                            updateValue(newValue, true /* from user */);
                        }
                    } catch (NumberFormatException e) {
                        Toast.makeText(c, R.string.invalid_value, Toast.LENGTH_SHORT).show();
                    }
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            }).show();

    return true;
}

From source file:de.j4velin.wifiAutoOff.Preferences.java

private static void showPre11NumberPicker(final Context c, final SharedPreferences prefs, final Preference p,
        final int summary, final int min, final int max, final String title, final String setting,
        final int def, final boolean changeTitle) {
    final EditText np = new EditText(c);
    np.setInputType(InputType.TYPE_CLASS_NUMBER);
    np.setText(String.valueOf(prefs.getInt(setting, def)));
    new AlertDialog.Builder(c).setTitle(title).setView(np)
            .setPositiveButton(android.R.string.ok, new OnClickListener() {
                @Override/*  w ww.j a  v  a2s  . com*/
                public void onClick(DialogInterface dialog, int which) {
                    int number = -1;
                    try {
                        number = Integer.parseInt(np.getText().toString());
                    } catch (Exception e) {
                    }
                    if (number >= min && number <= max) {
                        prefs.edit().putInt(setting, number).commit();
                        if (changeTitle)
                            p.setTitle(c.getString(summary, number));
                        else
                            p.setSummary(c.getString(summary, number));
                    } else {
                        Toast.makeText(c, c.getString(R.string.invalid_input_number_has_to_be_, min, max),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            }).create().show();
}

From source file:com.roiland.crm.sm.ui.view.ScOppoInfoFragment.java

/**
 * /*from w  w w  . ja  v a  2 s  .  c o  m*/
 * <pre>
 * ?
 * </pre>
 *
 * @param isDetail ??
 */
public void displayCustomerInfo(boolean isDetail) {
    if (customerInfo == null) {
        customerInfo = new ArrayList<BasicInfoListAdapter.Info>();

    }
    if (project == null) {
        project = new Project();
    }
    if (!isOldCust()) {
        project.setCustomer(getUpdatedCustomer());
    }

    //
    if (!isDetail) {
        customerInfo.clear();
        if (addFlag) {
            customerInfo.add(custNameInfo = new BasicInfoListAdapter.Info(getString(R.string.custName),
                    BaseInfoRowViewItem.RIGHT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCustName()
                            : null),
                    true, true));
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custName),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCustName()
                            : null),
                    true));
        }

        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custFrom),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustFrom() : null),
                true));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custType),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustType() : null),
                true));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.infoFrom),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getInfoFrom() : null),
                true));
        if (addFlag) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.collectFrom),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCollectFrom()
                            : null),
                    true));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custMobile),
                BaseInfoRowViewItem.MOBILETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustMobile()
                        : null),
                false, InputType.TYPE_CLASS_NUMBER));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custOtherPhone),
                BaseInfoRowViewItem.PSTNTEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustOtherPhone()
                        : null),
                false, InputType.TYPE_CLASS_PHONE));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.comment),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustComment()
                        : null),
                false));
    } else {
        customerInfo.clear();
        if (addFlag) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custName),
                    BaseInfoRowViewItem.RIGHT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCustName()
                            : null),
                    true));
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custName),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCustName()
                            : null),
                    true));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custFrom),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustFrom() : null),
                true));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custType),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustType() : null),
                true));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.infoFrom),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getInfoFrom() : null),
                true));
        if (addFlag) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.collectFrom),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCollectFrom()
                            : null),
                    true));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custMobile),
                BaseInfoRowViewItem.MOBILETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustMobile()
                        : null),
                false, InputType.TYPE_CLASS_NUMBER));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custOtherPhone),
                BaseInfoRowViewItem.PSTNTEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustOtherPhone()
                        : null),
                false, InputType.TYPE_CLASS_PHONE));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.gender),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getGender() : null),
                false));
        if (isSubmitNewCar() || isSubmitNewCar) {
            customerInfo.add(birthdayInfo = new BasicInfoListAdapter.Info(getString(R.string.birthday),
                    BaseInfoRowViewItem.DATE_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getBirthday()
                            : null),
                    true));
            customerInfo.add(idtypeInfo = new BasicInfoListAdapter.Info(getString(R.string.idType),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getIdType()
                            : null),
                    true));
            customerInfo.add(idnumberInfo = new BasicInfoListAdapter.Info(getString(R.string.idNumber),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getIdNumber()
                            : null),
                    true));
        } else {
            customerInfo.add(birthdayInfo = new BasicInfoListAdapter.Info(getString(R.string.birthday),
                    BaseInfoRowViewItem.DATE_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getBirthday()
                            : null),
                    false));
            customerInfo.add(idtypeInfo = new BasicInfoListAdapter.Info(getString(R.string.idType),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getIdType()
                            : null),
                    false));
            customerInfo.add(idnumberInfo = new BasicInfoListAdapter.Info(getString(R.string.idNumber),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getIdNumber()
                            : null),
                    false));
        }
        if (addFlag && !oldCustCollect) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.province),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getProvince()
                            : null),
                    false));
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.city),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getCity() : null),
                    false, false));
        } else {
            if (isSubmitNewCar() || isSubmitNewCar) {
                //
                customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.province),
                        BaseInfoRowViewItem.SELECTION_TYPE, null,
                        (project != null && project.getCustomer() != null ? project.getCustomer().getProvince()
                                : null),
                        true));
                if (StringUtils.isEmpty(project.getCustomer().getProvince())) {
                    customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.city),
                            BaseInfoRowViewItem.SELECTION_TYPE, null,
                            (project != null && project.getCustomer() != null ? project.getCustomer().getCity()
                                    : null),
                            true, false));
                } else {
                    customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.city),
                            BaseInfoRowViewItem.SELECTION_TYPE, null,
                            (project != null && project.getCustomer() != null ? project.getCustomer().getCity()
                                    : null),
                            true));
                }
            } else {
                //?
                customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.province),
                        BaseInfoRowViewItem.SELECTION_TYPE, null,
                        (project != null && project.getCustomer() != null ? project.getCustomer().getProvince()
                                : null),
                        false));
                if (StringUtils.isEmpty(project.getCustomer().getProvince())) {
                    customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.city),
                            BaseInfoRowViewItem.SELECTION_TYPE, null,
                            (project != null && project.getCustomer() != null ? project.getCustomer().getCity()
                                    : null),
                            false, false));
                } else {
                    customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.city),
                            BaseInfoRowViewItem.SELECTION_TYPE, null,
                            (project != null && project.getCustomer() != null ? project.getCustomer().getCity()
                                    : null),
                            false));
                }
            }
        }
        if (addFlag && !oldCustCollect || StringUtils.isEmpty(project.getCustomer().getCity())) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.district),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getDistrict()
                            : null),
                    false, false));
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.district),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getDistrict()
                            : null),
                    false));
        }

        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.qq),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getQq() : null),
                false, InputType.TYPE_CLASS_NUMBER));
        if (isSubmitNewCar() || isSubmitNewCar) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.address),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getAddress()
                            : null),
                    true));
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.address),
                    BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getAddress()
                            : null),
                    false));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.postcode),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getPostcode() : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.email),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getEmail() : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.convContactTime),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getConvContactTime()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.expectContactWay),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getExpectContactWay()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.fax),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getFax() : null),
                false));
        if (isSubmitNewCar() || isSubmitNewCar) {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.existingCar),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getExistingCar()
                            : null),
                    true));
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.existingCar),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getExistingCar()
                            : null),
                    false));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.industry),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getIndustry() : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.position),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getPosition() : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.education),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getEducation()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.existingcarbrand),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getExistingCarBrand()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custInterest1),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustInterest1()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custInterest2),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustInterest2()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.custInterest3),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustInterest3()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.existLisenPlate),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getExistLisenPlate()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.enterpType),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getEnterpType()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.enterpPeopleCount),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getEnterpPeopleCount()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.registeredCapital),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getRegisteredCapital()
                        : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.compeCarModel),
                BaseInfoRowViewItem.SELECTION_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCompeCarModel()
                        : null),
                false));
        if (addFlag) {
            if (isOldCust) {
                project.getCustomer().setRebuyStoreCustTag(true);
                customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.rebuyStoreCustTag),
                        BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                        (project != null && project.getCustomer() != null
                                && project.getCustomer().getRebuyStoreCustTag() != null ? "true" : null),
                        false, false));
            } else {
                customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.rebuyStoreCustTag),
                        BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                        (project != null && project.getCustomer() != null
                                && project.getCustomer().getRebuyStoreCustTag() != null ? "false" : null),
                        false, false));
            }
        } else {
            customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.rebuyStoreCustTag),
                    BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                    (project != null && project.getCustomer() != null
                            && project.getCustomer().getRebuyStoreCustTag() != null
                                    ? (project.getCustomer().getRebuyStoreCustTag() ? "true" : "false")
                                    : null),
                    false, false));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.rebuyOnlineCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getRebuyOnlineCustTag() != null
                                ? (project.getCustomer().getRebuyOnlineCustTag() ? "true" : "false")
                                : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.changeCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getChangeCustTag() != null
                                ? (project.getCustomer().getChangeCustTag() ? "true" : "false")
                                : null),
                false));
        customerInfo.add(oldCustInfo = new BasicInfoListAdapter.Info(getString(R.string.regularCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getRegularCustTag() != null
                                ? (project.getCustomer().getRegularCustTag() ? "true" : "false")
                                : "false"),
                false));
        //??
        if ("true".equals(oldCustInfo.value)) {
            customerInfo.add(oldCustSelectInfo = new BasicInfoListAdapter.Info(getString(R.string.regularCust),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getRegularCust()
                            : null),
                    true));
        } else {
            customerInfo.add(oldCustSelectInfo = new BasicInfoListAdapter.Info(getString(R.string.regularCust),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getRegularCust()
                            : null),
                    false, false));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.loanCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getLoanCustTag() != null
                                ? (project.getCustomer().getLoanCustTag() ? "true" : "false")
                                : null),
                false));
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.headerQuartCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getHeaderQuartCustTag() != null
                                ? (project.getCustomer().getHeaderQuartCustTag() ? "true" : "false")
                                : null),
                false));
        customerInfo.add(bigCustInfo = new BasicInfoListAdapter.Info(getString(R.string.bigCustTag),
                BaseInfoRowViewItem.BOOLEAN2_TYPE, null,
                (project != null && project.getCustomer() != null
                        && project.getCustomer().getBigCustTag() != null
                                ? (project.getCustomer().getBigCustTag() ? "true" : "false")
                                : "false"),
                false));
        //?
        if ("true".equals(bigCustInfo.value)) {
            customerInfo.add(bigCustSelectInfo = new BasicInfoListAdapter.Info(getString(R.string.bigCusts),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getBigCusts()
                            : null),
                    true));
        } else {
            customerInfo.add(bigCustSelectInfo = new BasicInfoListAdapter.Info(getString(R.string.bigCusts),
                    BaseInfoRowViewItem.SELECTION_TYPE, null,
                    (project != null && project.getCustomer() != null ? project.getCustomer().getBigCusts()
                            : null),
                    false, false));
        }
        customerInfo.add(new BasicInfoListAdapter.Info(getString(R.string.comment),
                BaseInfoRowViewItem.SIMPLETEXT_TYPE, null,
                (project != null && project.getCustomer() != null ? project.getCustomer().getCustComment()
                        : null),
                false));
        customerInfoCaches = new ArrayList<BasicInfoListAdapter.Info>();
        customerInfoCaches.addAll(customerInfo);
    }
    customerInfoAdapter.setContentList(customerInfo);
    customerInfoAdapter.notifyDataSetChanged();
    if (addFlag) {
        customerInfoAdapter.setEditable(true);
    }
    refreshCustList();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showSendMoneyPrompt() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    final String message = "Send Money to Friend In A Flash";
    String positiveButtonText = "Send";

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    final TextView labelAmount = new TextView(getActivity());
    final EditText editAmount = new EditText(getActivity());
    final TextView labelMobileNo = new TextView(getActivity());
    final EditText editMobileNo = new EditText(getActivity());
    final TextView labelMessage = new TextView(getActivity());
    final EditText editMessage = new EditText(getActivity());
    editAmount.setSingleLine(true);//from www . j  a va  2 s . c o  m
    editMobileNo.setSingleLine(true);
    editMessage.setSingleLine(true);

    labelAmount.setText("Amount");
    labelMobileNo.setText("Enter Mobile No of Friend");
    labelMessage.setText("Enter Message (Optional)");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    labelAmount.setLayoutParams(layoutParams);
    labelMobileNo.setLayoutParams(layoutParams);
    labelMessage.setLayoutParams(layoutParams);
    editAmount.setLayoutParams(layoutParams);
    editMobileNo.setLayoutParams(layoutParams);
    editMessage.setLayoutParams(layoutParams);

    linearLayout.addView(labelAmount);
    linearLayout.addView(editAmount);
    linearLayout.addView(labelMobileNo);
    linearLayout.addView(editMobileNo);
    linearLayout.addView(labelMessage);
    linearLayout.addView(editMessage);

    int paddingPx = Utils.getSizeInPx(getActivity(), 32);
    linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

    editAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    editMobileNo.setInputType(InputType.TYPE_CLASS_NUMBER);
    alert.setTitle("Send Money In A Flash");
    alert.setMessage(message);

    alert.setView(linearLayout);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String amount = editAmount.getText().toString();
            String mobileNo = editMobileNo.getText().toString();
            String message = editMessage.getText().toString();

            mCitrusClient.sendMoneyToMoblieNo(new Amount(amount), mobileNo, message,
                    new Callback<PaymentResponse>() {
                        @Override
                        public void success(PaymentResponse paymentResponse) {
                            //                        Utils.showToast(getActivity(), paymentResponse.getStatus() == CitrusResponse.Status.SUCCESSFUL ? "Sent Money Successfully." : "Failed To Send the Money");
                            ((UIActivity) getActivity()).showSnackBar(
                                    paymentResponse.getStatus() == CitrusResponse.Status.SUCCESSFUL
                                            ? "Sent Money Successfully."
                                            : "Failed To Send the Money");
                        }

                        @Override
                        public void error(CitrusError error) {
                            //                        Utils.showToast(getActivity(), error.getMessage());
                            ((UIActivity) getActivity()).showSnackBar(error.getMessage());
                        }
                    });
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    editAmount.requestFocus();
    alert.show();
}

From source file:hu.fnf.devel.atlas.Atlas.java

private void setViewCategoryProperties(int page) {
    /*// w  w w.  j  av a 2  s. c om
     * List LABEL
     */
    TextView header = (TextView) findViewById(R.id.header_text_view);
    TextView newe = (TextView) findViewById(R.id.new_etwas_text);
    EditText newc = (EditText) findViewById(R.id.new_etwas);
    ContentResolver cr = getContentResolver();
    Uri.Builder builder = new Builder();
    builder.scheme("content");
    builder.authority(AtlasData.DB_AUTHORITY);
    Cursor list = null;
    String[] projection = null;

    switch (page) {
    case AtlasData.PINCOME:
        newe.setText(getResources().getString(R.string.category) + ":");
        newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

        builder.appendPath(AtlasData.TABLE_DATA);
        builder.appendPath("guess");

        list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null);

        header.setText(getResources().getString(R.string.guess) + "(" + String.valueOf(list.getCount()) + ")");
        list.close();

        builder = new Builder();
        builder.scheme("content");
        builder.authority(AtlasData.DB_AUTHORITY);
        builder.appendPath(AtlasData.TABLE_DATA);
        projection = AtlasData.DATA_COLUMNS;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            Log.d("onCreate", "only toptask");
            builder.appendPath("topguess");

        } else {
            Log.d("onCreate", "all tasks");
            builder.appendPath("guess");
        }
        break;
    case AtlasData.PSUMMARY:
        newe.setText(getResources().getString(R.string.amount) + ":");
        newc.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                | InputType.TYPE_NUMBER_FLAG_SIGNED);
        builder.appendPath(AtlasData.TABLE_TRANSACTIONS);
        builder.appendPath("tasks");

        list = cr.query(builder.build(), AtlasData.TRANSACTIONS_COLUMNS, null, null, null);
        header.setText(getResources().getString(R.string.tasks) + "(" + String.valueOf(list.getCount()) + ")");
        list.close();

        builder = new Builder();
        builder.scheme("content");
        builder.authority(AtlasData.DB_AUTHORITY);
        builder.appendPath(AtlasData.TABLE_TRANSACTIONS);
        projection = AtlasData.TRANSACTIONS_COLUMNS;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            Log.d("onCreate", "only toptask");
            builder.appendPath("toptask");

        } else {
            Log.d("onCreate", "all tasks");
            builder.appendPath("tasks");
        }
        break;
    case AtlasData.POUTCOME:
        newe.setText(getResources().getString(R.string.category) + ":");
        newc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

        builder.appendPath(AtlasData.TABLE_DATA);
        builder.appendPath("data");

        list = cr.query(builder.build(), AtlasData.DATA_COLUMNS, null, null, null);
        header.setText(getResources().getString(R.string.data) + "(" + String.valueOf(list.getCount()) + ")");
        list.close();

        builder = new Builder();
        builder.scheme("content");
        builder.authority(AtlasData.DB_AUTHORITY);
        builder.appendPath(AtlasData.TABLE_DATA);
        projection = AtlasData.DATA_COLUMNS;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            Log.d("onCreate", "only toptask");
            builder.appendPath("topdata");

        } else {
            Log.d("onCreate", "all tasks");
            builder.appendPath("data");
        }
        break;
    default:
        Log.e("onPageSelected", "page?!: " + page);
        break;
    }
    header.setOnClickListener(onHeaderClickListener);
    Cursor tasks_result = cr.query(builder.build(), projection, null, null, null);
    DatabaseQueryAdapter ta = new DatabaseQueryAdapter(this, tasks_result, 0,
            builder.build().getPathSegments().get(0));

    Log.d("onCreate", "result count: " + tasks_result.getColumnCount());
    ListView lv = (ListView) findViewById(R.id.tasklist);
    lv.setAdapter(ta);
}

From source file:com.entertailion.android.dial.ServerFinder.java

private AlertDialog buildManualIpDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View view = LayoutInflater.from(this).inflate(R.layout.manual_ip, null);
    final EditText ipEditText = (EditText) view.findViewById(R.id.manual_ip_entry);

    ipEditText.setFilters(new InputFilter[] { new NumberKeyListener() {
        @Override// w w  w.  j  av a  2 s  . c o  m
        protected char[] getAcceptedChars() {
            return "0123456789.:".toCharArray();
        }

        public int getInputType() {
            return InputType.TYPE_CLASS_NUMBER;
        }
    } });

    SharedPreferences settings = getSharedPreferences(MainActivity.PREFS_NAME, Activity.MODE_PRIVATE);
    String ip = settings.getString(MANUAL_IP_ADDRESS, "");
    ipEditText.setText(ip);

    builder.setPositiveButton(R.string.manual_ip_connect, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            DialServer DialServer = DialServerFromString(ipEditText.getText().toString());
            if (DialServer != null) {
                connectToEntry(DialServer);
                try {
                    SharedPreferences settings = getSharedPreferences(MainActivity.PREFS_NAME,
                            Activity.MODE_PRIVATE);
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString(MANUAL_IP_ADDRESS, ipEditText.getText().toString());
                    editor.commit();
                } catch (Exception e) {
                }
            } else {
                Toast.makeText(ServerFinder.this, getString(R.string.manual_ip_error_address),
                        Toast.LENGTH_LONG).show();
            }
        }
    }).setNegativeButton(R.string.manual_ip_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // do nothing
        }
    }).setCancelable(true).setTitle(R.string.manual_ip_label).setMessage(R.string.manual_ip_entry_label)
            .setView(view);
    return builder.create();
}

From source file:foam.opensauces.StarwispBuilder.java

public void Build(final StarwispActivity ctx, final String ctxname, JSONArray arr, ViewGroup parent) {

    try {//  w w w.  j a v a  2  s  .  com
        String type = arr.getString(0);

        //Log.i("starwisp","building started "+type);

        if (type.equals("build-fragment")) {
            String name = arr.getString(1);
            int ID = arr.getInt(2);
            Fragment fragment = ActivityManager.GetFragment(name);
            LinearLayout inner = new LinearLayout(ctx);
            inner.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            inner.setId(ID);
            FragmentTransaction fragmentTransaction = ctx.getSupportFragmentManager().beginTransaction();
            fragmentTransaction.add(ID, fragment);
            fragmentTransaction.commit();
            parent.addView(inner);
            return;
        }

        if (type.equals("linear-layout")) {
            LinearLayout v = new LinearLayout(ctx);
            v.setId(arr.getInt(1));
            v.setOrientation(BuildOrientation(arr.getString(2)));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            //v.setPadding(2,2,2,2);
            JSONArray col = arr.getJSONArray(4);
            v.setBackgroundColor(Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(5);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        if (type.equals("draggable")) {
            final LinearLayout v = new LinearLayout(ctx);
            final int id = arr.getInt(1);
            v.setPadding(20, 20, 20, 20);
            v.setId(id);
            v.setOrientation(BuildOrientation(arr.getString(2)));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            v.setClickable(true);
            v.setFocusable(true);

            JSONArray col = arr.getJSONArray(4);
            v.setBackgroundResource(R.drawable.draggable);

            GradientDrawable drawable = (GradientDrawable) v.getBackground();
            final int colour = Color.argb(col.getInt(3), col.getInt(0), col.getInt(1), col.getInt(2));
            drawable.setColor(colour);

            parent.addView(v);
            JSONArray children = arr.getJSONArray(5);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }

            // Sets a long click listener for the ImageView using an anonymous listener object that
            // implements the OnLongClickListener interface
            /*                v.setOnLongClickListener(new View.OnLongClickListener() {
            public boolean onLongClick(View vv) {
                if (id!=99) {
                    ClipData dragData = ClipData.newPlainText("simple text", ""+id);
                    View.DragShadowBuilder myShadow = new MyDragShadowBuilder(v);
                    Log.i("starwisp","start drag id "+vv.getId());
                    v.startDrag(dragData, myShadow, null, 0);
                    v.setVisibility(View.GONE);
                    return true;
                }
                return false;
            }
                            });
            */
            // Sets a long click listener for the ImageView using an anonymous listener object that
            // implements the OnLongClickListener interface
            v.setOnTouchListener(new View.OnTouchListener() {
                public boolean onTouch(View vv, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN && id != 99) {
                        //                            ClipData dragData = ClipData.newPlainText("simple text", ""+id);

                        ClipData dragData = new ClipData(
                                new ClipDescription(null, new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN }),
                                new ClipData.Item("" + id));

                        View.DragShadowBuilder myShadow = new MyDragShadowBuilder(v);
                        Log.i("starwisp", "start drag id " + vv.getId());
                        v.startDrag(dragData, myShadow, null, 0);
                        v.setVisibility(View.GONE);
                        return true;
                    }
                    return false;
                }
            });

            v.setOnDragListener(new View.OnDragListener() {
                public boolean onDrag(View vv, DragEvent event) {
                    final int action = event.getAction();
                    switch (action) {
                    case DragEvent.ACTION_DRAG_STARTED:
                        if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
                            // returns true to indicate that the View can accept the dragged data.
                            return true;
                        } else {
                            // Returns false. During the current drag and drop operation, this View will
                            // not receive events again until ACTION_DRAG_ENDED is sent.
                            return false;
                        }
                    case DragEvent.ACTION_DRAG_ENTERED: {
                        return true;
                    }
                    case DragEvent.ACTION_DRAG_LOCATION:
                        return true;
                    case DragEvent.ACTION_DRAG_EXITED: {
                        return true;
                    }
                    case DragEvent.ACTION_DROP: {
                        ClipData.Item item = event.getClipData().getItemAt(0);
                        String dragData = item.getText().toString();
                        Log.i("starwisp", "Dragged view is " + dragData);
                        int otherid = Integer.parseInt(dragData);
                        View otherw = ctx.findViewById(otherid);
                        Log.i("starwisp", "removing from parent " + ((View) otherw.getParent()).getId());

                        // check we are not adding to ourself
                        if (id != otherid) {
                            ((ViewManager) otherw.getParent()).removeView(otherw);
                            Log.i("starwisp", "adding to " + id);
                            v.addView(otherw);
                        }
                        otherw.setVisibility(View.VISIBLE);
                        return true;
                    }
                    case DragEvent.ACTION_DRAG_ENDED: {
                        if (event.getResult()) {
                        } else {
                        }
                        ;
                        return true;
                    }
                    // An unknown action type was received.
                    default:
                        Log.e("starwisp", "Unknown action type received by OnDragListener.");
                        break;
                    }
                    ;
                    return true;
                }
            });
            return;
        }

        if (type.equals("frame-layout")) {
            FrameLayout v = new FrameLayout(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        /*
        if (type.equals("grid-layout")) {
        GridLayout v = new GridLayout(ctx);
        v.setId(arr.getInt(1));
        v.setRowCount(arr.getInt(2));
        //v.setColumnCount(arr.getInt(2));
        v.setOrientation(BuildOrientation(arr.getString(3)));
        v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
                
        parent.addView(v);
        JSONArray children = arr.getJSONArray(5);
        for (int i=0; i<children.length(); i++) {
            Build(ctx,ctxname,new JSONArray(children.getString(i)), v);
        }
                
        return;
        }
        */

        if (type.equals("scroll-view")) {
            HorizontalScrollView v = new HorizontalScrollView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        if (type.equals("scroll-view-vert")) {
            ScrollView v = new ScrollView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
            JSONArray children = arr.getJSONArray(3);
            for (int i = 0; i < children.length(); i++) {
                Build(ctx, ctxname, new JSONArray(children.getString(i)), v);
            }
            return;
        }

        if (type.equals("view-pager")) {
            ViewPager v = new ViewPager(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            v.setOffscreenPageLimit(3);
            final JSONArray items = arr.getJSONArray(3);

            v.setAdapter(new FragmentPagerAdapter(ctx.getSupportFragmentManager()) {

                @Override
                public int getCount() {
                    return items.length();
                }

                @Override
                public Fragment getItem(int position) {
                    try {
                        String fragname = items.getString(position);
                        return ActivityManager.GetFragment(fragname);
                    } catch (JSONException e) {
                        Log.e("starwisp", "Error parsing data " + e.toString());
                    }
                    return null;
                }
            });
            parent.addView(v);
            return;
        }

        if (type.equals("space")) {
            // Space v = new Space(ctx); (class not found runtime error??)
            TextView v = new TextView(ctx);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            parent.addView(v);
        }

        if (type.equals("image-view")) {
            ImageView v = new ImageView(ctx);
            v.setId(arr.getInt(1));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));

            String image = arr.getString(2);

            if (image.startsWith("/")) {
                Bitmap bitmap = BitmapFactory.decodeFile(image);
                v.setImageBitmap(bitmap);
            } else {
                int id = ctx.getResources().getIdentifier(image, "drawable", ctx.getPackageName());
                v.setImageResource(id);
            }

            parent.addView(v);
        }

        if (type.equals("text-view")) {
            TextView v = new TextView(ctx);
            v.setId(arr.getInt(1));
            v.setText(Html.fromHtml(arr.getString(2)));
            v.setTextSize(arr.getInt(3));
            v.setMovementMethod(LinkMovementMethod.getInstance());
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setClickable(false);
            v.setEnabled(false);

            v.setOnTouchListener(new View.OnTouchListener() {
                public boolean onTouch(View vv, MotionEvent event) {
                    return false;
                }
            });

            if (arr.length() > 5) {
                if (arr.getString(5).equals("left")) {
                    v.setGravity(Gravity.LEFT);
                } else {
                    if (arr.getString(5).equals("fill")) {
                        v.setGravity(Gravity.FILL);
                    } else {
                        v.setGravity(Gravity.CENTER);
                    }
                }
            } else {
                v.setGravity(Gravity.LEFT);
            }
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            parent.addView(v);
        }

        if (type.equals("debug-text-view")) {
            TextView v = (TextView) ctx.getLayoutInflater().inflate(R.layout.debug_text, null);
            //                v.setBackgroundResource(R.color.black);
            v.setId(arr.getInt(1));
            //                v.setText(Html.fromHtml(arr.getString(2)));
            //                v.setTextColor(R.color.white);
            //                v.setTextSize(arr.getInt(3));
            //                v.setMovementMethod(LinkMovementMethod.getInstance());
            //                v.setMaxLines(10);
            //                v.setVerticalScrollBarEnabled(true);
            //                v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            //v.setMovementMethod(new ScrollingMovementMethod());

            /*
            if (arr.length()>5) {
            if (arr.getString(5).equals("left")) {
                v.setGravity(Gravity.LEFT);
            } else {
                if (arr.getString(5).equals("fill")) {
                    v.setGravity(Gravity.FILL);
                } else {
                    v.setGravity(Gravity.CENTER);
                }
            }
            } else {
            v.setGravity(Gravity.LEFT);
            }
            v.setTypeface(((StarwispActivity)ctx).m_Typeface);*/
            parent.addView(v);
        }

        if (type.equals("web-view")) {
            WebView v = new WebView(ctx);
            v.setId(arr.getInt(1));
            v.setVerticalScrollBarEnabled(false);
            v.loadData(arr.getString(2), "text/html", "utf-8");
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            parent.addView(v);
        }

        if (type.equals("edit-text")) {
            final EditText v = new EditText(ctx);
            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));

            String inputtype = arr.getString(4);
            if (inputtype.equals("text")) {
                //v.setInputType(InputType.TYPE_CLASS_TEXT);
            } else if (inputtype.equals("numeric")) {
                v.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            } else if (inputtype.equals("email")) {
                v.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
            }

            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(5)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(5);
            //v.setSingleLine(true);

            v.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    CallbackArgs(ctx, ctxname, v.getId(), "\"" + s.toString() + "\"");
                }

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

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });

            parent.addView(v);
        }

        if (type.equals("button")) {
            Button v = new Button(ctx);
            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(5);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Callback(ctx, ctxname, v.getId());
                }
            });

            parent.addView(v);
        }

        if (type.equals("toggle-button")) {
            ToggleButton v = new ToggleButton(ctx);
            if (arr.getString(5).equals("fancy")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_fancy, null);
            }

            if (arr.getString(5).equals("yes")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_yes, null);
            }

            if (arr.getString(5).equals("maybe")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_maybe, null);
            }

            if (arr.getString(5).equals("no")) {
                v = (ToggleButton) ctx.getLayoutInflater().inflate(R.layout.toggle_button_no, null);
            }

            v.setId(arr.getInt(1));
            v.setText(arr.getString(2));
            v.setTextSize(arr.getInt(3));
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
            v.setTypeface(((StarwispActivity) ctx).m_Typeface);
            final String fn = arr.getString(6);
            v.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    String arg = "#f";
                    if (((ToggleButton) v).isChecked())
                        arg = "#t";
                    CallbackArgs(ctx, ctxname, v.getId(), arg);
                }
            });
            parent.addView(v);
        }

        if (type.equals("seek-bar")) {
            SeekBar v = new SeekBar(ctx);
            v.setId(arr.getInt(1));
            v.setMax(arr.getInt(2));
            v.setProgress(arr.getInt(2) / 2);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            final String fn = arr.getString(4);

            v.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                public void onProgressChanged(SeekBar v, int a, boolean s) {
                    CallbackArgs(ctx, ctxname, v.getId(), Integer.toString(a));
                }

                public void onStartTrackingTouch(SeekBar v) {
                }

                public void onStopTrackingTouch(SeekBar v) {
                }
            });
            parent.addView(v);
        }

        if (type.equals("spinner")) {
            Spinner v = new Spinner(ctx);
            final int wid = arr.getInt(1);
            v.setId(wid);
            final JSONArray items = arr.getJSONArray(2);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(3)));
            ArrayList<String> spinnerArray = new ArrayList<String>();

            for (int i = 0; i < items.length(); i++) {
                spinnerArray.add(items.getString(i));
            }

            ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<String>(ctx, R.layout.spinner_item,
                    spinnerArray) {
                public View getView(int position, View convertView, ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    ((TextView) v).setTypeface(((StarwispActivity) ctx).m_Typeface);
                    return v;
                }
            };

            spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout);

            v.setAdapter(spinnerArrayAdapter);
            v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
                    try {
                        CallbackArgs(ctx, ctxname, wid, "\"" + items.getString(pos) + "\"");
                    } catch (JSONException e) {
                        Log.e("starwisp", "Error parsing data " + e.toString());
                    }
                }

                public void onNothingSelected(AdapterView<?> v) {
                }
            });

            parent.addView(v);
        }

        if (type.equals("canvas")) {
            StarwispCanvas v = new StarwispCanvas(ctx);
            final int wid = arr.getInt(1);
            v.setId(wid);
            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));
            v.SetDrawList(arr.getJSONArray(3));
            parent.addView(v);
        }

        if (type.equals("camera-preview")) {
            PictureTaker pt = new PictureTaker();
            CameraPreview v = new CameraPreview(ctx, pt);
            final int wid = arr.getInt(1);
            v.setId(wid);

            //              LinearLayout.LayoutParams lp =
            //  new LinearLayout.LayoutParams(minWidth, minHeight, 1);

            v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(2)));

            //                v.setLayoutParams(lp);
            parent.addView(v);
        }

        if (type.equals("button-grid")) {
            LinearLayout horiz = new LinearLayout(ctx);
            final int id = arr.getInt(1);
            final String buttontype = arr.getString(2);
            horiz.setId(id);
            horiz.setOrientation(LinearLayout.HORIZONTAL);
            parent.addView(horiz);
            int height = arr.getInt(3);
            int textsize = arr.getInt(4);
            LinearLayout.LayoutParams lp = BuildLayoutParams(arr.getJSONArray(5));
            JSONArray buttons = arr.getJSONArray(6);
            int count = buttons.length();
            int vertcount = 0;
            LinearLayout vert = null;

            for (int i = 0; i < count; i++) {
                JSONArray button = buttons.getJSONArray(i);

                if (vertcount == 0) {
                    vert = new LinearLayout(ctx);
                    vert.setId(0);
                    vert.setOrientation(LinearLayout.VERTICAL);
                    horiz.addView(vert);
                }
                vertcount = (vertcount + 1) % height;

                if (buttontype.equals("button")) {
                    Button b = new Button(ctx);
                    b.setId(button.getInt(0));
                    b.setText(button.getString(1));
                    b.setTextSize(textsize);
                    b.setLayoutParams(lp);
                    b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                    final String fn = arr.getString(6);
                    b.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            CallbackArgs(ctx, ctxname, id, "" + v.getId() + " #t");
                        }
                    });
                    vert.addView(b);
                } else if (buttontype.equals("toggle")) {
                    ToggleButton b = new ToggleButton(ctx);
                    b.setId(button.getInt(0));
                    b.setText(button.getString(1));
                    b.setTextSize(textsize);
                    b.setLayoutParams(lp);
                    b.setTypeface(((StarwispActivity) ctx).m_Typeface);
                    final String fn = arr.getString(6);
                    b.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            String arg = "#f";
                            if (((ToggleButton) v).isChecked())
                                arg = "#t";
                            CallbackArgs(ctx, ctxname, id, "" + v.getId() + " " + arg);
                        }
                    });
                    vert.addView(b);
                }
            }
        }

    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing [" + arr.toString() + "] " + e.toString());
    }

    //Log.i("starwisp","building ended");

}

From source file:eu.operando.operandoapp.OperandoProxyStatus.java

private void CheckPhoneNumber() {
    if (new RequestFilterUtil(MainActivity.this).getPhoneNumber().equals("")) {
        try {//w  w  w .j  av  a 2 s .c o m
            final EditText phoneInput = new EditText(MainActivity.this);
            phoneInput.setInputType(InputType.TYPE_CLASS_NUMBER);
            final File phoneFile = new File(getFilesDir(), "phonenumber.conf");
            if (!phoneFile.exists()) {
                new AlertDialog.Builder(MainActivity.this).setIcon(R.drawable.logo_bevel)
                        .setTitle("Input phone number")
                        .setMessage(
                                "The phone number could not be fetched automatically. Please input it below for automated exfiltration checks.")
                        .setView(phoneInput).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                try {
                                    FileOutputStream stream = null;
                                    try {
                                        stream = new FileOutputStream(phoneFile);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    stream.write(phoneInput.getText().toString().getBytes());
                                    stream.close();
                                    Toast.makeText(getApplicationContext(), "Phone number saved successfully",
                                            Toast.LENGTH_SHORT).show();
                                } catch (Exception e) {
                                    Toast.makeText(getApplicationContext(), "Something went wrong",
                                            Toast.LENGTH_SHORT).show();
                                }
                                //after phone parsing, load download initial settings
                                DownloadInitialSettings();
                            }
                        }).setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //nothing
                            }
                        }).show();
            }
        } catch (Exception e) {
            Log.d("ERROR", e.getMessage());
        }
    }
}

From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java

private void inflateProductiveCollectionTable(CollectionSheetResponse collectionSheetResponse) {

    //Clear old views in case they are present.
    if (tableProductive.getChildCount() > 0) {
        tableProductive.removeAllViews();
    }// www. j  a  va  2 s.co  m

    if (tableAdditional.getVisibility() == View.VISIBLE) {
        tableAdditional.removeAllViews();
        tableAdditional.setVisibility(View.GONE);
    }

    //A List to be used to inflate Attendance Spinners
    ArrayList<String> attendanceTypes = new ArrayList<>();
    attendanceTypeOptions.clear();
    attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(),
            attendanceTypes);

    //Add the heading Row
    TableRow headingRow = new TableRow(getContext());
    TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    headingRowParams.gravity = Gravity.CENTER;
    headingRowParams.setMargins(0, 0, 0, 10);
    headingRow.setLayoutParams(headingRowParams);

    TextView tvGroupName = new TextView(getContext());
    tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName());
    tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD);
    tvGroupName.setGravity(Gravity.CENTER);
    headingRow.addView(tvGroupName);

    for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) {
        TextView tvProduct = new TextView(getContext());
        tvProduct.setText(getString(R.string.collection_heading_charges, loanProduct.getName()));
        tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD);
        tvProduct.setGravity(Gravity.CENTER);
        headingRow.addView(tvProduct);
    }

    TextView tvAttendance = new TextView(getContext());
    tvAttendance.setText(getString(R.string.attendance));
    tvAttendance.setGravity(Gravity.CENTER);
    tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD);
    headingRow.addView(tvAttendance);

    tableProductive.addView(headingRow);

    for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0)
            .getClients()) {
        //Insert rows
        TableRow row = new TableRow(getContext());
        TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        rowParams.gravity = Gravity.CENTER;
        rowParams.setMargins(0, 0, 0, 10);
        row.setLayoutParams(rowParams);

        //Column 1: Client Name and Id
        TextView tvClientName = new TextView(getContext());
        tvClientName.setText(
                concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId()));
        row.addView(tvClientName);

        //Subsequent columns: The Loan products
        for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) {
            //Since there may be several items in this column, create a container.
            LinearLayout productContainer = new LinearLayout(getContext());
            productContainer.setOrientation(LinearLayout.HORIZONTAL);

            //Iterate through all the loans in of this type and add in the container
            for (LoanCollectionSheet loanCollectionSheet : clientCollectionSheet.getLoans()) {
                if (loanProduct.getName().equals(loanCollectionSheet.getProductShortName())) {
                    //This loan should be shown in this column. So, add it in the container.
                    EditText editText = new EditText(getContext());
                    editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
                    editText.setText(String.format(Locale.getDefault(), "%f", 0.0));
                    //Set the loan id as the Tag of the EditText which
                    //will later be used as the identifier for this.
                    editText.setTag(TYPE_LOAN + ":" + loanCollectionSheet.getLoanId());
                    productContainer.addView(editText);
                }
            }
            row.addView(productContainer);
        }

        Spinner spAttendance = new Spinner(getContext());
        setSpinner(spAttendance, attendanceTypes);
        row.addView(spAttendance);

        tableProductive.addView(row);
    }

    if (btnSubmitProductive.getVisibility() != View.VISIBLE) {
        //Show the button the first time sheet is loaded.
        btnSubmitProductive.setVisibility(View.VISIBLE);
        btnSubmitProductive.setOnClickListener(this);
    }

    //If this block has been executed, that the CollectionSheet
    //which is already shown on screen is for center - Productive.
    btnSubmitProductive.setTag(TAG_TYPE_PRODUCTIVE);
}