Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- builder
- .setTitle("Cell tower selection")
- .setIcon(R.drawable.ic_cell)
- .setView(dialogViewCell)
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- /**
- *
- * SAVING ITEMS
- *
- */
- // we have to pick at least one
- if (mCellsSelected.size() == 0) {
- showMessageBox("Pick at least one radio tower!", true);
- return ;
- }
- // save condition & create new row
- final DialogOptions cond = new DialogOptions(opt.getTitle(), opt.getDescription(), opt.getIcon(), opt.getOptionType());
- cond.setSetting("selectedcell", (new Gson().toJson(mCellsSelected)));
- //cond.setSetting("text1", "Days ("+ selectedWifi.size() +")");
- cond.setSetting("text1", ((opt.getOptionType() == DialogOptions.type.CELL_IN) ? "Connected to " : "Not connected to ") + " specific cells");
- cond.setSetting("text2", "Cells selected: "+ mCellsSelected.size());
- // if we are editing in sub-dialog, clear previous entry
- if (isEditing)
- removeConditionOrAction(index, opt);
- addNewConditionOrAction(context, cond, index);
- }
- })
- .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- ;
- /**
- * create dialog
- */
- final AlertDialog dialogCell = builder.create();
- /**
- * fill dialog with cells
- */
- //newRow;
- for (final Cell single : mCellsToShow) {
- final ViewGroup newRow = (ViewGroup) inflater.inflate(R.layout.dialog_cellid_single, mCellTowers, false);
- ((TextView) newRow.findViewById(android.R.id.text1)).setText(single.getCellId());
- ((TextView) newRow.findViewById(android.R.id.text2))
- .setText(single.getStoreDate().getTime().toString());
- ImageView imageView = (ImageView)newRow.findViewById(R.id.cellid_delete);
- /**
- * if we're updating, lets set selected current if it was retrieved from settings
- */
- if (isEditing) {
- if (mCellsFromSettings.indexOf(single) > 0) {
- //newRow.isSelected();
- newRow.setClickable(true);
- newRow.setPressed(true);
- newRow.setSelected(true);
- // also, add this cell to "selected" array
- mCellsSelected.add(single);
- }
- }
- mCellTowers.addView(newRow);
- /**
- * clicking single row
- */
- newRow.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (newRow.isSelected()) {
- mCellsSelected.remove(single);
- newRow.setSelected(false);
- //System.out.println("removing tower to list: "+ mCellsSelected.toString());
- }
- else {
- //mCellsToShow.remove(single);
- mCellsSelected.add(single);
- newRow.setSelected(true);
- //System.out.println("adding tower to list: "+ mCellsSelected.toString());
- }
- }
- });
- /**
- * clicking trash bin, just unselect cell
- */
- imageView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- /**
- * remove cellID from history array
- */
- newRow.setSelected(false);
- mCellsSelected.remove(single);
- //removeCellIdFromArray(single.getCellId());
- }
- });
- //newRow = null;
- dialogCell.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment