@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // setContentView(R.layout.setting_main);

    Context ctx = getApplicationContext();
    Resources res = ctx.getResources();

    String[] options = res.getStringArray(R.array.setting_names);

    setListAdapter(new ArrayAdapter<String>(this, R.layout.setting_list_item, options));

    ArrayList<String> manuf = DatabaseOp.getAllManuf();

    final CharSequence[] dataManuf = new CharSequence[manuf.size()];

    for (int i = 0; !manuf.isEmpty(); i++) {
      dataManuf[i] = manuf.remove(0);
      Log.e("Manuf_Add", dataManuf[i].toString());
    }

    ArrayList<String> cities = DatabaseOp.getAllCities();

    final CharSequence[] dataCity = new CharSequence[cities.size() + 1];

    dataCity[0] = "All Cities";

    for (int i = 1; !cities.isEmpty(); i++) {
      dataCity[i] = cities.remove(0);
      Log.e("Citi_Add", dataCity[i].toString());
    }

    ListView lv = getListView();

    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
              case 0:
                showPopUpDistance();
                break;
              case 1:
                showPopUpCity(dataCity);
                break;
              case 2:
                showPopUpCashless();
                break;
              case 3:
                showPopUpManuf(dataManuf);
                break;
            }
          }
        });
  } // end of onCreate
Esempio n. 2
0
 private ProjectOp(List<ProjectionSpec> projections, DatabaseOp wrapped) {
   super(wrapped);
   for (ProjectionSpec spec : projections) {
     if (!spec.getColumn().isQualified()) {
       // See if there is a qualified version of this column in the wrapped
       for (ColumnName wrappedColumn : wrapped.getColumns()) {
         if (wrappedColumn.isQualified()
             && wrappedColumn.getColumn().equals(spec.getColumn().getColumn())) {
           spec = ProjectionSpec.create(wrappedColumn);
         }
       }
     }
     this.projections.add(spec);
     columnList.add(spec.getColumn());
   }
   // Build columns map
   for (ProjectionSpec spec : this.projections) {
     // Qualified names only
     if (!spec.getColumn().isQualified()) continue;
     if (columns.containsKey(spec.getColumn())) {
       throw new IllegalArgumentException(
           "Duplicate column name " + spec.getColumn() + " in projection list: " + projections);
     }
     columns.put(spec.getColumn(), spec);
     if (columns.containsKey(spec.getColumn().getUnqualified())) {
       // Mark unqualified name as ambiguous
       columns.put(spec.getColumn().getUnqualified(), null);
     } else {
       columns.put(spec.getColumn().getUnqualified(), spec);
     }
   }
   for (ProjectionSpec spec : this.projections) {
     // Unqualified names only
     if (spec.getColumn().isQualified()) continue;
     if (columns.containsKey(spec.getColumn())) {
       throw new IllegalArgumentException(
           "Duplicate column name " + spec.getColumn() + " in projection list: " + projections);
     }
     columns.put(spec.getColumn(), spec);
   }
   for (Key key : wrapped.getUniqueKeys()) {
     if (key.isContainedIn(columnList)) {
       uniqueKeys.add(key);
     }
   }
 }
Esempio n. 3
0
 public static DatabaseOp extend(
     DatabaseOp wrapped, Map<ColumnName, Expression> extensions, Vendor vendor) {
   if (extensions.isEmpty()) return wrapped;
   List<ProjectionSpec> specs = ProjectionSpec.createFromColumns(wrapped.getColumns());
   for (ColumnName column : extensions.keySet()) {
     specs.add(ProjectionSpec.create(column, extensions.get(column), vendor));
   }
   return ProjectOp.create(wrapped, specs);
 }