Example usage for android.widget RadioButton isChecked

List of usage examples for android.widget RadioButton isChecked

Introduction

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

Prototype

@ViewDebug.ExportedProperty
    @Override
    public boolean isChecked() 

Source Link

Usage

From source file:com.vkassin.mtrade.Common.java

public static void putOrder(final Context ctx, Quote quote) {

    final Instrument it = Common.selectedInstrument;// adapter.getItem(selectedRowId);

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.order_dialog);
    dialog.setTitle(R.string.OrderDialogTitle);

    datetxt = (EditText) dialog.findViewById(R.id.expdateedit);
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date dat1 = new Date();
    datetxt.setText(sdf.format(dat1));/*from  w  w  w  .j a va 2  s . c  o m*/
    mYear = dat1.getYear() + 1900;
    mMonth = dat1.getMonth();
    mDay = dat1.getDate();
    final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime();

    datetxt.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "Show DatePickerDialog");
            DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay);
            dpd.show();
        }
    });

    TextView itext = (TextView) dialog.findViewById(R.id.instrtext);
    itext.setText(it.symbol);

    final Spinner aspinner = (Spinner) dialog.findViewById(R.id.acc_spinner);
    List<String> list = new ArrayList<String>(Common.getAccountList());
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Common.app_ctx,
            android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    aspinner.setAdapter(dataAdapter);

    final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit);
    final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit);

    final Button buttonpm = (Button) dialog.findViewById(R.id.buttonPriceMinus);
    buttonpm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price -= 0.01;
                if (price < 0)
                    price = 0;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonpp = (Button) dialog.findViewById(R.id.buttonPricePlus);
    buttonpp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price += 0.01;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqm = (Button) dialog.findViewById(R.id.buttonQtyMinus);
    buttonqm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty -= 1;
                if (qty < 0)
                    qty = 0;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqp = (Button) dialog.findViewById(R.id.buttonQtyPlus);
    buttonqp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty += 1;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0);
    final RadioButton bu1 = (RadioButton) dialog.findViewById(R.id.radio1);

    if (quote != null) {

        // pricetxt.setText(quote.price.toString());
        pricetxt.setText(quote.getPriceS());
        if (quote.qtyBuy > 0) {

            quanttxt.setText(quote.qtyBuy.toString());
            bu1.setChecked(true);
            bu0.setChecked(false);

        } else {

            quanttxt.setText(quote.qtySell.toString());
            bu1.setChecked(false);
            bu0.setChecked(true);

        }
    }

    Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt);
    customDialog_Cancel.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.dismiss();
        }

    });

    Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder);
    customDialog_Put.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            Double price = new Double(0);
            Long qval = new Long(0);

            try {

                price = Double.valueOf(pricetxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
                return;
            }
            try {

                qval = Long.valueOf(quanttxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
                return;
            }

            if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay).getTime()) > 0) {

                Toast.makeText(ctx, R.string.CorrectDate, Toast.LENGTH_SHORT).show();

                return;

            }

            JSONObject msg = new JSONObject();
            try {

                msg.put("objType", Common.CREATE_REMOVE_ORDER);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("device", "Android");
                msg.put("instrumId", Long.valueOf(it.id));
                msg.put("price", price);
                msg.put("qty", qval);
                msg.put("ordType", 1);
                msg.put("side", bu0.isChecked() ? 0 : 1);
                msg.put("code", String.valueOf(aspinner.getSelectedItem()));
                msg.put("orderNum", ++ordernum);
                msg.put("action", "CREATE");
                boolean b = (((mYear - 1900) == dat.getYear()) && (mMonth == dat.getMonth())
                        && (mDay == dat.getDate()));
                if (!b)
                    msg.put("expired", String.format("%02d.%02d.%04d", mDay, mMonth + 1, mYear));

                if (isSSL) {

                    //                ? ?:    newOrder-orderNum-instrumId-side-price-qty-code-ordType
                    //               :                  newOrder-16807-20594623-0-1150-13-1027700451-1
                    String forsign = "newOrder-" + ordernum + "-" + msg.getString("instrumId") + "-"
                            + msg.getString("side") + "-"
                            + JSONObject.numberToString(Double.valueOf(msg.getDouble("price"))) + "-"
                            + msg.getString("qty") + "-" + msg.getString("code") + "-"
                            + msg.getString("ordType");
                    byte[] signed = Common.signText(Common.signProfile, forsign.getBytes(), true);
                    String gsign = Base64.encodeToString(signed, Base64.DEFAULT);
                    msg.put("gostSign", gsign);
                }
                mainActivity.writeJSONMsg(msg);

            } catch (Exception e) {

                e.printStackTrace();
                Log.e(TAG, "Error! Cannot create JSON order object", e);
            }

            dialog.dismiss();
        }

    });

    dialog.show();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    dialog.getWindow().setAttributes(lp);

}

From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseFragment.java

@Nullable
@Override/* w  w w  . j  a  v  a 2s  .  c  o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view);
    emptyTV = (TextView) root.findViewById(R.id.empty);
    arrow = (ImageView) root.findViewById(R.id.arrow);
    setRecyclerViewAdapter();

    FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab);
    addPurchaseFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            List<String> nseList = ShareUtils.getNseList(getContext());
            FilterWithSpaceAdapter<String> arrayAdapter = new FilterWithSpaceAdapter<>(getContext(),
                    android.R.layout.simple_dropdown_item_1line, nseList);
            name.setThreshold(1);
            name.setAdapter(arrayAdapter);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);

            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            if (shares.size() == 0)
                existingRB.setVisibility(View.GONE);
            (newRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.VISIBLE);
                    spinner.setVisibility(View.GONE);
                }
            });

            (existingRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.GONE);
                    spinner.setVisibility(View.VISIBLE);
                }
            });

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Share share = new Share();
                    share.setId(databaseHandler.getNextKey("share"));
                    share.setPurchases(new RealmList<Purchase>());
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));

                    if (newRB.isChecked()) {
                        String sName = name.getText().toString().trim();
                        if (sName.equals("")) {
                            Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show();
                            return;
                        } else {
                            share.setName(sName);
                            purchase.setName(sName);
                        }
                    }

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        share.setDateOfInitialPurchase(date);
                        purchase.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.buying_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("buy");
                    if (newRB.isChecked()) {
                        if (!databaseHandler.addShare(share, purchase)) {
                            Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        purchase.setName(spinner.getSelectedItem().toString());
                        databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    }
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:at.flack.MailMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    prefs = getActivity().getSharedPreferences("mail", Context.MODE_PRIVATE);
    if (!prefs.getString("mailaddress", "").equals("")) {
        View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false);

        loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
        contactList = (ListView) rootView.findViewById(R.id.listview);
        TextView padding = new TextView(getActivity());
        padding.setHeight(10);/*from w ww.  j  a  v a  2  s .  c  o  m*/
        contactList.addHeaderView(padding);
        contactList.setHeaderDividersEnabled(false);
        contactList.addFooterView(loadmore.getView(), null, false);
        contactList.setFooterDividersEnabled(false);
        progressbar = rootView.findViewById(R.id.load_screen);
        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToListView(contactList);
        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent newMail = new Intent(getActivity(), NewMailActivity.class);
                getActivity().startActivity(newMail);
            }
        });

        progressbar = rootView.findViewById(R.id.load_screen);
        if (MainActivity.getMailcontacts() == null)
            progressbar.setVisibility(View.VISIBLE);
        updateContactList(((MainActivity) this.getActivity()));

        swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (getActivity() instanceof MainActivity) {
                    MainActivity.mailprofile = null;
                    ((MainActivity) getActivity()).emailLogin(1, 0, limit);
                }

            }
        });
        contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                        : contactList.getChildAt(0).getTop();
                swipe.setEnabled(topRowVerticalPosition >= 0);
            }
        });

        contactList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (MainActivity.getListItems() == null) {
                    updateContactList((MainActivity) getActivity());
                }
                openMessageActivity(getActivity(), arg2 - 1);
            }

        });

        loadmore.getView().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                loadmore.setEnabled(false);
                MainActivity.mailprofile = null;
                limit += 12;
                ((MainActivity) getActivity()).emailLogin(1, 0, limit);
            }
        });

        setRetainInstance(true);
        return rootView;
    } else {
        View rootView = inflater.inflate(R.layout.fragment_email_login, container, false);
        final EditText mail = (EditText) rootView.findViewById(R.id.email);
        final EditText password = (EditText) rootView.findViewById(R.id.password);

        final EditText host = (EditText) rootView.findViewById(R.id.host);
        final EditText port = (EditText) rootView.findViewById(R.id.port);
        final EditText smtphost = (EditText) rootView.findViewById(R.id.smtphost);
        final EditText smtpport = (EditText) rootView.findViewById(R.id.smtpport);

        final Button login_button = (Button) rootView.findViewById(R.id.login_button);

        final RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radioGroup);
        final RadioButton imap = (RadioButton) rootView.findViewById(R.id.radioButtonImap);

        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                host.setVisibility(View.VISIBLE);
                port.setVisibility(View.VISIBLE);
                smtphost.setVisibility(View.VISIBLE);
                smtpport.setVisibility(View.VISIBLE);
            }
        });

        login_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int at = mail.getText().toString().indexOf("@");
                int dot = mail.getText().toString().lastIndexOf(".");
                if (mail.getText().length() <= 0 || at < 0 || dot < 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_mail),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                if (password.getText().length() <= 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_pw),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                String hostPart = mail.getText().toString().substring(at + 1, dot);

                MailAccounts mailacc = null;
                try {
                    mailacc = MailAccounts.valueOf(hostPart.toUpperCase(Locale.GERMAN));
                } catch (IllegalArgumentException e) {
                }
                if (mailacc == null) {
                    radioGroup.setVisibility(View.VISIBLE);
                    if (host.getText().toString().isEmpty() || port.getText().toString().isEmpty()
                            || smtphost.getText().toString().isEmpty()
                            || smtpport.getText().toString().isEmpty()) {
                        Toast.makeText(MailMainActivity.this.getActivity(),
                                MailMainActivity.this.getActivity().getResources().getString(
                                        R.string.activity_mail_enter_more_information),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                    prefs.edit().putString("mailsmtp", smtphost.getText().toString()).apply();
                    prefs.edit().putInt("mailsmtpport", Integer.parseInt(smtpport.getText().toString()));
                    prefs.edit().putString("mailimap", host.getText().toString()).apply();
                    prefs.edit().putInt("mailimapport", Integer.parseInt(port.getText().toString())).apply();
                    prefs.edit().putBoolean("mailuseimap", imap.isChecked()).apply();
                }

                login_button.setEnabled(false);
                login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
                prefs.edit().putString("mailaddress", mail.getText().toString()).apply();
                prefs.edit().putString("mailpassword", password.getText().toString()).apply();

                if (mailacc != null) {
                    prefs.edit().putString("mailsmtp", mailacc.getSmtpHost()).apply();
                    prefs.edit().putInt("mailsmtpport", mailacc.getSMTPPort());
                    prefs.edit().putString("mailimap", mailacc.getHost()).apply();
                    prefs.edit().putInt("mailimapport", mailacc.getPort()).apply();
                    prefs.edit().putBoolean("mailuseimap", true).apply();
                }

                prefs.edit().commit();
                ((MainActivity) getActivity()).emailLogin(0);
            }
        });

        setRetainInstance(true);

        return rootView;
    }
}

From source file:cm.aptoide.pt.MainActivity.java

private void displayOptionsDialog() {

    final SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(this);
    final Editor editor = sPref.edit();

    View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_order_popup, null);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(view);
    final AlertDialog orderDialog = dialogBuilder.create();
    orderDialog.setIcon(android.R.drawable.ic_menu_sort_by_size);
    orderDialog.setTitle(getString(R.string.menu_display_options));
    orderDialog.setCancelable(true);/*from  w  ww  .  j a va2 s . co  m*/

    final RadioButton ord_rct = (RadioButton) view.findViewById(R.id.org_rct);
    final RadioButton ord_abc = (RadioButton) view.findViewById(R.id.org_abc);
    final RadioButton ord_rat = (RadioButton) view.findViewById(R.id.org_rat);
    final RadioButton ord_dwn = (RadioButton) view.findViewById(R.id.org_dwn);
    final RadioButton ord_price = (RadioButton) view.findViewById(R.id.org_price);
    final RadioButton btn1 = (RadioButton) view.findViewById(R.id.shw_ct);
    final RadioButton btn2 = (RadioButton) view.findViewById(R.id.shw_all);

    final ToggleButton adult = (ToggleButton) view.findViewById(R.id.adultcontent_toggle);

    orderDialog.setButton(Dialog.BUTTON_NEUTRAL, "Ok", new Dialog.OnClickListener() {
        boolean pop_change = false;
        private boolean pop_change_category = false;

        public void onClick(DialogInterface dialog, int which) {
            if (ord_rct.isChecked()) {
                pop_change = true;
                order = Order.DATE;
            } else if (ord_abc.isChecked()) {
                pop_change = true;
                order = Order.NAME;
            } else if (ord_rat.isChecked()) {
                pop_change = true;
                order = Order.RATING;
            } else if (ord_dwn.isChecked()) {
                pop_change = true;
                order = Order.DOWNLOADS;
            } else if (ord_price.isChecked()) {
                pop_change = true;
                order = Order.PRICE;
            }

            if (btn1.isChecked()) {
                pop_change = true;
                pop_change_category = true;
                editor.putBoolean("orderByCategory", true);
            } else if (btn2.isChecked()) {
                pop_change = true;
                pop_change_category = true;
                editor.putBoolean("orderByCategory", false);
            }
            if (adult.isChecked()) {
                pop_change = true;
                editor.putBoolean("matureChkBox", false);
            } else {
                editor.putBoolean("matureChkBox", true);
            }
            if (pop_change) {
                editor.putInt("order_list", order.ordinal());
                editor.commit();
                if (pop_change_category) {

                    if (!depth.equals(ListDepth.CATEGORY1) && !depth.equals(ListDepth.STORES)) {
                        if (depth.equals(ListDepth.APPLICATIONS)) {
                            removeLastBreadCrumb();
                        }
                        removeLastBreadCrumb();
                        depth = ListDepth.CATEGORY1;
                    }

                }
                redrawAll();
                refreshAvailableList(true);
            }
        }
    });

    if (sPref.getBoolean("orderByCategory", false)) {
        btn1.setChecked(true);
    } else {
        btn2.setChecked(true);
    }
    if (!ApplicationAptoide.MATURECONTENTSWITCH) {
        adult.setVisibility(View.GONE);
        view.findViewById(R.id.dialog_adult_content_label).setVisibility(View.GONE);
    }
    adult.setChecked(!sPref.getBoolean("matureChkBox", false));
    // adult.setOnCheckedChangeListener(adultCheckedListener);
    switch (order) {
    case DATE:
        ord_rct.setChecked(true);
        break;
    case DOWNLOADS:
        ord_dwn.setChecked(true);
        break;
    case NAME:
        ord_abc.setChecked(true);
        break;
    case RATING:
        ord_rat.setChecked(true);
        break;
    case PRICE:
        ord_price.setChecked(true);
        break;

    default:
        break;
    }

    orderDialog.show();

}

From source file:cl.gisred.android.InspActivity.java

private void cerrarFormCrear(boolean bSave, View v, int idR) {
    if (bSave) {/*from  ww  w  . j  av  a  2s  .  c  om*/
        if (!validarForm(v)) {
            DialogoConfirmacion oDialog = new DialogoConfirmacion();
            oDialog.show(getFragmentManager(), "tagAlert");
            return;
        } else {

            Resources res = getResources();
            InputStream in_s = res.openRawResource(R.raw.index);
            try {
                View vAction = getLayoutValidate(v);
                byte[] b = new byte[in_s.available()];
                in_s.read(b);
                String sHtml = new String(b);
                HtmlUtils oHtml = new HtmlUtils(getApplicationContext(), sHtml);

                String sValueNumMed = "null";

                for (View view : vAction.getTouchables()) {

                    if (view.getClass().getGenericSuperclass().equals(EditText.class)) {
                        EditText oText = (EditText) view;
                        if (!oText.getText().toString().trim().isEmpty()) {
                            String sMapvalue = HtmlUtils.getMapvalue(oText.getId());
                            String sValorChr = oText.getText().toString();
                            oHtml.setValueById(sMapvalue, "txt", sValorChr);
                            if (oText.getId() == R.id.txtOT) {
                                sValueNumMed = sValorChr;
                            }

                            if (sMapvalue != null && sMapvalue.contains("txt_trabajo_cant")) {
                                try {
                                    double dValue = Double.valueOf(sValorChr);
                                    oHtml.sumHH += dValue;
                                } catch (Exception ex) {
                                    Log.e("Double Convert", "error: " + ex.getMessage());
                                }
                            }
                        }
                    } else if (view.getClass().getGenericSuperclass().equals(CheckBox.class)) {
                        CheckBox oCheck = (CheckBox) view;
                        String sCheck = HtmlUtils.getMapvalue(oCheck.getId());
                        sCheck += oCheck.isChecked() ? "si" : "no";
                        oHtml.setValueById(sCheck, "chk", "");
                    } else if (view.getClass().getGenericSuperclass().equals(Spinner.class)) {
                        Spinner oSpinner = (Spinner) view;
                        oHtml.setValueById(HtmlUtils.getMapvalue(oSpinner.getId()), "txt",
                                oSpinner.getSelectedItem().toString());
                    } else if (view.getClass().getGenericSuperclass().equals(RadioButton.class)) {
                        RadioButton oRadioButton = (RadioButton) view;
                        if (oRadioButton.isChecked()) {
                            String sRadio = HtmlUtils
                                    .getMapvalue(((RadioGroup) oRadioButton.getParent()).getId());
                            sRadio += oRadioButton.getText().toString().toLowerCase().replace(" ", "");
                            oHtml.setValueById(sRadio, "rad", "");
                        }
                    } else if (view.getClass().getGenericSuperclass().equals(ImageView.class)) {
                    }
                }

                //SUMA TOTAL HH
                oHtml.setValueById("txt_trabajo_cant_tot", "txt", "" + oHtml.sumHH);

                //VALIDAR FIRMAS
                if (valImage(vAction, R.id.imgFirmaIns))
                    oHtml.setValueById("firm_prop", "img", String.format("%s.jpg", R.id.imgFirmaIns));
                if (valImage(vAction, R.id.imgFirmaTec))
                    oHtml.setValueById("firm_tecn", "img", String.format("%s.jpg", R.id.imgFirmaTec));

                if (valImage(vAction, R.id.imgPhoto1))
                    oHtml.setValueById("foto_1", "img", "foto1.jpg");
                if (valImage(vAction, R.id.imgPhoto2))
                    oHtml.setValueById("foto_2", "img", "foto2.jpg");
                if (valImage(vAction, R.id.imgPhoto3))
                    oHtml.setValueById("foto_3", "img", "foto3.jpg");

                oHtml.setTitleHtml(sValueNumMed);

                String sHtmlFinal = oHtml.getHtmlFinal();

                //guardar en disco
                oHtml.createHtml(sHtmlFinal);

                //VIA CustomTabs
                /*String url = oHtml.getPathHtml();
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
                CustomTabsIntent customTabsIntent = builder.build();
                customTabsIntent.launchUrl(this, Uri.parse(url));*/

                //VIA CHROME scheme
                if (Util.isPackageExisted("com.android.chrome", this)) {
                    String url = oHtml.getPathHtml();

                    File f = new File(url);

                    MimeTypeMap mime = MimeTypeMap.getSingleton();
                    String ext = f.getName().substring(f.getName().lastIndexOf(".") + 1);
                    String type = mime.getMimeTypeFromExtension(ext);

                    Uri uri = Uri.parse("googlechrome://navigate?url=" + url);

                    Intent in = new Intent(Intent.ACTION_VIEW);
                    //in.setDataAndType(uri, "text/html");

                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    in.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

                    //Uri uriExternal = FileProvider.getUriForFile(getApplicationContext(), "cl.gisred.android", f);

                    in.setDataAndType(uri, type);

                    //startActivity(in);
                    startActivity(Intent.createChooser(in, "Escoja Chrome"));
                } else {
                    Toast.makeText(this, "Debe instalar Chrome, solo preview disponible", Toast.LENGTH_LONG)
                            .show();
                    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(oHtml.getPathHtml()));
                    startActivity(myIntent);
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    menuMultipleActions.setVisibility(View.VISIBLE);
    menuInspeccionActions.setVisibility(View.VISIBLE);
    fabShowForm.setVisibility(View.GONE);
    formCrear.dismiss();
}

From source file:usbong.android.likha_collection_1.UsbongDecisionTreeEngineActivity.java

public void processNextButtonPressed() {
    wasNextButtonPressed = true;/*  w w w . j a  va2 s  .c  o m*/
    hasUpdatedDecisionTrackerContainer = false;

    //edited by Mike, 20160417
    if ((mTts != null) && (mTts.isSpeaking())) {
        mTts.stop();
    }
    //edited by Mike, 20160417
    if ((myMediaPlayer != null) && (myMediaPlayer.isPlaying())) {
        myMediaPlayer.stop();
    }

    if (currAudioRecorder != null) {
        try {
            //if stop button is pressable
            if (stopButton.isEnabled()) {
                currAudioRecorder.stop();
            }
            if (currAudioRecorder.isPlaying()) {
                currAudioRecorder.stopPlayback();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        String path = currAudioRecorder.getPath();
        //               System.out.println(">>>>>>>>>>>>>>>>>>>currAudioRecorder: "+currAudioRecorder);
        if (!attachmentFilePaths.contains(path)) {
            attachmentFilePaths.add(path);
            //                  System.out.println(">>>>>>>>>>>>>>>>adding path: "+path);
        }
    }

    //END_STATE_SCREEN = last screen
    if (currScreen == UsbongConstants.END_STATE_SCREEN) {
        int usbongAnswerContainerSize = usbongAnswerContainer.size();
        StringBuffer outputStringBuffer = new StringBuffer();
        for (int i = 0; i < usbongAnswerContainerSize; i++) {
            outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
        }

        myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
        if (UsbongUtils.STORE_OUTPUT) {
            try {
                UsbongUtils.createNewOutputFolderStructure();
            } catch (Exception e) {
                e.printStackTrace();
            }
            UsbongUtils.storeOutputInSDCard(
                    UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getDateTimeStamp() + ".csv",
                    outputStringBuffer.toString());
        } else {
            UsbongUtils.deleteRecursive(new File(UsbongUtils.BASE_FILE_PATH + myOutputDirectory));
        }

        //wasNextButtonPressed=false; //no need to make this true, because this is the last node
        hasUpdatedDecisionTrackerContainer = true;

        /*
        //send to server
        UsbongUtils.performFileUpload(UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getTimeStamp() + ".csv");
                 
        //send to email
        Intent emailIntent = UsbongUtils.performEmailProcess(UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getTimeStamp() + ".csv", attachmentFilePaths);
        emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        //                emailIntent.addFlags(RESULT_OK);
        startActivityForResult(Intent.createChooser(emailIntent, "Email:"),EMAIL_SENDING_SUCCESS);
        */

        //added by Mike, Sept. 10, 2014
        UsbongUtils.clearTempFolder();

        //added by Mike, 20160415
        if (UsbongUtils.IS_IN_AUTO_LOOP_MODE) {
            //added by Mike, 20161118
            AppRater.showRateDialog(this);

            isAutoLoopedTree = true;
            initParser(myTree);
            return;
        } else {
            //return to main activity
            finish();
            //added by Mike, 20161118
            Intent toUsbongMainActivityIntent = new Intent(UsbongDecisionTreeEngineActivity.this,
                    UsbongMainActivity.class);
            toUsbongMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            toUsbongMainActivityIntent.putExtra("completed_tree", "true");
            startActivity(toUsbongMainActivityIntent);
        }
    } else {
        if (currScreen == UsbongConstants.YES_NO_DECISION_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;

                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.SEND_TO_WEBSERVER_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;
                //                     usbongAnswerContainer.addElement("Y;");         
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                decisionTrackerContainer.addElement(usbongAnswerContainer.lastElement());
                //                     wasNextButtonPressed=false; //no need to make this true, because "Y;" has already been added to decisionTrackerContainer
                hasUpdatedDecisionTrackerContainer = true;

                //edited by Mike, March 4, 2013
                //"save" the output into the SDCard as "output.txt"
                //                      int usbongAnswerContainerSize = usbongAnswerContainer.size();
                int usbongAnswerContainerSize = usbongAnswerContainerCounter;

                StringBuffer outputStringBuffer = new StringBuffer();
                for (int i = 0; i < usbongAnswerContainerSize; i++) {
                    outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
                }

                myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
                try {
                    UsbongUtils.createNewOutputFolderStructure();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                UsbongUtils.storeOutputInSDCard(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv", outputStringBuffer.toString());

                //send to server
                UsbongUtils.performFileUpload(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv");
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                       else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                //                      initParser();            
            }
            initParser();
        } else if (currScreen == UsbongConstants.SEND_TO_CLOUD_BASED_SERVICE_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;
                //                     usbongAnswerContainer.addElement("Y;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                decisionTrackerContainer.addElement(usbongAnswerContainer.lastElement());
                //                     wasNextButtonPressed=false; //no need to make this true, because "Y;" has already been added to decisionTrackerContainer
                hasUpdatedDecisionTrackerContainer = true;

                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < decisionTrackerContainer.size(); i++) {
                    sb.append(decisionTrackerContainer.elementAt(i));
                }
                Log.d(">>>>>>>>>>>>>decisionTrackerContainer", sb.toString());

                //edited by Mike, March 4, 2013
                //"save" the output into the SDCard as "output.txt"
                //                      int usbongAnswerContainerSize = usbongAnswerContainer.size();
                int usbongAnswerContainerSize = usbongAnswerContainerCounter;

                StringBuffer outputStringBuffer = new StringBuffer();
                for (int i = 0; i < usbongAnswerContainerSize; i++) {
                    outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
                }

                myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
                try {
                    UsbongUtils.createNewOutputFolderStructure();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                UsbongUtils.storeOutputInSDCard(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv", outputStringBuffer.toString());

                //send to cloud-based service
                Intent sendToCloudBasedServiceIntent = UsbongUtils
                        .performSendToCloudBasedServiceProcess(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                                + UsbongUtils.getDateTimeStamp() + ".csv", attachmentFilePaths);
                /*emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                */
                //                      emailIntent.addFlags(RESULT_OK);
                //                      startActivityForResult(Intent.createChooser(emailIntent, "Email:"),EMAIL_SENDING_SUCCESS);
                //answer from Llango J, stackoverflow
                //Reference: http://stackoverflow.com/questions/7479883/problem-with-sending-email-goes-back-to-previous-activity;
                //last accessed: 22 Oct. 2012
                startActivity(
                        Intent.createChooser(sendToCloudBasedServiceIntent, "Send to Cloud-based Service:"));
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                       else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                //                      initParser();            

                /*
                                       if (!isAnOptionalNode) {
                  showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                 wasNextButtonPressed=false;
                 hasUpdatedDecisionTrackerContainer=true;
                         
                 return;
                                       }
                                       else {
                 currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                //                        usbongAnswerContainer.addElement("A;");                                             
                 UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                        
                initParser();            
                                       }
                */
            }
            /*                    
                              currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                              usbongAnswerContainer.addElement("Any;");                                             
            */
            initParser();
        } else if (currScreen == UsbongConstants.MULTIPLE_CHECKBOXES_SCREEN) {
            //                   requiredTotalCheckedBoxes   
            LinearLayout myMultipleCheckboxesLinearLayout = (LinearLayout) findViewById(
                    R.id.multiple_checkboxes_linearlayout);
            StringBuffer sb = new StringBuffer();
            int totalCheckedBoxes = 0;
            int totalCheckBoxChildren = myMultipleCheckboxesLinearLayout.getChildCount();
            //begin with i=1, because i=0 is for checkboxes_textview
            for (int i = 1; i < totalCheckBoxChildren; i++) {
                if (((CheckBox) myMultipleCheckboxesLinearLayout.getChildAt(i)).isChecked()) {
                    totalCheckedBoxes++;
                    sb.append("," + (i - 1)); //do a (i-1) so that i starts with 0 for the checkboxes (excluding checkboxes_textview) to maintain consistency with the other components
                }
            }

            if (totalCheckedBoxes >= requiredTotalCheckedBoxes) {
                currUsbongNode = nextUsbongNodeIfYes;
                sb.insert(0, "Y"); //insert in front of stringBuffer
                sb.append(";");
            } else {
                currUsbongNode = nextUsbongNodeIfNo;
                sb.delete(0, sb.length());
                sb.append("N,;"); //make sure to add the comma
            }
            //                   usbongAnswerContainer.addElement(sb.toString());
            UsbongUtils.addElementToContainer(usbongAnswerContainer, sb.toString(),
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        } else if (currScreen == UsbongConstants.MULTIPLE_RADIO_BUTTONS_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            //                   if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                         usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
            //                   }
            /*                   
                               else {
            //                      usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
              UsbongUtils.addElementToContainer(usbongAnswerContainer, myRadioGroup.getCheckedRadioButtonId()+";", usbongAnswerContainerCounter);
             usbongAnswerContainerCounter++;
                      
              initParser();                      
                               }
            */
        } else if (currScreen == UsbongConstants.MULTIPLE_RADIO_BUTTONS_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            /*                   if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
             */
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked                                                  
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                if (myMultipleRadioButtonsWithAnswerScreenAnswer
                        .equals("" + myRadioGroup.getCheckedRadioButtonId())) {
                    currUsbongNode = nextUsbongNodeIfYes;
                    UsbongUtils.addElementToContainer(usbongAnswerContainer,
                            "Y," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                } else {
                    currUsbongNode = nextUsbongNodeIfNo;
                    UsbongUtils.addElementToContainer(usbongAnswerContainer,
                            "N," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                }

                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if (currScreen == UsbongConstants.LINK_SCREEN) {
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            try {
                currUsbongNode = UsbongUtils.getLinkFromRadioButton(
                        radioButtonsContainer.elementAt(myRadioGroup.getCheckedRadioButtonId()));
            } catch (Exception e) {
                //if the user hasn't ticked any radio button yet
                //put the currUsbongNode to default
                //                currUsbongNode = UsbongUtils.getLinkFromRadioButton(nextUsbongNodeIfYes); //nextUsbongNodeIfNo will also do, since this is "Any"
                //of course, showPleaseAnswerAlert() will be called                        
                //edited by Mike, 20160613
                //don't change the currUsbongNode anymore if no radio button has been ticked                
            }

            //                   Log.d(">>>>>>>>>>currUsbongNode",currUsbongNode);
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked
                //                         if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                if (!isAnOptionalNode) {
                    showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                    wasNextButtonPressed = false;
                    hasUpdatedDecisionTrackerContainer = true;

                    return;
                }
                //                         }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                         usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
            /*                   }
                               else {
              usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
               initParser();                      
                               }
            */
        } else if ((currScreen == UsbongConstants.TEXTFIELD_SCREEN)
                || (currScreen == UsbongConstants.TEXTFIELD_WITH_UNIT_SCREEN)
                || (currScreen == UsbongConstants.TEXTFIELD_NUMERICAL_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            EditText myTextFieldScreenEditText = (EditText) findViewById(R.id.textfield_edittext);

            //                    if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            //if it's blank
            if (myTextFieldScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                //                           usbongAnswerContainer.addElement("A;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A,;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                        usbongAnswerContainer.addElement("A,"+myTextFieldScreenEditText.getText()+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextFieldScreenEditText.getText() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.TEXTFIELD_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            EditText myTextFieldScreenEditText = (EditText) findViewById(R.id.textfield_edittext);
            //if it's blank
            if (myTextFieldScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else {
                //added by Mike, Jan. 27, 2014
                Vector<String> myPossibleAnswers = new Vector<String>();
                StringTokenizer myPossibleAnswersStringTokenizer = new StringTokenizer(
                        myTextFieldWithAnswerScreenAnswer, "||");
                if (myPossibleAnswersStringTokenizer != null) {
                    while (myPossibleAnswersStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                        myPossibleAnswers.add(myPossibleAnswersStringTokenizer.nextToken());
                    }
                }
                int size = myPossibleAnswers.size();
                for (int i = 0; i < size; i++) {
                    if (myPossibleAnswers.elementAt(i)
                            .equals(myTextFieldScreenEditText.getText().toString().trim())) {
                        currUsbongNode = nextUsbongNodeIfYes;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "Y," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                        break;
                    }

                    if (i == size - 1) { //if this is the last element in the vector
                        currUsbongNode = nextUsbongNodeIfNo;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "N," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                    }
                }
                /*                        
                  if (myTextFieldWithAnswerScreenAnswer.equals(myTextFieldScreenEditText.getText().toString().trim())) {
                   currUsbongNode = nextUsbongNodeIfYes;    
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y,"+myTextFieldScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }
                  else {
                   currUsbongNode = nextUsbongNodeIfNo;                                               
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "N,"+myTextFieldScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }                    
                */
                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if ((currScreen == UsbongConstants.TEXTAREA_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            EditText myTextAreaScreenEditText = (EditText) findViewById(R.id.textarea_edittext);

            //                    if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            //if it's blank
            if (myTextAreaScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A,;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                        usbongAnswerContainer.addElement("A,"+myTextAreaScreenEditText.getText()+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextAreaScreenEditText.getText() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.TEXTAREA_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            EditText myTextAreaScreenEditText = (EditText) findViewById(R.id.textarea_edittext);
            //if it's blank
            if (myTextAreaScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else {
                /*                        
                  if (myTextAreaWithAnswerScreenAnswer.equals(myTextAreaScreenEditText.getText().toString().trim())) {
                   currUsbongNode = nextUsbongNodeIfYes;    
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y,"+myTextAreaScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }
                  else {
                   currUsbongNode = nextUsbongNodeIfNo;                                               
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "N,"+myTextAreaScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }                    
                */
                //added by Mike, Jan. 27, 2014
                Vector<String> myPossibleAnswers = new Vector<String>();
                StringTokenizer myPossibleAnswersStringTokenizer = new StringTokenizer(
                        myTextAreaWithAnswerScreenAnswer, "||");
                if (myPossibleAnswersStringTokenizer != null) {
                    while (myPossibleAnswersStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textAreaWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike||mike")
                        myPossibleAnswers.add(myPossibleAnswersStringTokenizer.nextToken());
                    }
                }
                int size = myPossibleAnswers.size();
                for (int i = 0; i < size; i++) {
                    //                           Log.d(">>>>>>myPossibleAnswers: ",myPossibleAnswers.elementAt(i));
                    if (myPossibleAnswers.elementAt(i)
                            .equals(myTextAreaScreenEditText.getText().toString().trim())) {
                        currUsbongNode = nextUsbongNodeIfYes;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "Y," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                        break;
                    }

                    if (i == size - 1) { //if this is the last element in the vector
                        currUsbongNode = nextUsbongNodeIfNo;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "N," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                    }
                }
                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if (currScreen == UsbongConstants.GPS_LOCATION_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            TextView myLongitudeTextView = (TextView) findViewById(R.id.longitude_textview);
            TextView myLatitudeTextView = (TextView) findViewById(R.id.latitude_textview);

            //                  usbongAnswerContainer.addElement(myLongitudeTextView.getText()+","+myLatitudeTextView.getText()+";");                     
            UsbongUtils.addElementToContainer(usbongAnswerContainer,
                    "A," + myLongitudeTextView.getText() + "," + myLatitudeTextView.getText() + ";",
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();

        } else if (currScreen == UsbongConstants.SIMPLE_ENCRYPT_SCREEN) {
            EditText myPinEditText = (EditText) findViewById(R.id.pin_edittext);

            if (myPinEditText.getText().toString().length() != 4) {
                String message = "";
                if (currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageFILIPINO);
                } else if (currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageJAPANESE);
                } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageENGLISH);
                }

                new AlertDialog.Builder(UsbongDecisionTreeEngineActivity.this).setTitle("Hey!")
                        .setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            } else {
                int yourKey = Integer.parseInt(myPinEditText.getText().toString());
                currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do

                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                //                  Log.d(">>>>>>>start encode","encode");
                for (int i = 0; i < usbongAnswerContainerCounter; i++) {
                    try {
                        usbongAnswerContainer.set(i, UsbongUtils.performSimpleFileEncrypt(yourKey,
                                usbongAnswerContainer.elementAt(i)));
                        //                        Log.d(">>>>>>"+i,""+usbongAnswerContainer.get(i));
                        //                        Log.d(">>>decoded"+i,""+UsbongUtils.performSimpleFileDecode(yourKey, usbongAnswerContainer.get(i)));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                initParser();
            }
        } else if (currScreen == UsbongConstants.DATE_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            //added by Mike, 13 Oct. 2015
            DatePicker myDatePicker = (DatePicker) findViewById(R.id.date_picker);
            UsbongUtils.addElementToContainer(usbongAnswerContainer, "A," + myDatePicker.getMonth()
                    + myDatePicker.getDayOfMonth() + "," + myDatePicker.getYear() + ";",
                    usbongAnswerContainerCounter);

            /*                   
                         Spinner dateMonthSpinner = (Spinner) findViewById(R.id.date_month_spinner);
                          Spinner dateDaySpinner = (Spinner) findViewById(R.id.date_day_spinner);
                          EditText myDateYearEditText = (EditText)findViewById(R.id.date_edittext);
            //             usbongAnswerContainer.addElement("A,"+monthAdapter.getItem(dateMonthSpinner.getSelectedItemPosition()).toString() +
            //                                      dayAdapter.getItem(dateDaySpinner.getSelectedItemPosition()).toString() + "," +
            //                                      myDateYearEditText.getText().toString()+";");                         
                         UsbongUtils.addElementToContainer(usbongAnswerContainer, "A,"+monthAdapter.getItem(dateMonthSpinner.getSelectedItemPosition()).toString() +
                              dayAdapter.getItem(dateDaySpinner.getSelectedItemPosition()).toString() + "," +
                              myDateYearEditText.getText().toString()+";", usbongAnswerContainerCounter);
            */
            usbongAnswerContainerCounter++;

            //             System.out.println(">>>>>>>>>>>>>Date screen: "+usbongAnswerContainer.lastElement());
            initParser();
        } else if (currScreen == UsbongConstants.TIMESTAMP_DISPLAY_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            UsbongUtils.addElementToContainer(usbongAnswerContainer, timestampString + ";",
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        } else if (currScreen == UsbongConstants.QR_CODE_READER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do

            if (!myQRCodeContent.equals("")) {
                //                      usbongAnswerContainer.addElement("Y,"+myQRCodeContent+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y," + myQRCodeContent + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else {
                //                      usbongAnswerContainer.addElement("N;");                                           
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            }
            initParser();
        } else if ((currScreen == UsbongConstants.DCAT_SUMMARY_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            /*
            LinearLayout myDCATSummaryLinearLayout = (LinearLayout)findViewById(R.id.dcat_summary_linearlayout);
            int total = myDCATSummaryLinearLayout.getChildCount();
                    
                              StringBuffer dcatSummary= new StringBuffer();
            for (int i=0; i<total; i++) {
               dcatSummary.append(((TextView) myDCATSummaryLinearLayout.getChildAt(i)).getText().toString());
            }
            */
            //                   UsbongUtils.addElementToContainer(usbongAnswerContainer, "dcat_end;", usbongAnswerContainerCounter);
            UsbongUtils.addElementToContainer(usbongAnswerContainer,
                    "dcat_end," + myDcatSummaryStringBuffer.toString() + ";", usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        }

        else { //TODO: do this for now                
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            //                  usbongAnswerContainer.addElement("A;");                                             
            UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        }
    }
}

From source file:usbong.android.retrocc.UsbongDecisionTreeEngineActivity.java

public void processNextButtonPressed() {
    wasNextButtonPressed = true;//from   w w w  .  ja v  a 2  s.  com
    hasUpdatedDecisionTrackerContainer = false;

    //edited by Mike, 20160417
    if ((mTts != null) && (mTts.isSpeaking())) {
        mTts.stop();
    }
    //edited by Mike, 20160417
    if ((myMediaPlayer != null) && (myMediaPlayer.isPlaying())) {
        myMediaPlayer.stop();
    }

    if (currAudioRecorder != null) {
        try {
            //if stop button is pressable
            if (stopButton.isEnabled()) {
                currAudioRecorder.stop();
            }
            if (currAudioRecorder.isPlaying()) {
                currAudioRecorder.stopPlayback();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        String path = currAudioRecorder.getPath();
        //               System.out.println(">>>>>>>>>>>>>>>>>>>currAudioRecorder: "+currAudioRecorder);
        if (!attachmentFilePaths.contains(path)) {
            attachmentFilePaths.add(path);
            //                  System.out.println(">>>>>>>>>>>>>>>>adding path: "+path);
        }
    }

    //END_STATE_SCREEN = last screen
    if (currScreen == UsbongConstants.END_STATE_SCREEN) {
        int usbongAnswerContainerSize = usbongAnswerContainer.size();
        StringBuffer outputStringBuffer = new StringBuffer();
        for (int i = 0; i < usbongAnswerContainerSize; i++) {
            outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
        }

        myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
        if (UsbongUtils.STORE_OUTPUT) {
            try {
                UsbongUtils.createNewOutputFolderStructure();
            } catch (Exception e) {
                e.printStackTrace();
            }
            UsbongUtils.storeOutputInSDCard(
                    UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getDateTimeStamp() + ".csv",
                    outputStringBuffer.toString());
        } else {
            UsbongUtils.deleteRecursive(new File(UsbongUtils.BASE_FILE_PATH + myOutputDirectory));
        }

        //wasNextButtonPressed=false; //no need to make this true, because this is the last node
        hasUpdatedDecisionTrackerContainer = true;

        /*
        //send to server
        UsbongUtils.performFileUpload(UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getTimeStamp() + ".csv");
                 
        //send to email
        Intent emailIntent = UsbongUtils.performEmailProcess(UsbongUtils.BASE_FILE_PATH + myOutputDirectory + UsbongUtils.getTimeStamp() + ".csv", attachmentFilePaths);
        emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        //                emailIntent.addFlags(RESULT_OK);
        startActivityForResult(Intent.createChooser(emailIntent, "Email:"),EMAIL_SENDING_SUCCESS);
        */

        //added by Mike, Sept. 10, 2014
        UsbongUtils.clearTempFolder();

        //added by Mike, 20160415
        if (UsbongUtils.IS_IN_AUTO_LOOP_MODE) {
            //added by Mike, 20161117
            AppRater.showRateDialog(this);

            isAutoLoopedTree = true;
            initParser(myTree);
            return;
        } else {
            //return to main activity
            finish();
            //added by Mike, 20161117
            Intent toUsbongMainActivityIntent = new Intent(UsbongDecisionTreeEngineActivity.this,
                    UsbongMainActivity.class);
            toUsbongMainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            toUsbongMainActivityIntent.putExtra("completed_tree", "true");
            startActivity(toUsbongMainActivityIntent);
        }
    } else {
        if (currScreen == UsbongConstants.YES_NO_DECISION_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;

                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.SEND_TO_WEBSERVER_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;
                //                     usbongAnswerContainer.addElement("Y;");         
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                decisionTrackerContainer.addElement(usbongAnswerContainer.lastElement());
                //                     wasNextButtonPressed=false; //no need to make this true, because "Y;" has already been added to decisionTrackerContainer
                hasUpdatedDecisionTrackerContainer = true;

                //edited by Mike, March 4, 2013
                //"save" the output into the SDCard as "output.txt"
                //                      int usbongAnswerContainerSize = usbongAnswerContainer.size();
                int usbongAnswerContainerSize = usbongAnswerContainerCounter;

                StringBuffer outputStringBuffer = new StringBuffer();
                for (int i = 0; i < usbongAnswerContainerSize; i++) {
                    outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
                }

                myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
                try {
                    UsbongUtils.createNewOutputFolderStructure();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                UsbongUtils.storeOutputInSDCard(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv", outputStringBuffer.toString());

                //send to server
                UsbongUtils.performFileUpload(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv");
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                       else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                //                      initParser();            
            }
            initParser();
        } else if (currScreen == UsbongConstants.SEND_TO_CLOUD_BASED_SERVICE_SCREEN) {
            RadioButton myYesRadioButton = (RadioButton) findViewById(R.id.yes_radiobutton);
            RadioButton myNoRadioButton = (RadioButton) findViewById(R.id.no_radiobutton);

            if (myYesRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfYes;
                //                     usbongAnswerContainer.addElement("Y;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                decisionTrackerContainer.addElement(usbongAnswerContainer.lastElement());
                //                     wasNextButtonPressed=false; //no need to make this true, because "Y;" has already been added to decisionTrackerContainer
                hasUpdatedDecisionTrackerContainer = true;

                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < decisionTrackerContainer.size(); i++) {
                    sb.append(decisionTrackerContainer.elementAt(i));
                }
                Log.d(">>>>>>>>>>>>>decisionTrackerContainer", sb.toString());

                //edited by Mike, March 4, 2013
                //"save" the output into the SDCard as "output.txt"
                //                      int usbongAnswerContainerSize = usbongAnswerContainer.size();
                int usbongAnswerContainerSize = usbongAnswerContainerCounter;

                StringBuffer outputStringBuffer = new StringBuffer();
                for (int i = 0; i < usbongAnswerContainerSize; i++) {
                    outputStringBuffer.append(usbongAnswerContainer.elementAt(i));
                }

                myOutputDirectory = UsbongUtils.getDateTimeStamp() + "/";
                try {
                    UsbongUtils.createNewOutputFolderStructure();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                UsbongUtils.storeOutputInSDCard(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                        + UsbongUtils.getDateTimeStamp() + ".csv", outputStringBuffer.toString());

                //send to cloud-based service
                Intent sendToCloudBasedServiceIntent = UsbongUtils
                        .performSendToCloudBasedServiceProcess(UsbongUtils.BASE_FILE_PATH + myOutputDirectory
                                + UsbongUtils.getDateTimeStamp() + ".csv", attachmentFilePaths);
                /*emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                */
                //                      emailIntent.addFlags(RESULT_OK);
                //                      startActivityForResult(Intent.createChooser(emailIntent, "Email:"),EMAIL_SENDING_SUCCESS);
                //answer from Llango J, stackoverflow
                //Reference: http://stackoverflow.com/questions/7479883/problem-with-sending-email-goes-back-to-previous-activity;
                //last accessed: 22 Oct. 2012
                startActivity(Intent.createChooser(sendToCloudBasedServiceIntent, "Email Book Request:"));
            } else if (myNoRadioButton.isChecked()) {
                currUsbongNode = nextUsbongNodeIfNo;
                //                     usbongAnswerContainer.addElement("N;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else { //if no radio button was checked                       
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                       else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                //                      initParser();            

                /*
                                       if (!isAnOptionalNode) {
                  showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                 wasNextButtonPressed=false;
                 hasUpdatedDecisionTrackerContainer=true;
                         
                 return;
                                       }
                                       else {
                 currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                //                        usbongAnswerContainer.addElement("A;");                                             
                 UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
                        
                initParser();            
                                       }
                */
            }
            /*                    
                              currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                              usbongAnswerContainer.addElement("Any;");                                             
            */
            initParser();
        } else if (currScreen == UsbongConstants.MULTIPLE_CHECKBOXES_SCREEN) {
            //                   requiredTotalCheckedBoxes   
            LinearLayout myMultipleCheckboxesLinearLayout = (LinearLayout) findViewById(
                    R.id.multiple_checkboxes_linearlayout);
            StringBuffer sb = new StringBuffer();
            int totalCheckedBoxes = 0;
            int totalCheckBoxChildren = myMultipleCheckboxesLinearLayout.getChildCount();
            //begin with i=1, because i=0 is for checkboxes_textview
            for (int i = 1; i < totalCheckBoxChildren; i++) {
                if (((CheckBox) myMultipleCheckboxesLinearLayout.getChildAt(i)).isChecked()) {
                    totalCheckedBoxes++;
                    sb.append("," + (i - 1)); //do a (i-1) so that i starts with 0 for the checkboxes (excluding checkboxes_textview) to maintain consistency with the other components
                }
            }

            if (totalCheckedBoxes >= requiredTotalCheckedBoxes) {
                currUsbongNode = nextUsbongNodeIfYes;
                sb.insert(0, "Y"); //insert in front of stringBuffer
                sb.append(";");
            } else {
                currUsbongNode = nextUsbongNodeIfNo;
                sb.delete(0, sb.length());
                sb.append("N,;"); //make sure to add the comma
            }
            //                   usbongAnswerContainer.addElement(sb.toString());
            UsbongUtils.addElementToContainer(usbongAnswerContainer, sb.toString(),
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        } else if (currScreen == UsbongConstants.MULTIPLE_RADIO_BUTTONS_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            //                   if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                         usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
            //                   }
            /*                   
                               else {
            //                      usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
              UsbongUtils.addElementToContainer(usbongAnswerContainer, myRadioGroup.getCheckedRadioButtonId()+";", usbongAnswerContainerCounter);
             usbongAnswerContainerCounter++;
                      
              initParser();                      
                               }
            */
        } else if (currScreen == UsbongConstants.MULTIPLE_RADIO_BUTTONS_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            /*                   if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
             */
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked                                                  
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                if (myMultipleRadioButtonsWithAnswerScreenAnswer
                        .equals("" + myRadioGroup.getCheckedRadioButtonId())) {
                    currUsbongNode = nextUsbongNodeIfYes;
                    UsbongUtils.addElementToContainer(usbongAnswerContainer,
                            "Y," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                } else {
                    currUsbongNode = nextUsbongNodeIfNo;
                    UsbongUtils.addElementToContainer(usbongAnswerContainer,
                            "N," + myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                }

                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if (currScreen == UsbongConstants.LINK_SCREEN) {
            RadioGroup myRadioGroup = (RadioGroup) findViewById(R.id.multiple_radio_buttons_radiogroup);

            try {
                currUsbongNode = UsbongUtils.getLinkFromRadioButton(
                        radioButtonsContainer.elementAt(myRadioGroup.getCheckedRadioButtonId()));
            } catch (Exception e) {
                //if the user hasn't ticked any radio button yet
                //put the currUsbongNode to default
                currUsbongNode = UsbongUtils.getLinkFromRadioButton(nextUsbongNodeIfYes); //nextUsbongNodeIfNo will also do, since this is "Any"
                //of course, showPleaseAnswerAlert() will be called                        
            }

            //                   Log.d(">>>>>>>>>>currUsbongNode",currUsbongNode);
            if (myRadioGroup.getCheckedRadioButtonId() == -1) { //no radio button checked
                //                         if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                if (!isAnOptionalNode) {
                    showRequiredFieldAlert(PLEASE_CHOOSE_AN_ANSWER_ALERT_TYPE);
                    wasNextButtonPressed = false;
                    hasUpdatedDecisionTrackerContainer = true;

                    return;
                }
                //                         }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                         usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        myRadioGroup.getCheckedRadioButtonId() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
            /*                   }
                               else {
              usbongAnswerContainer.addElement(myRadioGroup.getCheckedRadioButtonId()+";");
               initParser();                      
                               }
            */
        } else if ((currScreen == UsbongConstants.TEXTFIELD_SCREEN)
                || (currScreen == UsbongConstants.TEXTFIELD_WITH_UNIT_SCREEN)
                || (currScreen == UsbongConstants.TEXTFIELD_NUMERICAL_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            EditText myTextFieldScreenEditText = (EditText) findViewById(R.id.textfield_edittext);

            //                    if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            //if it's blank
            if (myTextFieldScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                //                           usbongAnswerContainer.addElement("A;");                                             
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A,;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //added by Mike, 20170207
                TextView myTextFieldScreenTextView = (TextView) this.findViewById(R.id.textfield_textview);

                //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
                //; last accessed: 20150609
                //answer by Elenasys
                //added by Mike, 20170207
                SharedPreferences.Editor editor = getSharedPreferences(UsbongConstants.MY_ACCOUNT_DETAILS,
                        MODE_PRIVATE).edit();
                if (myTextFieldScreenTextView.getText().toString().contains("First Name")) {
                    editor.putString("firstName", myTextFieldScreenEditText.getText().toString());
                } else if (myTextFieldScreenTextView.getText().toString().contains("Surname")) {
                    editor.putString("surname", myTextFieldScreenEditText.getText().toString());
                } else if (myTextFieldScreenTextView.getText().toString().contains("Contact Number")) {
                    editor.putString("contactNumber", myTextFieldScreenEditText.getText().toString());
                } else if (myTextFieldScreenTextView.getText().toString().contains("Shipping Address")) {
                    editor.putString("shippingAddress", myTextFieldScreenEditText.getText().toString());
                }
                editor.commit();

                //                        usbongAnswerContainer.addElement("A,"+myTextFieldScreenEditText.getText()+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextFieldScreenEditText.getText() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.TEXTFIELD_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            EditText myTextFieldScreenEditText = (EditText) findViewById(R.id.textfield_edittext);
            //if it's blank
            if (myTextFieldScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else {
                //added by Mike, Jan. 27, 2014
                Vector<String> myPossibleAnswers = new Vector<String>();
                StringTokenizer myPossibleAnswersStringTokenizer = new StringTokenizer(
                        myTextFieldWithAnswerScreenAnswer, "||");
                if (myPossibleAnswersStringTokenizer != null) {
                    while (myPossibleAnswersStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textFieldWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike")
                        myPossibleAnswers.add(myPossibleAnswersStringTokenizer.nextToken());
                    }
                }
                int size = myPossibleAnswers.size();
                for (int i = 0; i < size; i++) {
                    if (myPossibleAnswers.elementAt(i)
                            .equals(myTextFieldScreenEditText.getText().toString().trim())) {
                        currUsbongNode = nextUsbongNodeIfYes;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "Y," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                        break;
                    }

                    if (i == size - 1) { //if this is the last element in the vector
                        currUsbongNode = nextUsbongNodeIfNo;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "N," + myTextFieldScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                    }
                }
                /*                        
                  if (myTextFieldWithAnswerScreenAnswer.equals(myTextFieldScreenEditText.getText().toString().trim())) {
                   currUsbongNode = nextUsbongNodeIfYes;    
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y,"+myTextFieldScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }
                  else {
                   currUsbongNode = nextUsbongNodeIfNo;                                               
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "N,"+myTextFieldScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }                    
                */
                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if ((currScreen == UsbongConstants.TEXTAREA_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            EditText myTextAreaScreenEditText = (EditText) findViewById(R.id.textarea_edittext);

            //                    if (UsbongUtils.IS_IN_DEBUG_MODE==false) {
            //if it's blank
            if (myTextAreaScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                //                          else {
                currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A,;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
                //                          }
            } else {
                //                        usbongAnswerContainer.addElement("A,"+myTextAreaScreenEditText.getText()+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextAreaScreenEditText.getText() + ";", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            }
        } else if (currScreen == UsbongConstants.TEXTAREA_WITH_ANSWER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            EditText myTextAreaScreenEditText = (EditText) findViewById(R.id.textarea_edittext);
            //if it's blank
            if (myTextAreaScreenEditText.getText().toString().trim().equals("")) {
                if (!UsbongUtils.IS_IN_DEBUG_MODE) {
                    if (!isAnOptionalNode) {
                        showRequiredFieldAlert(PLEASE_ANSWER_FIELD_ALERT_TYPE);
                        wasNextButtonPressed = false;
                        hasUpdatedDecisionTrackerContainer = true;
                        return;
                    }
                }
                currUsbongNode = nextUsbongNodeIfYes; //choose Yes if "Any"
                UsbongUtils.addElementToContainer(usbongAnswerContainer,
                        "A," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                initParser();
            } else {
                /*                        
                  if (myTextAreaWithAnswerScreenAnswer.equals(myTextAreaScreenEditText.getText().toString().trim())) {
                   currUsbongNode = nextUsbongNodeIfYes;    
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y,"+myTextAreaScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }
                  else {
                   currUsbongNode = nextUsbongNodeIfNo;                                               
                    UsbongUtils.addElementToContainer(usbongAnswerContainer, "N,"+myTextAreaScreenEditText.getText().toString().trim()+";", usbongAnswerContainerCounter);
                  }                    
                */
                //added by Mike, Jan. 27, 2014
                Vector<String> myPossibleAnswers = new Vector<String>();
                StringTokenizer myPossibleAnswersStringTokenizer = new StringTokenizer(
                        myTextAreaWithAnswerScreenAnswer, "||");
                if (myPossibleAnswersStringTokenizer != null) {
                    while (myPossibleAnswersStringTokenizer.hasMoreTokens()) { //get last element (i.e. Mike in "textAreaWithAnswer~Who is the founder of Usbong (nickname)?Answer=Mike||mike")
                        myPossibleAnswers.add(myPossibleAnswersStringTokenizer.nextToken());
                    }
                }
                int size = myPossibleAnswers.size();
                for (int i = 0; i < size; i++) {
                    //                           Log.d(">>>>>>myPossibleAnswers: ",myPossibleAnswers.elementAt(i));
                    if (myPossibleAnswers.elementAt(i)
                            .equals(myTextAreaScreenEditText.getText().toString().trim())) {
                        currUsbongNode = nextUsbongNodeIfYes;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "Y," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                        break;
                    }

                    if (i == size - 1) { //if this is the last element in the vector
                        currUsbongNode = nextUsbongNodeIfNo;
                        UsbongUtils.addElementToContainer(usbongAnswerContainer,
                                "N," + myTextAreaScreenEditText.getText().toString().trim() + ";",
                                usbongAnswerContainerCounter);
                    }
                }
                usbongAnswerContainerCounter++;
                initParser();
            }
        } else if (currScreen == UsbongConstants.GPS_LOCATION_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            TextView myLongitudeTextView = (TextView) findViewById(R.id.longitude_textview);
            TextView myLatitudeTextView = (TextView) findViewById(R.id.latitude_textview);

            //                  usbongAnswerContainer.addElement(myLongitudeTextView.getText()+","+myLatitudeTextView.getText()+";");                     
            UsbongUtils.addElementToContainer(usbongAnswerContainer,
                    "A," + myLongitudeTextView.getText() + "," + myLatitudeTextView.getText() + ";",
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();

        } else if (currScreen == UsbongConstants.SIMPLE_ENCRYPT_SCREEN) {
            EditText myPinEditText = (EditText) findViewById(R.id.pin_edittext);

            if (myPinEditText.getText().toString().length() != 4) {
                String message = "";
                if (currLanguageBeingUsed == UsbongUtils.LANGUAGE_FILIPINO) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageFILIPINO);
                } else if (currLanguageBeingUsed == UsbongUtils.LANGUAGE_JAPANESE) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageJAPANESE);
                } else { //if (udtea.currLanguageBeingUsed==UsbongUtils.LANGUAGE_ENGLISH) {
                    message = (String) getResources().getText(R.string.Usbong4DigitsPinAlertMessageENGLISH);
                }

                new AlertDialog.Builder(UsbongDecisionTreeEngineActivity.this).setTitle("Hey!")
                        .setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            } else {
                int yourKey = Integer.parseInt(myPinEditText.getText().toString());
                currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do

                UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;

                //                  Log.d(">>>>>>>start encode","encode");
                for (int i = 0; i < usbongAnswerContainerCounter; i++) {
                    try {
                        usbongAnswerContainer.set(i, UsbongUtils.performSimpleFileEncrypt(yourKey,
                                usbongAnswerContainer.elementAt(i)));
                        //                        Log.d(">>>>>>"+i,""+usbongAnswerContainer.get(i));
                        //                        Log.d(">>>decoded"+i,""+UsbongUtils.performSimpleFileDecode(yourKey, usbongAnswerContainer.get(i)));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                initParser();
            }
        } else if (currScreen == UsbongConstants.DATE_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            Spinner dateMonthSpinner = (Spinner) findViewById(R.id.date_month_spinner);
            Spinner dateDaySpinner = (Spinner) findViewById(R.id.date_day_spinner);
            EditText myDateYearEditText = (EditText) findViewById(R.id.date_edittext);
            /*                   usbongAnswerContainer.addElement("A,"+monthAdapter.getItem(dateMonthSpinner.getSelectedItemPosition()).toString() +
                                    dayAdapter.getItem(dateDaySpinner.getSelectedItemPosition()).toString() + "," +
                                    myDateYearEditText.getText().toString()+";");                         
            */
            UsbongUtils.addElementToContainer(usbongAnswerContainer,
                    "A," + monthAdapter.getItem(dateMonthSpinner.getSelectedItemPosition()).toString()
                            + dayAdapter.getItem(dateDaySpinner.getSelectedItemPosition()).toString() + ","
                            + myDateYearEditText.getText().toString() + ";",
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            //                   System.out.println(">>>>>>>>>>>>>Date screen: "+usbongAnswerContainer.lastElement());
            initParser();
        } else if (currScreen == UsbongConstants.TIMESTAMP_DISPLAY_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes;
            UsbongUtils.addElementToContainer(usbongAnswerContainer, timestampString + ";",
                    usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        } else if (currScreen == UsbongConstants.QR_CODE_READER_SCREEN) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do

            if (!myQRCodeContent.equals("")) {
                //                      usbongAnswerContainer.addElement("Y,"+myQRCodeContent+";");                     
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "Y," + myQRCodeContent + ";",
                        usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            } else {
                //                      usbongAnswerContainer.addElement("N;");                                           
                UsbongUtils.addElementToContainer(usbongAnswerContainer, "N;", usbongAnswerContainerCounter);
                usbongAnswerContainerCounter++;
            }
            initParser();
        } else if ((currScreen == UsbongConstants.DCAT_SUMMARY_SCREEN)) {
            currUsbongNode = nextUsbongNodeIfYes; //= nextIMCIQuestionIfNo will also do
            /*
            LinearLayout myDCATSummaryLinearLayout = (LinearLayout)findViewById(R.id.dcat_summary_linearlayout);
            int total = myDCATSummaryLinearLayout.getChildCount();
                    
                              StringBuffer dcatSummary= new StringBuffer();
            for (int i=0; i<total; i++) {
               dcatSummary.append(((TextView) myDCATSummaryLinearLayout.getChildAt(i)).getText().toString());
            }
            */
            //                   UsbongUtils.addElementToContainer(usbongAnswerContainer, "dcat_end;", usbongAnswerContainerCounter);
            UsbongUtils.addElementToContainer(usbongAnswerContainer,
                    "dcat_end," + myDcatSummaryStringBuffer.toString() + ";", usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        }

        else { //TODO: do this for now                
            currUsbongNode = nextUsbongNodeIfYes; //nextUsbongNodeIfNo will also do, since this is "Any"
            //                  usbongAnswerContainer.addElement("A;");                                             
            UsbongUtils.addElementToContainer(usbongAnswerContainer, "A;", usbongAnswerContainerCounter);
            usbongAnswerContainerCounter++;

            initParser();
        }
    }
}

From source file:pt.aptoide.backupapps.Aptoide.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    EnumOptionsMenu menuEntry = EnumOptionsMenu.reverseOrdinal(item.getItemId());
    Log.d("Aptoide-OptionsMenu", "menuOption: " + menuEntry + " itemid: " + item.getItemId());
    switch (menuEntry) {
    //         case MANAGE_REPO:
    //            availableAdapter.sleep();
    //            Intent manageRepo = new Intent(this, ManageRepos.class);
    //            startActivity(manageRepo);
    //            return true;

    case UNINSTALL:
        try {//from  www  .j  a  va  2s  .co m
            serviceDataCaller.callUninstallApps(installedAdapter.getSelectedIds());
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;

    case DELETE:
        //TODO improve listIds as an extended parcelable array ;) then use it as a carrier for checked hashids list
        return true;

    case DISPLAY_OPTIONS:
        if (!loadingRepos.get()) {
            //TODO refactor extract dialog management class
            LayoutInflater displayOptionsInflater = LayoutInflater.from(this);
            View displayOptions = displayOptionsInflater.inflate(R.layout.dialog_display_options, null);
            Builder dialogBuilder = new AlertDialog.Builder(theme).setView(displayOptions);
            final AlertDialog sortDialog = dialogBuilder.create();
            sortDialog.setIcon(android.R.drawable.ic_menu_sort_by_size);
            sortDialog.setTitle(getString(R.string.display_options));

            // ***********************************************************
            // Categories
            //               final RadioButton byCategory = (RadioButton) displayOptions.findViewById(R.id.by_category);
            //               final RadioButton byAll = (RadioButton) displayOptions.findViewById(R.id.by_all);
            //               if(availableByCategory){
            //                  byCategory.setChecked(true);
            //               }else{
            //                  byAll.setChecked(true);
            //               }
            //   
            //               final View spacer = displayOptions.findViewById(R.id.spacer);
            //               
            //               if(currentAppsList != EnumAppsLists.Available){
            //                  spacer.setVisibility(View.GONE);
            //                  ((RadioGroup) displayOptions.findViewById(R.id.group_show)).setVisibility(View.GONE);
            //               }

            // ***********************************************************
            // Sorting            
            final View group_sort = displayOptions.findViewById(R.id.group_sort);
            final RadioButton byAlphabetic = (RadioButton) displayOptions.findViewById(R.id.by_alphabetic);
            final RadioButton byFreshness = (RadioButton) displayOptions.findViewById(R.id.by_freshness);
            final RadioButton bySize = (RadioButton) displayOptions.findViewById(R.id.by_size);

            //               spacer.setVisibility(View.VISIBLE);
            group_sort.setVisibility(View.VISIBLE);
            switch (appsSortingPolicy) {
            case ALPHABETIC:
                byAlphabetic.setChecked(true);
                break;

            case FRESHNESS:
                byFreshness.setChecked(true);
                break;

            case SIZE:
                bySize.setChecked(true);
                break;

            default:
                break;
            }

            // ***********************************************************

            final CheckBox showSystemApps = (CheckBox) displayOptions.findViewById(R.id.show_system_apps);
            boolean showSystemAppsState = false;
            try {
                showSystemAppsState = serviceDataCaller.callGetShowSystemApps();
            } catch (RemoteException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            showSystemApps.setChecked(showSystemAppsState);
            final boolean storedShowSystemAppsState = showSystemAppsState;

            sortDialog.setButton(getString(R.string.done), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    //                     boolean byCategoryChanged = false;
                    EnumAppsSorting newSortingPolicy = null;

                    //                     if(byCategory.isChecked() != availableByCategory){
                    //                        byCategoryChanged = true;
                    //                        availableByCategory = byCategory.isChecked();
                    //                        setAvailableListBy(availableByCategory);
                    //                     }

                    if (showSystemApps.isChecked() != storedShowSystemAppsState) {
                        setShowSystemApps(showSystemApps.isChecked());
                    }

                    if (byAlphabetic.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.ALPHABETIC;
                    } else if (byFreshness.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.FRESHNESS;
                    } else if (bySize.isChecked()) {
                        newSortingPolicy = EnumAppsSorting.SIZE;
                    }
                    if (newSortingPolicy != null && newSortingPolicy != appsSortingPolicy) {
                        //                        availableAdapter.sleep();
                        appsSortingPolicy = newSortingPolicy;
                        setAppsSortingPolicy(appsSortingPolicy);
                    }

                    //                     if(byCategoryChanged){
                    //                        if(availableByCategory){
                    //                           availableAdapter.sleep();
                    //                           categoriesAdapter.resetDisplayCategories();
                    //                        }else{
                    //                           availableAdapter.resetDisplay(null);                        
                    //                        }
                    //                     }
                    sortDialog.dismiss();
                }
            });

            sortDialog.show();
        } else {
            Toast.makeText(Aptoide.this, getString(R.string.option_not_available_while_updating_repos),
                    Toast.LENGTH_SHORT).show();
        }
        return true;

    //         case SEARCH_MENU:
    //            onSearchRequested();
    //            return true;

    case UN_SELECT_ALL:
        switch (currentAppsList) {
        case RESTORE:
            if (availableAdapter.isDynamic()) {
                Toast.makeText(Aptoide.this, getString(R.string.too_many_apps_to_select_at_once),
                        Toast.LENGTH_SHORT).show();
                return true;
            }
            availableAdapter.toggleSelectAll();
            break;

        case BACKUP:
            installedAdapter.toggleSelectAll();
            break;

        default:
            break;
        }
        return true;

    case ABOUT:
        LayoutInflater aboutInflater = LayoutInflater.from(this);
        View about = aboutInflater.inflate(R.layout.about, null);
        TextView info = (TextView) about.findViewById(R.id.credits);
        info.setText(getString(R.string.credits, versionName));
        Builder aboutCreator = new AlertDialog.Builder(theme).setView(about);
        final AlertDialog aboutDialog = aboutCreator.create();
        aboutDialog.setIcon(R.drawable.icon);
        aboutDialog.setTitle(R.string.self_name);
        //            aboutDialog.setButton(getText(R.string.changelog), new DialogInterface.OnClickListener() {
        //               public void onClick(DialogInterface dialog, int   whichButton) {
        //                  Uri uri = Uri.parse(getString(R.string.changelog_url));
        //                  startActivity(new Intent( Intent.ACTION_VIEW, uri));
        //               }
        //            });
        aboutDialog.show();
        return true;

    case SETTINGS:
        //            availableAdapter.sleep();
        Intent settings = new Intent(this, Settings.class);
        startActivity(settings);
        return true;

    case LOGIN:
        //            boolean insertingRepo = false;
        //            try {
        //               insertingRepo = serviceDataCaller.callIsInsertingRepo();
        //            } catch (RemoteException e1) {
        //               // TODO Auto-generated catch block
        //               e1.printStackTrace();
        //            }
        //            if(insertingRepo){
        //               AptoideLog.d(Aptoide.this, getString(R.string.updating_repo_please_wait));
        //               Toast.makeText(getApplicationContext(), getResources().getString(R.string.updating_repo_please_wait), Toast.LENGTH_SHORT).show();
        //            }
        //            else{
        Log.d("Aptoide-Settings", "clicked set server login");
        String token = null;
        try {
            token = serviceDataCaller.callGetServerToken();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (token == null) {
            Log.d("Aptoide-Settings", "No login set");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.NO_CREDENTIALS_SET.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.NO_CREDENTIALS_SET);
            //               loginComments.setOnDismissListener(new OnDismissListener() {
            //                  @Override
            //                  public void onDismiss(DialogInterface dialog) {
            //                     addAppVersionComment();
            //                  }
            //               });
            //               dialogLogin.show();
        } else {
            Log.d("Aptoide-Settings", "Login edit");
            Intent login = new Intent(Aptoide.this, BazaarLogin.class);
            login.putExtra("InvoqueType", BazaarLogin.InvoqueType.OVERRIDE_CREDENTIALS.ordinal());
            startActivity(login);
            //               DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.OVERRIDE_CREDENTIALS);
            //               Toast.makeText(Settings.this, "Login already set", Toast.LENGTH_SHORT).show();
            //               dialogLogin.show();
        }
        //            }
        return true;

    case FOLLOW:
        new DialogFollowOnSocialNets(this, serviceDataCaller).show();
        return true;

    //         case SCHEDULED_DOWNLOADS:
    //            availableAdapter.sleep();
    //            Intent manageScheduled = new Intent(this, ManageScheduled.class);
    //            startActivity(manageScheduled);
    //            return true;

    //         case UPDATE_ALL:
    //            if(!loadingRepos.get()){
    //               AptoideLog.d(this, "Update all");
    //               try {
    //                  serviceDataCaller.callUpdateAll();
    //               } catch (RemoteException e) {
    //                  // TODO Auto-generated catch block
    //                  e.printStackTrace();
    //               }
    //            }else{
    //               Toast.makeText(Aptoide.this, "Option not available while updating stores!", Toast.LENGTH_SHORT).show();
    //            }
    //            return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

private SavedViewContents saveViewContents() {
    SavedViewContents sv = new SavedViewContents();
    final EditText dlg_prof_name_et = (EditText) mDialog.findViewById(R.id.edit_profile_action_profile_et_name);
    final CheckBox cb_active = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_enabled);
    final CheckBox cb_enable_env_parms = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_enable_env_parms);

    final TextView tv_sound_filename = (TextView) mDialog
            .findViewById(R.id.edit_profile_action_exec_sound_file_name);
    final CheckBox cb_music_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_sound_use_volume);
    final SeekBar sb_music_vol = (SeekBar) mDialog.findViewById(R.id.edit_profile_action_profile_sound_volume);
    final CheckBox cb_ringtone_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_use_volume);
    final SeekBar sb_ringtone_vol = (SeekBar) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_volume);
    final Spinner spinnerActionType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_action_type);
    final Spinner spinnerActivityName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_name);
    final Spinner spinnerActivityDataType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_data_type);
    final Spinner spinnerRingtoneType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_type);
    final Spinner spinnerRingtoneName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_name);
    final Spinner spinnerCompareType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_compare_type);
    final EditText et_comp_value1 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value1);
    final EditText et_comp_value2 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value2);
    final ListView lv_comp_data = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_compare_value_listview);
    final Spinner spinnerCompareResult = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_result);
    final Spinner spinnerCompareTarget = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_target);
    final Spinner spinnerMessageType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_message_type);
    final EditText et_msg_text = (EditText) mDialog.findViewById(R.id.edit_profile_action_message_message);
    final CheckBox cb_vib_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_vibration);
    final CheckBox cb_led_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_led);
    final RadioButton rb_msg_blue = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_blue);
    final RadioButton rb_msg_red = (RadioButton) mDialog.findViewById(R.id.edit_profile_action_message_led_red);
    final RadioButton rb_msg_green = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_green);
    final Spinner spinnerTimeType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_type);
    final Spinner spinnerTimeTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_target);
    final Spinner spinnerTaskType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_type);
    final Spinner spinnerTaskTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_target);
    final Spinner spinnerWaitTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_wait_target);
    final Spinner spinnerWaitTimeoutType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout);
    final Spinner spinnerWaitTimeoutValue = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_value);
    final Spinner spinnerWaitTimeoutUnits = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_units);
    final EditText et_bsh_script = (EditText) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_script_text);
    final Spinner spinnerBshMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_add_method);
    final Spinner spinnerCatMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_cat_method);

    final EditText uri_data = (EditText) mDialog.findViewById(R.id.edit_profile_action_exec_activity_uri_data);
    final ListView lv_aed = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_extra_data_listview);

    sv.dlg_prof_name_et = dlg_prof_name_et.getText();
    sv.dlg_prof_name_et_spos = dlg_prof_name_et.getSelectionStart();
    sv.dlg_prof_name_et_epos = dlg_prof_name_et.getSelectionEnd();
    sv.cb_active = cb_active.isChecked();
    sv.cb_enable_env_parms = cb_enable_env_parms.isChecked();

    sv.tv_sound_filename = tv_sound_filename.getText();
    sv.cb_music_vol = cb_music_vol.isChecked();
    sv.sb_music_vol = sb_music_vol.getProgress();
    sv.cb_ringtone_vol = cb_ringtone_vol.isChecked();
    sv.sb_ringtone_vol = sb_ringtone_vol.getProgress();
    sv.spinnerActionType = spinnerActionType.getSelectedItemPosition();
    sv.spinnerActivityName = spinnerActivityName.getSelectedItemPosition();
    sv.spinnerActivityDataType = spinnerActivityDataType.getSelectedItemPosition();
    sv.spinnerRingtoneType = spinnerRingtoneType.getSelectedItemPosition();
    sv.spinnerRingtoneName = spinnerRingtoneName.getSelectedItemPosition();
    sv.spinnerCompareType = spinnerCompareType.getSelectedItemPosition();
    sv.et_comp_value1 = et_comp_value1.getText();
    sv.et_comp_value2 = et_comp_value2.getText();
    sv.lv_comp_data[0] = lv_comp_data.getFirstVisiblePosition();
    if (lv_comp_data.getChildAt(0) != null)
        sv.lv_comp_data[1] = lv_comp_data.getChildAt(0).getTop();
    sv.spinnerCompareResult = spinnerCompareResult.getSelectedItemPosition();
    sv.spinnerCompareTarget = spinnerCompareTarget.getSelectedItemPosition();
    sv.spinnerMessageType = spinnerMessageType.getSelectedItemPosition();
    sv.et_msg_text = et_msg_text.getText();
    sv.cb_vib_used = cb_vib_used.isChecked();
    sv.cb_led_used = cb_led_used.isChecked();
    sv.rb_msg_blue = rb_msg_blue.isChecked();
    sv.rb_msg_red = rb_msg_red.isChecked();
    sv.rb_msg_green = rb_msg_green.isChecked();
    sv.spinnerTimeType = spinnerTimeType.getSelectedItemPosition();
    sv.spinnerTimeTarget = spinnerTimeTarget.getSelectedItemPosition();
    sv.spinnerTaskType = spinnerTaskType.getSelectedItemPosition();
    sv.spinnerTaskTarget = spinnerTaskTarget.getSelectedItemPosition();
    sv.spinnerWaitTarget = spinnerWaitTarget.getSelectedItemPosition();
    sv.spinnerWaitTimeoutType = spinnerWaitTimeoutType.getSelectedItemPosition();
    sv.spinnerWaitTimeoutValue = spinnerWaitTimeoutValue.getSelectedItemPosition();
    sv.spinnerWaitTimeoutUnits = spinnerWaitTimeoutUnits.getSelectedItemPosition();
    sv.et_bsh_script = et_bsh_script.getText();

    sv.spinnerBshMethod = spinnerBshMethod.getSelectedItemPosition();
    sv.spinnerCatMethod = spinnerCatMethod.getSelectedItemPosition();
    sv.uri_data = uri_data.getText();//from  w ww  .  j a v  a 2s. co m
    sv.lv_aed[0] = lv_aed.getFirstVisiblePosition();
    if (lv_aed.getChildAt(0) != null)
        sv.lv_aed[1] = lv_aed.getChildAt(0).getTop();
    for (int i = 0; i < mGlblParms.activityExtraDataEditListAdapter.getCount(); i++)
        sv.aed_adapter_list.add(mGlblParms.activityExtraDataEditListAdapter.getItem(i));
    for (int i = 0; i < mGlblParms.actionCompareDataAdapter.getCount(); i++)
        sv.data_array_adapter_list.add(mGlblParms.actionCompareDataAdapter.getItem(i));

    return sv;
}

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 * Show frequency dialog//w w  w .  j  av  a  2  s.c  o  m
 */
private void showFrequencyPurchaseDialog(final int value) {
    final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.alert_dialog_main);
    final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title);
    final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg);
    final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt);
    Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn);
    Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn);
    final RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.myRadioGroup);

    final RadioButton radioOneMonth = (RadioButton) dialog.findViewById(R.id.oneMonth);
    final RadioButton radioThreeMonth = (RadioButton) dialog.findViewById(R.id.threeMonth);
    final RadioButton radioSixMonth = (RadioButton) dialog.findViewById(R.id.sixMonth);
    final RadioButton radioOneYear = (RadioButton) dialog.findViewById(R.id.oneYear);

    //long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);
    radioGroup.setVisibility(View.VISIBLE);
    alertTitle.setText("Purchase Product");
    if (value == updateDurationValue[0]) {
        alertMsg.setText("Buy Update Frequency for 1 Minutes");
        //radioOneMonth.setChecked(true);
        if (userType == PurchaseStatus.FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[1]) {
        alertMsg.setText("Buy Update Frequency for 2 Minutes");
        if (userType == PurchaseStatus.SEMI_FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[2]) {
        alertMsg.setText("Buy Update Frequency for 3 Minutes");

        if (userType == PurchaseStatus.PARTIAL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    }
    alertEditTxt.setVisibility(View.GONE);

    radioOneMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
            }
        }
    });
    radioThreeMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
            }
        }
    });
    radioSixMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
            }
        }
    });
    radioOneYear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
            }
        }
    });
    cancelBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);

            // Set Spinner
            setSpinnerUpdateTime(updateTime);
            firstSelect = false;
        }
    });
    okBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            if (radioOneMonth.isChecked() || radioThreeMonth.isChecked() || radioSixMonth.isChecked()
                    || radioOneYear.isChecked()) {
                // One min update
                if (value == updateDurationValue[0] && radioOneMonth.isChecked()) {
                    fullPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioThreeMonth.isChecked()) {
                    fullPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioSixMonth.isChecked()) {
                    fullPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioOneYear.isChecked()) {
                    fullPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Two min update
                else if (value == updateDurationValue[1] && radioOneMonth.isChecked()) {
                    semiparticalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioThreeMonth.isChecked()) {
                    semiparticalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioSixMonth.isChecked()) {
                    semiparticalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioOneYear.isChecked()) {
                    semiparticalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Three min update
                else if (value == updateDurationValue[2] && radioOneMonth.isChecked()) {
                    particalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioThreeMonth.isChecked()) {
                    particalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioSixMonth.isChecked()) {
                    particalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioOneYear.isChecked()) {
                    particalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }

                long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF,
                        AppConstants.DEFAULT_TIME_INTERVAL);
                // Set Spinner
                setSpinnerUpdateTime(updateTime);
                firstSelect = false;
                dialog.dismiss();
            } else {
                dialog.show();
                Utils.showToast("Select durations");
                //Toast.makeText(getActivity(), "Select durations", Toast.LENGTH_LONG).show();
            }
        }
    });
    dialog.show();
}