List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:com.ameron32.apps.tapnotes._unused.original.LoginFragmentBase.java
protected void debugLog(String text) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_DEBUG && Log.isLoggable(getLogTag(), Log.WARN)) { Log.w(getLogTag(), text);//from w w w . j a va 2 s . c o m } }
From source file:carbon.internal.PercentLayoutHelper.java
/** * Iterates over children and changes their width and height to one calculated from percentage * values.// w w w . j a va2 s. c o m * * @param widthMeasureSpec Width MeasureSpec of the parent ViewGroup. * @param heightMeasureSpec Height MeasureSpec of the parent ViewGroup. */ public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "adjustChildren: " + mHost + " widthMeasureSpec: " + View.MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec: " + View.MeasureSpec.toString(heightMeasureSpec)); } int widthHint = View.MeasureSpec.getSize(widthMeasureSpec); int heightHint = View.MeasureSpec.getSize(heightMeasureSpec); for (int i = 0, N = mHost.getChildCount(); i < N; i++) { View view = mHost.getChildAt(i); ViewGroup.LayoutParams params = view.getLayoutParams(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "should adjust " + view + " " + params); } if (params instanceof PercentLayoutParams) { PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "using " + info); } if (info != null) { if (params instanceof ViewGroup.MarginLayoutParams) { info.fillMarginLayoutParams((ViewGroup.MarginLayoutParams) params, widthHint, heightHint); } else { info.fillLayoutParams(params, widthHint, heightHint); } } } } }
From source file:com.phonemetra.turbo.lockclock.weather.OpenWeatherMapProvider.java
@Override public List<LocationResult> getLocations(String input) { String url = String.format(URL_LOCATION, Uri.encode(input), getLanguageCode()); String response = HttpRetriever.retrieve(url); if (response == null) { return null; }/*from w w w . j a va2s . c om*/ if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "URL = " + url + " returning a response of " + response); } try { JSONArray jsonResults = new JSONObject(response).getJSONArray("list"); ArrayList<LocationResult> results = new ArrayList<LocationResult>(); int count = jsonResults.length(); for (int i = 0; i < count; i++) { JSONObject result = jsonResults.getJSONObject(i); LocationResult location = new LocationResult(); location.id = result.getString("id"); location.city = result.getString("name"); location.countryId = result.getJSONObject("sys").getString("country"); results.add(location); } return results; } catch (JSONException e) { Log.w(TAG, "Received malformed location data (input=" + input + ")", e); } return null; }
From source file:com.ibm.commerce.worklight.android.maps.StoreMapActivity.java
/** * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle) *//*from ww w .j a v a2s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { final String METHOD_NAME = CLASS_NAME + ".onCreate()"; boolean loggingEnabled = Log.isLoggable(LOG_TAG, Log.DEBUG); if (loggingEnabled) { Log.d(METHOD_NAME, "ENTRY"); } super.onCreate(savedInstanceState); setContentView(R.layout.map_layout); String centerLatitude = getIntent().getStringExtra("mapCenterLatitude"); String centerLongitude = getIntent().getStringExtra("mapCenterLongitude"); String storeName = getIntent().getStringExtra("storeName"); String storeLatitude = getIntent().getStringExtra("storeLatitude"); String storeLongitude = getIntent().getStringExtra("storeLongitude"); String storeCity = getIntent().getStringExtra("storeCity"); String storeState = getIntent().getStringExtra("storeState"); String storeAddr1 = getIntent().getStringExtra("storeAddress1"); String storeAddr2 = getIntent().getStringExtra("storeAddress2"); String storeAddr3 = getIntent().getStringExtra("storeAddress3"); if (loggingEnabled) { Log.d(METHOD_NAME, new StringBuilder("Intent extras = {centerLatitude: ").append(centerLatitude) .append(", centerLongitude: ").append(centerLongitude).append(", storeName: ").append(storeName) .append(", storeLatitude: ").append(storeLatitude).append(", storeLongitude: ") .append(storeLongitude).append(", storeCity: ").append(storeCity).append(", storeState: ") .append(storeState).append(", storeAddr1: ").append(storeAddr1).append(", storeAddr2: ") .append(storeAddr2).append(", storeAddr3: ").append(storeAddr3).append("}").toString()); } // Obtain the fragment from the layout XML and initialize the map GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_fragment)) .getMap(); if (map != null) { try { // show current location on the map map.setMyLocationEnabled(true); // create the coordinate set LatLng storePosition = null; LatLng mapStart = null; if ((storeLatitude != null && storeLatitude.length() > 0) || (storeLongitude != null && storeLongitude.length() > 0)) { storePosition = new LatLng(Double.parseDouble(storeLatitude), Double.parseDouble(storeLongitude)); // if GPS is not used then load the map at the store coordinates if ((centerLatitude != null && centerLatitude.length() > 0) || (centerLongitude != null && centerLongitude.length() > 0)) { mapStart = new LatLng(Double.parseDouble(centerLatitude), Double.parseDouble(centerLongitude)); } else { mapStart = storePosition; } // pan the camera over to the initial coordinates and then move over to the physical store coordinates map.moveCamera(CameraUpdateFactory.newLatLng(mapStart)); map.animateCamera(CameraUpdateFactory.newLatLngZoom(storePosition, 15)); map.addMarker(new MarkerOptions().position(storePosition).title(storeName) .snippet(new StringBuilder(this.getResources().getString(R.string.addressTitle)) .append(": ").append(storeAddr1).append(", ").append(storeCity).append(", ") .append(storeState).toString())); } else { if (loggingEnabled) { Log.d(METHOD_NAME, "Store coordinates are not available"); } } } catch (NumberFormatException e) { Log.d(METHOD_NAME, "Store latitude and/or longtiude cannot be parsed into Double"); } catch (NullPointerException e) { Log.d(METHOD_NAME, "Cannot construct string message for marker"); } } else { if (loggingEnabled) { Log.d(METHOD_NAME, "Map is unavailable. Check the availability of Google Play services."); } } if (loggingEnabled) { Log.d(METHOD_NAME, "EXIT"); } }
From source file:org.openschedule.api.impl.EventTemplate.java
public Event getEvent(String shortName) { Log.v(TAG, "getEvent : enter"); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "getEvent : shortName=" + shortName); }//w ww .j a va 2s . c om Event event = restTemplate.getForObject(buildUri("public/" + shortName), Event.class); Log.v(TAG, "getEvent : event=" + event.toString()); Log.v(TAG, "getEvent : exit"); return event; }
From source file:com.example.android.wearable.timer.TimerNotificationService.java
private void restartAlarm() { Intent dialogIntent = new Intent(this, SetTimerActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dialogIntent);//from www . j a v a 2 s .c o m if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Timer restarted."); } }
From source file:com.joptimizer.optimizers.NewtonUnconstrained.java
@Override public int optimize() throws Exception { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "optimize"); OptimizationResponse response = new OptimizationResponse(); // checking responsibility if (getA() != null || getFi() != null) { // forward to the chain return forwardOptimizationRequest(); }/*from w ww.j ava 2s . c om*/ if (getF0() instanceof StrictlyConvexMultivariateRealFunction) { // OK, it's my duty } else { throw new Exception("Unsolvable problem"); } long tStart = System.currentTimeMillis(); DoubleMatrix1D X0 = getInitialPoint(); if (X0 == null) { X0 = F1.make(getDim()); } if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0: " + ArrayUtils.toString(X0.toArray())); } DoubleMatrix1D X = X0; double previousLambda = Double.NaN; int iteration = 0; while (true) { iteration++; 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, "f(X)=" + F0X); } // custom exit condition if (checkCustomExitConditions(X)) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } DoubleMatrix1D gradX = getGradF0(X); DoubleMatrix2D hessX = getHessF0(X); // Newton step and decrement DoubleMatrix1D step = calculateNewtonStep(hessX, gradX); //DoubleMatrix1D step = calculateNewtonStepCM(hessX, gradX); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "step: " + ArrayUtils.toString(step.toArray())); } //Newton decrement double lambda = Math.sqrt(-ALG.mult(gradX, step)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "lambda: " + lambda); if (lambda / 2. <= getTolerance()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // iteration limit condition if (iteration == getMaxIteration()) { response.setReturnCode(OptimizationResponse.WARN); Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached"); break; } // progress conditions if (isCheckProgressConditions()) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "previous: " + previousLambda); if (!Double.isNaN(previousLambda) && previousLambda <= lambda) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved, exit iterations loop without desired accuracy"); response.setReturnCode(OptimizationResponse.WARN); break; } } previousLambda = lambda; // backtracking line search double s = 1d; DoubleMatrix1D X1 = null; int cnt = 0; while (cnt < 25) { cnt++; // @TODO: can we use semplification 9.7.1 (Pre-computation for line searches)? X1 = X.copy().assign(step.copy().assign(Mult.mult(s)), Functions.plus);// x + t*step double condSX = getF0(X1); //NB: this will also check !Double.isNaN(getF0(X1)) double condDX = F0X + getAlpha() * s * ALG.mult(gradX, step); if (condSX <= condDX) { break; } s = getBeta() * s; } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s); // update X = X1; } long tStop = System.currentTimeMillis(); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart)); response.setSolution(X.toArray()); setOptimizationResponse(response); return response.getReturnCode(); }
From source file:com.goliathonline.android.kegbot.io.RemoteUserHandler.java
/** {@inheritDoc} */ @Override/* www . jav a 2 s .c om*/ public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver) throws JSONException, IOException { final ArrayList<ContentProviderOperation> batch = Lists.newArrayList(); // Walk document, parsing any incoming entries if (!parser.has("result")) return batch; JSONObject result = parser.getJSONObject("result"); JSONObject keg = result.getJSONObject("user"); final String userId = sanitizeId(keg.getString("username")); final Uri userUri = Users.buildUserUri(userId); // Check for existing details, only update when changed final ContentValues values = queryUserDetails(userUri, resolver); final long localUpdated = values.getAsLong(SyncColumns.UPDATED); final long serverUpdated = 500; //entry.getUpdated(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "found user " + userId); Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated); } // Clear any existing values for this session, treating the // incoming details as authoritative. batch.add(ContentProviderOperation.newDelete(userUri).build()); final ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(Users.CONTENT_URI); builder.withValue(SyncColumns.UPDATED, serverUpdated); builder.withValue(Users.USER_ID, userId); if (keg.has("image")) { JSONObject image = keg.getJSONObject("image"); if (image.has("url")) builder.withValue(Users.USER_IMAGE_URL, image.getString("url")); } // Normal session details ready, write to provider batch.add(builder.build()); return batch; }
From source file:com.goliathonline.android.kegbot.io.RemoteKegHandler.java
/** {@inheritDoc} */ @Override//from w ww. ja va2 s . c om public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver) throws JSONException, IOException { final ArrayList<ContentProviderOperation> batch = Lists.newArrayList(); // Walk document, parsing any incoming entries JSONObject result = parser.getJSONObject("result"); JSONObject keg = result.getJSONObject("keg"); JSONObject type = result.getJSONObject("type"); JSONObject image = type.getJSONObject("image"); final String kegId = sanitizeId(keg.getString("id")); final Uri kegUri = Kegs.buildKegUri(kegId); // Check for existing details, only update when changed final ContentValues values = queryKegDetails(kegUri, resolver); final long localUpdated = values.getAsLong(SyncColumns.UPDATED); final long serverUpdated = 500; //entry.getUpdated(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "found keg " + kegId); Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated); } // Clear any existing values for this session, treating the // incoming details as authoritative. batch.add(ContentProviderOperation.newDelete(kegUri).build()); final ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(Kegs.CONTENT_URI); builder.withValue(SyncColumns.UPDATED, serverUpdated); builder.withValue(Kegs.KEG_ID, kegId); // Inherit starred value from previous row if (values.containsKey(Kegs.KEG_STARRED)) { builder.withValue(Kegs.KEG_STARRED, values.getAsInteger(Kegs.KEG_STARRED)); } if (keg.has("status")) builder.withValue(Kegs.STATUS, keg.getString("status")); if (keg.has("volume_ml_remain")) builder.withValue(Kegs.VOLUME_REMAIN, keg.getDouble("volume_ml_remain")); if (keg.has("description")) builder.withValue(Kegs.DESCRIPTION, keg.getString("description")); if (keg.has("type_id")) builder.withValue(Kegs.TYPE_ID, keg.getString("type_id")); if (keg.has("size_id")) builder.withValue(Kegs.SIZE_ID, keg.getInt("size_id")); if (keg.has("percent_full")) builder.withValue(Kegs.PERCENT_FULL, keg.getDouble("percent_full")); if (keg.has("size_name")) builder.withValue(Kegs.SIZE_NAME, keg.getString("size_name")); if (keg.has("spilled_ml")) builder.withValue(Kegs.VOLUME_SPILL, keg.getDouble("spilled_ml")); if (keg.has("size_volume_ml")) builder.withValue(Kegs.VOLUME_SIZE, keg.getDouble("size_volume_ml")); if (type.has("name")) builder.withValue(Kegs.KEG_NAME, type.getString("name")); if (type.has("abv")) builder.withValue(Kegs.KEG_ABV, type.getDouble("abv")); if (image.has("url")) builder.withValue(Kegs.IMAGE_URL, image.getString("url")); // Normal keg details ready, write to provider batch.add(builder.build()); return batch; }
From source file:ir.keloud.android.lib.common.SingleSessionManager.java
@Override public KeloudClient getClientFor(KeloudAccount account, Context context) throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "getClientFor starting "); }//from w w w. j a v a 2s .c o m if (account == null) { throw new IllegalArgumentException("Cannot get an KeloudClient for a null account"); } KeloudClient client = null; String accountName = account.getName(); String sessionName = account.getCredentials() == null ? "" : AccountUtils.buildAccountName(account.getBaseUri(), account.getCredentials().getAuthToken()); if (accountName != null) { client = mClientsWithKnownUsername.get(accountName); } boolean reusingKnown = false; // just for logs if (client == null) { if (accountName != null) { client = mClientsWithUnknownUsername.remove(sessionName); if (client != null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for session " + sessionName); } mClientsWithKnownUsername.put(accountName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "moved client to account " + accountName); } } } else { client = mClientsWithUnknownUsername.get(sessionName); } } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for account " + accountName); } reusingKnown = true; } if (client == null) { // no client to reuse - create a new one client = KeloudClientFactory.createKeloudClient(account.getBaseUri(), context.getApplicationContext(), true); // TODO remove dependency on KeloudClientFactory client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); // enable cookie tracking AccountUtils.restoreCookies(accountName, client, context); account.loadCredentials(context); client.setCredentials(account.getCredentials()); if (accountName != null) { mClientsWithKnownUsername.put(accountName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "new client for account " + accountName); } } else { mClientsWithUnknownUsername.put(sessionName, client); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "new client for session " + sessionName); } } } else { if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) { Log_OC.v(TAG, "reusing client for session " + sessionName); } keepCredentialsUpdated(account, client); keepUriUpdated(account, client); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log_OC.d(TAG, "getClientFor finishing "); } return client; }