List of usage examples for android.util Log DEBUG
int DEBUG
To view the source code for android.util Log DEBUG.
Click Source Link
From source file:com.digipom.manteresting.android.service.cache.ImageDownloader.java
byte[] download(String uri) { final HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(uri); byte[] data = null; try {/*from w w w. j a v a 2s .c om*/ HttpResponse response = httpClient.execute(httpGet); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) { for (String extension : otherExtensionsToTry) { final String rewrittenUri = FileUtils.getFileNameWithoutExtension(uri) + '.' + extension; if (LoggerConfig.canLog(Log.VERBOSE)) { Log.v(TAG, "Original URI " + uri + " not found. Trying with another extension: " + rewrittenUri); } // Consume the content so the connection can be re-used. response.getEntity().consumeContent(); httpGet = new HttpGet(rewrittenUri); response = httpClient.execute(httpGet); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { break; } } } InputStream is = null; try { final HttpEntity responseEntity = response.getEntity(); is = responseEntity.getContent(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final byte[] buffer = new byte[4096]; int read; while ((read = is.read(buffer)) > 0) { baos.write(buffer, 0, read); } data = baos.toByteArray(); } finally { if (is != null) { is.close(); is = null; } } } catch (Throwable t) { if (LoggerConfig.canLog(Log.DEBUG)) { Log.d(TAG, "Download failed: " + uri, t); } } return data; }
From source file:com.example.android.wearable.elizachat.ResponderService.java
private void showNotification() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Sent: " + mLastResponse); }/*from w ww . j av a 2 s. c o m*/ NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.eliza)).setContentText(mLastResponse) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza)) .setSmallIcon(R.drawable.bg_eliza).setPriority(NotificationCompat.PRIORITY_DEFAULT); Intent intent = new Intent(ACTION_RESPONSE); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = builder.extend(new NotificationCompat.WearableExtender() .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_reply, getString(R.string.reply), pendingIntent).addRemoteInput( new RemoteInput.Builder(EXTRA_REPLY).setLabel(getString(R.string.reply)).build()) .build())) .build(); NotificationManagerCompat.from(this).notify(0, notification); }
From source file:com.android.ex.chips.RecipientAlternatesAdapter.java
/** * Get a HashMap of address to RecipientEntry that contains all contact * information for a contact with the provided address, if one exists. This * may block the UI, so run it in an async task. * @param context/*w ww .j av a2s . co m*/ * Context. * @param inAddresses * Array of addresses on which to perform the lookup. * @return HashMap<String,RecipientEntry> */ public static HashMap<String, RecipientEntry> getMatchingRecipients(Context context, ArrayList<String> inAddresses, int addressType) { Queries.Query query; if (addressType == QUERY_TYPE_EMAIL) { query = Queries.EMAIL; } else { query = Queries.PHONE; } int addressesSize = Math.min(MAX_LOOKUPS, inAddresses.size()); String[] addresses = new String[addressesSize]; StringBuilder bindString = new StringBuilder(); // Create the "?" string and set up arguments. for (int i = 0; i < addressesSize; i++) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(inAddresses.get(i).toLowerCase()); addresses[i] = (tokens.length > 0 ? tokens[0].getAddress() : inAddresses.get(i)); bindString.append("?"); if (i < addressesSize - 1) { bindString.append(","); } } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Doing reverse lookup for " + addresses.toString()); } HashMap<String, RecipientEntry> recipientEntries = new HashMap<String, RecipientEntry>(); Cursor c = context.getContentResolver().query(query.getContentUri(), query.getProjection(), query.getProjection()[Queries.Query.DESTINATION] + " IN (" + bindString.toString() + ")", addresses, null); if (c != null) { try { if (c.moveToFirst()) { do { String address = c.getString(Queries.Query.DESTINATION); recipientEntries.put(address, RecipientEntry.constructTopLevelEntry( c.getString(Queries.Query.NAME), c.getInt(Queries.Query.DISPLAY_NAME_SOURCE), c.getString(Queries.Query.DESTINATION), c.getInt(Queries.Query.DESTINATION_TYPE), c.getString(Queries.Query.DESTINATION_LABEL), c.getLong(Queries.Query.CONTACT_ID), c.getLong(Queries.Query.DATA_ID), c.getString(Queries.Query.PHOTO_THUMBNAIL_URI))); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Received reverse look up information for " + address + " RESULTS: " + " NAME : " + c.getString(Queries.Query.NAME) + " CONTACT ID : " + c.getLong(Queries.Query.CONTACT_ID) + " ADDRESS :" + c.getString(Queries.Query.DESTINATION)); } } while (c.moveToNext()); } } finally { c.close(); } } return recipientEntries; }
From source file:com.variable.demo.api.fragment.ThermoCoupleFragment.java
@Override public void onThermoCoupleReading(ThermocoupleSensor sensor, SensorReading<Float> reading) { Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_THERMA_TEMPERATURE); m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, reading.getValue()); final Context thiscontext = this.getActivity(); final String serialnumOne = sensor.getSerialNumber(); final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", ""); final String scan = Float.toString(reading.getValue()); String json = "thermocouple;" + serialnum + ";" + scan; // POST to variable dashboard Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false); Ion.with(thiscontext).load(/*from ww w .j av a2s . c om*/ "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]=" + json) .setLogging("MyLogs", Log.DEBUG).asString().withResponse() .setCallback(new FutureCallback<Response<String>>() { @Override public void onCompleted(Exception e, Response<String> result) { if (e == null) { Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString()); } else { Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION"); e.printStackTrace(); } } }); m.sendToTarget(); }
From source file:com.cbsb.ftpserv.Util.java
public static void newFileNotify(String path) { if (Defaults.do_mediascanner_notify) { myLog.l(Log.DEBUG, "Notifying others about new file: " + path); new MediaScannerNotifier(Globals.getContext(), path); }/*from www . j a v a 2 s . com*/ }
From source file:com.scvngr.levelup.core.util.LogManager.java
/** * Log a message.// w ww .j ava2 s . co m * * @param msg message to log. This message is expected to be a format string if varargs are * passed in. * @param args optional arguments to be formatted into {@code msg}. */ public static void d(@NonNull final String msg, @Nullable final Object... args) { logMessage(Log.DEBUG, msg, args, null); }
From source file:com.sleekcoder.weardemo.NotificationUpdateService.java
private void dismissPhoneNotification(int id) { final Uri dataItemUri = new Uri.Builder().scheme(WEAR_URI_SCHEME).path(Constants.BOTH_PATH).build(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Deleting Uri: " + dataItemUri.toString()); }//from ww w .j a v a 2 s . c o m Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri).setResultCallback(this); }
From source file:com.variable.demo.api.fragment.OxaFragment.java
@Override public void onOxaUpdate(OxaSensor sensor, SensorReading<Float> reading) { Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_OXA_READING); m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, reading.getValue()); final Context thiscontext = this.getActivity(); final String serialnumOne = sensor.getSerialNumber(); final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", ""); final String scan = Float.toString(reading.getValue()); String json = "oxygen;" + serialnum + ";" + scan; // POST to variable dashboard Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false); Ion.with(thiscontext).load(//ww w .ja v a 2 s . co m "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]=" + json) .setLogging("MyLogs", Log.DEBUG).asString().withResponse() .setCallback(new FutureCallback<Response<String>>() { @Override public void onCompleted(Exception e, Response<String> result) { if (e == null) { Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString()); } else { Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION"); e.printStackTrace(); } } }); m.sendToTarget(); }
From source file:com.joptimizer.optimizers.PrimalDualMethod.java
@Override public int optimize() throws Exception { Log.i(MainActivity.JOPTIMIZER_LOGTAG, "optimize"); long tStart = System.currentTimeMillis(); OptimizationResponse response = new OptimizationResponse(); // @TODO: check assumptions!!! // if(getA()!=null){ // if(ALG.rank(getA())>=getA().rows()){ // throw new IllegalArgumentException("A-rank must be less than A-rows"); // }/*from w w w .j a va2 s . c o m*/ // } DoubleMatrix1D X0 = getInitialPoint(); if (X0 == null) { DoubleMatrix1D X0NF = getNotFeasibleInitialPoint(); if (X0NF != null) { double rPriX0NFNorm = Math.sqrt(ALG.norm2(rPri(X0NF))); DoubleMatrix1D fiX0NF = getFi(X0NF); int maxIndex = Utils.getMaxIndex(fiX0NF.toArray()); double maxValue = fiX0NF.get(maxIndex); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriX0NFNorm : " + rPriX0NFNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0NF : " + ArrayUtils.toString(X0NF.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "fiX0NF : " + ArrayUtils.toString(fiX0NF.toArray())); } if (maxValue < 0 && rPriX0NFNorm <= getToleranceFeas()) { //the provided not-feasible starting point is already feasible Log.d(MainActivity.JOPTIMIZER_LOGTAG, "the provided initial point is already feasible"); X0 = X0NF; } } if (X0 == null) { BasicPhaseIPDM bf1 = new BasicPhaseIPDM(this); X0 = bf1.findFeasibleInitialPoint(); } } //check X0 feasibility DoubleMatrix1D fiX0 = getFi(X0); int maxIndex = Utils.getMaxIndex(fiX0.toArray()); double maxValue = fiX0.get(maxIndex); double rPriX0Norm = Math.sqrt(ALG.norm2(rPri(X0))); if (maxValue >= 0 || rPriX0Norm > getToleranceFeas()) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriX0Norm : " + rPriX0Norm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "ineqX0 : " + ArrayUtils.toString(fiX0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq index: " + maxIndex); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq value: " + maxValue); throw new Exception("initial point must be strictly feasible"); } DoubleMatrix1D V0 = (getA() != null) ? F1.make(getA().rows()) : F1.make(0); DoubleMatrix1D L0 = getInitialLagrangian(); if (L0 != null) { for (int j = 0; j < L0.size(); j++) { // must be >0 if (L0.get(j) <= 0) { throw new IllegalArgumentException("initial lagrangian must be strictly > 0"); } } } else { //L0 = F1.make(getFi().length, 1.);// must be >0 L0 = F1.make(getFi().length, Math.min(1, (double) getDim() / getFi().length));// must be >0 } if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0: " + ArrayUtils.toString(X0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V0: " + ArrayUtils.toString(V0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "L0: " + ArrayUtils.toString(L0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "toleranceFeas: " + getToleranceFeas()); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "tolerance : " + getTolerance()); } DoubleMatrix1D X = X0; DoubleMatrix1D V = V0; DoubleMatrix1D L = L0; //double F0X; //DoubleMatrix1D gradF0X = null; //DoubleMatrix1D fiX = null; //DoubleMatrix2D GradFiX = null; //DoubleMatrix1D rPriX = null; //DoubleMatrix1D rCentXLt = null; //DoubleMatrix1D rDualXLV = null; //double rPriXNorm = Double.NaN; //double rCentXLtNorm = Double.NaN; //double rDualXLVNorm = Double.NaN; //double normRXLVt = Double.NaN; double previousF0X = Double.NaN; double previousRPriXNorm = Double.NaN; double previousRDualXLVNorm = Double.NaN; double previousSurrDG = Double.NaN; double t; int iteration = 0; while (true) { iteration++; // iteration limit condition if (iteration == getMaxIteration() + 1) { response.setReturnCode(OptimizationResponse.WARN); Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached"); break; } double F0X = getF0(X); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "iteration: " + iteration); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X=" + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "L=" + ArrayUtils.toString(L.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V=" + ArrayUtils.toString(V.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f0(X)=" + F0X); } // if(!Double.isNaN(previousF0X)){ // if (previousF0X < F0X) { // throw new Exception("critical minimization problem"); // } // } // previousF0X = F0X; // determine functions evaluations DoubleMatrix1D gradF0X = getGradF0(X); DoubleMatrix1D fiX = getFi(X); DoubleMatrix2D GradFiX = getGradFi(X); DoubleMatrix2D[] HessFiX = getHessFi(X); // determine t double surrDG = getSurrogateDualityGap(fiX, L); t = getMu() * getFi().length / surrDG; Log.d(MainActivity.JOPTIMIZER_LOGTAG, "t: " + t); // determine residuals DoubleMatrix1D rPriX = rPri(X); DoubleMatrix1D rCentXLt = rCent(fiX, L, t); DoubleMatrix1D rDualXLV = rDual(GradFiX, gradF0X, L, V); double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); double rCentXLtNorm = Math.sqrt(ALG.norm2(rCentXLt)); double rDualXLVNorm = Math.sqrt(ALG.norm2(rDualXLV)); double normRXLVt = Math .sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rCentXLtNorm, 2) + Math.pow(rDualXLVNorm, 2)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPri norm: " + rPriXNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rCent norm: " + rCentXLtNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rDual norm: " + rDualXLVNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "surrDG : " + surrDG); // custom exit condition if (checkCustomExitConditions(X)) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // exit condition if (rPriXNorm <= getToleranceFeas() && rDualXLVNorm <= getToleranceFeas() && surrDG <= getTolerance()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // progress conditions if (isCheckProgressConditions()) { if (!Double.isNaN(previousRPriXNorm) && !Double.isNaN(previousRDualXLVNorm) && !Double.isNaN(previousSurrDG)) { if ((previousRPriXNorm <= rPriXNorm && rPriXNorm >= getToleranceFeas()) || (previousRDualXLVNorm <= rDualXLVNorm && rDualXLVNorm >= getToleranceFeas())) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved, exit iterations loop without desired accuracy"); response.setReturnCode(OptimizationResponse.WARN); break; } } previousRPriXNorm = rPriXNorm; previousRDualXLVNorm = rDualXLVNorm; previousSurrDG = surrDG; } // compute primal-dual search direction // a) prepare 11.55 system DoubleMatrix2D HessSum = getHessF0(X); for (int j = 0; j < getFi().length; j++) { if (HessFiX[j] != FunctionsUtils.ZEROES_MATRIX_PLACEHOLDER) { HessSum.assign(HessFiX[j].copy().assign(Mult.mult(L.get(j))), Functions.plus); } //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"HessSum : " + ArrayUtils.toString(HessSum.toArray())); } // DoubleMatrix2D GradSum = F2.make(getDim(), getDim()); // for (int j = 0; j < getFi().length; j++) { // DoubleMatrix1D g = GradFiX.viewRow(j); // GradSum.assign(ALG.multOuter(g, g, null).assign(Mult.mult(-L.get(j) / fiX.get(j))), Functions.plus); // //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"GradSum : " + ArrayUtils.toString(GradSum.toArray())); // } DoubleMatrix2D GradSum = F2.make(getDim(), getDim()); for (int j = 0; j < getFi().length; j++) { final double c = -L.getQuick(j) / fiX.getQuick(j); DoubleMatrix1D g = GradFiX.viewRow(j); SeqBlas.seqBlas.dger(c, g, g, GradSum); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"GradSum : " + ArrayUtils.toString(GradSum.toArray())); } DoubleMatrix2D Hpd = HessSum.assign(GradSum, Functions.plus); //DoubleMatrix2D Hpd = getHessF0(X).assign(HessSum, Functions.plus).assign(GradSum, Functions.plus); DoubleMatrix1D gradSum = F1.make(getDim()); for (int j = 0; j < getFi().length; j++) { gradSum.assign(GradFiX.viewRow(j).copy().assign(Mult.div(-t * fiX.get(j))), Functions.plus); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"gradSum : " + ArrayUtils.toString(gradSum.toArray())); } DoubleMatrix1D g = null; if (getAT() == null) { g = gradF0X.copy().assign(gradSum, Functions.plus); } else { g = gradF0X.copy().assign(gradSum, Functions.plus).assign(ALG.mult(getAT(), V), Functions.plus); } // b) solving 11.55 system if (this.kktSolver == null) { this.kktSolver = new BasicKKTSolver(); } //KKTSolver solver = new DiagonalKKTSolver(); if (isCheckKKTSolutionAccuracy()) { kktSolver.setCheckKKTSolutionAccuracy(true); kktSolver.setToleranceKKT(getToleranceKKT()); } kktSolver.setHMatrix(Hpd.toArray()); kktSolver.setGVector(g.toArray()); if (getA() != null) { kktSolver.setAMatrix(getA().toArray()); kktSolver.setATMatrix(getAT().toArray()); kktSolver.setHVector(rPriX.toArray()); } double[][] sol = kktSolver.solve(); DoubleMatrix1D stepX = F1.make(sol[0]); DoubleMatrix1D stepV = (sol[1] != null) ? F1.make(sol[1]) : F1.make(0); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepX: " + ArrayUtils.toString(stepX.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepV: " + ArrayUtils.toString(stepV.toArray())); } // c) solving for L DoubleMatrix1D stepL = null; DoubleMatrix2D diagFInv = F2.diagonal(fiX.copy().assign(Functions.inv)); DoubleMatrix2D diagL = F2.diagonal(L); stepL = ALG.mult(diagFInv, ALG.mult(diagL, ALG.mult(GradFiX, stepX))).assign(Mult.mult(-1)) .assign(ALG.mult(diagFInv, rCentXLt), Functions.plus); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepL: " + ArrayUtils.toString(stepL.toArray())); } // line search and update // a) sMax computation double sMax = Double.MAX_VALUE; for (int j = 0; j < getFi().length; j++) { if (stepL.get(j) < 0) { sMax = Math.min(-L.get(j) / stepL.get(j), sMax); } } sMax = Math.min(1, sMax); double s = 0.99 * sMax; // b) backtracking with f DoubleMatrix1D X1 = F1.make(X.size()); DoubleMatrix1D L1 = F1.make(L.size()); DoubleMatrix1D V1 = F1.make(V.size()); DoubleMatrix1D fiX1 = null; DoubleMatrix1D gradF0X1 = null; DoubleMatrix2D GradFiX1 = null; DoubleMatrix1D rPriX1 = null; DoubleMatrix1D rCentX1L1t = null; DoubleMatrix1D rDualX1L1V1 = null; int cnt = 0; boolean areAllNegative = true; while (cnt < 500) { cnt++; // X1 = X + s*stepX X1 = stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus); DoubleMatrix1D ineqValueX1 = getFi(X1); areAllNegative = true; for (int j = 0; areAllNegative && j < getFi().length; j++) { areAllNegative = (Double.compare(ineqValueX1.get(j), 0.) < 0); } if (areAllNegative) { break; } s = getBeta() * s; } if (!areAllNegative) { //exited from the feasible region throw new Exception("Optimization failed: impossible to remain within the faesible region"); } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s); // c) backtracking with norm double previousNormRX1L1V1t = Double.NaN; cnt = 0; while (cnt < 500) { cnt++; X1 = stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus); L1 = stepL.copy().assign(Mult.mult(s)).assign(L, Functions.plus); V1 = stepV.copy().assign(Mult.mult(s)).assign(V, Functions.plus); // X1.assign(stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus)); // L1.assign(stepL.copy().assign(Mult.mult(s)).assign(L, Functions.plus)); // V1.assign(stepV.copy().assign(Mult.mult(s)).assign(V, Functions.plus)); if (isInDomainF0(X1)) { fiX1 = getFi(X1); gradF0X1 = getGradF0(X1); GradFiX1 = getGradFi(X1); rPriX1 = rPri(X1); rCentX1L1t = rCent(fiX1, L1, t); rDualX1L1V1 = rDual(GradFiX1, gradF0X1, L1, V1); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPriX1 : "+ArrayUtils.toString(rPriX1.toArray())); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rCentX1L1t : "+ArrayUtils.toString(rCentX1L1t.toArray())); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDualX1L1V1: "+ArrayUtils.toString(rDualX1L1V1.toArray())); double normRX1L1V1t = Math .sqrt(ALG.norm2(rPriX1) + ALG.norm2(rCentX1L1t) + ALG.norm2(rDualX1L1V1)); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"normRX1L1V1t: "+normRX1L1V1t); if (normRX1L1V1t <= (1 - getAlpha() * s) * normRXLVt) { break; } if (!Double.isNaN(previousNormRX1L1V1t)) { if (previousNormRX1L1V1t <= normRX1L1V1t) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved in backtracking with norm"); break; } } previousNormRX1L1V1t = normRX1L1V1t; } s = getBeta() * s; //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"s: " + s); } // update X = X1; V = V1; L = L1; // fiX = fiX1; // gradF0X = gradF0X1; // GradFiX = GradFiX1; // // rPriX = rPriX1; // rCentXLt = rCentX1L1t; // rDualXLV = rDualX1L1V1; // rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); // rCentXLtNorm = Math.sqrt(ALG.norm2(rCentXLt)); // rDualXLVNorm = Math.sqrt(ALG.norm2(rDualXLV)); // normRXLVt = Math.sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rCentXLtNorm, 2) + Math.pow(rDualXLVNorm, 2)); // if(Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)){ // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPri norm: " + rPriXNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rCent norm: " + rCentXLtNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDual norm: " + rDualXLVNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"surrDG : " + surrDG); // } } long tStop = System.currentTimeMillis(); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "sol : " + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "ret code: " + response.getReturnCode()); response.setSolution(X.toArray()); setOptimizationResponse(response); return response.getReturnCode(); }
From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerHelper.java
public void doAudioAlert(Context context) { // Use a throttler to keep this from interrupting itself too much. if (System.currentTimeMillis() - mLastAudioMs < THROTTLE_LIMIT_MS) { return;/*from w w w . j a va2 s .c om*/ } mLastAudioMs = System.currentTimeMillis(); final MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(context, mNotification); mediaPlayer.setOnPreparedListener(MEDIA_PLAYER_ON_PREPARED_LISTENER); mediaPlayer.setOnCompletionListener(MEDIA_PLAYER_COMPLETION_LISTENER); // Don't prepare the mediaplayer on the UI thread! That's asking for trouble. mediaPlayer.prepareAsync(); } catch (IOException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "error getting notification sound"); } } }