List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:cl.gisred.android.CatastroActivity.java
public void dialogBusqueda() { AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this); dialogBusqueda.setTitle("Busqueda"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.dialog_busqueda, null); dialogBusqueda.setView(v);/* w w w . j a v a 2s .co m*/ Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda); final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar); final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, searchArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SpiBusqueda = position; if (position != 3) { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.VISIBLE); } else { if (llDireccion != null) llDireccion.setVisibility(View.VISIBLE); if (llBuscar != null) llBuscar.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show(); } }); final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar); final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle); final EditText eNumber = (EditText) v.findViewById(R.id.txtNum); dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (SpiBusqueda == 3) { txtBusqueda = new String(); if (!eStreet.getText().toString().isEmpty()) txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 " : eNumber.getText().toString().trim() + " "; txtBusqueda = txtBusqueda + eStreet.getText().toString(); } else { txtBusqueda = eSearch.getText().toString(); } if (txtBusqueda.trim().isEmpty()) { Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show(); } else { // Escala de calle para busquedas por default // TODO Asignar a res values o strings iBusqScale = 4000; switch (SpiBusqueda) { case 0: callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"), LyCLIENTES.getUrl().concat("/0")); if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0) iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 1: callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1")); if (LySED.getLayers() != null && LySED.getLayers().length > 1) iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 2: callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0")); if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0) iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 3: iBusqScale = 5000; String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() }; String[] sFields = { "nombre_calle", "numero" }; callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0")); break; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:com.if3games.chessonline.DroidFish.java
private final Dialog moveListMenuDialog() { final int EDIT_HEADERS = 0; final int EDIT_COMMENTS = 1; final int REMOVE_SUBTREE = 2; final int MOVE_VAR_UP = 3; final int MOVE_VAR_DOWN = 4; final int ADD_NULL_MOVE = 5; List<CharSequence> lst = new ArrayList<CharSequence>(); List<Integer> actions = new ArrayList<Integer>(); lst.add(getString(R.string.edit_headers)); actions.add(EDIT_HEADERS);// ww w.jav a2 s.c o m if (ctrl.humansTurn()) { lst.add(getString(R.string.edit_comments)); actions.add(EDIT_COMMENTS); } lst.add(getString(R.string.truncate_gametree)); actions.add(REMOVE_SUBTREE); if (ctrl.numVariations() > 1) { lst.add(getString(R.string.move_var_up)); actions.add(MOVE_VAR_UP); lst.add(getString(R.string.move_var_down)); actions.add(MOVE_VAR_DOWN); } boolean allowNullMove = gameMode.analysisMode() || (gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive()); if (allowNullMove) { lst.add(getString(R.string.add_null_move)); actions.add(ADD_NULL_MOVE); } final List<Integer> finalActions = actions; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit_game); builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (finalActions.get(item)) { case EDIT_HEADERS: { final TreeMap<String, String> headers = new TreeMap<String, String>(); ctrl.getHeaders(headers); AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this); builder.setTitle(R.string.edit_headers); View content = View.inflate(DroidFish.this, R.layout.edit_headers, null); builder.setView(content); final TextView event, site, date, round, white, black; event = (TextView) content.findViewById(R.id.ed_header_event); site = (TextView) content.findViewById(R.id.ed_header_site); date = (TextView) content.findViewById(R.id.ed_header_date); round = (TextView) content.findViewById(R.id.ed_header_round); white = (TextView) content.findViewById(R.id.ed_header_white); black = (TextView) content.findViewById(R.id.ed_header_black); event.setText(headers.get("Event")); site.setText(headers.get("Site")); date.setText(headers.get("Date")); round.setText(headers.get("Round")); white.setText(headers.get("White")); black.setText(headers.get("Black")); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { headers.put("Event", event.getText().toString().trim()); headers.put("Site", site.getText().toString().trim()); headers.put("Date", date.getText().toString().trim()); headers.put("Round", round.getText().toString().trim()); headers.put("White", white.getText().toString().trim()); headers.put("Black", black.getText().toString().trim()); ctrl.setHeaders(headers); setBoardFlip(true); } }); builder.show(); break; } case EDIT_COMMENTS: { AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this); builder.setTitle(R.string.edit_comments); View content = View.inflate(DroidFish.this, R.layout.edit_comments, null); builder.setView(content); DroidChessController.CommentInfo commInfo = ctrl.getComments(); final TextView preComment, moveView, nag, postComment; preComment = (TextView) content.findViewById(R.id.ed_comments_pre); moveView = (TextView) content.findViewById(R.id.ed_comments_move); nag = (TextView) content.findViewById(R.id.ed_comments_nag); postComment = (TextView) content.findViewById(R.id.ed_comments_post); preComment.setText(commInfo.preComment); postComment.setText(commInfo.postComment); moveView.setText(commInfo.move); String nagStr = Node.nagStr(commInfo.nag).trim(); if ((nagStr.length() == 0) && (commInfo.nag > 0)) nagStr = String.format(Locale.US, "%d", commInfo.nag); nag.setText(nagStr); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String pre = preComment.getText().toString().trim(); String post = postComment.getText().toString().trim(); int nagVal = Node.strToNag(nag.getText().toString()); DroidChessController.CommentInfo commInfo = new DroidChessController.CommentInfo(); commInfo.preComment = pre; commInfo.postComment = post; commInfo.nag = nagVal; ctrl.setComments(commInfo); } }); builder.show(); break; } case REMOVE_SUBTREE: ctrl.removeSubTree(); break; case MOVE_VAR_UP: ctrl.moveVariation(-1); break; case MOVE_VAR_DOWN: ctrl.moveVariation(1); break; case ADD_NULL_MOVE: ctrl.makeHumanNullMove(); break; } moveListMenuDlg = null; } }); AlertDialog alert = builder.create(); moveListMenuDlg = alert; return alert; }
From source file:cl.gisred.android.LectorActivity.java
public void dialogBusqueda() { AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this); dialogBusqueda.setTitle("Busqueda"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.dialog_busqueda, null); dialogBusqueda.setView(v);//from w w w . j a v a 2 s. c o m Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda); final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar); final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, searchArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SpiBusqueda = position; if (position != 4) { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.VISIBLE); } else { if (llDireccion != null) llDireccion.setVisibility(View.VISIBLE); if (llBuscar != null) llBuscar.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show(); } }); final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar); final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle); final EditText eNumber = (EditText) v.findViewById(R.id.txtNum); dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (SpiBusqueda == 4) { txtBusqueda = new String(); if (!eStreet.getText().toString().isEmpty()) txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 " : eNumber.getText().toString().trim() + " "; txtBusqueda = txtBusqueda + eStreet.getText().toString(); } else { if (SpiBusqueda > 1) txtBusqueda = eSearch.getText().toString(); else txtBusqueda = Util.extraerNum(eSearch.getText().toString()); } if (txtBusqueda.trim().isEmpty()) { Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show(); } else { // Escala de calle para busquedas por default iBusqScale = 4000; switch (SpiBusqueda) { case 0: callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"), LyCLIENTES.getUrl().concat("/0")); if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0) iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 1: callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1")); if (LySED.getLayers() != null && LySED.getLayers().length > 1) iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 2: callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0")); if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0) iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 3: callQuery(txtBusqueda, "serie_medidor", LyMEDIDORES.getUrl().concat("/1")); if (LyMEDIDORES.getLayers() != null && LyMEDIDORES.getLayers().length > 1) iBusqScale = LyMEDIDORES.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 4: iBusqScale = 5000; String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() }; String[] sFields = { "nombre_calle", "numero" }; callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0")); break; case 5: callQuery(txtBusqueda, new String[] { "id_equipo", "nombre" }, LyEQUIPOSLINEA.getUrl().concat("/0")); if (LyEQUIPOSLINEA.getLayers() != null && LyEQUIPOSLINEA.getLayers().length > 0) iBusqScale = LyEQUIPOSLINEA.getLayers()[0].getLayerServiceInfo().getMinScale(); break; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:cl.gisred.android.InspActivity.java
public void dialogBusqueda() { AlertDialog.Builder dialogBusqueda = new AlertDialog.Builder(this); dialogBusqueda.setTitle("Busqueda"); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.dialog_busqueda, null); dialogBusqueda.setView(v);/* w w w .jav a2 s . co m*/ Spinner spinner = (Spinner) v.findViewById(R.id.spinnerBusqueda); final LinearLayout llBuscar = (LinearLayout) v.findViewById(R.id.llBuscar); final LinearLayout llDireccion = (LinearLayout) v.findViewById(R.id.llBuscarDir); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, searchArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SpiBusqueda = position; if (position != 4) { if (llDireccion != null) llDireccion.setVisibility(View.GONE); if (llBuscar != null) llBuscar.setVisibility(View.VISIBLE); } else { if (llDireccion != null) llDireccion.setVisibility(View.VISIBLE); if (llBuscar != null) llBuscar.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(getApplicationContext(), "Nada seleccionado", Toast.LENGTH_SHORT).show(); } }); final EditText eSearch = (EditText) v.findViewById(R.id.txtBuscar); final EditText eStreet = (EditText) v.findViewById(R.id.txtCalle); final EditText eNumber = (EditText) v.findViewById(R.id.txtNum); dialogBusqueda.setPositiveButton("Buscar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (SpiBusqueda == 4) { txtBusqueda = new String(); if (!eStreet.getText().toString().isEmpty()) txtBusqueda = (eNumber.getText().toString().trim().isEmpty()) ? "0 " : eNumber.getText().toString().trim() + " "; txtBusqueda = txtBusqueda + eStreet.getText().toString(); } else { if (SpiBusqueda > 1) txtBusqueda = eSearch.getText().toString(); else txtBusqueda = Util.extraerNum(eSearch.getText().toString()); } if (txtBusqueda.trim().isEmpty()) { Toast.makeText(myMapView.getContext(), "Debe ingresar un valor", Toast.LENGTH_SHORT).show(); } else { // Escala de calle para busquedas por default // TODO Asignar a res values o strings iBusqScale = 4000; switch (SpiBusqueda) { case 0: callQuery(txtBusqueda, getValueByEmp("CLIENTES_XY_006.nis"), LyCLIENTES.getUrl().concat("/0")); if (LyCLIENTES.getLayers() != null && LyCLIENTES.getLayers().length > 0) iBusqScale = LyCLIENTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 1: callQuery(txtBusqueda, "codigo", LySED.getUrl().concat("/1")); if (LySED.getLayers() != null && LySED.getLayers().length > 1) iBusqScale = LySED.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 2: callQuery(txtBusqueda, "rotulo", LyPOSTES.getUrl().concat("/0")); if (LyPOSTES.getLayers() != null && LyPOSTES.getLayers().length > 0) iBusqScale = LyPOSTES.getLayers()[0].getLayerServiceInfo().getMinScale(); break; case 3: callQuery(txtBusqueda, "serie_medidor", LyMEDIDORES.getUrl().concat("/1")); if (LyMEDIDORES.getLayers() != null && LyMEDIDORES.getLayers().length > 1) iBusqScale = LyMEDIDORES.getLayers()[1].getLayerServiceInfo().getMinScale(); break; case 4: iBusqScale = 5000; String[] sBuscar = { eStreet.getText().toString(), eNumber.getText().toString() }; String[] sFields = { "nombre_calle", "numero" }; callQuery(sBuscar, sFields, LyDIRECCIONES.getUrl().concat("/0")); break; case 5: callQuery(txtBusqueda, new String[] { "id_equipo", "nombre" }, LyEQUIPOSLINEA.getUrl().concat("/0")); if (LyEQUIPOSLINEA.getLayers() != null && LyEQUIPOSLINEA.getLayers().length > 0) iBusqScale = LyEQUIPOSLINEA.getLayers()[0].getLayerServiceInfo().getMinScale(); break; } } } }); dialogBusqueda.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialogBusqueda.show(); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void show_tours_dialog(final boolean byTag) { final List<String> listTours = new ArrayList<String>(); tourDB.open();//from w w w .j a v a 2 s. c om if (byTag) //only select tours from data basethat have this tag { Cursor c = tourDB.getRecordByTag(getlasttagScanned()); if (c != null && c.moveToFirst()) { for (int i = 0; i < c.getCount(); i++) { listTours.add(c.getString(1)); c.moveToNext(); } } } else //select all tours from data base { Cursor c = tourDB.getDistinctRecordByColumn("1"); if (c != null && c.moveToFirst()) { for (int i = 0; i < c.getCount(); i++) { listTours.add(c.getString(0)); c.moveToNext(); } } } tourDB.close(); if (listTours.size() > 0) { //add cancel listTours.add("Cancel"); final CharSequence[] tours = listTours.toArray(new CharSequence[listTours.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select a Tour"); builder.setItems(tours, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int location) { if (location != listTours.size() - 1) //tour selected { //if tour started but not completed write to the trp file //touritemNumber > 0 indicates that at least one tag has been scanned if (GTConstants.trpfilename.length() > 1 && touritemNumber >= 0) endtrpFile(false); else cleantourInfo(); //set the new tour name GTConstants.tourName = listTours.get(location); //set up the tag scan list to false by getting the total number of items in the tour and then calling refreshtourtagList tourDB.open(); Cursor c = tourDB.getRecordByTour(GTConstants.tourName); c.moveToFirst(); tourDB.close(); refreshtourtagList(c.getCount(), true, false, false, false); //update the warning text setwarningText(""); //set the tour reminder //parse the time info to see if a reminder message offset was included //the offset will be in minutes and be preceded by either a + or - sign Long offset = (long) 0; c.moveToFirst(); String setTime = c.getString(4); if (setTime.contains("+") || setTime.contains("-")) { String[] parse = null; if (setTime.contains("+")) parse = setTime.split("\\+"); if (setTime.contains("-")) parse = setTime.split("\\-"); setTime = parse[0]; offset = Long.valueOf(parse[1]) * 60000; Date now = null; try { now = sdf.parse(Utility.getLocalDate() + " " + parse[0]); tourEnd = now.getTime() + offset; } catch (ParseException e) { tourEnd = (long) 0; } tourTime = parse[0].substring(0, parse[0].length() - 3) + " hrs for " + parse[1] + " mins"; } else { Date now = null; try { now = sdf.parse(Utility.getLocalDate() + " " + setTime); tourEnd = now.getTime(); } catch (ParseException e) { tourEnd = (long) 0; } tourTime = setTime.substring(0, setTime.length() - 3); } //set reminder Utility.settourReminder(ctx, setTime, offset, "Tour " + GTConstants.tourName + " not completed!"); //write to dar file Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.darfileName, "Event; Tour " + GTConstants.tourName + " selected;" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); //write to srp file if (GTConstants.srpfileName.length() > 1) Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.srpfileName, "Event; Tour " + GTConstants.tourName + " selected;" + Utility.getLocalTime() + ";" + Utility.getLocalDate() + "\r\n", true); //if the tour was established by a tag scan then update the list if (byTag) updateTour(getlasttagScanned()); else updateTour(""); //Utility.settourReminder(ctx, setTime, offset,"Reminder: " + c.getString(2)); //Toast.makeText(HomeScreen.this,"Set time: " + setTime, Toast.LENGTH_SHORT).show(); } else //this is the cancel selection { //previous tour not completed //touritemNumber > 0 indicates that at least one tag has been scanned if (GTConstants.trpfilename.length() > 1 && touritemNumber >= 0) endtrpFile(false); else cleantourInfo(); //update the warning text setwarningText(""); } } }); builder.show(); } }
From source file:com.rfo.basic.Run.java
private void doDebugSwapDialog() { ArrayList<String> msg = new ArrayList<String>(); msg.addAll(Arrays.asList("Program", "Scalars", "Array", "List", "Stack", "Bundle", "Watch")); final String[] names = { "View Program", "View Scalars", "View Array", "View List", "View Stack", "View Bundle", "View Watch", "View Console" }; LayoutInflater inflater = getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.debug_list_s_layout, null); ListView debugView = (ListView) dialogLayout.findViewById(R.id.debug_list_s); debugView.setAdapter(new ArrayAdapter<String>(Run.this, R.layout.simple_list_layout_1, msg)); debugView.setVerticalScrollBarEnabled(true); debugView.setClickable(true);/* w ww . j a va2 s .c om*/ debugView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { DialogSelector(position); boolean dosel = (dbDialogArray && WatchedArray == null) || (dbDialogList && WatchedList == -1) || (dbDialogStack && WatchedStack == -1) || (dbDialogBundle && WatchedBundle == -1); if (dosel) { // if the element has not been defined ask if user wishes to do so. // or at least this is where it will go. // for now, default to view program. DialogSelector(0); position = 0; } String name = (position < names.length) ? names[position] : ""; Toaster(name).show(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(Run.this).setCancelable(true).setTitle("Select View:") .setView(dialogLayout); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface arg0) { WaitForSwap = false; } }); builder.setPositiveButton("Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { WaitForSwap = false; dbSwap = false; } }); /* // leave out until the element selector is done. builder.setNeutralButton("Choose Element", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { WaitForSelect = true; } }); */ dbSwapDialog = builder.show(); dbSwapDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); }
From source file:com.rfo.basic.Run.java
private void doDebugDialog() { int lineIndex = 0; String text = ""; if (mInterpreter != null) { lineIndex = mInterpreter.ExecutingLineIndex; text = mInterpreter.ExecutingLineBuffer.text(); }//from w ww . j a v a 2 s .c o m ArrayList<String> msg = new ArrayList<String>(); if (!dbDialogProgram) { msg = mInterpreter.dbDoFunc(); msg.add("Executable Line #: " + Integer.toString(lineIndex + 1) + '\n' + chomp(text)); } if (dbDialogScalars) msg.addAll(mInterpreter.dbDoScalars(" ")); if (dbDialogArray) msg.addAll(mInterpreter.dbDoArray(" ")); if (dbDialogList) msg.addAll(mInterpreter.dbDoList(" ")); if (dbDialogStack) msg.addAll(mInterpreter.dbDoStack(" ")); if (dbDialogBundle) msg.addAll(mInterpreter.dbDoBundle(" ")); if (dbDialogWatch) msg.addAll(mInterpreter.dbDoWatch(" ")); if (dbDialogProgram) { for (int i = 0; i < Basic.lines.size(); ++i) { msg.add(((i == lineIndex) ? " >>" : " ") // mark current line + (i + 1) + ": " // one-based line index + chomp(Basic.lines.get(i).text())); // remove newline } } LayoutInflater inflater = getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.debug_dialog_layout, null); ListView debugView = (ListView) dialogLayout.findViewById(R.id.debug_list); debugView.setAdapter(new ArrayAdapter<String>(Run.this, R.layout.debug_list_layout, msg)); debugView.setVerticalScrollBarEnabled(true); if (dbDialogProgram) { debugView.setSelection(lineIndex); } AlertDialog.Builder builder = new AlertDialog.Builder(Run.this).setCancelable(true) .setTitle(R.string.debug_name).setView(dialogLayout); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface arg0) { DebuggerHalt = true; WaitForDebugResume = false; releaseDebugLOCK(); } }); builder.setPositiveButton("Resume", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { WaitForDebugResume = false; releaseDebugLOCK(); } }); builder.setNeutralButton("Step", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DebuggerStep = true; WaitForDebugResume = true; releaseDebugLOCK(); } }); builder.setNegativeButton("View Swap", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dbSwap = true; releaseDebugLOCK(); } }); dbDialog = builder.show(); dbDialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); }
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void voice_click() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("Microphone"); dialog.setMessage("Record a voice note?"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from www. j av a 2 s .c o m*/ public void onClick(DialogInterface dialog, int which) { try { //open the voice recorder Intent recordIntent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION); /* String path = GTConstants.sendfileFolder + Utility.createFileName() + ".3ga"; file_name = path; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); recordIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, outputFileUri); */ startActivityForResult(recordIntent, REQUEST_CODE_RECORD); } catch (Exception e) { Toast.makeText(HomeScreen.this, "Voice Recorder not found: ", Toast.LENGTH_LONG).show(); } } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { /* boolean temp = Utility.isInsideGeofence(HomeScreen.this, "42.76823265", "-74.236642"); Toast.makeText(HomeScreen.this,String.valueOf(temp), Toast.LENGTH_SHORT).show(); Double d = Utility.getDistance("42.76823265","-74.236642","42.66823265","-74.2466428"); Toast.makeText(HomeScreen.this,"Distance: " + String.valueOf(d), Toast.LENGTH_SHORT).show(); boolean temp = Utility.isInsideGeofence(HomeScreen.this, "42.76823265", "-74.236642"); Toast.makeText(HomeScreen.this,String.valueOf(temp), Toast.LENGTH_SHORT).show(); List<String> temp = new ArrayList<String>(); temp = Utility.getGpsGeoFence(HomeScreen.this,1); Toast.makeText(HomeScreen.this,"size: " + String.valueOf(temp.size()), Toast.LENGTH_SHORT).show(); for(int i=0;i<temp.size();i++)Toast.makeText(HomeScreen.this,temp.get(i), Toast.LENGTH_SHORT).show(); Double d = Utility.getDistance("40.6680185","-74.2452543","40.6671548","-74.2375617"); Toast.makeText(HomeScreen.this,"Distance: " + String.valueOf(d), Toast.LENGTH_SHORT).show(); boolean temp = Utility.isInsideGeofence(HomeScreen.this, "40.68", "-74.25"); Toast.makeText(HomeScreen.this,String.valueOf(temp), Toast.LENGTH_SHORT).show(); temp = Utility.isInsideGeofence(HomeScreen.this, "40.65", "-74.25"); Toast.makeText(HomeScreen.this,String.valueOf(temp), Toast.LENGTH_SHORT).show(); List<String> temp = new ArrayList<String>(); temp = Utility.getGpsGeoFence(HomeScreen.this); for(int i=0;i<temp.size();i++)Toast.makeText(HomeScreen.this,temp.get(i), Toast.LENGTH_SHORT).show(); String temp = Utility.get_from_GTParamsDataBase(HomeScreen.this, "gps_call"); Toast.makeText(HomeScreen.this,temp, Toast.LENGTH_SHORT).show(); GTParams gtDB; gtDB = new GTParams(ctx); //open the Database to insert the values gtDB.open(); Cursor c = gtDB.getRecordByParam("gps_loc"); Toast.makeText(HomeScreen.this,"Num records = " + String.valueOf(c.getCount()), Toast.LENGTH_SHORT).show(); String [] parse; if(c != null && c.moveToFirst()) { for(int i = 0;i<c.getCount();i++) { parse = c.getString(2).split("&"); //Toast.makeText(HomeScreen.this,c.getString(2), Toast.LENGTH_LONG).show(); for(int j=0;j<4;j++)Toast.makeText(HomeScreen.this,parse[j], Toast.LENGTH_SHORT).show(); c.moveToNext(); } } gtDB.close(); Toast.makeText(HomeScreen.this, "reminder: " + String.valueOf(Utility.istourOntime(tourEnd)), Toast.LENGTH_SHORT).show(); String value = String.valueOf(GTConstants.sendData) + "," + GTConstants.darfileName + "," + GTConstants.tarfileName + "," + GTConstants.trpfilename + "," + GTConstants.tourName; Utility.storesharedPreference(HomeScreen.this, "serviceString", value); //get the parameters that were saved when HomeScreen was shut down String serviceString = Utility.getsharedPreference(HomeScreen.this, "serviceString"); Toast.makeText(HomeScreen.this, "serviceString: " + serviceString, Toast.LENGTH_SHORT).show(); try { String [] parse = serviceString.split(","); GTConstants.sendData = Boolean.valueOf(parse[0]); GTConstants.darfileName = parse[1]; GTConstants.tarfileName = parse[2]; GTConstants.trpfilename = parse[3]; GTConstants.tourName = parse[4]; }catch(Exception e) { Toast.makeText(HomeScreen.this, "error: " + e, Toast.LENGTH_SHORT).show(); } //get the parameters from the data base preferenceDB.open(); Cursor c = preferenceDB.getRecordByRowID("1"); GTConstants.LOCATIONUPDATESINTERVAL = c.getString(1); GTConstants.LOCATIONUPDATEDISTANCEINTERVAL = c.getString(2); GTConstants.SERVERIP = c.getString(3); GTConstants.SERVERPORT = Integer.parseInt(c.getString(4)); GTConstants.PANIC_NUMBER = c.getString(5); GTConstants.UNIQUE_ID = c.getString(6); GTConstants.ACCELEROMETER_SPEED = Integer.parseInt(c.getString(7)); GTConstants.LICENSE_ID = c.getString(8); GTConstants.PHONE_TYPE = c.getString(9); GTConstants.REGISTRATION = c.getString(10); c.close(); //Retrieve last saved user name from preferences GTConstants.report_name = Utility.getsharedPreference(HomeScreen.this, "userName"); c.close(); preferenceDB.close(); if(!test) { Intent service_intent = new Intent(HomeScreen.this,StandAloneMainService.class); startService(service_intent); test = true; } else { Toast.makeText(HomeScreen.this,"Stopping...", Toast.LENGTH_SHORT).show(); stopService(new Intent(HomeScreen.this, StandAloneMainService.class)); } //Intent service_intent = new Intent(HomeScreen.this, MainService.class); //startService(service_intent); //List<Boolean> returnList = new ArrayList<Boolean>(); //refreshtourtagList(5, true,false,false,false); //refreshtourtagList(3, false,false,false,true); //returnList = refreshtourtagList(5, false,false,true,false); //for(int i =0;i<returnList.size();i++)Toast.makeText(HomeScreen.this,String.valueOf(i) + " " + String.valueOf(returnList.get(i)), Toast.LENGTH_SHORT).show(); /* //Toast.makeText(HomeScreen.this,String.valueOf(GTConstants.locationInfoDTO.getLastAcquire(System.currentTimeMillis() / 1000)), Toast.LENGTH_LONG).show(); if(MainService.isgpsActivated()) Toast.makeText(HomeScreen.this,"Active", Toast.LENGTH_SHORT).show(); else Toast.makeText(HomeScreen.this,"Not Active", Toast.LENGTH_SHORT).show(); tourDB.open(); Cursor c = tourDB.getRecordByTag("0E401005317A9CED"); if(c != null && c.moveToFirst()) { Toast.makeText(HomeScreen.this,"Num records = " + String.valueOf(c.getCount()), Toast.LENGTH_SHORT).show(); for(int i = 0;i<c.getCount();i++) { Toast.makeText(HomeScreen.this,"Tour " + c.getString(1), Toast.LENGTH_SHORT).show(); c.moveToNext(); } } //Toast.makeText(HomeScreen.this,String.valueOf(tourDB.getNumRecords()), Toast.LENGTH_SHORT).show(); tourDB.close(); String temp = String.valueOf(MainService.istourReminder()); Toast.makeText(HomeScreen.this,temp , Toast.LENGTH_SHORT).show(); try { String setTime = "11:11:11+5"; long offset = 0; if(setTime.contains("+") || setTime.contains("-")) { String[] parse = null; if(setTime.contains("+"))parse = setTime.split("\\+"); if(setTime.contains("-"))parse = setTime.split("\\-"); setTime = parse[0]; offset = Long.valueOf(parse[1])*60000; } Toast.makeText(HomeScreen.this,setTime , Toast.LENGTH_SHORT).show(); Toast.makeText(HomeScreen.this,String.valueOf(offset) , Toast.LENGTH_SHORT).show(); }catch(Exception e) { Toast.makeText(HomeScreen.this,"Error: " +e, Toast.LENGTH_LONG).show(); } Toast.makeText(HomeScreen.this,String.valueOf(tourtagsScanned.size()) , Toast.LENGTH_SHORT).show(); for(int i = 0;i<tourtagsScanned.size();i++) { Toast.makeText(HomeScreen.this,String.valueOf(tourtagsScanned.get(i)) , Toast.LENGTH_SHORT).show(); } tourtagsScanned.set(1, true); Toast.makeText(HomeScreen.this,String.valueOf(tourtagsScanned.get(1)) , Toast.LENGTH_SHORT).show(); tourtagsScanned.clear(); tourtagsScanned.add(true); tourtagsScanned.add(false); tourtagsScanned.add(true); Toast.makeText(HomeScreen.this,String.valueOf(tourtagsScanned.size()) , Toast.LENGTH_LONG).show(); for(int i = 0;i<tourtagsScanned.size();i++) { Toast.makeText(HomeScreen.this,String.valueOf(tourtagsScanned.get(i)) , Toast.LENGTH_LONG).show(); } //String temp = Utility.offsetTime(Utility.getLocalDate() + " " + "01:00:00",86400000); //Toast.makeText(HomeScreen.this,temp , Toast.LENGTH_LONG).show(); String temp = Utility.gettimeDiff("10-26-14 23:00:00",Utility.getLocalDate() + " " + "01:00:00"); Toast.makeText(HomeScreen.this,temp, Toast.LENGTH_LONG).show(); if(temp.charAt(0) == '-' && Integer.valueOf(temp.substring(4, 6)) >= 12) { Toast.makeText(HomeScreen.this,temp.substring(4, 6), Toast.LENGTH_LONG).show(); //add one day temp = Utility.offsetTime(Utility.getLocalDate() + " " + "01:00:00",86400000); Toast.makeText(HomeScreen.this,temp , Toast.LENGTH_LONG).show(); } //String temp = Utility.parsetarFile(HomeScreen.this); //Toast.makeText(HomeScreen.this,temp, Toast.LENGTH_LONG).show(); //Utility.parsetarFile(HomeScreen.this); //show_taaSignature_dialog(); try { String[] test = {"1","2"}; Toast.makeText(HomeScreen.this,test[0] + " " + test[1], Toast.LENGTH_LONG).show(); }catch(Exception e) { Toast.makeText(HomeScreen.this,"Error: " +e, Toast.LENGTH_LONG).show(); } //test = test + "3"; try { String temp = Utility.offsetTime(Utility.getLocalDateTime(),10000); //Toast.makeText(HomeScreen.this,temp + " " + temp1, Toast.LENGTH_LONG).show(); MainService.initializetourReminder(temp,"Hello"); }catch(Exception e) { Toast.makeText(HomeScreen.this,"Error: " +e, Toast.LENGTH_LONG).show(); } //Toast.makeText(HomeScreen.this,"MB = " + Utility.gettotalmegaBytes(HomeScreen.this), Toast.LENGTH_LONG).show(); //long tx=TrafficStats.getTotalTxBytes(); try { if(tourDB.checkDataBase()) { tourDB.open(); Toast.makeText(HomeScreen.this,"Num records = " + String.valueOf(tourDB.getNumRecords()), Toast.LENGTH_SHORT).show(); //tourDB.deleteDB(); //tourDB.insertRecord("Tour 1","2nd Floor Bathroom" ," "," "); //tourDB.insertRecord("Tour 1","3rd Floor Bathroom" ," "," "); //tourDB.insertRecord("Tour 1","4rth Floor Bathroom" ," "," "); //tourDB.insertRecord("Tour 2","1st Floor Bathroom" ," "," "); //tourDB.insertRecord("Tour 2","1st Floor lobby" ," "," "); //Cursor c = tourDB.getRecordByParameter("Tour 1"); //Cursor c = tourDB.getallRecords(); Cursor c = tourDB.getDistinctRecordByColumn("1"); Toast.makeText(HomeScreen.this,"Num records = " + String.valueOf(c.getCount()), Toast.LENGTH_SHORT).show(); if(c != null && c.moveToFirst()) { for(int i = 0;i<c.getCount();i++) { Toast.makeText(HomeScreen.this,c.getString(0), Toast.LENGTH_SHORT).show(); //Toast.makeText(HomeScreen.this,c.getString(1) + " " + c.getString(2), Toast.LENGTH_SHORT).show(); c.moveToNext(); } } //Toast.makeText(HomeScreen.this,String.valueOf(tourDB.getNumRecords()), Toast.LENGTH_SHORT).show(); tourDB.close(); } else { tourDB.open(); tourDB.close(); } }catch(Exception e) { Toast.makeText(HomeScreen.this,"error: " + e, Toast.LENGTH_SHORT).show(); } //MainService.mainserviceDialog("Test","Test"); //Toast.makeText(HomeScreen.this,"Time: " + Utility.getLocalTime(), Toast.LENGTH_LONG).show(); //Toast.makeText(HomeScreen.this,"Time: " + Utility.getLocalDate(), Toast.LENGTH_LONG).show(); //Toast.makeText(HomeScreen.this,"Server: " + Utility.getServerResponse(), Toast.LENGTH_LONG).show(); //Toast.makeText(HomeScreen.this,"Lunch Out = " + String.valueOf(lunchoutLocation), Toast.LENGTH_SHORT).show(); //Toast.makeText(HomeScreen.this,"Break Out = " + String.valueOf(breakoutLocation), Toast.LENGTH_SHORT).show(); trafficDB.open(); Cursor c = trafficDB.getallRecords(); if(c != null && c.moveToFirst()) { for(int i=0;i<trafficDB.getNumRecords();i++) { Toast.makeText(HomeScreen.this,"License: " + c.getString(1) + " " + c.getString(2), Toast.LENGTH_SHORT).show(); c.moveToNext(); } } trafficDB.close(); //Toast.makeText(HomeScreen.this,"Current time = " + Utility.getLocalDateTime(), Toast.LENGTH_SHORT).show(); //Toast.makeText(HomeScreen.this,"Lunch start = " + Utility.getlunchStart(), Toast.LENGTH_SHORT).show(); //Toast.makeText(HomeScreen.this,"Diff = " + Utility.gettimeDiff(Utility.getlunchStart(), Utility.getLocalDateTime()), Toast.LENGTH_SHORT).show(); //Toast.makeText(HomeScreen.this,"Diff = " + Utility.gettimeDiff(Utility.getsessionStart(), new SimpleDateFormat("MM-dd-yy HH:mm:ss")), Toast.LENGTH_SHORT).show(); /* trafficDB.open(); String license = "AAA123"; String fields [] ={"NJ","AAA123","01-01-12","01-02-14","2"}; int i = 0; //check if license already in data base, if not just insert Cursor c = trafficDB.getRecordByParameter(fields[i+1]); if(c != null && c.moveToFirst()) { //choose which parameters to update data base with String temp [] = new String[5]; //test State if(fields[i].equalsIgnoreCase("--")) temp[0] = c.getString(1); else temp[0] = fields[i]; //set license from incoming data temp[1] = fields[i+1]; //test first date of violation. Keep the earlier one. if(Integer.parseInt(Utility.getdiffDays(c.getString(3), fields[i+2])) >= 0) temp[2] = c.getString(3); else temp[2] =fields[i+2]; //test last date of violation. Keep the later one. Toast.makeText(HomeScreen.this,"Days = " + Utility.getdiffDays(c.getString(4), fields[i+3]), Toast.LENGTH_SHORT).show(); if(Integer.parseInt(Utility.getdiffDays(c.getString(4), fields[i+3])) >= 0) temp[3] = fields[i+3]; else temp[3] = c.getString(4); //test the number of violations. Put in the greater of the two if(Integer.parseInt( fields[i+4]) >= Integer.parseInt(c.getString(5))) temp[4] = fields[i+4]; else temp[4] = c.getString(5); //update the data base trafficDB.UpdateRecord(Long.parseLong(c.getString(0)), temp[0], temp[1], temp[2], temp[3], temp[4]); } else trafficDB.insertRecord(fields[i], fields[i+1], fields[i+2], fields[i+3], fields[i+4]); trafficDB.close(); c = Utility.getTrafficViolations(HomeScreen.this,license); if(c != null && c.moveToFirst()) { Toast.makeText(HomeScreen.this,"Data: " + c.getString(1) + " " + c.getString(2)+ " " + c.getString(3) + " "+ c.getString(4) + " " + c.getString(5), Toast.LENGTH_SHORT).show(); } else Toast.makeText(HomeScreen.this,"No violations", Toast.LENGTH_LONG).show(); /* Toast.makeText(HomeScreen.this,"Days = " + Utility.getdiffDays("01-01-14", "01-01-13"), Toast.LENGTH_SHORT).show(); String license = "NJ,SHX73Y"; Cursor c = Utility.getTrafficViolations(HomeScreen.this,license); if(c != null && c.moveToFirst()) { Toast.makeText(HomeScreen.this,"Data: " + c.getString(1) + " " + c.getString(2)+ " " + c.getString(3) + " "+ c.getString(4) + " " + c.getString(5), Toast.LENGTH_SHORT).show(); } else Toast.makeText(HomeScreen.this,"No violations", Toast.LENGTH_SHORT).show(); license = "SHX73Y"; c = Utility.getTrafficViolations(HomeScreen.this,license); if(c != null && c.moveToFirst()) { Toast.makeText(HomeScreen.this,"Data 2: " + c.getString(1) + " " + c.getString(2)+ " " + c.getString(3) + " "+ c.getString(4) + " " + c.getString(5), Toast.LENGTH_SHORT).show(); } else Toast.makeText(HomeScreen.this,"No violations", Toast.LENGTH_SHORT).show(); String test = "trafficModule"; if(test.contains("traffic")) Toast.makeText(HomeScreen.this,"True", Toast.LENGTH_SHORT).show(); else Toast.makeText(HomeScreen.this,"False ", Toast.LENGTH_SHORT).show(); try { trafficDB.open(); trafficDB.deleteDB(); trafficDB.insertRecord("NJ","SHX75Y" ,"09-14-13","09-14-14","1"); trafficDB.insertRecord("NJ","ABCDEF" ,"09-14-13","09-14-14","2"); trafficDB.insertRecord("NJ","HIJKLM" ,"09-14-13","09-14-14","3"); trafficDB.insertRecord("NJ","234567" ,"09-14-13","09-14-14","4"); trafficDB.insertRecord("NJ","AAA111" ,"09-14-13","09-14-13","4"); trafficDB.close(); Toast.makeText(HomeScreen.this,"Days = " + Utility.getdayssincelastViolation(HomeScreen.this, "AAA 111"), Toast.LENGTH_SHORT).show(); }catch(Exception e) { Toast.makeText(HomeScreen.this,"error: " + e, Toast.LENGTH_SHORT).show(); } try { String license = "ABC 123"; Cursor c = Utility.getTrafficViolations(HomeScreen.this,license); //Cursor c = Utility.getTrafficViolations(HomeScreen.this,"234 567"); if(!(c == null)) { c.moveToFirst(); Toast.makeText(HomeScreen.this,"Last violation = " + c.getString(4), Toast.LENGTH_SHORT).show(); Toast.makeText(HomeScreen.this,"num violations = " + c.getString(5), Toast.LENGTH_SHORT).show(); } else Toast.makeText(HomeScreen.this,"No violations", Toast.LENGTH_SHORT).show(); Utility.updatetrafficViolations(HomeScreen.this, "NJ", license); }catch(Exception e) { Toast.makeText(HomeScreen.this,"error: " + e, Toast.LENGTH_SHORT).show(); } try { if(trafficDB.checkDataBase()) { trafficDB.open(); Cursor c = trafficDB.getRecordByParameter("234567"); if(!(c == null)) { c.moveToFirst(); Toast.makeText(HomeScreen.this,"num violations = " + c.getString(5), Toast.LENGTH_SHORT).show(); } for(int i=1;i<trafficDB.getNumRecords()+1;i++) { Toast.makeText(HomeScreen.this,"num: " + String.valueOf(i), Toast.LENGTH_SHORT).show(); //Cursor c = trafficDB.getRecordByRowID(String.valueOf(i)); Cursor c = trafficDB.getallRecords(); c.moveToFirst(); Toast.makeText(HomeScreen.this,"c " + c.getString(1) + c.getString(2), Toast.LENGTH_SHORT).show(); } //trafficDB.deleteDB(); //trafficDB.insertRecord("NJ","SHX75Y" ,"091413","091414","1"); //trafficDB.insertRecord("NJ","ABCDEF" ,"091413","091414","2"); //trafficDB.insertRecord("NJ","HIJKLM" ,"091413","091414","3"); //trafficDB.insertRecord("NJ","234567" ,"091413","091414","4"); //int i = trafficDB.getNumRecords(); trafficDB.close(); //Toast.makeText(HomeScreen.this,"num: " + String.valueOf(i), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(HomeScreen.this,"Creating trafficDB", Toast.LENGTH_SHORT).show(); trafficDB.open(); trafficDB.close(); } }catch(Exception e) { Toast.makeText(HomeScreen.this,"error: " + e, Toast.LENGTH_SHORT).show(); } myDatabase.open(); myDatabase.deleteDB(); myDatabase.close(); myDatabase.open(); { cursor = myDatabase.getRecordByStatus("0"); if (cursor.moveToFirst()) { do { //get the data String dMessage = cursor.getString(1).toString(); Toast.makeText(HomeScreen.this,dMessage, Toast.LENGTH_SHORT).show(); } while (cursor.moveToNext()); } cursor.close(); } myDatabase.close(); myDatabase.open(); Toast.makeText(HomeScreen.this,"Num records = " + String.valueOf(myDatabase.getnumRecords()), Toast.LENGTH_SHORT).show(); myDatabase.close(); File wFile = new File(GTConstants.sendfileFolder); Toast.makeText(HomeScreen.this,"Num files = " + String.valueOf(Utility.getnumFiles(wFile)), Toast.LENGTH_SHORT).show(); Utility.checkboxDialog(HomeScreen.this,"email","reportEmailPref"); accountsDB aDB; aDB = new accountsDB(HomeScreen.this); aDB.open(); for(int i=1;i<aDB.getNumRecords()+1;i++) { Cursor c = aDB.getRecordByRowID(String.valueOf(i)); Toast.makeText(HomeScreen.this,c.getString(1) + " " + c.getString(2), Toast.LENGTH_SHORT).show(); } aDB.close(); */ /* * * ActivityManager activityManager = (ActivityManager) getSystemService( ACTIVITY_SERVICE ); List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses(); for(int i = 0; i < procInfos.size(); i++) { if(procInfos.get(i).processName.equals("com.guardtrax")) { Toast.makeText(getApplicationContext(), "GuardTrax is running", Toast.LENGTH_LONG).show(); } } incidentCodeDataBase icdatabase; icdatabase = new incidentCodeDataBase(HomeScreen.this); icdatabase.open(); for(int i=1;i<icdatabase.getNumRecords()+1;i++) { Cursor c = icdatabase.getRecordByRowID(String.valueOf(i)); Toast.makeText(HomeScreen.this, "Code: " + c.getString(1), Toast.LENGTH_SHORT).show(); } icdatabase.close(); String test; for(int i=0;i<4;i++) { test = Utility.getkeyCode(HomeScreen.this,i); Toast.makeText(HomeScreen.this, "Code: " + test, Toast.LENGTH_SHORT).show(); } if( Utility.isfilewithexExists("/GT/temp/", "dar")) { Toast.makeText(HomeScreen.this, "Exists", Toast.LENGTH_SHORT).show(); List<String> temp = Utility.get_saved_file_names("/GT/temp", false, true, "dar"); for(int i = 0; i < temp.size();i++) { Toast.makeText(HomeScreen.this, temp.get(i).toString() , Toast.LENGTH_SHORT).show(); } }else { Toast.makeText(HomeScreen.this, "not exists" , Toast.LENGTH_SHORT).show(); } if(Utility.isOnline(HomeScreen.this)) Toast.makeText(HomeScreen.this, "Data connection", Toast.LENGTH_LONG).show(); else { Toast.makeText(HomeScreen.this, "No Data connection - " + GTConstants.nodataSMS, Toast.LENGTH_LONG).show(); Utility.send_nodata_message(HomeScreen.this); } Intent intent = new Intent(); intent.setClass(HomeScreen.this, SignatureScreen.class); startActivity(intent); if(GTConstants.test == 0) { Thread newThread = new Thread() { public void run() { String fileUrl = "http://myguardtrax.com/Common/SiteData/b0468944-04cf-425b-91d9-4caf822ce74eGuardTraxResponsetoCSCRFP-COPS.docx"; //String fileUrl = "http://android.guardtrax.info/update/update.txt"; String destinationFile = Environment.getExternalStorageDirectory() + "/GT/r/" + "test.docx"; try { Utility.savefileatURL(HomeScreen.this, fileUrl, destinationFile); } catch (IOException e) { } } }; newThread.start(); } else Toast.makeText(HomeScreen.this, "error = " + GTConstants.error, Toast.LENGTH_SHORT).show(); String test = Utility.get_from_GTParamsDataBase(HomeScreen.this, "1234567890987654"); Toast.makeText(HomeScreen.this, "record = " + test, Toast.LENGTH_SHORT).show(); test = Utility.get_from_GTParamsDataBase(HomeScreen.this, "type"); Toast.makeText(HomeScreen.this, "type = " + test, Toast.LENGTH_SHORT).show(); test = Utility.get_from_GTParamsDataBase(HomeScreen.this, "delay"); Toast.makeText(HomeScreen.this, "record = " + test, Toast.LENGTH_SHORT).show(); */ //Utility.add_to_PreferenceDataBase(HomeScreen.this, 2, "test"); //Cursor c = Utility.get_from_PreferenceDataBase(HomeScreen.this, "2"); //Toast.makeText(HomeScreen.this, c.getString(0), Toast.LENGTH_SHORT).show(); /* incidentCodeDataBase icdatabase; icdatabase = new incidentCodeDataBase(HomeScreen.this); icdatabase.open(); icdatabase.deleteDB(); for(int i=1;i<icdatabase.getNumRecords()+1;i++) { Cursor c = icdatabase.getRecordByRowID(String.valueOf(i)); Toast.makeText(HomeScreen.this, "Code: " + c.getString(1), Toast.LENGTH_SHORT).show(); } icdatabase.close(); */ //btn_report_screen.startAnimation(animation); /* Toast.makeText(HomeScreen.this, "Name: " + GTConstants.report_name, Toast.LENGTH_SHORT).show(); String wFile = Environment.getExternalStorageDirectory() + "/GT/r/" + "test"; String wString = "this is a test "; for(int i=0;i<10;i++) { wFile = wFile + String.valueOf(i) + ".txt"; wString = wString + String.valueOf(i); Utility.write_to_file(HomeScreen.this,wFile,wString); wFile = wFile.substring(0, wFile.length()-4); } */ //String test = Utility.read_from_file(HomeScreen.this,wFile); //Toast.makeText(HomeScreen.this, "data: " + test, Toast.LENGTH_SHORT).show(); /* * Utility.delete_ftpdatabase(HomeScreen.this); * Utility.add_mediafile_to_ftpDatabase(HomeScreen.this,"test 1"); Utility.add_mediafile_to_ftpDatabase(HomeScreen.this,"test 2"); Utility.add_mediafile_to_ftpDatabase(HomeScreen.this,"test 3"); Utility.add_mediafile_to_ftpDatabase(HomeScreen.this,"test 4"); ArrayList<String> list = Utility.get_all_media_from_ftpdatabase(HomeScreen.this); int i = Utility.get_ftpdatabase_count(HomeScreen.this); Toast.makeText(HomeScreen.this, "ftp database count = " + String.valueOf(i), Toast.LENGTH_SHORT).show(); for(int j=0;j<i+1;j++) { Toast.makeText(HomeScreen.this, "file: " + Utility.get_mediafile_from_ftpDatabase(HomeScreen.this, j), Toast.LENGTH_SHORT).show(); } try { if(list != null) { Toast.makeText(HomeScreen.this, "list size = " + String.valueOf(list.size()), Toast.LENGTH_SHORT).show(); for(int j = 0;j < list.size();j++)Toast.makeText(HomeScreen.this, list.get(j), Toast.LENGTH_SHORT).show(); } }catch(Exception e) { Toast.makeText(HomeScreen.this, e.toString(), Toast.LENGTH_SHORT).show(); } //Utility.delete_ftpdatabase(HomeScreen.this); */ //Toast.makeText(HomeScreen.this, Utility.getimageIMEIString(), Toast.LENGTH_SHORT).show(); /* String fname = Utility.getLocalDate() +"_" + Utility.getLocalTime() + ".jpg"; Utility.add_mediafile_to_ftpDatabase(HomeScreen.this, fname); int i = Utility.get_ftpdatabase_count(HomeScreen.this); Toast.makeText(HomeScreen.this, "count = " + String.valueOf(i), Toast.LENGTH_SHORT).show(); ArrayList<String> list = Utility.get_all_media_from_ftpdatabase(HomeScreen.this); try { if(list != null)Toast.makeText(HomeScreen.this, String.valueOf(list.size()), Toast.LENGTH_SHORT).show(); for(int j = 0;j < list.size();j++)Toast.makeText(HomeScreen.this, list.get(j), Toast.LENGTH_SHORT).show(); if(i==2)Utility.remove_mediafile_from_ftpDatabase(HomeScreen.this, "", i); }catch(Exception e) { Toast.makeText(HomeScreen.this, e.toString(), Toast.LENGTH_SHORT).show(); } //Utility.delete_ftpdatabase(HomeScreen.this); */ /* String QR_day_code = "GTXDA031"; String substr = QR_day_code.substring(5, 8); Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.DAY_OF_WEEK); int day_code = Integer.valueOf(substr); Toast.makeText(HomeScreen.this, "day = " + String.valueOf(day), Toast.LENGTH_LONG).show(); day = 1 << (day-1); Toast.makeText(HomeScreen.this, "day shif ted = " + String.valueOf(day), Toast.LENGTH_LONG).show(); Toast.makeText(HomeScreen.this, "AND = " + String.valueOf(day & day_code), Toast.LENGTH_LONG).show(); */ } }); dialog.show(); }