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:com.dirkgassen.wator.ui.view.RangeSlider.java

/**
 * Handle touch events: drag the thumb to new values. This method also detects clicks.
 *
 * @param event the touch event/*from  www .  j  a v a  2  s . c  o  m*/
 * @return {@code true} if the event was handled; {@code false} otherwise
 */
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
    if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
        Log.d("Wa-Tor", "Got touch event: " + event);
    }
    int paddingLeft = getPaddingLeft();
    int paddingRight = getPaddingRight();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        touchEventStartTime = System.currentTimeMillis();
        valueBeforeDragging = value;
        activePointerId = event.getPointerId(0);
        float valuePos = positionFromValue(paddingLeft, paddingRight);
        float x = event.getX();
        if (x < valuePos - thumbSize / 2 || x > valuePos + thumbSize / 2) {
            int newValue = valueFromPosition(x, paddingLeft, paddingRight);
            if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                Log.d("Wa-Tor", "Starting to drag thumb OUTSIDE of thumb");
            }
            if (newValue != value) {
                touchEventStartTime = 0L; // Not a click
                updateValue(newValue, true /* from user */);
            }
            touchOffset = 0f;
        } else {
            touchOffset = x - valuePos;
            if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                Log.d("Wa-Tor", "Starting to drag thumb INSIDE of thumb; offset = " + touchOffset);
            }
        }
        isDragging = true;
        return true;
    case MotionEvent.ACTION_MOVE:
        if (activePointerId != -1) {
            final int pointerIndex = event.findPointerIndex(activePointerId);
            float currentPos = event.getX(pointerIndex) - touchOffset;
            int newValue = valueFromPosition(currentPos, paddingLeft, paddingRight);
            if (newValue != value) {
                if (Log.isLoggable("Wa-Tor", Log.DEBUG)) {
                    Log.d("Wa-Tor", "Got new value " + newValue + " (old = " + value + ")");
                }
                touchEventStartTime = 0L; // Not a click
                updateValue(newValue, true /* from user */);
            }
        }
        return true;
    case MotionEvent.ACTION_UP:
        if (touchEventStartTime > 0L && System.currentTimeMillis() - touchEventStartTime < MAX_CLICK_DURATION) {
            performClick();
        }
        isDragging = false;
        break;
    case MotionEvent.ACTION_CANCEL:
        isDragging = false;
        updateValue(valueBeforeDragging, true /* from user */);
        break;
    case MotionEvent.ACTION_POINTER_UP:
        isDragging = false;
        break;
    }

    return super.onTouchEvent(event);
}

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

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

    try {//from   w w w. ja  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:android.percent.support.PercentLayoutHelper.java

/**
 * Iterates over children and restores their original dimensions that were changed for
 * percentage values. Calling this method only makes sense if you previously called
 * {@link PercentLayoutHelper#adjustChildren(int, int)}.
 *//*from  w ww. ja  v  a  2  s .c o  m*/

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);
        }
        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.android.ex.chips.RecipientEditTextView.java

private CharSequence ellipsizeText(final CharSequence text, final TextPaint paint, final float maxWidth) {
    paint.setTextSize(mChipFontSize);// w w w.  j av  a2s .c o  m
    if (maxWidth <= 0 && Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, "Max width is negative: " + maxWidth);
    final CharSequence ellipsize = TextUtils.ellipsize(text, paint, maxWidth, TextUtils.TruncateAt.END);
    return ellipsize;
}

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

/**
 * Clears the current quiz when user clicks on "New Quiz."
 * On this end, this involves clearing the quiz status layout and deleting all DataItems. The
 * wearable will then remove any outstanding question notifications upon receiving this change.
 *//*ww w  .  j a v  a  2  s  .c  o  m*/
public void newQuiz(View view) {
    clearQuizStatus();
    if (mGoogleApiClient.isConnected()) {
        Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(new ResultCallback<DataItemBuffer>() {
            @Override
            public void onResult(DataItemBuffer result) {
                try {
                    if (result.getStatus().isSuccess()) {
                        List<Uri> dataItemUriList = new ArrayList<Uri>();
                        for (final DataItem dataItem : result) {
                            dataItemUriList.add(dataItem.getUri());
                        }
                        deleteDataItems(dataItemUriList);
                    } else {
                        if (Log.isLoggable(TAG, Log.DEBUG)) {
                            Log.d(TAG, "Clear quiz: failed to get Data Items for " + "deletion");

                        }
                    }
                } finally {
                    result.release();
                }
            }
        });
    } else {
        Log.e(TAG, "Failed to delete data items because client is disconnected from " + "Google Play Services");
    }
}

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

private void deleteDataItems(List<Uri> dataItemUriList) {
    if (mGoogleApiClient.isConnected()) {
        for (final Uri dataItemUri : dataItemUriList) {
            Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri)
                    .setResultCallback(new ResultCallback<DataApi.DeleteDataItemsResult>() {
                        @Override
                        public void onResult(DataApi.DeleteDataItemsResult deleteResult) {
                            if (Log.isLoggable(TAG, Log.DEBUG)) {
                                if (deleteResult.getStatus().isSuccess()) {
                                    Log.d(TAG, "Successfully deleted data item " + dataItemUri);
                                } else {
                                    Log.d(TAG, "Failed to delete data item " + dataItemUri);
                                }//from  w  w  w.ja  v  a2  s  . c om
                            }
                        }
                    });
        }
    } else {
        Log.e(TAG, "Failed to delete data items because client is disconnected from " + "Google Play Services");
    }
}

From source file:android.percent.support.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/>/*ww w  . j  a v  a 2  s.c o  m*/
 * 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)) {
            Log.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)) {
        Log.d(TAG, "should trigger second measure pass: " + needsSecondMeasure);
    }
    return needsSecondMeasure;
}

From source file:com.samsung.spen.SpenPlugin.java

/**
 * Delete SpenSurface/*  ww w .  j a  va 2  s  . com*/
 * 
 * @param id
 *           String
 */
void deleteSpenSurface(String id) {
    if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
        Log.d(TAG, "Inside deleteSpenSurface");
    }
    if (mSpenSurfaceViews.getSurfaceView(id) != null) {
        mSpenSurfaceViews.removeSurfaceView(id);
    }
}

From source file:com.samsung.spen.SpenPlugin.java

/**
 * checks if the Spen feature is enabled or not. Send the result as
 * SPEN_SUPPORTED if the Spen is supported otherwise the corresponding error
 * message./*from w ww  .  j  a  va2  s  .  com*/
 * 
 * @param context
 *                Context
 * @param callbackContext
 *                CallbackContext
 * @return spenState
 */
private int isSpenFeatureEnabled(Context context, CallbackContext callbackContext) {
    if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
        Log.d(TAG, "inside isSpenFeatureEnabled");
    }
    int spenState = SPEN_INITILIZATION_ERROR;
    Spen spenPackage = new Spen();
    try {
        if (isStatic) {
            spenPackage.initialize(context, 5, Spen.SPEN_STATIC_LIB_MODE);
        } else {
            spenPackage.initialize(context);
        }
        if (spenPackage.isFeatureEnabled(Spen.DEVICE_PEN)) {
            spenState = SPEN_AND_HAND_SUPPORTED;
        } else {
            spenState = ONLY_HAND_SUPPORTED;
        }
    } catch (SsdkUnsupportedException e) {
        Log.d(TAG, "failed initializing the spen package " + e.getMessage());
        e.printStackTrace();
        // if the spen sdk version name (dynamic sdk) is lesser than
        // the jar version name (which is inlcuded in the spen plugin
        // then LIBRARY_UPDATE_IS_REQUIRED should be thrown.
        // Current, Spen SDK not handled it properly.
        SpenExceptionType errorType = null;
        boolean isExceptionTypeFound = false;
        if (spenPackage != null && !isStatic) {
            String dynamicSDKPkgName = Spen.SPEN_NATIVE_PACKAGE_NAME;
            try {
                PackageInfo packageInfo = mActivity.getPackageManager().getPackageInfo(dynamicSDKPkgName, 0);
                if (packageInfo != null) {
                    String dynamicSDKVersionName = packageInfo.versionName.replace(".", "");
                    String pluginJarVersionName = spenPackage.getVersionName().replace(".", "");
                    if (dynamicSDKVersionName.compareTo(pluginJarVersionName) < 0) {
                        errorType = SpenExceptionType.LIBRARY_UPDATE_IS_REQUIRED;
                        isExceptionTypeFound = true;
                    }
                }
            } catch (NameNotFoundException e1) {
                e1.printStackTrace();
            }
        }
        if (!isExceptionTypeFound) {
            errorType = SpenException.processUnsupportedException(e);
        }
        PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, errorType.toString());
        pluginResult.setKeepCallback(false);
        callbackContext.sendPluginResult(pluginResult);
    }
    spenPackage = null;
    return spenState;
}

From source file:com.android.contacts.model.AccountTypeManager.java

/**
 * Find the best {@link DataKind} matching the requested
 * {@link AccountType#accountType}, {@link AccountType#dataSet}, and {@link DataKind#mimeType}.
 * If no direct match found, we try searching {@link FallbackAccountType}.
 *///from   ww w  .  j  a  va2 s .  c o  m
@Override
public DataKind getKindOrFallback(AccountType type, String mimeType) {
    DataKind kind = null;

    // Try finding account type and kind matching request
    if (type != null) {
        kind = type.getKindForMimetype(mimeType);
    }

    if (kind == null) {
        // Nothing found, so try fallback as last resort
        kind = mFallbackAccountType.getKindForMimetype(mimeType);
    }

    if (kind == null) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Unknown type=" + type + ", mime=" + mimeType);
        }
    }

    return kind;
}