public void commandAction(Command command, Displayable displayable) { display.setCurrent(parentView); if (command == cmdSelect) { setString(list.getString(list.getSelectedIndex())); } if (command == cmdClear) { recentList.removeAllElements(); saveRecentList(); } }
public void commandAction(Command command, Displayable displayable) { if (command == back) { controller.MainMenu(); } if (command == viewStages) { busNos = busNo.getString().toUpperCase(); fetchStagesData(busNos); } if (command == backToNo) { controller.getDisp().setCurrent(this); } if (command == MapStages) { controller.pointresultCanvas.busStagesPoints.removeAllElements(); for (int mapStages = 0; mapStages < PostionAddress.length - 1; mapStages++) { String pos = PostionAddress[mapStages]; String[] point = StringUtil.split(pos, "||"); System.out.println(point[0] + "== " + point[1]); controller.pointBusStages(point[0], point[1]); } String pos = PostionAddress[Stages.getSelectedIndex()]; String[] point = StringUtil.split(pos, "||"); controller.gotoSpot(point[0], point[1]); controller.ShowPointingCanvas(); } if (command == backToPlaces) { controller.getDisp().setCurrent(Stages); } if (command == showBuses) { controller.showProgressBar(); fetchBusNoData(); } if (command == showStages) { busNos = busesNearMe.getString(busesNearMe.getSelectedIndex()).toUpperCase(); fetchStagesData(busNos); } if (command == viewBusPosition) { String[] data = GetBusPosition("Tt"); String Message = "" + data[0] + "\n" + data[1] + "\n" + data[2]; controller.showBusPosition(Message, data[3], data[4]); } }
protected void hook43(List down) { if (down.getString(down.getSelectedIndex()).equals("Videos")) videoController.init(videoAlbumData); original(down); }
public void commandAction(Command c, Displayable d) { if (c == mExitCommand) { destroyApp(true); notifyDestroyed(); } else if ((c == List.SELECT_COMMAND) && (d == mMenu)) { int selection = mMenu.getSelectedIndex(); String item = "[none]"; if ((selection >= 0) && (selection < mMenu.size())) { item = mMenu.getString(selection); } if (item == kQuerySlots) { Form slotList = new Form("Slots"); String slots = System.getProperty("microedition.smartcardslots"); int index = 0; while (index < slots.length()) { String slot; int comma = slots.indexOf(',', index); if (comma == -1) { slot = slots.substring(index).trim(); index = slots.length(); } else { slot = slots.substring(index, comma).trim(); index = comma + 1; } StringItem slotItem = new StringItem(null, slot); slotItem.setLayout(Item.LAYOUT_2 | Item.LAYOUT_NEWLINE_AFTER); slotList.append(slotItem); } slotList.addCommand(mBackCommand); slotList.setCommandListener(this); mDisplay.setCurrent(slotList); } else if (item == kSignTest) { System.out.println("Starting sign test..."); /* try { CMSMessageSignatureService.sign( "This is the message to sign", CMSMessageSignatureService.SIG_INCLUDE_CONTENT | CMSMessageSignatureService.SIG_INCLUDE_CERTIFICATE, null, "This is the prompt"); } catch (Exception e) { System.out.println("sign() barfed: " + e); }*/ new Thread() { public void run() { fromSpecification(); System.out.println("Sign test finished."); } }.start(); } } else if (c == mBackCommand) { mDisplay.setCurrent(mMenu); } }
public void commandAction(Command c, Displayable d) { if (c == List.SELECT_COMMAND) { List down = (List) dsp.getCurrent(); String title = down.getTitle(); if (title.equals("Menu:")) { switch (down.getSelectedIndex()) { case 0: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); addRecordForm(); break; } case 1: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); showAllRecordForm(); break; } case 2: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); showFirstRecord(); break; } case 3: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); getNumberRecord(); break; } case 4: { System.out.println("Stisknul jsi " + down.getString(down.getSelectedIndex())); editRecord(1); break; } } } } if (c == cmdExit) { // rs.closeRecordStore(); notifyDestroyed(); } if (c == cmdMenu) { dsp.setCurrent(listMenu); } if (c == cmdEdit) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // filtr; filtr dostane pri vytvoreni stream jako parametr; // format dat nezavisly na platforme // definuje metodu write() pro vsechny primitivni typy DataOutputStream dout = new DataOutputStream(buffer); // byte [] data = txf.getString().getBytes(); try { dout.writeUTF(txfName.getString()); dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue()); txfName.delete(0, txfName.size()); txfNumber.delete(0, txfNumber.size()); // zapise buffer do streamu dout.flush(); // prevod ByteArrayOutputStream na pole bytu; byte[] b = buffer.toByteArray(); rs.setRecord(1, b, 0, b.length); } catch (Exception e) { } finally { try { dout.close(); } catch (Exception e2) { } } } if (c == cmdAdd) { // vystupni stream; zapisuje do buferu v pamžti ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // filtr; filtr dostane pri vytvoreni stream jako parametr; // format dat nezavisly na platforme // definuje metodu write() pro vsechny primitivni typy DataOutputStream dout = new DataOutputStream(buffer); // byte [] data = txf.getString().getBytes(); try { dout.writeUTF(txfName.getString()); dout.writeInt(Integer.valueOf(txfNumber.getString()).intValue()); txfName.delete(0, txfName.size()); txfNumber.delete(0, txfNumber.size()); // zapise buffer do streamu dout.flush(); // prevod ByteArrayOutputStream na pole bytu; byte[] b = buffer.toByteArray(); rs.addRecord(b, 0, b.length); } catch (Exception e) { } finally { try { dout.close(); } catch (Exception e2) { } } } }
public String fetchBusNoData() { busesNearMe.deleteAll(); busesNearMe.setTitle("Buses for " + Stages.getString(Stages.getSelectedIndex())); new Thread() { public void run() { String toF = ""; try { String[] tt = StringUtil.split(Stages.getString(Stages.getSelectedIndex()), " "); System.out.println("From field" + tt[0]); for (int y = 0; y < tt.length; y++) { if (y != tt.length - 1) { toF = toF + "" + tt[y] + "%20"; System.out.println("From field" + toF); } else { toF = toF + tt[y]; System.out.print("in else "); } System.out.print("Out of loop"); } System.out.print(BusNowebsite + toF); } catch (Exception e) { controller.showAlert("Network Error", 3, AlertType.ERROR); displayList(); } String addloc = ""; StreamConnection c = null; InputStream s = null; StringBuffer b = new StringBuffer(); System.out.print(BusNowebsite + toF); try { c = (StreamConnection) Connector.open(BusNowebsite + toF); s = c.openDataInputStream(); int ch; int k = 0; while ((ch = s.read()) != -1) { // System.out.print((char) ch); b.append((char) ch); } result = b.toString(); System.out.print(result); // String stagesString = fetchStagesData(); JSONObject ff1 = new JSONObject(result); String data1 = ff1.getString("routes"); JSONArray jsonArray1 = new JSONArray(data1); for (int i = 0; i < jsonArray1.length(); i++) { // JSONObject jsonUser = jsonArray1.getJSONObject(i); // String lat = jsonUser.getString ("lat"); busesNearMe.append(jsonArray1.optString(i), null); System.out.println(jsonArray1.optString(i)); } controller.getDisp().setCurrent(busesNearMe); } catch (Exception e) { System.out.print("Error " + e); // controller.getDisp().setCurrent(Stages); // controller.showAlert("Network Error", 3, AlertType.ERROR); // // controller.getDisp().setCurrent(controller.showAlert("Network Error", 3, // AlertType.ERROR), Stages); } } }.start(); controller.getDisp().setCurrent(Stages); return result; }
public void commandAction(Command command, Displayable displayable) { if ((displayable == D_MAIN) && D_MAIN.Responds()) { if (command == c_exit) { exitMIDlet(); } if (command == c_history) { switchDisplayable(null, getL_history()); Stack st = D_MAIN.getEqHS(); Enumeration en = st.elements(); l_history.deleteAll(); while (en.hasMoreElements()) { l_history.append((String) en.nextElement(), null); } } if (command == c_tovars) { getL_vars().deleteAll(); StringBuffer sb; Enumeration values = D_MAIN.getEqVars().elements(); Enumeration names = D_MAIN.getEqVars().keys(); String name; Real value; while ((values.hasMoreElements()) && (names.hasMoreElements())) { name = String.valueOf(names.nextElement()); value = new Real(String.valueOf((values.nextElement()))); Real.NumberFormat n = new Real.NumberFormat(); n.maxwidth = 17; n.fse = Real.NumberFormat.FSE_NONE; sb = new StringBuffer(value.toString(n)); if (chartools.contains(sb, 'e')) { StringBuffer ev = new StringBuffer(); for (int i = sb.length() - 1; i > -1; --i) { if (sb.charAt(i) == 'e') { sb.deleteCharAt(i); break; } ev.append(sb.charAt(i)); sb.deleteCharAt(i); } ev.reverse(); sb.append(" * 10^(" + ev + ")"); if ((!(sb.equals(new StringBuffer("")))) && (!(name.equals(""))) && (!(sb.equals(new StringBuffer("null")))) && (!(name.equals("null")))) { l_vars.append(name + " = " + sb.toString(), null); } } else { if ((!(sb.equals(new StringBuffer("")))) && (!(name.equals(""))) && (!(sb.equals(new StringBuffer("null")))) && (!(name.equals("null")))) { getL_vars().append(name + " = " + sb.toString(), null); } } } switchDisplayable(null, getL_vars()); } } if (displayable == f_welcome) { if (command == c_canvas) { switchDisplayable(null, D_MAIN); } } else if (displayable == form) { if (command == c_history) { } else if (command == c_tovars) { } } else if (displayable == l_history) { if (command == List.SELECT_COMMAND) { l_historyAction(); } else if (command == c_canvas) { switchDisplayable(null, D_MAIN); } else if (command == c_insert) { if (l_history.size() != 0) { StringBuffer sb = new StringBuffer(); String his = l_history.getString(l_history.getSelectedIndex()); boolean p_end = false; for (int i = 0; i < his.length(); i++) { if (his.charAt(i) == '=') { break; } if (p_end) { sb.append(his.charAt(i)); } if (his.charAt(i) == ':') { p_end = true; } } sb.deleteCharAt(sb.length() - 1); D_MAIN.appendDispCont(" " + sb.toString()); } switchDisplayable(null, D_MAIN); D_MAIN.repaint(); } } else if (displayable == l_vars) { if (command == List.SELECT_COMMAND) { l_varsAction(); } else if (command == c_canvas) { switchDisplayable(null, D_MAIN); } else if (command == c_delvar) { try { StringBuffer sb = new StringBuffer(); String his = l_vars.getString(l_vars.getSelectedIndex()); for (int i = 0; i < his.length(); i++) { if (his.charAt(i) == '=') { break; } sb.append(his.charAt(i)); } D_MAIN.deletevar(sb.toString().trim()); l_vars.delete(l_vars.getSelectedIndex()); } catch (error er) { switchDisplayable(null, getA_error()); a_error.setString(er.getMessage()); } } else if (command == c_insert) { StringBuffer sb = new StringBuffer(); String his = l_vars.getString(l_vars.getSelectedIndex()); for (int i = 0; i < his.length(); i++) { if (his.charAt(i) == '=') { break; } sb.append(his.charAt(i)); } D_MAIN.appendDispCont(sb.toString()); switchDisplayable(null, D_MAIN); D_MAIN.repaint(); } } }