Example usage for android.util Log WARN

List of usage examples for android.util Log WARN

Introduction

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

Prototype

int WARN

To view the source code for android.util Log WARN.

Click Source Link

Document

Priority constant for the println method; use Log.w.

Usage

From source file:com.digipom.manteresting.android.fragment.NailFragment.java

private boolean handleMenuItemSelected(int listItemPosition, int itemId) {
    listItemPosition -= listView.getHeaderViewsCount();

    if (listItemPosition >= 0 && listItemPosition < nailAdapter.getCount()) {
        switch (itemId) {
        case R.id.share:
            try {
                final Cursor cursor = (Cursor) nailAdapter.getItem(listItemPosition);

                if (cursor != null && !cursor.isClosed()) {
                    final int nailId = cursor.getInt(cursor.getColumnIndex(Nails.NAIL_ID));
                    final JSONObject nailJson = new JSONObject(
                            cursor.getString(cursor.getColumnIndex(Nails.NAIL_JSON)));

                    final Uri uri = MANTERESTING_SERVER.buildUpon().appendPath("nail")
                            .appendPath(String.valueOf(nailId)).build();
                    String description = nailJson.getString("description");

                    if (description.length() > 100) {
                        description = description.substring(0, 97) + '';
                    }//from www  .  ja v  a2s.c  o m

                    final String user = nailJson.getJSONObject("user").getString("username");
                    final String category = nailJson.getJSONObject("workbench").getJSONObject("category")
                            .getString("title");

                    final Intent shareIntent = new Intent(Intent.ACTION_SEND);
                    shareIntent.setType("text/plain");
                    shareIntent.putExtra(Intent.EXTRA_TEXT, description + ' ' + uri.toString());
                    shareIntent.putExtra(Intent.EXTRA_SUBJECT,
                            String.format(getResources().getString(R.string.shareSubject), user, category));
                    try {
                        startActivity(Intent.createChooser(shareIntent, getText(R.string.share)));
                    } catch (ActivityNotFoundException e) {
                        new AlertDialog.Builder(getActivity()).setMessage(R.string.noShareApp).show();
                    }
                }
            } catch (Exception e) {
                if (LoggerConfig.canLog(Log.WARN)) {
                    Log.w(TAG, "Could not share nail at position " + listItemPosition + " with id " + itemId);
                }
            }

            return true;
        default:
            return false;
        }
    } else {
        return false;
    }
}

From source file:org.fs.galleon.presenters.ToolsFragmentPresenter.java

private Observable<List<File>> dispatchImageToPdfProcess() {
    return Observable.just(images).flatMap(Observable::from).map(uri -> new File(uri.getImageUri().getPath()))
            .map(file -> {/*w w w  . j  av  a 2s. com*/
                File toolsDirectory = fileManager.toolsDirectory();
                if (toolsDirectory == null) {
                    ThreadManager.runOnUiThread(() -> {
                        if (view.isAvailable()) {
                            view.showError(
                                    "You should picked a tools directory for working with img to pdf conversions.");
                        }
                    });
                    return null;
                }
                String newFileName = file.getName();
                newFileName = newFileName.substring(0, newFileName.lastIndexOf('.'));
                File jpegFile = new File(fileManager.toolsDirectory(), newFileName + FILE_EXTENSION);
                File pdfFile = new File(fileManager.toolsDirectory(), newFileName + FILE_PDF_EXTENSION);

                Pix pixs = ReadFile.readFile(file);
                pixs = AdaptiveMap.backgroundNormSimple(pixs);
                pixs = pixs.convertRGBToGray();
                float angle = Skew.findSkew(pixs);
                pixs = Rotate.rotate(pixs, angle, true, true);
                pixs = MorphApp.pixTophat(pixs);
                pixs = MorphApp.pixInvert(pixs);
                pixs = GrayQuant.pixGammaRTC(pixs);
                pixs = GrayQuant.pixThresholdToBinary(pixs);
                pixs.write(jpegFile, ImageFormat.JfifJpg);

                PdfCore.createFromJpeg(jpegFile, pixs.getWidth(), pixs.getHeight(), pdfFile);
                if (pdfFile.exists()) {
                    log(Log.WARN, String.format(Locale.ENGLISH, "%s named file has size of %d",
                            pdfFile.getName(), pdfFile.length()));
                }
                pixs.recycle();
                return pdfFile;
            }).filter(f -> !StringUtility.isNullOrEmpty(f)).toList();
}

From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java

private void serializeSession() {
    // Attempt to serialize the session for later use
    if (Collect.getInstance().getInformOnlineState().getSession() instanceof CookieStore) {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, t + "serializing session");

        try {/*from  w  ww.j  av  a2 s  . co m*/
            InformOnlineSession session = new InformOnlineSession();

            Iterator<Cookie> cookies = Collect.getInstance().getInformOnlineState().getSession().getCookies()
                    .iterator();

            while (cookies.hasNext()) {
                Cookie c = cookies.next();
                session.getCookies().add(new InformOnlineSession(c.getDomain(), c.getExpiryDate(), c.getName(),
                        c.getPath(), c.getValue(), c.getVersion()));
            }

            FileOutputStream fos = new FileOutputStream(
                    new File(getCacheDir(), FileUtilsExtended.SESSION_CACHE_FILE));
            ObjectOutputStream out = new ObjectOutputStream(fos);
            out.writeObject(session);
            out.close();
            fos.close();
        } catch (Exception e) {
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, t + "problem serializing session " + e.toString());
            e.printStackTrace();

            // Make sure that we don't leave a broken file hanging
            new File(getCacheDir(), FileUtilsExtended.SESSION_CACHE_FILE).delete();
        }
    } else {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, t + "no session to serialize");
    }
}

From source file:com.radicaldynamic.groupinform.services.DatabaseService.java

private void openLocalDb(String db) throws DbUnavailableException {
    final String tt = t + "openLocalDb(): ";

    try {//  w w  w.ja va  2  s  .  c  o m
        /*
         * We used to create the database if it did not exist HOWEVER this had unintended side effects.
         * 
         * Since local databases are typically initialized on-demand the first time the user selects
         * them for operations, databases that were selected for replication but not yet "switched to" 
         * would be created as empty databases if the user backed out of the folder selection screen 
         * without specifically choosing a database.
         * 
         * Because the database then existed, attempts to "switch to" the database via the folder
         * selection screen (and have it initialized on-demand as expected) would fail.  At least,
         * until the system got around to creating and replicating it automatically.
         */
        if (mLocalDbInstance.getAllDatabases().indexOf("db_" + db) == -1) {
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, tt + "database does not exist; failing attempt to open");
            throw new DbUnavailableException();
        }

        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, tt + "opening database " + db);
        mLocalDbConnector = new InformCouchDbConnector("db_" + db, mLocalDbInstance);
    } catch (Exception e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "while opening DB " + db + ": " + e.toString());
        e.printStackTrace();
        throw new DbUnavailableException();
    }
}

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

/**
 * Check if the {@link View} this element represents matches a particular class.
 *
 * @param referenceClass the class to check against the class of this element
 * @return {@link Boolean#TRUE} if the {@code View} this element represents is an instance of the
 *     class whose name is {@code referenceClass}. {@link Boolean#FALSE} if it does not. {@code
 *     null} if a determination cannot be made.
 *///  ww  w.ja va  2  s .c om
public @Nullable Boolean checkInstanceOf(Class<?> referenceClass) {
    if ((className == null) || (referenceClass == null)) {
        return null;
    }

    Class<?> targetClass = null;
    ClassLoader classLoader = getClass().getClassLoader();
    try {
        if (classLoader != null) {
            targetClass = classLoader.loadClass(className.toString());
        }
    } catch (ClassNotFoundException e) {
        // Do nothing
    }

    if (targetClass == null) {
        LogUtils.log(this, Log.WARN, "Unsuccessful attempt to resolve class %1$s while comparing against %2$s",
                className, referenceClass);
        return null;
    }

    return referenceClass.isAssignableFrom(targetClass);
}

From source file:biz.bokhorst.xprivacy.Util.java

public static void setPermissions(String path, int mode, int uid, int gid) {
    try {/*from www  .ja v a 2 s  .c o  m*/
        // frameworks/base/core/java/android/os/FileUtils.java
        Class<?> fileUtils = Class.forName("android.os.FileUtils");
        Method setPermissions = fileUtils.getMethod("setPermissions", String.class, int.class, int.class,
                int.class);
        setPermissions.invoke(null, path, mode, uid, gid);
        Util.log(null, Log.WARN, "Changed permission path=" + path + " mode=" + Integer.toOctalString(mode)
                + " uid=" + uid + " gid=" + gid);
    } catch (Throwable ex) {
        Util.bug(null, ex);
    }
}

From source file:com.radicaldynamic.groupinform.services.DatabaseService.java

private void performHousekeeping() {
    final String tt = t + "performHousekeeping(): ";

    try {//from w  w  w. j  a v a  2 s.  c o  m
        List<String> allDatabases = mLocalDbInstance.getAllDatabases();
        Iterator<String> dbs = allDatabases.iterator();

        while (dbs.hasNext()) {
            String db = dbs.next();

            // Skip special databases
            if (!db.startsWith("_")) {
                // Our metadata knows nothing about the db_ prefix
                db = db.substring(3);

                AccountFolder folder = Collect.getInstance().getInformOnlineState().getAccountFolders().get(db);

                if (folder == null) {
                    // Remove databases that exist locally but for which we have no metadata
                    if (Collect.Log.DEBUG)
                        Log.d(Collect.LOGTAG, tt + "no metatdata for " + db + " (removing)");
                    mLocalDbInstance.deleteDatabase("db_" + db);
                } else if (isDbLocal(db) && folder.isReplicated() == false) {
                    // Purge any databases that are local but not on the replication list                        
                    try {
                        ReplicationStatus status = replicate(db, REPLICATE_PUSH);

                        if (status != null && status.isOk()) {
                            if (Collect.Log.DEBUG)
                                Log.d(Collect.LOGTAG, tt + "final replication push successful, removing " + db);
                            mLocalDbInstance.deleteDatabase("db_" + db);
                        }
                    } catch (Exception e) {
                        if (Collect.Log.ERROR)
                            Log.e(Collect.LOGTAG,
                                    tt + "final replication push of " + db + " failed at " + e.toString());
                        e.printStackTrace();
                    }
                }
            }
        }
    } catch (DbAccessException e) {
        if (Collect.Log.WARN)
            Log.w(Collect.LOGTAG, tt + "database not available " + e.toString());
    } catch (Exception e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "unhandled exception " + e.toString());
        e.printStackTrace();
    }
}

From source file:com.google.android.marvin.mytalkback.CursorController.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
        final AccessibilityNodeInfo node = event.getSource();
        if (node == null) {
            LogUtils.log(this, Log.WARN, "TYPE_VIEW_ACCESSIBILITY_FOCUSED event without a source.");
            return;
        }/*from   ww w  . j  ava 2 s.  c  o m*/

        // When a new view gets focus, clear the state of the granularity
        // manager if this event came from a different node than the locked
        // node but from the same window.
        final AccessibilityNodeInfoCompat nodeCompat = new AccessibilityNodeInfoCompat(node);
        mGranularityManager.onNodeFocused(nodeCompat);
        nodeCompat.recycle();
    }
}

From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java

private boolean activateNode(AccessibilityNodeInfoCompat node, int position) {
    if (node == null) {
        return false;
    }/* w ww  . j  a  va2 s  . c o m*/
    AccessibilityNodeInfoRef current = AccessibilityNodeInfoRef.unOwned(node);
    try {
        do {
            LogUtils.log(this, Log.VERBOSE, "Considering to click: %s", current.get().getInfo());
            int supportedActions = current.get().getActions();
            int action = 0;
            // For edit texts, the click action doesn't currently focus
            // the view, so we special case it here.
            // TODO: Revise when that changes.
            if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(mAccessibilityService, current.get(),
                    EditText.class)) {
                if ((supportedActions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) {
                    action = AccessibilityNodeInfo.ACTION_FOCUS;
                } else {
                    // Put accessibility focus on the field.  If it is
                    // already focused and the IME is selected, that will
                    // activate the editing.
                    action = AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
                }
            } else if (position >= 0 && isSelfBrailled(current.get())
                    && (supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                // Generate a fake "action". For instance, a click at
                // position 33 maps to -275000033.
                // TODO: Remove this hack when a better way to pass this
                // information exists.
                int fakeAction = ACTION_BRAILLE_CLICK_MAX - position;
                if (fakeAction < ACTION_BRAILLE_CLICK_MIN) {
                    LogUtils.log(this, Log.WARN, "underflow activating node %s at position %d", current.get(),
                            position);
                    fakeAction = ACTION_BRAILLE_CLICK_MIN;
                } else if (fakeAction > ACTION_BRAILLE_CLICK_MAX) {
                    LogUtils.log(this, Log.WARN, "overflow activating node %s at position %d", current.get(),
                            position);
                    fakeAction = ACTION_BRAILLE_CLICK_MAX;
                }
                if (WebInterfaceUtils.performSpecialAction(current.get(), fakeAction)) {
                    return true;
                }
            } else if ((supportedActions & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                action = AccessibilityNodeInfo.ACTION_CLICK;
            }
            if (action != 0 && current.get().performAction(action)) {
                return true;
            } else {
                LogUtils.log(this, Log.VERBOSE, "Action %d failed", action);
            }
        } while (current.parent());
    } finally {
        current.recycle();
    }
    LogUtils.log(this, Log.VERBOSE, "Click action failed");
    return false;
}

From source file:com.android.screenspeak.formatter.EventSpeechRule.java

/**
 * Factory method that creates all speech rules from the DOM representation
 * of a speechstrategy.xml. This class does not verify if the <code>document</code>
 * is well-formed and it is responsibility of the client to do that.
 *
 * @param context A {@link Context} instance for loading resources.
 * @param document The parsed XML.//from   w w  w  .j a  va2 s  .  c om
 * @return The list of loaded speech rules.
 */
public static ArrayList<EventSpeechRule> createSpeechRules(ScreenSpeakService context, Document document)
        throws IllegalStateException {
    final ArrayList<EventSpeechRule> speechRules = new ArrayList<>();

    if (document == null || context == null) {
        return speechRules;
    }

    final NodeList children = document.getDocumentElement().getChildNodes();

    for (int i = 0, count = children.getLength(); i < count; i++) {
        final Node child = children.item(i);

        if (child.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        try {
            final EventSpeechRule rule = new EventSpeechRule(context, child, i);

            speechRules.add(rule);
        } catch (Exception e) {
            e.printStackTrace();

            LogUtils.log(EventSpeechRule.class, Log.WARN, "Failed loading speech rule: %s",
                    getTextContent(child));
        }
    }

    return speechRules;
}