Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

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

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

From source file:com.example.jumpnote.android.jsonrpc.JsonRpcJavaClient.java

public void callBatch(final List<JsonRpcClient.Call> calls, final JsonRpcClient.BatchCallback callback) {
    HttpPost httpPost = new HttpPost(mRpcUrl);
    JSONObject requestJson = new JSONObject();
    JSONArray callsJson = new JSONArray();
    try {/*from  w  w  w  .ja v a  2 s .  co m*/
        for (int i = 0; i < calls.size(); i++) {
            JsonRpcClient.Call call = calls.get(i);

            JSONObject callJson = new JSONObject();

            callJson.put("method", call.getMethodName());

            if (call.getParams() != null) {
                JSONObject callParams = (JSONObject) call.getParams();
                @SuppressWarnings("unchecked")
                Iterator<String> keysIterator = callParams.keys();
                String key;
                while (keysIterator.hasNext()) {
                    key = keysIterator.next();
                    callJson.put(key, callParams.get(key));
                }
            }

            callsJson.put(i, callJson);
        }

        requestJson.put("calls", callsJson);
        httpPost.setEntity(new StringEntity(requestJson.toString(), "UTF-8"));
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "POST request: " + requestJson.toString());
        }
    } catch (JSONException e) {
        // throw e;
    } catch (UnsupportedEncodingException e) {
        // throw e;
    }

    try {
        HttpResponse httpResponse = mHttpClient.execute(httpPost);
        final int responseStatusCode = httpResponse.getStatusLine().getStatusCode();
        if (200 <= responseStatusCode && responseStatusCode < 300) {
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"), 8 * 1024);

            StringBuilder sb = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "POST response: " + sb.toString());
            }
            JSONTokener tokener = new JSONTokener(sb.toString());
            JSONObject responseJson = new JSONObject(tokener);
            JSONArray resultsJson = responseJson.getJSONArray("results");
            Object[] resultData = new Object[calls.size()];

            for (int i = 0; i < calls.size(); i++) {
                JSONObject result = resultsJson.getJSONObject(i);
                if (result.has("error")) {
                    callback.onError(i, new JsonRpcException((int) result.getInt("error"),
                            calls.get(i).getMethodName(), result.getString("message"), null));
                    resultData[i] = null;
                } else {
                    resultData[i] = result.get("data");
                }
            }

            callback.onData(resultData);
        } else {
            callback.onError(-1, new JsonRpcException(-1, "Received HTTP status code other than HTTP 2xx: "
                    + httpResponse.getStatusLine().getReasonPhrase()));
        }
    } catch (IOException e) {
        Log.e("JsonRpcJavaClient", e.getMessage());
        e.printStackTrace();
    } catch (JSONException e) {
        Log.e("JsonRpcJavaClient", "Error parsing server JSON response: " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.google.android.apps.forscience.whistlepunk.PictureUtils.java

private static String capturePictureLabel(Context context, IStartable startable) {
    // Starts a picture intent.
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(context.getPackageManager()) != null) {
        File photoFile = null;/*w  ww . java 2 s.  co  m*/
        try {
            photoFile = PictureUtils.createImageFile(
                    AppSingleton.getInstance(context).getSensorEnvironment().getDefaultClock().getNow());
        } catch (IOException ex) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, ex.getMessage());
            }
        }
        if (photoFile != null) {
            Uri photoUri = FileProvider.getUriForFile(context, context.getPackageName(), photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                // Needed to avoid security exception on KitKat.
                takePictureIntent.setClipData(ClipData.newRawUri(null, photoUri));
            }
            takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            String pictureLabelPath = "file:" + photoFile.getAbsoluteFile();
            startable.startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            return pictureLabelPath;
        }
    }
    return null;
}

From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java

/**
 * @see SearchRecentSuggestionsProvider#onCreate()
 *///from  w  w w.jav a  2  s .  c o  m
public boolean onCreate() {
    final String METHOD_NAME = CLASS_NAME + ".onCreate()";
    boolean loggingEnabled = Log.isLoggable(LOG_TAG, Log.DEBUG);
    if (loggingEnabled) {
        Log.d(METHOD_NAME, "ENTRY");
    }

    setupSuggestions(AUTHORITY, MODE);

    if (loggingEnabled) {
        Log.d(METHOD_NAME, "EXIT");
    }

    return super.onCreate();
}

From source file:com.joptimizer.optimizers.NewtonLEConstrainedISP.java

@Override
public int optimize() throws Exception {
    Log.d(MainActivity.JOPTIMIZER_LOGTAG, "optimize");
    OptimizationResponse response = new OptimizationResponse();

    //checking responsibility
    if (getFi() != null) {
        // forward to the chain
        return forwardOptimizationRequest();
    }//from  w ww  .  ja  v a2 s  .  c o  m

    long tStart = System.currentTimeMillis();
    DoubleMatrix1D X0 = getInitialPoint();
    if (X0 == null) {
        if (getA() != null) {
            X0 = F1.make(findEqFeasiblePoint(getA().toArray(), getB().toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG,
                    "Switch to the linear equality feasible starting point Newton algorithm ");
            NewtonLEConstrainedFSP opt = new NewtonLEConstrainedFSP();
            OptimizationRequest req = getOptimizationRequest();
            req.setInitialPoint(X0.toArray());
            opt.setOptimizationRequest(req);
            int retcode = opt.optimize();
            OptimizationResponse resp = opt.getOptimizationResponse();
            setOptimizationResponse(resp);
            return retcode;
        } else {
            X0 = F1.make(getDim());
        }
    }
    DoubleMatrix1D V0 = (getA() != null) ? F1.make(getA().rows()) : F1.make(0);
    if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) {
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0:  " + ArrayUtils.toString(X0.toArray()));
    }

    DoubleMatrix1D X = X0;
    DoubleMatrix1D V = V0;
    double F0X;
    DoubleMatrix1D gradX = null;
    DoubleMatrix2D hessX = null;
    DoubleMatrix1D rDualXV = null;
    DoubleMatrix1D rPriX = null;
    double previousF0X = Double.NaN;
    double previousRPriXNorm = Double.NaN;
    double previousRXVNorm = Double.NaN;
    int iteration = 0;
    while (true) {
        iteration++;
        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, "V=" + ArrayUtils.toString(V.toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f(X)=" + F0X);
        }

        //         if(!Double.isNaN(previousF0X)){
        //            if (previousF0X < F0X) {
        //               throw new Exception("critical minimization problem");
        //            }
        //         }
        //         previousF0X = F0X;

        // custom exit condition
        if (checkCustomExitConditions(X)) {
            response.setReturnCode(OptimizationResponse.SUCCESS);
            break;
        }

        gradX = getGradF0(X);
        hessX = getHessF0(X);
        rDualXV = rDual(X, V, gradX);
        rPriX = rPri(X);

        // exit condition
        double rPriXNorm = Math.sqrt(ALG.norm2(rPriX));
        double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV));
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriXNorm : " + rPriXNorm);
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rDualXVNorm: " + rDualXVNorm);
        double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rDualXVNorm, 2));
        if (rPriXNorm <= getTolerance() && rXVNorm <= getTolerance()) {
            response.setReturnCode(OptimizationResponse.SUCCESS);
            break;
        }

        // Newton step and decrement
        if (this.kktSolver == null) {
            this.kktSolver = new BasicKKTSolver();
        }
        if (isCheckKKTSolutionAccuracy()) {
            kktSolver.setCheckKKTSolutionAccuracy(isCheckKKTSolutionAccuracy());
            kktSolver.setToleranceKKT(getToleranceKKT());
        }
        kktSolver.setHMatrix(hessX.toArray());
        kktSolver.setGVector(rDualXV.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()));
        }

        //         // exit condition
        //         double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); 
        //         double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV));
        //         Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPriXNorm : "+rPriXNorm);
        //         Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDualXVNorm: "+rDualXVNorm);
        //         double rXVNorm = Math.sqrt(Math.pow(rPriXNorm, 2)+ Math.pow(rDualXVNorm, 2));
        //         if (rPriXNorm <= getTolerance() && rXVNorm <= 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()) {
            if (!Double.isNaN(previousRPriXNorm) && !Double.isNaN(previousRXVNorm)) {
                if ((previousRPriXNorm <= rPriXNorm && rPriXNorm >= getTolerance())
                        || (previousRXVNorm <= rXVNorm && rXVNorm >= getTolerance())) {
                    Log.w(MainActivity.JOPTIMIZER_LOGTAG,
                            "No progress achieved, exit iterations loop without desired accuracy");
                    response.setReturnCode(OptimizationResponse.WARN);
                    break;

                }
            }
        }
        previousRPriXNorm = rPriXNorm;
        previousRXVNorm = rXVNorm;

        // backtracking line search
        double s = 1d;
        DoubleMatrix1D X1 = null;
        DoubleMatrix1D V1 = null;
        DoubleMatrix1D gradX1 = null;
        DoubleMatrix1D rDualX1V1 = null;
        DoubleMatrix1D rPriX1V1 = null;
        double previousNormRX1V1 = Double.NaN;
        while (true) {
            // @TODO: can we use 9.7.1?
            X1 = X.copy().assign(stepX.copy().assign(Mult.mult(s)), Functions.plus);// X + s*stepX
            V1 = V.copy().assign(stepV.copy().assign(Mult.mult(s)), Functions.plus);// V + s*stepV
            if (isInDomainF0(X1)) {
                gradX1 = getGradF0(X1);
                rDualX1V1 = rDual(X1, V1, gradX1);
                rPriX1V1 = rPri(X1);
                double normRX1V1 = Math.sqrt(ALG.norm2(rDualX1V1) + ALG.norm2(rPriX1V1));
                if (normRX1V1 <= (1 - getAlpha() * s) * rXVNorm) {
                    break;
                }

                Log.d(MainActivity.JOPTIMIZER_LOGTAG, "normRX1V1: " + normRX1V1);
                if (!Double.isNaN(previousNormRX1V1)) {
                    if (previousNormRX1V1 <= normRX1V1) {
                        Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved in backtracking with norm");
                        break;
                    }
                }
                previousNormRX1V1 = normRX1V1;
            }

            s = getBeta() * s;
        }
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s);

        // update
        X = X1;
        V = V1;
    }

    long tStop = System.currentTimeMillis();
    Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart));
    response.setSolution(X.toArray());
    setOptimizationResponse(response);
    return response.getReturnCode();
}

From source file:cm.confide.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 Context.//from w  ww .  ja  va2 s.c  o  m
 * @param inAddresses Array of addresses on which to perform the lookup.
 * @param callback RecipientMatchCallback called when a match or matches are found.
 * @return HashMap<String,RecipientEntry>
 */
public static void getMatchingRecipients(Context context, BaseRecipientAdapter adapter,
        ArrayList<String> inAddresses, int addressType, Account account, RecipientMatchCallback callback) {
    Queries.Query query;
    if (addressType == QUERY_TYPE_EMAIL) {
        query = Queries.EMAIL;
    } else {
        query = Queries.PHONE;
    }
    int addressesSize = Math.min(MAX_LOOKUPS, inAddresses.size());
    HashSet<String> addresses = new HashSet<String>();
    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.add(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());
    }

    String[] addressArray = new String[addresses.size()];
    addresses.toArray(addressArray);
    HashMap<String, RecipientEntry> recipientEntries = null;
    Cursor c = null;

    try {
        c = context.getContentResolver().query(query.getContentUri(), query.getProjection(),
                query.getProjection()[Queries.Query.DESTINATION] + " IN (" + bindString.toString() + ")",
                addressArray, null);
        recipientEntries = processContactEntries(c);
        callback.matchesFound(recipientEntries);
    } finally {
        if (c != null) {
            c.close();
        }
    }
    // See if any entries did not resolve; if so, we need to check other
    // directories
    final Set<String> matchesNotFound = new HashSet<String>();
    if (recipientEntries.size() < addresses.size()) {
        final List<DirectorySearchParams> paramsList;
        Cursor directoryCursor = null;
        try {
            directoryCursor = context.getContentResolver().query(DirectoryListQuery.URI,
                    DirectoryListQuery.PROJECTION, null, null, null);
            if (directoryCursor == null) {
                paramsList = null;
            } else {
                paramsList = BaseRecipientAdapter.setupOtherDirectories(context, directoryCursor, account);
            }
        } finally {
            if (directoryCursor != null) {
                directoryCursor.close();
            }
        }
        // Run a directory query for each unmatched recipient.
        HashSet<String> unresolvedAddresses = new HashSet<String>();
        for (String address : addresses) {
            if (!recipientEntries.containsKey(address)) {
                unresolvedAddresses.add(address);
            }
        }

        matchesNotFound.addAll(unresolvedAddresses);

        if (paramsList != null) {
            Cursor directoryContactsCursor = null;
            for (String unresolvedAddress : unresolvedAddresses) {
                for (int i = 0; i < paramsList.size(); i++) {
                    try {
                        directoryContactsCursor = doQuery(unresolvedAddress, 1, paramsList.get(i).directoryId,
                                account, context.getContentResolver(), query);
                    } finally {
                        if (directoryContactsCursor != null && directoryContactsCursor.getCount() == 0) {
                            directoryContactsCursor.close();
                            directoryContactsCursor = null;
                        } else {
                            break;
                        }
                    }
                }
                if (directoryContactsCursor != null) {
                    try {
                        final Map<String, RecipientEntry> entries = processContactEntries(
                                directoryContactsCursor);

                        for (final String address : entries.keySet()) {
                            matchesNotFound.remove(address);
                        }

                        callback.matchesFound(entries);
                    } finally {
                        directoryContactsCursor.close();
                    }
                }
            }
        }
    }

    // If no matches found in contact provider or the directories, try the extension
    // matcher.
    // todo (aalbert): This whole method needs to be in the adapter?
    if (adapter != null) {
        final Map<String, RecipientEntry> entries = adapter.getMatchingRecipients(matchesNotFound);
        if (entries != null && entries.size() > 0) {
            callback.matchesFound(entries);
            for (final String address : entries.keySet()) {
                matchesNotFound.remove(address);
            }
        }
    }
    callback.matchesNotFound(matchesNotFound);
}

From source file:it.geosolutions.android.map.loaders.FeatureCircleLoader.java

/**
 * Process a single <FeatureCircleQuery>
 * @param query/* w  ww .  java  2s .  c  om*/
 * @param data the result will be added to this array
 */
private boolean processQuery(FeatureCircleTaskQuery query, List<FeatureCircleQueryResult> data) {
    SpatialDataSourceHandler handler = query.getHandler();
    SpatialVectorTable table = query.getTable();
    String tableName = query.getTable().getName();
    // check visibility before adding the table
    // AdvancedStyle s = sm.getStyle(tableName);
    // if ( !StyleUtils.isVisible(s, zoomLevel) ) {
    // onProgressUpdate(0);
    // continue;
    // }

    double x = query.getX();
    double y = query.getY();
    double radius = query.getRadius();

    Integer start = query.getStart();
    Integer limit = query.getLimit();
    if (Log.isLoggable("FEATURE_Circle_TASK", Log.DEBUG)) { // Log check to avoid
                                                            // string creation
        Log.d("FEATURE_Circle_TASK", "starting query for table " + tableName);
    }
    // this is empty to skip geometries that returns errors
    ArrayList<Feature> features = new ArrayList<Feature>();
    try {
        features = handler.intersectionToCircle("4326", table, x, y, radius, start, limit);
    } catch (Exception e) {
        Log.e("FEATURE_Circle_TASK",
                "unable to retrive data for table'" + tableName + "\'.Error:" + e.getLocalizedMessage());
        // TODO now simply skip, do better work
    }
    // add features
    FeatureCircleQueryResult result = new FeatureCircleQueryResult();
    result.setLayerName(tableName);
    result.setFeatures(features);
    Log.v("FEATURE_Circle_TASK", features.size() + " items found for table " + tableName);
    features_loaded += features.size();
    // publishProgress(result);
    data.add(result);

    return true;

}

From source file:it.geosolutions.android.map.loaders.FeatureInfoLoader.java

/**
 * Process a single <FeatureInfoQuery>
 * @param query//from  w  w w  . j av a  2s.  com
 * @param data the result will be added to this array
 */
private boolean processQuery(FeatureInfoTaskQuery query, List<FeatureInfoQueryResult> data) {
    SpatialDataSourceHandler handler = query.getHandler();
    SpatialVectorTable table = query.getTable();
    String tableName = query.getTable().getName();
    // check visibility before adding the table
    // AdvancedStyle s = sm.getStyle(tableName);
    // if ( !StyleUtils.isVisible(s, zoomLevel) ) {
    // onProgressUpdate(0);
    // continue;
    // }
    double north = query.getN();
    double south = query.getS();
    double east = query.getE();
    double west = query.getW();
    Integer start = query.getStart();
    Integer limit = query.getLimit();
    if (Log.isLoggable("FEATURE_INFO_TASK", Log.DEBUG)) { // Log check to avoid
                                                          // string creation
        Log.d("FEATURE_INFO_TASK", "starting query for table " + tableName);
    }
    // this is empty to skip geometries that returns errors
    ArrayList<Feature> features = new ArrayList<Feature>();
    try {
        features = handler.intersectionToFeatureListBBOX("4326", table, north, south, east, west, start, limit);
    } catch (Exception e) {
        Log.e("FEATURE_INFO_TASK",
                "unable to retrive data for table'" + tableName + "\'.Error:" + e.getLocalizedMessage());
        // TODO now simply skip, do better work
    }
    // add features
    FeatureInfoQueryResult result = new FeatureInfoQueryResult();
    result.setLayerName(tableName);
    result.setFeatures(features);
    Log.v("FEATURE_INFO_TASK", features.size() + " items found for table " + tableName);
    features_loaded += features.size();
    // publishProgress(result);
    data.add(result);

    return true;

}

From source file:au.com.cybersearch2.classyfy.provider.ClassyFyProvider.java

/**
 * onCreate() called before Application onCreate(), so can do nothing as DI not initialized.
 * @see android.content.ContentProvider#onCreate()
 *///from  w  w w.  j a  va 2 s  .  c  o  m
@Override
public boolean onCreate() {
    final ClassyFyApplication application = ClassyFyApplication.getInstance();
    AsyncBackgroundTask starter = new AsyncBackgroundTask(application) {
        @Override
        public Boolean loadInBackground() {
            Log.i(TAG, "Loading in background...");
            // Get perisistence context to trigger database initialization
            // Build Dagger2 configuration
            if (Log.isLoggable(TAG, Log.INFO))
                Log.i(TAG, "ClassyFy application Dagger build");
            DaoManager.clearCache();
            try {
                classyFyComponent = DaggerClassyFyComponent.builder()
                        .classyFyApplicationModule(new ClassyFyApplicationModule(application)).build();
                startApplicationSetup(classyFyComponent.persistenceContext());
            } catch (PersistenceException e) {
                Log.e(TAG, "Database error on initialization", e);
                return Boolean.FALSE;
            }
            classyFySearchEngine = classyFyComponent.classyFySearchEngine();
            FtsEngine ftsEngine = classyFyComponent.ftsEngine();
            classyFySearchEngine.setFtsQuery(ftsEngine);
            application.setComponent(classyFyComponent);
            return Boolean.TRUE;
        }

        @Override
        public void onLoadComplete(Loader<Boolean> loader, Boolean success) {
            Log.i(TAG, "Loading completed " + success);
        }
    };
    starter.startLoading();
    return true;
}

From source file:it.geosolutions.android.map.loaders.FeaturePolygonLoader.java

/**
 * Process a single <FeaturePolygonQuery>
 * @param query/*  w w w.j  a  v a  2s. c  om*/
 * @param data the result will be added to this array
 */
private boolean processQuery(FeaturePolygonTaskQuery query, List<FeaturePolygonQueryResult> data) {
    SpatialDataSourceHandler handler = query.getHandler();
    SpatialVectorTable table = query.getTable();
    String tableName = query.getTable().getName();
    // check visibility before adding the table
    // AdvancedStyle s = sm.getStyle(tableName);
    // if ( !StyleUtils.isVisible(s, zoomLevel) ) {
    // onProgressUpdate(0);
    // continue;
    // }

    ArrayList<Coordinates_Query> polygon_points = query.getPolygonPoints();

    Integer start = query.getStart();
    Integer limit = query.getLimit();
    if (Log.isLoggable("FEATURE_Polygon_TASK", Log.DEBUG)) { // Log check to avoid
                                                             // string creation
        Log.d("FEATURE_Polygon_TASK", "starting query for table " + tableName);
    }
    // this is empty to skip geometries that returns errors
    ArrayList<Feature> features = new ArrayList<Feature>();
    /*try {
        features = handler.intersectionToPolygon("4326", table, polygon_points, start, limit);
    } catch (Exception e) {
        Log.e("FEATURE_Polygon_TASK", "unable to retrive data for table'"
        + tableName + "\'.Error:" + e.getLocalizedMessage());
        // TODO now simply skip, do better work
    }*/
    // add features
    FeaturePolygonQueryResult result = new FeaturePolygonQueryResult();
    result.setLayerName(tableName);
    result.setFeatures(features);
    Log.v("FEATURE_Polygon_TASK", features.size() + " items found for table " + tableName);
    features_loaded += features.size();
    // publishProgress(result);
    data.add(result);

    return true;

}

From source file:com.samsung.richnotification.RichNotification.java

/**
  * This method will initialize RichNotification on the device.
  *//ww  w .  ja v  a  2  s. c  om
  */
private boolean initRichNotification(CallbackContext callbackContext) {
    if (Log.isLoggable(RICHNOTI, Log.DEBUG))
        Log.d(TAG, "Initializing RichNotification...");

    // This function takes care of error callbacks
    if (!isRichNotificationSupported(callbackContext)) {
        return false;
    } else if (mRichNotificationManager == null) {
        mRichNotificationManager = new SrnRichNotificationManager(mContext);
        mRichNotificationManager.start();
        mRichNotificationManager.registerRichNotificationListener(this);
    }

    boolean isConnected = mRichNotificationManager.isConnected();
    if (!isConnected) {
        Log.e(TAG, "Cannot send RichNotification. Device not connected.");
        callbackContext.error(RichNotificationHelper.DEVICE_NOT_CONNECTED);
        return false;
    } else {
        if (Log.isLoggable(RICHNOTI, Log.DEBUG))
            Log.d(TAG, "Initialization complete. Device is connected.");
    }

    return true;
}