lordgreg

Untitled

Aug 12th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.53 KB | None | 0 0
  1.  
  2.                 builder
  3.                         .setTitle("Cell tower selection")
  4.                         .setIcon(R.drawable.ic_cell)
  5.                         .setView(dialogViewCell)
  6.                         .setPositiveButton("OK", new DialogInterface.OnClickListener() {
  7.                             @Override
  8.                             public void onClick(DialogInterface dialog, int which) {
  9.                                 dialog.dismiss();
  10.  
  11.  
  12.                                 /**
  13.                                  *
  14.                                  * SAVING ITEMS
  15.                                  *
  16.                                  */
  17.                                 // we have to pick at least one
  18.                                 if (mCellsSelected.size() == 0) {
  19.                                     showMessageBox("Pick at least one radio tower!", true);
  20.                                     return ;
  21.                                 }
  22.  
  23.  
  24.                                 // save condition & create new row
  25.                                 final DialogOptions cond = new DialogOptions(opt.getTitle(), opt.getDescription(), opt.getIcon(), opt.getOptionType());
  26.  
  27.  
  28.                                 cond.setSetting("selectedcell", (new Gson().toJson(mCellsSelected)));
  29.                                 //cond.setSetting("text1", "Days ("+ selectedWifi.size() +")");
  30.                                 cond.setSetting("text1", ((opt.getOptionType() == DialogOptions.type.CELL_IN) ? "Connected to " : "Not connected to ") + " specific cells");
  31.                                 cond.setSetting("text2", "Cells selected: "+ mCellsSelected.size());
  32.  
  33.  
  34.                                 // if we are editing in sub-dialog, clear previous entry
  35.                                 if (isEditing)
  36.                                     removeConditionOrAction(index, opt);
  37.  
  38.  
  39.                                 addNewConditionOrAction(context, cond, index);
  40.  
  41.  
  42.  
  43.                             }
  44.                         })
  45.                         .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  46.                             @Override
  47.                             public void onClick(DialogInterface dialog, int which) {
  48.                                 dialog.dismiss();
  49.                             }
  50.                         })
  51.                 ;
  52.  
  53.                 /**
  54.                  * create dialog
  55.                  */
  56.                 final AlertDialog dialogCell = builder.create();
  57.  
  58.                 /**
  59.                  * fill dialog with cells
  60.                  */
  61.                 //newRow;
  62.                 for (final Cell single : mCellsToShow) {
  63.                     final ViewGroup newRow = (ViewGroup) inflater.inflate(R.layout.dialog_cellid_single, mCellTowers, false);
  64.  
  65.  
  66.                     ((TextView) newRow.findViewById(android.R.id.text1)).setText(single.getCellId());
  67.                     ((TextView) newRow.findViewById(android.R.id.text2))
  68.                             .setText(single.getStoreDate().getTime().toString());
  69.  
  70.                     ImageView imageView = (ImageView)newRow.findViewById(R.id.cellid_delete);
  71.  
  72.  
  73.                     /**
  74.                      * if we're updating, lets set selected current if it was retrieved from settings
  75.                      */
  76.                     if (isEditing) {
  77.                         if (mCellsFromSettings.indexOf(single) > 0) {
  78.  
  79.                             //newRow.isSelected();
  80.                             newRow.setClickable(true);
  81.                             newRow.setPressed(true);
  82.                             newRow.setSelected(true);
  83.  
  84.  
  85.  
  86.                             // also, add this cell to "selected" array
  87.                             mCellsSelected.add(single);
  88.  
  89.                         }
  90.                     }
  91.  
  92.                     mCellTowers.addView(newRow);
  93.  
  94.                     /**
  95.                      * clicking single row
  96.                      */
  97.                     newRow.setOnClickListener(new View.OnClickListener() {
  98.                         @Override
  99.                         public void onClick(View v) {
  100.                             if (newRow.isSelected()) {
  101.                                 mCellsSelected.remove(single);
  102.                                 newRow.setSelected(false);
  103.                                 //System.out.println("removing tower to list: "+ mCellsSelected.toString());
  104.                             }
  105.                             else {
  106.                                 //mCellsToShow.remove(single);
  107.                                 mCellsSelected.add(single);
  108.                                 newRow.setSelected(true);
  109.                                 //System.out.println("adding tower to list: "+ mCellsSelected.toString());
  110.                             }
  111.                         }
  112.                     });
  113.  
  114.                     /**
  115.                      * clicking trash bin, just unselect cell
  116.                      */
  117.                     imageView.setOnClickListener(new View.OnClickListener() {
  118.                         @Override
  119.                         public void onClick(View v) {
  120.                             /**
  121.                              * remove cellID from history array
  122.                              */
  123.                             newRow.setSelected(false);
  124.                             mCellsSelected.remove(single);
  125.                             //removeCellIdFromArray(single.getCellId());
  126.                         }
  127.                     });
  128.  
  129.                     //newRow = null;
  130.  
  131.  
  132.                     dialogCell.show();
  133.  
  134.                 }
Advertisement
Add Comment
Please, Sign In to add comment