public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); Review_Tab2_Context = getActivity(); rvInflater = inflater; view = inflater.inflate(R.layout.review2, null); // reviewArr = new ArrayList<Review>(); activity = "Review_Tab2"; if (Build.VERSION.SDK_INT >= 11) { new ReviewAsyncTask("Review_Tab2").executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { new ReviewAsyncTask("Review_Tab2").execute(); } Review_Tab2_MessageHandler = new InnerHandler(Review_Tab2.this); ProgressThread progressThread = new ProgressThread(); progressThread.start(); Review_Tab2_ListView = (ListView) view.findViewById(R.id.reviewListView); Review_Tab2_ListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { // TODO Auto-generated method stub Position = position; startActivity(new Intent(getActivity(), ReviewView.class)); } }); return view; }
public void refreshReview() { if (Build.VERSION.SDK_INT >= 11) { new ReviewAsyncTask("Review_Tab2").executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { new ReviewAsyncTask("Review_Tab2").execute(); } ProgressThread progressThread = new ProgressThread(); progressThread.start(); }
/** @see FieldChangeListener#fieldChanged(Field, int) */ public void fieldChanged(final Field field, final int context) { if (field == _processButton) { if (_progressThread != null) { // Kill the currently running progress thread _progressThread.stopThread(); } // Start a new progress thread _progressThread = new ProgressThread(); _progressThread.start(); } else if (field == _cancelButton) { _model.cancel(); } else if (field == _resumeButton) { _model.resume(); } }
@Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case PROGRESS_DIALOG: progressDialog.setProgress(0); progressThread = new ProgressThread(handler); progressThread.start(); } }
@Override public void handleMessage(Message msg) { int total = msg.arg1; progressDialog.setProgress(total); if (total >= 100) { dismissDialog(PROGRESS_DIALOG); progressThread.setState(ProgressThread.STATE_DONE); } }
/** * Run in separate thread protected by a modal progress dialog. Replacement for * javax.swing.ProgressMonitor, which does not create a modal dialog. Ensures that the GUI gets * repaint events while the runnable is running, but cannot get other events and displays a * progress bar as a user feedback. The progress dialog is displayed for at least one second. * * @param owner Parent for the progress dialog. * @param message Title for the progress dialog. * @param runnable Runnable to run. * @throws Throwable Any exception that ProgressRunnable.run throwed, you have to use instanceof * to check for specific exception classes. */ public static void runProgress(Frame owner, String message, ProgressRunnable runnable) throws Throwable { assert SwingUtilities.isEventDispatchThread(); JDialog dialog = new JDialog(owner, message, true); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); JProgressBar progressBar = new JProgressBar(0, 100); // progressBar.setIndeterminate(true); progressBar.setStringPainted(true); JPanel panel = new JPanel(); panel.setBorder(createSmallEmptyBorder()); panel.add(progressBar); dialog.getContentPane().add(panel); dialog.pack(); dialog.setLocationRelativeTo(owner); ProgressThread thread = new ProgressThread(dialog, runnable, progressBar); thread.start(); dialog.setVisible(true); if (thread.getThrowable() != null) throw thread.getThrowable(); }
@Override public void handleMessage(Message msg) { // Get the current value of the variable total from the message data // and update the progress bar. int total = msg.getData().getInt("total"); progDialog.setProgress(total); if (total <= 0) { dismissDialog(typeBar); progThread.setState(ProgressThread.DONE); } }
// Method to create a progress bar dialog of either spinner or horizontal // type @Override protected Dialog onCreateDialog(int id) { switch (id) { case 0: // Spinner progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setMessage("Loading..."); progThread = new ProgressThread(handler); progThread.start(); return progDialog; case 1: // Horizontal progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progDialog.setMax(maxBarValue); progDialog.setMessage("Dollars in checking account:"); progThread = new ProgressThread(handler); progThread.start(); return progDialog; default: return null; } }
public void handleMessage(Message msg) { Bundle data = msg.getData(); if (data.containsKey("error")) { // error has occured - show it: DKDialog.ShowMessage( TaxProgramsManageActivity.this, Translate.translate("Error"), Translate.translate(data.getString("error")), Translate.translate("OK"), Translate.translate("Cancel")); removeDialog(typeBar); progThread.setState(ProgressThread.DONE); } else { // Get the current value of the variable total from the message data // and update the progress bar. int total = data.getInt("total"); progDialog.setProgress(total); if (total >= (maxBarValue)) { removeDialog(typeBar); progThread.setState(ProgressThread.DONE); presentResults(); try { recalculateTaxRate(); } catch (JSONException e) { DKDialog.ShowMessage( TaxProgramsManageActivity.this, Translate.translate("Error"), Translate.translate("Failed to recalculate tax rate!"), Translate.translate("OK"), Translate.translate("Cancel")); } } } }
// Method to create a progress bar dialog of either spinner or horizontal type @Override protected Dialog onCreateDialog(int id) { maxBarValue = selected.size(); switch (id) { case 0: // Spinner progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setMessage("Loading..."); progThread = new ProgressThread(handler, TaxPayerID, TaxYearID, selected); progThread.start(); return progDialog; case 1: // Horizontal progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progDialog.setMax(maxBarValue); progDialog.setMessage("Negotiating with Institution agents:"); progThread = new ProgressThread(handler, TaxPayerID, TaxYearID, selected); progThread.start(); return progDialog; default: return null; } }
public void stopProgress() { if (currentProgressThread != null && !currentProgressThread.isInterrupted()) { currentProgressThread.interrupt(); } }
public void startProgress() { currentProgressThread = new ProgressThread(); currentProgressThread.start(); }
/** * generatorMassData * * <p>Generiert Massendaten die durch "config" und "fileSize" definiert werden. * * @param config Massendaten Konfigurationsdatei * @param fileSize Größe der Nutzdaten in Byte * @return Protobuf Builder für Massendaten */ public Massendaten generatorMassData(final MassenDef config, final int fileSize) { Massendaten mDaten; Massendaten.Builder massendatenBuilder = Massendaten.newBuilder(); ProgressThread thread = new ProgressThread(); thread.setPorgress(new AtomicInteger(0)); thread.start(); double pos = 0.0f; int typeSize = 11; int procent = 0; Massendaten.MassenInfo.Builder massenInfoBuilder = Massendaten.MassenInfo.newBuilder(); Massendaten.MassenDef.Builder massenDefBuilder = Massendaten.MassenDef.newBuilder(); for (Frequency f : config.getFrequencies()) { Massendaten.Frequency.Builder freqBuilder = Massendaten.Frequency.newBuilder(); freqBuilder.setFrequency(f.getFrequency()); freqBuilder.setAmplitude(f.getAmplitude()); freqBuilder.setPhase(f.getPhase()); massenDefBuilder.addFrequency(freqBuilder); } massenDefBuilder.setAbtastrate(config.getAbtastrate()); massenInfoBuilder.setDef(massenDefBuilder); long longWert; // für progressbar double temp; // Schleife um die Daten zu generieren: for (int i = 0; i < fileSize / typeSize; i++) { double value = 0.0f; // Amplitude für diesen Schritt erzeugen for (Frequency f : config.getFrequencies()) { value += sin(f.getPhase() + f.getFrequency() * pos) * f.getAmplitude(); } // Prozentanzeige wenn im DEBUG-Modus longWert = (long) (i) * 100; temp = longWert / (fileSize / typeSize); if (procent != temp) { thread.setPorgress(new AtomicInteger((int) temp)); procent = (int) temp; } massendatenBuilder.addValue(Massendaten.Werte.newBuilder().setNumber(value)); // erhöhen der Position der Abtastung pos += config.getAbtastrate(); } // 1: einmal builden, um die serializedSize zu bekommen Massendaten tempMdaten = massendatenBuilder.build(); // 2: serializedSize und id in info eintragen int hashID = System.identityHashCode(tempMdaten.getValueList()); massenInfoBuilder.setId(hashID); massenInfoBuilder.setPaketGroesseKB(tempMdaten.getSerializedSize()); Printer.println("size: " + tempMdaten.getSerializedSize()); massendatenBuilder.setInfo(massenInfoBuilder); thread.setPorgress(new AtomicInteger(100)); thread.killProgress(); mDaten = massendatenBuilder.build(); return mDaten; }
/** * generatorDeepStructure * * <p>Generiert Struktdaten die durch "struktDef" definiert werden. * * @param struktDef Definition welche Anzahl an Datensätzen generiert werden soll * @return Protobuf Builder für Struktdaten */ public Struktdaten generatorDeepStructure(StruktDef struktDef) { ProgressThread thread = new ProgressThread(); thread.setPorgress(new AtomicInteger(0)); thread.start(); Struktdaten.Builder structBuilder = Struktdaten.newBuilder(); Struktdaten.SelAIDNameUnitID.Builder selAIDNameUnitIDBuilder; Struktdaten.AIDName.Builder aIDNameBuilder; Struktdaten.LongLong.Builder longLong; Struktdaten.JoinDef.Builder joinDef; Struktdaten.SelOrder.Builder selOrder; Struktdaten.SelItem.Builder selItem; Struktdaten.SelValueExt.Builder selValueExt; Struktdaten.TS_Value.Builder ts_Value; Struktdaten.AIDNameUnitID.Builder aIDNameUnitID; // Erzeugen der ItemAIDName Elementen for (int i = 0; i < struktDef.getItemAIDNameCount(); i++) { thread.setPorgress(new AtomicInteger(i * 20 / struktDef.getItemAIDNameCount())); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(523300 + i); longLong.setHigh(315100 + i); aIDNameBuilder = Struktdaten.AIDName.newBuilder(); aIDNameBuilder.setAaName("AName"); aIDNameBuilder.setAid(longLong); selAIDNameUnitIDBuilder = Struktdaten.SelAIDNameUnitID.newBuilder(); selAIDNameUnitIDBuilder.setAggregate("Test"); selAIDNameUnitIDBuilder.setAidname(aIDNameBuilder); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(302350 + i); longLong.setHigh(6235300 + i); selAIDNameUnitIDBuilder.setUnitid(longLong); structBuilder.addAnuSeq(selAIDNameUnitIDBuilder); } // Erzeugen der JoinDef Elementen for (int i = 0; i < struktDef.getItemJoinDefCount(); i++) { thread.setPorgress(new AtomicInteger(20 + i * 20 / struktDef.getItemAIDNameCount())); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(200); longLong.setHigh(200); joinDef = Struktdaten.JoinDef.newBuilder(); joinDef.setFromAID(longLong); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(654200 + i); longLong.setHigh(203440 + i); joinDef.setToAID(longLong); joinDef.setJoiningType("JoiningType"); joinDef.setRefName("RefName"); structBuilder.addJoinSeq(joinDef); } // Erzeugen der SelOrder Elemente for (int i = 0; i < struktDef.getItemSelOrderCount(); i++) { thread.setPorgress(new AtomicInteger(40 + i * 20 / struktDef.getItemAIDNameCount())); selOrder = Struktdaten.SelOrder.newBuilder(); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(203470 + i); longLong.setHigh(2078760 + i); aIDNameBuilder = Struktdaten.AIDName.newBuilder(); aIDNameBuilder.setAaName("AName"); aIDNameBuilder.setAid(longLong); selOrder.setAttr(aIDNameBuilder); selOrder.setAscending(true); structBuilder.addOrderBy(selOrder); } // Erzeugen der SelUID Elemente for (int i = 0; i < struktDef.getItemSelUIDCount(); i++) { thread.setPorgress(new AtomicInteger(60 + i * 20 / struktDef.getItemAIDNameCount())); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(2062440 + i); longLong.setHigh(25600 + i); aIDNameBuilder = Struktdaten.AIDName.newBuilder(); aIDNameBuilder.setAaName("AName"); aIDNameBuilder.setAid(longLong); structBuilder.addGroupBy(aIDNameBuilder); } // Erzeugen der SelItem Elemente for (int i = 0; i < struktDef.getItemSelItemCount(); i++) { thread.setPorgress(new AtomicInteger(80 + i * 20 / struktDef.getItemAIDNameCount())); selItem = Struktdaten.SelItem.newBuilder(); ts_Value = Struktdaten.TS_Value.newBuilder(); ts_Value.setU("Unit"); ts_Value.setFlag(0x8001); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(30034 + i); longLong.setHigh(300526 + i); aIDNameBuilder = Struktdaten.AIDName.newBuilder(); aIDNameBuilder.setAaName("AName"); aIDNameBuilder.setAid(longLong); aIDNameUnitID = Struktdaten.AIDNameUnitID.newBuilder(); aIDNameUnitID.setAttr(aIDNameBuilder); longLong = Struktdaten.LongLong.newBuilder(); longLong.setLow(20); longLong.setHigh(200); aIDNameUnitID.setUnitID(longLong); selValueExt = Struktdaten.SelValueExt.newBuilder(); selValueExt.setValue(ts_Value); selValueExt.setAttr(aIDNameUnitID); selItem.setValue(selValueExt); selItem.setOperator("Oper"); structBuilder.addCondSeq(selItem); } // Erzeugen der Informationen zu dieser Struktur StruktdatenProtos.Struktdaten.StruktInfo.Builder info = StruktdatenProtos.Struktdaten.StruktInfo.newBuilder(); StruktdatenProtos.Struktdaten.StruktInfo.StruktDef.Builder def = StruktdatenProtos.Struktdaten.StruktInfo.StruktDef.newBuilder(); def.setItemAIDNameCount(struktDef.getItemAIDNameCount()); def.setItemSelUIDCount(struktDef.getItemSelUIDCount()); def.setItemSelOrderCount(struktDef.getItemSelOrderCount()); def.setItemSelItemCount(struktDef.getItemSelItemCount()); def.setItemJoinDefCount(struktDef.getItemJoinDefCount()); info.setDef(def); info.setSize(structBuilder.build().getSerializedSize()); info.setId((int) (Calendar.getInstance().getTime().getTime() / 2000)); structBuilder.setInfo(info); thread.setPorgress(new AtomicInteger(100)); thread.killProgress(); // Rückgabe der kompletten Struktur return structBuilder.build(); }