List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.kevinquan.google.activityrecoginition.model.MotionHelper.java
public static JSONObject asJson(List<MotionSnapshot> snapshots) { if (snapshots == null || snapshots.size() == 0) { Log.w(TAG, "No snapshots were provided to convert."); return null; }/*from w ww .ja va2 s.c o m*/ JSONObject output = new JSONObject(); JSONArray snapshotsArray = new JSONArray(); for (MotionSnapshot snapshot : snapshots) { snapshotsArray.put(snapshot.asJson()); } JSONUtils.safePutArray(output, JSON_FIELD_SNAPSHOTS, snapshotsArray); return output; }
From source file:com.admob.mobileads.YandexBanner.java
@Override public void requestBannerAd(final Context context, final CustomEventBannerListener customEventBannerListener, final String serverParameter, final AdSize adMobAdSize, final MediationAdRequest mediationAdRequest, final Bundle adMobExtras) { mBannerListener = customEventBannerListener; if (mBannerListener == null) { Log.w(TAG, "customEventBannerListener must not be null"); return;//from w ww. j a v a 2 s .com } if (isValidServerExtras(serverParameter)) { try { parseServerExtras(serverParameter); final com.yandex.mobile.ads.AdSize adSize = calculateAdSize(adMobAdSize); final com.yandex.mobile.ads.AdRequest adRequest = configureAdRequest(mediationAdRequest); mAdView = new AdView(context); mAdView.setAdSize(adSize); mAdView.setBlockId(mBlockId); mAdView.shouldOpenLinksInApp(mOpenLinksInApp); mAdView.setAdEventListener(mAdEventListener); mAdView.loadAd(adRequest); } catch (JSONException e) { mBannerListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL); } } else { mBannerListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL); } }
From source file:gmc.hotplate.logic.ServerDataManager.java
@Override public List<Recipe> getRecipes(int limit) { Map<String, String> params = new HashMap<String, String>(); params.put(PARAM_KEY_TYPE, PARAM_VAL_ALL); params.put(PARAM_KEY_OFFSET, PARAM_VAL_DEFAULT_OFFSET); params.put(PARAM_KEY_LIMIT, String.valueOf(limit)); String response = connection.requestServer(urlString, params); if (connection.getStatus() != ConnectionStatus.CONNECT_OK) { // TODO(arhangeldim): Handle error Log.w(LOG_TAG, "No recipes to display"); } else {/* w w w . ja va2s .com*/ Log.d(LOG_TAG, response); JsonParser parser = new JsonParser(); try { JSONObject obj = new JSONObject(response); recipes = parser.parseMessage(obj); } catch (JSONException e) { Log.w(LOG_TAG, "No recipes to display"); } } for (Recipe r : recipes) { recipeCache.put(r.getId(), r); } return recipes; }
From source file:at.bitfire.davdroid.URIUtils.java
/** * Parse a received absolute/relative URL and generate a normalized URI that can be compared. * @param original URI to be parsed, may be absolute or relative * @param mustBePath true if it's known that original is a path (may contain ":") and not an URI, i.e. ":" is not the scheme separator * @return normalized URI/* w ww . j a va2s.c o m*/ * @throws URISyntaxException */ public static URI parseURI(String original, boolean mustBePath) throws URISyntaxException { if (mustBePath) { // may contain ":" // case 1: "my:file" won't be parsed by URI correctly because it would consider "my" as URI scheme // case 2: "path/my:file" will be parsed by URI correctly // case 3: "my:path/file" won't be parsed by URI correctly because it would consider "my" as URI scheme int idxSlash = original.indexOf('/'), idxColon = original.indexOf(':'); if (idxColon != -1) { // colon present if ((idxSlash != -1) && idxSlash < idxColon) // There's a slash, and it's before the colon everything OK ; else // No slash before the colon; we have to put it there original = "./" + original; } } // escape some common invalid characters servers keep sending unescaped crap like "my calendar.ics" or "{guid}.vcf" // this is only a hack, because for instance, "[" may be valid in URLs (IPv6 literal in host name) String repaired = original.replaceAll(" ", "%20").replaceAll("\\{", "%7B").replaceAll("\\}", "%7D"); if (!repaired.equals(original)) Log.w(TAG, "Repaired invalid URL: " + original + " -> " + repaired); URI uri = new URI(repaired); URI normalized = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment()); Log.v(TAG, "Normalized URL " + original + " -> " + normalized.toASCIIString()); return normalized; }
From source file:fr.pasteque.client.models.Discount.java
public Discount(String id, double rate, String start, String end, String barcode, int barcodeType) throws ParseException { this.id = id; this.rate = rate; if (barcode == null) { Log.w(LOG_TAG, "barcode null not expected"); }//ww w. j av a 2 s . co m this.startDate = convertDateFromString(start); this.endDate = convertDateFromString(end); this.barcode = new Barcode(barcode, barcodeType); }
From source file:edu.asu.msse.sgowdru.movieplus.MovieDescription.java
public void readFile(Context context) { String json = ""; String line;//from w w w . j av a2 s. co m try ( //Set reader to omdb.json BufferedReader reader = new BufferedReader( new InputStreamReader(context.getAssets().open("omdb.json")));) { while ((line = reader.readLine()) != null) { json += line; } Log.w(getClass().getSimpleName(), json); } catch (Exception e) { Log.w(getClass().getSimpleName(), "From exception"); e.printStackTrace(); } parseJson(json); }
From source file:Main.java
/** * Create an {@code List<Integer>} from the {@code List<>} by using {@code convertFrom} and * {@code convertTo} as a one-to-one map (via the index). * * <p>Strings not appearing in {@code convertFrom} are ignored (with a logged warning); * strings appearing in {@code convertFrom} but not {@code convertTo} are silently * dropped.</p>/*from w ww. j a v a2s . c o m*/ * * @param list Source list of strings * @param convertFrom Conversion list of strings * @param convertTo Conversion list of ints * @return A list of ints where the values correspond to the ones in {@code convertTo} * or {@code null} if {@code list} was {@code null} */ public static List<Integer> convertStringListToIntList(List<String> list, String[] convertFrom, int[] convertTo) { if (list == null) { return null; } List<Integer> convertedList = new ArrayList<>(list.size()); for (String str : list) { int strIndex = getArrayIndex(convertFrom, str); // Guard against unexpected values if (strIndex < 0) { Log.w(TAG, "Ignoring invalid value " + str); continue; } // Ignore values we can't map into (intentional) if (strIndex < convertTo.length) { convertedList.add(convertTo[strIndex]); } } return convertedList; }
From source file:it.cdpaf.helper.DrawableManager.java
public static Drawable fetchDrawable(String urlString, Context ctx) { if (drawableMap.containsKey(urlString)) { Log.d(ctx.getClass().getSimpleName(), "DRAWABLE MANAGER FD:" + "RIUSO: " + urlString + " Size:" + drawableMap.size()); return drawableMap.get(urlString); }// www . j av a 2s. c om Log.d(ctx.getClass().getSimpleName(), "image url:" + urlString); try { InputStream is = fetch(urlString, ctx); Drawable drawable = Drawable.createFromStream(is, "src"); if (drawable != null) { drawableMap.put(urlString, drawable); Log.d(ctx.getClass().getSimpleName(), "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth()); } else { Log.w(ctx.getClass().getSimpleName(), "could not get thumbnail"); } return drawable; } catch (MalformedURLException e) { Log.e(ctx.getClass().getSimpleName(), "MALFORMEDURL EXC fetchDrawable failed", e); return null; } catch (IOException e) { Log.e(ctx.getClass().getSimpleName(), "IO EXCP fetchDrawable failed", e); return null; } }
From source file:com.eugene.fithealthmaingit.FatSecretSearchAndGet.FatSecretGetMethod.java
public JSONObject getFood(Long ab) { List<String> params = new ArrayList<>(Arrays.asList(generateOauthParams())); String[] template = new String[1]; params.add("method=food.get"); params.add("food_id=" + ab); params.add("oauth_signature=" + sign(Globals.APP_METHOD, Globals.APP_URL, params.toArray(template))); JSONObject food = null;//from w w w . j a v a2 s . co m try { URL url = new URL(Globals.APP_URL + "?" + paramify(params.toArray(template))); URLConnection api = url.openConnection(); String line; StringBuilder builder = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(api.getInputStream())); while ((line = reader.readLine()) != null) builder.append(line); JSONObject foodGet = new JSONObject(builder.toString()); food = foodGet.getJSONObject("food"); } catch (Exception e) { Log.w("Fit", e.toString()); e.printStackTrace(); } return food; }
From source file:com.eugene.fithealthmaingit.FatSecretSearchAndGet.FatSecretGetMethod.java
private static String sign(String method, String uri, String[] params) { String[] p = { method, Uri.encode(uri), Uri.encode(paramify(params)) }; String s = join(p, "&"); SecretKey sk = new SecretKeySpec(Globals.APP_SECRET.getBytes(), Globals.HMAC_SHA1_ALGORITHM); try {/* ww w .j a v a 2s . co m*/ Mac m = Mac.getInstance(Globals.HMAC_SHA1_ALGORITHM); m.init(sk); return Uri.encode(new String(Base64.encode(m.doFinal(s.getBytes()), Base64.DEFAULT)).trim()); } catch (java.security.NoSuchAlgorithmException e) { Log.w("FatSecret_TEST FAIL", e.getMessage()); return null; } catch (java.security.InvalidKeyException e) { Log.w("FatSecret_TEST FAIL", e.getMessage()); return null; } }