Example usage for android.util Log DEBUG

List of usage examples for android.util Log DEBUG

Introduction

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

Prototype

int DEBUG

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

Click Source Link

Document

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

Usage

From source file:carbon.internal.PercentLayoutHelper.java

/**
 * Iterates over children and changes their width and height to one calculated from percentage
 * values.//from   w  ww .j a  v a 2 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:org.thoughtland.xlocation.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;/*from   www.j a  v  a  2 s  . co  m*/
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XLocation", msg);
        else
            Log.println(priority, String.format("XLocation/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

From source file:com.ibm.commerce.worklight.android.maps.StoreMapActivity.java

/**
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 *///from   w  w  w.jav  a  2s  .  co m
@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);
    }//from   w ww  .j  av  a 2 s. c o m

    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:biz.bokhorst.xprivacy.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;/*from  ww  w . j  av a 2  s .c  o m*/
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XPrivacy", msg);
        else
            Log.println(priority, String.format("XPrivacy/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

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   w ww  . j av  a2 s  . com
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Timer restarted.");
    }
}

From source file:de.madvertise.android.sdk.Ad.java

/**
 * Constructor, blocking due to http request, should be called in a thread pool, a request queue, 
 * a network thread//from  www  .  j  a  v  a  2  s  . co m
 * 
 * @param context 
 *      the applications context
 * @param json 
 *      json object containing all ad information
 */
protected Ad(Context context, JSONObject json) {
    this.context = context;

    MadUtil.logMessage(null, Log.DEBUG, "Creating ad");

    // init json arrays and print all keys / values
    jsonNames = json.names();
    try {
        jsonValues = json.toJSONArray(jsonNames);

        if (MadUtil.PRINT_LOG) {
            for (int i = 0; i < jsonNames.length(); i++) {
                MadUtil.logMessage(null, Log.DEBUG,
                        "Key => " + jsonNames.getString(i) + " Value => " + jsonValues.getString(i));
            }
        }

        clickURL = json.isNull(CLICK_URL_CODE) ? "" : json.getString(CLICK_URL_CODE);
        bannerURL = json.isNull(BANNER_URL_CODE) ? "" : json.getString(BANNER_URL_CODE);
        text = json.isNull(TEXT_CODE) ? "" : json.getString(TEXT_CODE);
        hasBannerLink = Boolean
                .parseBoolean(json.isNull(HAS_BANNER_CODE) ? "true" : json.getString(HAS_BANNER_CODE));

    } catch (JSONException e) {
        MadUtil.logMessage(null, Log.DEBUG, "Error in json string");
        e.printStackTrace();
    }

    if (hasBannerLink) {
        imageByteArray = downloadImage(bannerURL);
    } else {
        MadUtil.logMessage(null, Log.DEBUG, "No banner link in json found");
    }

    if (imageByteArray != null) {
        hasBanner = true;
    } else {
        hasBanner = false;
    }
}

From source file:de.madvertise.android.sdk.MadvertiseImageView.java

public MadvertiseImageView(final Context context, final int newWidth, final int newHeight,
        final MadvertiseAd ad, final Handler loadingCompletedHandler,
        final AnimationEndListener animationListener) {
    super(context);

    mAnimationListener = animationListener;

    mImageAd = ad;//  ww  w.  j av  a  2 s .  c  o m

    // Remove the ScrollBar so that we have no padding.
    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(false);
    setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

    // No visible background
    setBackgroundColor(Color.TRANSPARENT);

    WebViewClient webViewClient = new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            if (loadingCompletedHandler != null) {
                loadingCompletedHandler.sendEmptyMessage(MadvertiseView.MAKE_VISIBLE);
            }
        }
    };
    setWebViewClient(webViewClient);

    StringBuilder content = new StringBuilder();
    content.append("<html><head><style>* {margin:0;padding:0;}</style></head><body>")
            .append("<img src=\"" + mImageAd.getBannerUrl() + "\" height=\"" + newHeight + "\" width=\""
                    + newWidth + "\"/>" + getImpressionTrackingTag())
            .append("</body></html>");
    MadvertiseUtil.logMessage(null, Log.DEBUG, "Loading ad : " + content.toString());
    loadDataWithBaseURL(null, content.toString(), "text/html", "UTF-8", null);
}

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();
    }//w w  w  . ja v a 2  s  .  c o m
    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:nl.frankkie.bronylivewallpaper.CLog.java

public static void d(String tag, String msg) {
    if (shouldLog && errorLevel <= Log.DEBUG) {
        Log.d(tag, msg);
    }
}