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:ir.keloud.android.lib.common.SingleSessionManager.java

@Override
public KeloudClient getClientFor(KeloudAccount account, Context context)
        throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException {

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log_OC.d(TAG, "getClientFor starting ");
    }//from   ww w . j a v  a  2s. com
    if (account == null) {
        throw new IllegalArgumentException("Cannot get an KeloudClient for a null account");
    }

    KeloudClient client = null;
    String accountName = account.getName();
    String sessionName = account.getCredentials() == null ? ""
            : AccountUtils.buildAccountName(account.getBaseUri(), account.getCredentials().getAuthToken());

    if (accountName != null) {
        client = mClientsWithKnownUsername.get(accountName);
    }
    boolean reusingKnown = false; // just for logs
    if (client == null) {
        if (accountName != null) {
            client = mClientsWithUnknownUsername.remove(sessionName);
            if (client != null) {
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log_OC.v(TAG, "reusing client for session " + sessionName);
                }
                mClientsWithKnownUsername.put(accountName, client);
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log_OC.v(TAG, "moved client to account " + accountName);
                }
            }
        } else {
            client = mClientsWithUnknownUsername.get(sessionName);
        }
    } else {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log_OC.v(TAG, "reusing client for account " + accountName);
        }
        reusingKnown = true;
    }

    if (client == null) {
        // no client to reuse - create a new one
        client = KeloudClientFactory.createKeloudClient(account.getBaseUri(), context.getApplicationContext(),
                true); // TODO remove dependency on KeloudClientFactory
        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        // enable cookie tracking

        AccountUtils.restoreCookies(accountName, client, context);

        account.loadCredentials(context);
        client.setCredentials(account.getCredentials());
        if (accountName != null) {
            mClientsWithKnownUsername.put(accountName, client);
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log_OC.v(TAG, "new client for account " + accountName);
            }

        } else {
            mClientsWithUnknownUsername.put(sessionName, client);
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log_OC.v(TAG, "new client for session " + sessionName);
            }
        }
    } else {
        if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) {
            Log_OC.v(TAG, "reusing client for session " + sessionName);
        }
        keepCredentialsUpdated(account, client);
        keepUriUpdated(account, client);
    }

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log_OC.d(TAG, "getClientFor finishing ");
    }
    return client;
}

From source file:com.cerema.cloud2.lib.common.SingleSessionManager.java

@Override
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
        throws AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException {

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log_OC.d(TAG, "getClientFor starting ");
    }/*from  w w w.ja  va  2  s .  c om*/
    if (account == null) {
        throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account");
    }

    OwnCloudClient client = null;
    String accountName = account.getName();
    String sessionName = account.getCredentials() == null ? ""
            : AccountUtils.buildAccountName(account.getBaseUri(), account.getCredentials().getAuthToken());

    if (accountName != null) {
        client = mClientsWithKnownUsername.get(accountName);
    }
    boolean reusingKnown = false; // just for logs
    if (client == null) {
        if (accountName != null) {
            client = mClientsWithUnknownUsername.remove(sessionName);
            if (client != null) {
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log_OC.v(TAG, "reusing client for session " + sessionName);
                }
                mClientsWithKnownUsername.put(accountName, client);
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log_OC.v(TAG, "moved client to account " + accountName);
                }
            }
        } else {
            client = mClientsWithUnknownUsername.get(sessionName);
        }
    } else {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log_OC.v(TAG, "reusing client for account " + accountName);
        }
        reusingKnown = true;
    }

    if (client == null) {
        // no client to reuse - create a new one
        client = OwnCloudClientFactory.createOwnCloudClient(account.getBaseUri(),
                context.getApplicationContext(), true); // TODO remove dependency on OwnCloudClientFactory
        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        // enable cookie tracking

        AccountUtils.restoreCookies(accountName, client, context);

        account.loadCredentials(context);
        client.setCredentials(account.getCredentials());
        if (accountName != null) {
            mClientsWithKnownUsername.put(accountName, client);
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log_OC.v(TAG, "new client for account " + accountName);
            }

        } else {
            mClientsWithUnknownUsername.put(sessionName, client);
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log_OC.v(TAG, "new client for session " + sessionName);
            }
        }
    } else {
        if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) {
            Log_OC.v(TAG, "reusing client for session " + sessionName);
        }
        keepCredentialsUpdated(account, client);
        keepUriUpdated(account, client);
    }

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log_OC.d(TAG, "getClientFor finishing ");
    }
    return client;
}

From source file:com.variable.demo.api.fragment.BarCodeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.barcode, null, false);
    final Context thiscontext = container.getContext();
    //Create a Listener for recieving barcodes and update the edit text box.
    final EditText barCodeEditText = (EditText) root.findViewById(R.id.editBarCode);
    listener = new BarCodeScanner.BarCodeScannerListener() {
        @Override//from w  ww .  j ava  2  s .  c  o  m
        public void onBarCodeTransmitted(BarCodeScanner barCodeScanner,
                final SensorReading<String> barCodeReading) {
            // convert the UTF
            final String serialnumOne = barCodeScanner.getSerialNumber();
            final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
            final String scann = barCodeReading.getValue();
            final String scan = scann.replaceAll("[\u0000-\u001f]", "");
            String json = "barcode;" + serialnum + ";" + scan;
            // POST to variable dashboard
            Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
            Ion.with(thiscontext).load(
                    "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                            + json)
                    .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
                    .setCallback(new FutureCallback<Response<String>>() {
                        @Override
                        public void onCompleted(Exception e, Response<String> result) {
                            if (e == null) {
                                Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                            } else {
                                Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                                e.printStackTrace();
                            }
                        }
                    });
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    barCodeEditText.setText(barCodeReading.getValue());

                }
            });

        }
    };
    return root;
}

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

/**
 * Constructor, blocking due to http request, should be called in a thread
 * pool, a request queue, a network thread
 *
 * @param context the applications context
 * @param json json object containing all ad information
 *//*from   w ww.ja  v a 2s  .  com*/
protected MadvertiseAd(final Context context, final JSONObject json,
        final MadvertiseViewCallbackListener listener) {
    this.mContext = context;
    this.mCallbackListener = listener;

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

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

        for (int i = 0; i < mJsonNames.length(); i++) {
            MadvertiseUtil.logMessage(null, Log.DEBUG,
                    "Key => " + mJsonNames.getString(i) + " Value => " + mJsonValues.getString(i));
        }

        markup = MadvertiseUtil.getJSONValue(json, MARKUP);
        if (null != markup && !markup.equals("")) {
            mBannerType = MadvertiseUtil.BANNER_TYPE_RICH_MEDIA;
            mIsMraid = true;
            mHasBanner = true;
            mBannerHeight = Integer.parseInt(MadvertiseUtil.getJSONValue(json, "height"));
            mBannerWidth = Integer.parseInt(MadvertiseUtil.getJSONValue(json, "width"));
            return;
        }

        // first get not nested values
        mClickUrl = MadvertiseUtil.getJSONValue(json, CLICK_URL_CODE);
        mText = MadvertiseUtil.getJSONValue(json, TEXT_CODE);
        mImpressionTrackingArray = MadvertiseUtil.getJSONArray(json, IMPRESSION_TRACKING_ARRAY_CODE);

        // check, if we have a banner
        JSONObject bannerJson = MadvertiseUtil.getJSONObject(json, "banner");
        if (bannerJson == null) {
            return;
        }

        // logic for new ad response
        mBannerUrl = MadvertiseUtil.getJSONValue(bannerJson, BANNER_URL_CODE);
        mHasBanner = true;
        mBannerType = MadvertiseUtil.getJSONValue(bannerJson, "type");

        // check, if rich media banner
        JSONObject richMediaJson = MadvertiseUtil.getJSONObject(bannerJson, "rich_media");
        if (richMediaJson == null) {
            return;
        }

        // check, if mraid type
        if (!MadvertiseUtil.getJSONBoolean(richMediaJson, "mraid")) {
            mHasBanner = false;
            mBannerUrl = "";
            return;
        }

        mIsMraid = true;

        // overwrite banner url
        mBannerUrl = MadvertiseUtil.getJSONValue(richMediaJson, "full_url");

        // get sizes for rich media ad
        try {
            mBannerHeight = Integer.parseInt(MadvertiseUtil.getJSONValue(richMediaJson, "height"));
            mBannerWidth = Integer.parseInt(MadvertiseUtil.getJSONValue(richMediaJson, "width"));
        } catch (NumberFormatException e) {
            mBannerHeight = 53;
            mBannerWidth = 320;
        }

    } catch (JSONException e) {
        MadvertiseUtil.logMessage(null, Log.DEBUG, "Error in json string");
        if (mCallbackListener != null) {
            mCallbackListener.onError(e);
        }
        e.printStackTrace();
    }
}

From source file:org.cocos2dx.plugin.AnalyticsFlurry.java

@Override
public void setDebugMode(boolean isDebugMode) {
    isDebug = isDebugMode;//from   w  ww.  j a  v  a2  s  . c  o  m
    FlurryAgent.setLogEnabled(isDebug);
    if (isDebugMode) {
        FlurryAgent.setLogLevel(Log.DEBUG);
    }
}

From source file:com.example.android.wearable.timer.TimerNotificationService.java

private void deleteTimer() {
    cancelCountdownNotification();/*from   w ww .j a v a2s. c  o m*/

    AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(Constants.ACTION_SHOW_ALARM, null, this, TimerNotificationService.class);
    PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    alarm.cancel(pendingIntent);

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Timer deleted.");
    }
}

From source file:com.joptimizer.optimizers.NewtonLEConstrainedFSP.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();
    }/* w  w w  . ja v  a 2  s . co m*/

    long tStart = System.currentTimeMillis();

    //initial point must be feasible (i.e., satisfy x in domF and Ax = b).
    DoubleMatrix1D X0 = getInitialPoint();
    double rPriX0Norm = (X0 != null) ? Math.sqrt(ALG.norm2(rPri(X0))) : 0d;
    //if (X0 == null   || (getA()!=null && Double.compare(ALG.norm2(getA().zMult(X0, getB().copy(), 1., -1., false)), 0d) != 0)) {
    //if (X0 == null   || rPriX0Norm > Utils.getDoubleMachineEpsilon()) {   
    if (X0 == null || rPriX0Norm > getTolerance()) {
        // infeasible starting point, forward to the chain
        return forwardOptimizationRequest();
    }

    if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) {
        Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0:  " + ArrayUtils.toString(X0.toArray()));
    }
    DoubleMatrix1D X = X0;
    double F0X;
    //double previousF0X = Double.NaN;
    double previousLambda = 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, "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;
        }

        DoubleMatrix1D gradX = getGradF0(X);
        DoubleMatrix2D hessX = getHessF0(X);

        double gradXNorm = Math.sqrt(ALG.norm2(gradX));
        if (gradXNorm < Utils.getDoubleMachineEpsilon()) {
            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(gradX.toArray());
        if (getA() != null) {
            kktSolver.setAMatrix(getA().toArray());
            kktSolver.setATMatrix(getAT().toArray());
        }
        double[][] sol = kktSolver.solve();
        DoubleMatrix1D step = F1.make(sol[0]);
        DoubleMatrix1D w = (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(step.toArray()));
            Log.d(MainActivity.JOPTIMIZER_LOGTAG, "w    : " + ArrayUtils.toString(w.toArray()));
        }

        // exit condition: check the Newton decrement
        double lambda = Math.sqrt(ALG.mult(step, ALG.mult(hessX, 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()) {
            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 < 250) {
            cnt++;
            // @TODO: can we use simplification 9.7.1 ??
            X1 = X.copy().assign(step.copy().assign(Mult.mult(s)), Functions.plus);// x + t*step
            //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"X1: "+ArrayUtils.toString(X1.toArray()));

            if (isInDomainF0(X1)) {
                double condSX = getF0(X1);
                //NB: this will also check !Double.isNaN(getF0(X1))
                double condDX = F0X + getAlpha() * s * ALG.mult(gradX, step);
                //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"condSX: "+condSX);
                //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"condDX: "+condDX);
                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:com.sleekcoder.weardemo.DismissListener.java

private void dismissWearableNotification(final int id) {
    mGoogleApiClient.connect();/*from   ww w. j  ava2  s . c om*/
    final Uri dataItemUri = new Uri.Builder().scheme(WEAR_URI_SCHEME).path(Constants.BOTH_PATH).build();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Deleting Uri: " + dataItemUri.toString());
    }
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri).setResultCallback(this);
}

From source file:com.wearclan.mechanicalwatchface.DataLayerListenerService.java

public static void LOGD(final String tag, String message) {
    if (Log.isLoggable(tag, Log.DEBUG)) {
        Log.d(tag, message);//from ww w  .ja  v a  2  s . c  om
    }
}

From source file:com.example.android.elizachat.ResponderService.java

private void showNotification() {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Sent: " + mLastResponse);
    }//w w w.  java2 s .  c  o m
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setContentTitle(getString(R.string.eliza)).setContentText(mLastResponse)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza))
            .setSmallIcon(R.drawable.bg_eliza).setPriority(NotificationCompat.PRIORITY_MIN);

    Intent intent = new Intent(ACTION_RESPONSE);
    PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT);
    Notification notification = builder.extend(new NotificationCompat.WearableExtender()
            .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_reply,
                    getString(R.string.reply), pendingIntent).addRemoteInput(
                            new RemoteInput.Builder(EXTRA_REPLY).setLabel(getString(R.string.reply)).build())
                            .build()))
            .build();
    NotificationManagerCompat.from(this).notify(0, notification);
}