public void editTextInfoOnClick(View view) { String transportList = options.getTransportList(); if (transportList != null && !TextUtils.isEmpty(transportList)) { EditText et = (EditText) findViewById(R.id.editTextInfo); Editable data = et.getText(); Matcher m = transportListPattern.matcher(data); if (!m.matches()) { et.setText(transportList); } } }
public void onClickRefresh(View view) { EditText et = (EditText) findViewById(R.id.editTextInfo); Editable data = et.getText(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et.getWindowToken(), 0); Matcher m = transportListPattern.matcher(data); if (m.matches()) { options.setTransportList(data.toString()); } ReuestToServer(); }
private void ReuestToServer() { Button button = (Button) findViewById(R.id.buttonRefresh); button.setEnabled(false); // http://transit.in.ua/import.php?dataRequest[]=dnepropetrovsk-taxi-1 // http://transit.in.ua/importTransport.php?dataRequest%5B%5D=dnepropetrovsk-taxi-1&dataRequest%5B%5D=dnepropetrovsk-taxi-2 String[] transportsArray = options.getTransportsArray(); if (transportsArray != null) { List<String> parameters = new ArrayList<String>(); for (String string : transportsArray) { parameters.add("dataRequest%5B%5D=dnepropetrovsk-taxi-" + string); } String parametersString = TextUtils.join("&", parameters); // String url = // "http://transit.in.ua/importTransport.php?dataRequest%5B%5D=dnepropetrovsk-taxi-" + // spyMarshrut; String url = "http://transit.in.ua/importTransport.php?" + parametersString; aq.ajax(url, String.class, this, "GetNewDataCallback"); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); aq = new AQuery(this); transportListPattern = Pattern.compile("(\\s*\\w+\\d*,*\\s*)+"); transportNumberPatern = Pattern.compile("№\\s*(\\d+\\w*)"); setContentView(R.layout.activity_main); MapView mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); MapController mapController = mapView.getController(); DBConnector connector = new DBConnector(this); options = connector.getOptions(); if (options == null) { options = new Options(10, "136, 32"); // defailtOptions; } mapController.setZoom(options.getZoom()); ReuestToServer(); }