Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

In this page you can find the example usage for android.util Log w.

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:org.ttrssreader.net.deprecated.HttpClientFactory.java

public HttpClientFactory() {

    boolean trustAllSslCerts = Controller.getInstance().trustAllSsl();
    boolean useCustomKeyStore = Controller.getInstance().useKeystore();

    registry = new SchemeRegistry();
    registry.register(new Scheme("http", new PlainSocketFactory(), 80));

    SocketFactory socketFactory;//  w  w w  .j av a2s. c om

    if (useCustomKeyStore && !trustAllSslCerts) {
        String keystorePassword = Controller.getInstance().getKeystorePassword();

        socketFactory = newSslSocketFactory(keystorePassword);
        if (socketFactory == null) {
            socketFactory = SSLSocketFactory.getSocketFactory();
            Log.w(TAG, "Custom key store could not be read, using default settings.");
        }

    } else if (trustAllSslCerts) {
        socketFactory = new FakeSocketFactory();
    } else {
        socketFactory = SSLSocketFactory.getSocketFactory();
    }

    registry.register(new Scheme("https", socketFactory, 443));

}

From source file:com.etime.ETimeUtils.java

protected static String getHtmlPageWithProgress(DefaultHttpClient client, String url, ETimeAsyncTask asyncTask,
        int startProgress, int maxProgress, int estimatedPageSize) {
    HttpResponse response;//  w  w  w  . j a  v  a  2  s  . co m
    HttpGet httpGet;
    BufferedReader in = null;
    String page = null;
    int runningSize = 0;
    int progress = startProgress;
    int tempProgress;
    String redirect = null;

    try {
        httpGet = new HttpGet(url);

        response = client.execute(httpGet);

        in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

        StringBuilder sb = new StringBuilder("");
        String line;
        String NL = System.getProperty("line.separator");

        Header[] headers = response.getAllHeaders();
        for (Header header : headers) {
            if (header.getName().equals("Content-Length")) {
                try {
                    estimatedPageSize = Integer.parseInt(header.getValue());
                } catch (Exception e) {
                    Log.w(TAG, e.toString());
                }
            } else if (header.getName().equals("Location")) {
                redirect = header.getValue();
            }
            if (asyncTask != null) {
                progress += 5 / (maxProgress - startProgress);
                asyncTask.publishToProgressBar(progress);
            }
        }
        while ((line = in.readLine()) != null) {
            if (asyncTask != null) {
                runningSize += line.length();
                tempProgress = startProgress + (int) (((double) runningSize / ((double) estimatedPageSize))
                        * (maxProgress - startProgress));
                progress = (progress >= tempProgress ? progress : tempProgress);
                if (progress > maxProgress) { //happens when estimatedPageSize <= runningSize
                    progress = maxProgress;
                }

                asyncTask.publishToProgressBar(progress);
            }
            sb.append(line).append(NL);
        }
        page = sb.toString();

    } catch (Exception e) {
        Log.v(TAG, e.toString());
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    if (redirect != null) {
        return redirect;
    }

    return page;
}

From source file:com.juick.android.WsClient.java

@Override
public void terminate() {
    terminated = true;/* w  w w .  j  a  v a 2  s.c  om*/
    setPaused(false); // these are various means to terminate socket
    disconnect();
    listener = null; // these are measures to unreference gui if sockets stuck anyway
    ctx = null;
    Log.w("UgnichWS", "inst=" + toString() + ": terminated=" + terminated);
}

From source file:com.swavdev.tc.DrawableManager.java

protected Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        Log.i(TAG, "key found:" + urlString);
        return drawableMap.get(urlString);
    }/* w w  w. ja v a2 s . co m*/

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");

        if (drawable != null && !drawableMap.containsKey(urlString)) {
            drawableMap.put(urlString, drawable);

        } else {
            Log.w(this.getClass().getSimpleName(), "could not get thumbnail");
        }

        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.obj.handler.ProfileScanningObjHandler.java

@Override
public void handleObj(Context context, DbEntryHandler handler, DbObj obj) {
    JSONObject json = obj.getJson();//from w ww .j  ava  2s .c o  m
    if (DBG)
        Log.d(TAG, "ProfileScanning obj " + json);
    Iterator<String> iter = json.keys();
    while (iter.hasNext()) {
        String attr = iter.next();
        try {
            if (Contact.isWellKnownAttribute(attr)) {
                if (DBG)
                    Log.d(TAG, "Inserting attribute " + attr + " for " + obj.getSender());
                String val = json.getString(attr);
                DbContactAttributes.update(context, obj.getSender().getLocalId(), attr, val);
            }
        } catch (JSONException e) {
            if (DBG)
                Log.w(TAG, "Could not pull attribute " + attr);
        }
    }
}

From source file:br.com.brunogrossi.MediaScannerPlugin.MediaScannerPlugin.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    try {/*from ww w.j a v a  2s.  c  om*/
        if (action.equals("scanFile")) {
            String fileUri = args.optString(0);
            if (fileUri != null && !fileUri.equals("")) {
                Uri contentUri = Uri.parse(fileUri);

                Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                mediaScanIntent.setData(contentUri);
                this.cordova.getActivity().sendBroadcast(mediaScanIntent);

                callbackContext.success();

                return true;
            } else {
                Log.w(TAG, "No action param provided: " + action);
                callbackContext.error("No action param provided: " + action);
                return false;
            }
        } else {
            Log.w(TAG, "Wrong action was provided: " + action);
            return false;
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
        callbackContext.error(e.getMessage());
        return false;
    }
}

From source file:com.calvitium.playground.marvelcharacters.util.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//from   www  .  j  a  v a2 s. co m

    Log.d(TAG, "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");

        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(TAG,
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        } else {
            Log.w(TAG, "could not get thumbnail");
        }

        return drawable;
    } catch (MalformedURLException e) {
        Log.e(TAG, "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(TAG, "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.lillicoder.newsblurry.stories.StoryParser.java

/**
 * Parses the given root stories {@link JSONObject} into a collection
 * of {@link Story}.//from w  w w.java  2  s .c  om
 * @param storiesJson Root stories {@link JSONObject} to parse.
 * @return {@link List} of parsed {@link Story}.
 * @throws JSONException Thrown when given root stories JSON node has an invalid format
 *                    or cannot reliably be parsed.
 */
public List<Story> parseStories(JSONObject storiesJson) throws JSONException {
    List<Story> stories = new ArrayList<Story>();

    JSONArray storiesArray = storiesJson.getJSONArray("stories");
    for (int index = 0; index < storiesArray.length(); index++) {
        try {
            JSONObject storyJson = storiesArray.getJSONObject(index);
            Story story = this.parseStory(storyJson);

            stories.add(story);
        } catch (JSONException e) {
            Log.w(TAG, String.format(FAILED_TO_PARSE_STORY, index));
        }
    }

    return stories;
}

From source file:im.whistle.crypt.Crypt.java

/**
 * Generates a private/public key pair./*w  ww  .j  a  va  2  s . co m*/
 * @param args Arguments, element at 0 is the key size
 * @param callback Callback
 */
public static void genkeys(JSONArray args, AsyncCallback<JSONArray> callback) {
    try {
        Log.i("whistle", "Generating key pair ...");
        PRNGProvider.init(); // Ensure OpenSSL fix
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
        int bits = args.getInt(0);
        int exp = args.getInt(1);
        keyPairGenerator.initialize(new RSAKeyGenParameterSpec(bits, BigInteger.valueOf(exp)));
        KeyPair keyPair = keyPairGenerator.genKeyPair();
        String priv = "-----BEGIN RSA PRIVATE KEY-----\n"
                + Base64.encodeToString(keyPair.getPrivate().getEncoded(), Base64.DEFAULT).trim()
                + "\n-----END RSA PRIVATE KEY-----";
        String pub = "-----BEGIN PUBLIC KEY-----\n"
                + Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.DEFAULT).trim()
                + "\n-----END PUBLIC KEY-----";
        JSONArray res = new JSONArray();
        res.put(priv);
        res.put(pub);
        callback.success(res);
    } catch (Exception ex) {
        Log.w("whistle", "Key pair generation failed: " + ex.getMessage());
        callback.error(ex);
    }
}

From source file:com.github.marcosalis.kraken.utils.http.DefaultBackOffRequired.java

private void logBackoffRequired(@Nonnull String message, @Nonnull HttpResponse response) {
    if (DroidConfig.DEBUG) {
        Log.w(TAG, message + ": " + response.getRequest().getUrl());
    }/*from www. j  ava 2 s .c om*/
}