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:KSView.PercentLayoutHelper.java

/**
 * Iterates over children and checks if any of them would like to get more space than it
 * received through the percentage dimension.
 * <p/>//from w w  w. ja v  a  2  s.c om
 * If you are building a layout that supports percentage dimensions you are encouraged to take
 * advantage of this method. The developer should be able to specify that a child should be
 * remeasured by adding normal dimension attribute with {@code wrap_content} value. For example
 * he might specify child's attributes as {@code app:layout_widthPercent="60%p"} and
 * {@code android:layout_width="wrap_content"}. In this case if the child receives too little
 * space, it will be remeasured with width set to {@code WRAP_CONTENT}.
 *
 * @return True if the measure phase needs to be rerun because one of the children would like
 * to receive more space.
 */
public boolean handleMeasuredStateTooSmall() {
    boolean needsSecondMeasure = false;
    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)) {
            LogUtil.d(TAG, "should handle measured state too small " + view + " " + params);
        }
        if (params instanceof PercentLayoutParams) {
            PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo();
            if (info != null) {
                if (shouldHandleMeasuredWidthTooSmall(view, info)) {
                    needsSecondMeasure = true;
                    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
                }
                if (shouldHandleMeasuredHeightTooSmall(view, info)) {
                    needsSecondMeasure = true;
                    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
                }
            }
        }
    }
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        LogUtil.d(TAG, "should trigger second measure pass: " + needsSecondMeasure);
    }
    return needsSecondMeasure;
}

From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java

/**
 * Peek the given {@link WearableDrawerView}, which may either be the top drawer or bottom
 * drawer. This should only be used after the drawer has been added as a child of the {@link
 * WearableDrawerLayout}.//from  w  ww .j  a  v  a2  s.  c o  m
 */
void peekDrawer(WearableDrawerView drawer) {
    if (drawer == null) {
        throw new IllegalArgumentException("peekDrawer(WearableDrawerView) received a null drawer.");
    } else if (drawer != mTopDrawerView && drawer != mBottomDrawerView) {
        throw new IllegalArgumentException(
                "peekDrawer(WearableDrawerView) received a drawer that isn't a child.");
    }

    if (!isLaidOut()) {
        // If this view is not laid out yet, postpone the peek until onLayout is called.
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "WearableDrawerLayout not laid out yet. Postponing peek.");
        }
        if (drawer == mTopDrawerView) {
            mShouldPeekTopDrawerAfterLayout = true;
        } else if (drawer == mBottomDrawerView) {
            mShouldPeekBottomDrawerAfterLayout = true;
        }
        return;
    }

    maybePeekDrawer(drawer);
}

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

private void loadImage() {
    try {/*from w  w  w  . j  a va 2 s .c  om*/
        imageLayoutView.findViewById(R.id.image_progress).setVisibility(View.VISIBLE);
        String link = "";
        if (imageData.getJSONObject().has(ImgurHoloActivity.IMAGE_DATA_COVER)) //temporary to fix large gif bug
            link = "http://imgur.com/" + imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_COVER)
                    + ".png";
        else
            link = imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_LINK);
        Ion.with(getActivity(), link).setLogging("MyLogs", Log.DEBUG)
                .progressBar((ProgressBar) imageLayoutView.findViewById(R.id.image_progress)).withBitmap()
                .deepZoom().intoImageView(imageView).setCallback(new FutureCallback<ImageView>() {
                    @Override
                    public void onCompleted(Exception e, ImageView result) {
                        imageLayoutView.findViewById(R.id.image_progress).setVisibility(View.GONE);
                    }
                });
    } catch (JSONException e) {
        Log.e("Error!", e.toString());
    }
}

From source file:com.example.android.wearable.quiz.MainActivity.java

/**
 * Resets the current quiz when Reset Quiz is pressed.
 *//*from  w  ww. j  a v a  2 s. c o m*/
public void resetQuiz(View view) {
    // Reset quiz status in phone layout.
    for (int i = 0; i < questionsContainer.getChildCount(); i++) {
        LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(i);
        TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question);
        TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status);
        questionText.setTextColor(Color.WHITE);
        questionStatus.setText(R.string.question_unanswered);
    }
    // Reset data items and notifications on wearable.
    if (mGoogleApiClient.isConnected()) {
        Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() {
            @Override
            public void onResult(DataItemBuffer result) {
                try {
                    if (result.getStatus().isSuccess()) {
                        resetDataItems(result);
                    } else {
                        if (Log.isLoggable(TAG, Log.DEBUG)) {
                            Log.d(TAG, "Reset quiz: failed to get Data Items to reset");
                        }
                    }
                } finally {
                    result.release();
                }
            }
        });
    } else {
        Log.e(TAG, "Failed to reset data items because client is disconnected from " + "Google Play Services");
    }
    setHasQuestionBeenAsked(false);
    mNumCorrect = 0;
    mNumIncorrect = 0;
    mNumSkipped = 0;
}

From source file:com.xorcode.andtweet.TweetListActivity.java

/**
 * Listener that checks for clicks on the main list view.
 * //  w  ww .java 2  s  .  c om
 * @param adapterView
 * @param view
 * @param position
 * @param id
 */
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    if (MyLog.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "onItemClick, id=" + id);
    }
    if (id <= 0) {
        return;
    }
    Uri uri = ContentUris.withAppendedId(Tweets.CONTENT_URI, id);
    String action = getIntent().getAction();
    if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {
        if (MyLog.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "onItemClick, setData=" + uri);
        }
        setResult(RESULT_OK, new Intent().setData(uri));
    } else {
        if (MyLog.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "onItemClick, startActivity=" + uri);
        }
        startActivity(new Intent(Intent.ACTION_VIEW, uri));
    }
}

From source file:com.cbsb.ftpserv.ProxyConnector.java

private JSONObject sendCmdSocketRequest(JSONObject json) {
    try {//from  w w w  .  j  ava2s . c  om
        boolean queued;
        synchronized (this) {
            if (responseWaiter == null) {
                responseWaiter = Thread.currentThread();
                queued = false;
                myLog.d("sendCmdSocketRequest proceeding without queue");
            } else if (!responseWaiter.isAlive()) {
                // This code should never run. It is meant to recover from a situation
                // where there is a thread that sent a proxy request but died before
                // starting the subsequent request. If this is the case, the correct
                // behavior is to run the next queued thread in the queue, or if the
                // queue is empty, to perform our own request. 
                myLog.l(Log.INFO, "Won't wait on dead responseWaiter");
                if (queuedRequestThreads.size() == 0) {
                    responseWaiter = Thread.currentThread();
                    queued = false;
                } else {
                    queuedRequestThreads.add(Thread.currentThread());
                    queuedRequestThreads.remove().interrupt(); // start queued thread
                    queued = true;
                }
            } else {
                myLog.d("sendCmdSocketRequest queueing thread");
                queuedRequestThreads.add(Thread.currentThread());
                queued = true;
            }
        }
        // If a different thread has sent a request and is waiting for a response,
        // then the current thread will be in a queue waiting for an interrupt
        if (queued) {
            // The current thread must wait until we are popped off the waiting queue
            // and receive an interrupt()
            boolean interrupted = false;
            try {
                myLog.d("Queued cmd session request thread sleeping...");
                Thread.sleep(QUEUE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.l(Log.DEBUG, "Proxy request popped and ready");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Timed out waiting on proxy queue");
                return null;
            }
        }
        // We have been popped from the wait queue if necessary, and now it's time
        // to send the request.
        try {
            responseWaiter = Thread.currentThread();
            byte[] outboundData = Util.jsonToByteArray(json);
            try {
                out.write(outboundData);
            } catch (IOException e) {
                myLog.l(Log.INFO, "IOException sending proxy request");
                return null;
            }
            // Wait RESPONSE_WAIT_MS for a response from the proxy
            boolean interrupted = false;
            try {
                // Wait for the main ProxyConnector thread to interrupt us, meaning
                // that a response has been received.
                myLog.d("Cmd session request sleeping until response");
                Thread.sleep(RESPONSE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.d("Cmd session response received");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Proxy request timed out");
                return null;
            }
            // At this point, the main ProxyConnector thread will have stored
            // our response in "JSONObject response".
            myLog.d("Cmd session response was: " + response);
            return response;
        } finally {
            // Make sure that when this request finishes, the next thread on the
            // queue gets started.
            synchronized (this) {
                if (queuedRequestThreads.size() != 0) {
                    queuedRequestThreads.remove().interrupt();
                }
            }
        }
    } catch (JSONException e) {
        myLog.l(Log.INFO, "JSONException in sendRequest: " + e);
        return null;
    }
}

From source file:com.example.lenovo.networktools.widget.ftp.swiftp.ProxyConnector.java

@SuppressWarnings("unused")
private JSONObject sendCmdSocketRequest(JSONObject json) {
    try {/*from w  ww. j a v  a  2s .  c o m*/
        boolean queued;
        synchronized (this) {
            if (responseWaiter == null) {
                responseWaiter = Thread.currentThread();
                queued = false;
                myLog.d("sendCmdSocketRequest proceeding without queue");
            } else if (!responseWaiter.isAlive()) {
                // This code should never run. It is meant to recover from a situation
                // where there is a thread that sent a proxy request but died before
                // starting the subsequent request. If this is the case, the correct
                // behavior is to run the next queued thread in the queue, or if the
                // queue is empty, to perform our own request. 
                myLog.l(Log.INFO, "Won't wait on dead responseWaiter");
                if (queuedRequestThreads.size() == 0) {
                    responseWaiter = Thread.currentThread();
                    queued = false;
                } else {
                    queuedRequestThreads.add(Thread.currentThread());
                    queuedRequestThreads.remove().interrupt(); // start queued thread
                    queued = true;
                }
            } else {
                myLog.d("sendCmdSocketRequest queueing thread");
                queuedRequestThreads.add(Thread.currentThread());
                queued = true;
            }
        }
        // If a different thread has sent a request and is waiting for a response,
        // then the current thread will be in a queue waiting for an interrupt
        if (queued) {
            // The current thread must wait until we are popped off the waiting queue
            // and receive an interrupt()
            boolean interrupted = false;
            try {
                myLog.d("Queued cmd session request thread sleeping...");
                Thread.sleep(QUEUE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.l(Log.DEBUG, "Proxy request popped and ready");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Timed out waiting on proxy queue");
                return null;
            }
        }
        // We have been popped from the wait queue if necessary, and now it's time
        // to send the request.
        try {
            responseWaiter = Thread.currentThread();
            byte[] outboundData = Util.jsonToByteArray(json);
            try {
                out.write(outboundData);
            } catch (IOException e) {
                myLog.l(Log.INFO, "IOException sending proxy request");
                return null;
            }
            // Wait RESPONSE_WAIT_MS for a response from the proxy
            boolean interrupted = false;
            try {
                // Wait for the main ProxyConnector thread to interrupt us, meaning
                // that a response has been received.
                myLog.d("Cmd session request sleeping until response");
                Thread.sleep(RESPONSE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.d("Cmd session response received");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Proxy request timed out");
                return null;
            }
            // At this point, the main ProxyConnector thread will have stored
            // our response in "JSONObject response".
            myLog.d("Cmd session response was: " + response);
            return response;
        } finally {
            // Make sure that when this request finishes, the next thread on the
            // queue gets started.
            synchronized (this) {
                if (queuedRequestThreads.size() != 0) {
                    queuedRequestThreads.remove().interrupt();
                }
            }
        }
    } catch (JSONException e) {
        myLog.l(Log.INFO, "JSONException in sendRequest: " + e);
        return null;
    }
}

From source file:com.kevin.percentsupportextends.PercentLayoutHelper.java

public void restoreOriginalParams() {
    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 restore " + view + " " + params);
        }/*  w  w  w.j a  v  a  2  s.c  o m*/
        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.restoreMarginLayoutParams((ViewGroup.MarginLayoutParams) params);
                } else {
                    info.restoreLayoutParams(params);
                }
            }
        }
    }
}

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

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

    try {//from  w  w  w .  jav a  2s . com
        /*
         * 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:org.swiftp.server.ProxyConnector.java

@SuppressWarnings("unused")
private JSONObject sendCmdSocketRequest(JSONObject json) {
    try {/*from ww w  .j a va  2  s.  c o m*/
        boolean queued;
        synchronized (this) {
            if (responseWaiter == null) {
                responseWaiter = Thread.currentThread();
                queued = false;
                myLog.d("sendCmdSocketRequest proceeding without queue");
            } else if (!responseWaiter.isAlive()) {
                // This code should never run. It is meant to recover from a situation
                // where there is a thread that sent a proxy request but died before
                // starting the subsequent request. If this is the case, the correct
                // behavior is to run the next queued thread in the queue, or if the
                // queue is empty, to perform our own request.
                myLog.l(Log.INFO, "Won't wait on dead responseWaiter");
                if (queuedRequestThreads.size() == 0) {
                    responseWaiter = Thread.currentThread();
                    queued = false;
                } else {
                    queuedRequestThreads.add(Thread.currentThread());
                    queuedRequestThreads.remove().interrupt(); // start queued thread
                    queued = true;
                }
            } else {
                myLog.d("sendCmdSocketRequest queueing thread");
                queuedRequestThreads.add(Thread.currentThread());
                queued = true;
            }
        }
        // If a different thread has sent a request and is waiting for a response,
        // then the current thread will be in a queue waiting for an interrupt
        if (queued) {
            // The current thread must wait until we are popped off the waiting queue
            // and receive an interrupt()
            boolean interrupted = false;
            try {
                myLog.d("Queued cmd session request thread sleeping...");
                Thread.sleep(QUEUE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.l(Log.DEBUG, "Proxy request popped and ready");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Timed out waiting on proxy queue");
                return null;
            }
        }
        // We have been popped from the wait queue if necessary, and now it's time
        // to send the request.
        try {
            responseWaiter = Thread.currentThread();
            byte[] outboundData = Util.jsonToByteArray(json);
            try {
                out.write(outboundData);
            } catch (IOException e) {
                myLog.l(Log.INFO, "IOException sending proxy request");
                return null;
            }
            // Wait RESPONSE_WAIT_MS for a response from the proxy
            boolean interrupted = false;
            try {
                // Wait for the main ProxyConnector thread to interrupt us, meaning
                // that a response has been received.
                myLog.d("Cmd session request sleeping until response");
                Thread.sleep(RESPONSE_WAIT_MS);
            } catch (InterruptedException e) {
                myLog.d("Cmd session response received");
                interrupted = true;
            }
            if (!interrupted) {
                myLog.l(Log.INFO, "Proxy request timed out");
                return null;
            }
            // At this point, the main ProxyConnector thread will have stored
            // our response in "JSONObject response".
            myLog.d("Cmd session response was: " + response);
            return response;
        } finally {
            // Make sure that when this request finishes, the next thread on the
            // queue gets started.
            synchronized (this) {
                if (queuedRequestThreads.size() != 0) {
                    queuedRequestThreads.remove().interrupt();
                }
            }
        }
    } catch (JSONException e) {
        myLog.l(Log.INFO, "JSONException in sendRequest: " + e);
        return null;
    }
}