当前位置: 首页>>代码示例>>Java>>正文


Java Log.isLoggable方法代码示例

本文整理汇总了Java中android.util.Log.isLoggable方法的典型用法代码示例。如果您正苦于以下问题:Java Log.isLoggable方法的具体用法?Java Log.isLoggable怎么用?Java Log.isLoggable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.Log的用法示例。


在下文中一共展示了Log.isLoggable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showProgress

import android.util.Log; //导入方法依赖的package包/类
public void showProgress(int message) {
    if (Log.isLoggable(UILog.TAG, Log.DEBUG)) {
        UILog.d("show " + FRAGMENT_PROGRESS + ", " + message + ": " + message
                + ", stopped: " + isStopped());
    }
    if (isStopped()) {
        return;
    }
    hideDisabled();
    hideAppProgress();
    ProgressFragment fragment = (ProgressFragment) getFragmentManager()
            .findFragmentByTag(FRAGMENT_PROGRESS);
    if (fragment == null || fragment.getMessage() != message) {
        if (fragment != null) {
            fragment.dismiss();
        }
        fragment = new ProgressFragment();
        fragment.setMessage(message);
        fragment.show(getFragmentManager(), FRAGMENT_PROGRESS);
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:22,代码来源:BreventActivity.java

示例2: get

import android.util.Log; //导入方法依赖的package包/类
@Override
public File get(Key key) {
  String safeKey = safeKeyGenerator.getSafeKey(key);
  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "Get: Obtained: " + safeKey + " for for Key: " + key);
  }
  File result = null;
  try {
    // It is possible that the there will be a put in between these two gets. If so that shouldn't
    // be a problem because we will always put the same value at the same key so our input streams
    // will still represent the same data.
    final DiskLruCache.Value value = getDiskCache().get(safeKey);
    if (value != null) {
      result = value.getFile(0);
    }
  } catch (IOException e) {
    if (Log.isLoggable(TAG, Log.WARN)) {
      Log.w(TAG, "Unable to get from disk cache", e);
    }
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DiskLruCacheWrapper.java

示例3: loadData

import android.util.Log; //导入方法依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super InputStream> callback) {
  long startTime = LogTime.getLogTime();
  final InputStream result;
  try {
    result = loadDataWithRedirects(glideUrl.toURL(), 0 /*redirects*/, null /*lastUrl*/,
        glideUrl.getHeaders());
  } catch (IOException e) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
      Log.d(TAG, "Failed to load data for url", e);
    }
    callback.onLoadFailed(e);
    return;
  }

  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "Finished http url fetcher fetch in " + LogTime.getElapsedMillis(startTime)
        + " ms and loaded " + result);
  }
  callback.onDataReady(result);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:HttpUrlFetcher.java

示例4: getPhotoCacheDir

import android.util.Log; //导入方法依赖的package包/类
/**
 * Returns a directory with the given name in the private cache directory of the application to
 * use to store retrieved media and thumbnails.
 *
 * @param context   A context.
 * @param cacheName The name of the subdirectory in which to store the cache.
 * @see #getPhotoCacheDir(android.content.Context)
 */
@Nullable
public static File getPhotoCacheDir(Context context, String cacheName) {
  File cacheDir = context.getCacheDir();
  if (cacheDir != null) {
    File result = new File(cacheDir, cacheName);
    if (!result.mkdirs() && (!result.exists() || !result.isDirectory())) {
      // File wasn't able to create a directory, or the result exists but not a directory
      return null;
    }
    return result;
  }
  if (Log.isLoggable(TAG, Log.ERROR)) {
    Log.e(TAG, "default disk cache dir is null");
  }
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Glide.java

示例5: inputStreamToBytes

import android.util.Log; //导入方法依赖的package包/类
private static byte[] inputStreamToBytes(InputStream is) {
  final int bufferSize = 16384;
  ByteArrayOutputStream buffer = new ByteArrayOutputStream(bufferSize);
  try {
    int nRead;
    byte[] data = new byte[bufferSize];
    while ((nRead = is.read(data)) != -1) {
      buffer.write(data, 0, nRead);
    }
    buffer.flush();
  } catch (IOException e) {
    if (Log.isLoggable(TAG, Log.WARN)) {
      Log.w(TAG, "Error reading data from stream", e);
    }
    return null;
  }
  return buffer.toByteArray();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:StreamGifDecoder.java

示例6: getLoggingLevel

import android.util.Log; //导入方法依赖的package包/类
/**
 * @return loggingLevel see {@link #LOG_NONE}, {@link #LOG_DEBUG} and
 *         {@link #LOG_VERBOSE}.
 */
private int getLoggingLevel() {
    int loggingLevel;
    if (Log.isLoggable(LOG_TAG, Log.VERBOSE)) {
        loggingLevel = LOG_VERBOSE;
    } else if (Log.isLoggable(LOG_TAG, Log.DEBUG)) {
        loggingLevel = LOG_DEBUG;
    } else {
        loggingLevel = LOG_NONE;
    }
    return loggingLevel;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:16,代码来源:CronetUrlRequestContext.java

示例7: parseNetworkError

import android.util.Log; //导入方法依赖的package包/类
@Override
protected VolleyError parseNetworkError(VolleyError volleyError) {
  if (Log.isLoggable(TAG, Log.DEBUG)) {
    Log.d(TAG, "Volley failed to retrieve response", volleyError);
  }
  callback.onLoadFailed(volleyError);
  return super.parseNetworkError(volleyError);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:VolleyStreamFetcher.java

示例8: get

import android.util.Log; //导入方法依赖的package包/类
@Override
public <T> T get(int size, Class<T> arrayClass) {
  ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass);
  T result;
  synchronized (this) {
    Integer possibleSize = getSizesForAdapter(arrayClass).ceilingKey(size);
    final Key key;
    if (mayFillRequest(size, possibleSize)) {
      key = keyPool.get(possibleSize, arrayClass);
    } else {
      key = keyPool.get(size, arrayClass);
    }

    result = getArrayForKey(key);
    if (result != null) {
      currentSize -= arrayAdapter.getArrayLength(result) * arrayAdapter.getElementSizeInBytes();
      decrementArrayOfSize(arrayAdapter.getArrayLength(result), arrayClass);
    }
  }

  if (result == null) {
    if (Log.isLoggable(arrayAdapter.getTag(), Log.VERBOSE)) {
      Log.v(arrayAdapter.getTag(), "Allocated " + size + " bytes");
    }
    result = arrayAdapter.newArray(size);
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:LruArrayPool.java

示例9: decodeResourceWithList

import android.util.Log; //导入方法依赖的package包/类
private Resource<ResourceType> decodeResourceWithList(DataRewinder<DataType> rewinder, int width,
    int height, Options options, List<Throwable> exceptions) throws GlideException {
  Resource<ResourceType> result = null;
  for (int i = 0, size = decoders.size(); i < size; i++) {
    ResourceDecoder<DataType, ResourceType> decoder = decoders.get(i);
    try {
      DataType data = rewinder.rewindAndGet();
      if (decoder.handles(data, options)) {
        data = rewinder.rewindAndGet();
        result = decoder.decode(data, width, height, options);
      }
      // Some decoders throw unexpectedly. If they do, we shouldn't fail the entire load path, but
      // instead log and continue. See #2406 for an example.
    } catch (IOException | RuntimeException | OutOfMemoryError e) {
      if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "Failed to decode data for " + decoder, e);
      }
      exceptions.add(e);
    }

    if (result != null) {
      break;
    }
  }

  if (result == null) {
    throw new GlideException(failureMessage, new ArrayList<>(exceptions));
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:DecodePath.java

示例10: loadData

import android.util.Log; //导入方法依赖的package包/类
@Override
public void loadData(Priority priority, DataCallback<? super InputStream> callback) {
  try {
    inputStream = openThumbInputStream();
  } catch (FileNotFoundException e) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
      Log.d(TAG, "Failed to find thumbnail file", e);
    }
    callback.onLoadFailed(e);
    return;
  }

  callback.onDataReady(inputStream);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ThumbFetcher.java

示例11: centerInside

import android.util.Log; //导入方法依赖的package包/类
/**
 * If the Bitmap is smaller or equal to the Target it returns the original size, if not then
 * {@link #fitCenter(BitmapPool, Bitmap, int, int)} is called instead.
 *
 * @param pool   The BitmapPool obtain a bitmap from.
 * @param inBitmap  The Bitmap to center.
 * @param width  The width in pixels of the target.
 * @param height The height in pixels of the target.
 * @return returns input Bitmap if smaller or equal to target, or toFit if the Bitmap's width or
 * height is larger than the given dimensions
 */
public static Bitmap centerInside(@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width,
                               int height) {
  if (inBitmap.getWidth() <= width && inBitmap.getHeight() <= height) {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
      Log.v(TAG, "requested target size larger or equal to input, returning input");
    }
    return inBitmap;
  } else {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
      Log.v(TAG, "requested target size too big for input, fit centering instead");
    }
    return fitCenter(pool, inBitmap, width, height);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:TransformationUtils.java

示例12: v

import android.util.Log; //导入方法依赖的package包/类
public static void v(final String tag, String message, Throwable cause) {
    if (BuildConfig.DEBUG) {
        if (TextUtils.isEmpty(tag)) {
            if (Log.isLoggable(BASE_TAG, Log.VERBOSE)) {
                Log.v(BASE_TAG, message, cause);
            }
        } else {
            if (Log.isLoggable(tag, Log.VERBOSE)) {
                Log.v(tag, message, cause);
            }
        }
    }
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:14,代码来源:LogUtil.java

示例13: calculateScaling

import android.util.Log; //导入方法依赖的package包/类
static void calculateScaling(DownsampleStrategy downsampleStrategy, int degreesToRotate,
    int sourceWidth, int sourceHeight, int targetWidth, int targetHeight,
    BitmapFactory.Options options) {
  // We can't downsample source content if we can't determine its dimensions.
  if (sourceWidth <= 0 || sourceHeight <= 0) {
    return;
  }

  final float exactScaleFactor;
  if (degreesToRotate == 90 || degreesToRotate == 270) {
    // If we're rotating the image +-90 degrees, we need to downsample accordingly so the image
    // width is decreased to near our target's height and the image height is decreased to near
    // our target width.
    //noinspection SuspiciousNameCombination
    exactScaleFactor = downsampleStrategy.getScaleFactor(sourceHeight, sourceWidth,
        targetWidth, targetHeight);
  } else {
    exactScaleFactor =
        downsampleStrategy.getScaleFactor(sourceWidth, sourceHeight, targetWidth, targetHeight);
  }

  if (exactScaleFactor <= 0f) {
    throw new IllegalArgumentException("Cannot scale with factor: " + exactScaleFactor
        + " from: " + downsampleStrategy);
  }
  SampleSizeRounding rounding = downsampleStrategy.getSampleSizeRounding(sourceWidth,
      sourceHeight, targetWidth, targetHeight);
  if (rounding == null) {
    throw new IllegalArgumentException("Cannot round with null rounding");
  }

  int outWidth = (int) (exactScaleFactor * sourceWidth + 0.5f);
  int outHeight = (int) (exactScaleFactor * sourceHeight + 0.5f);

  int widthScaleFactor = sourceWidth / outWidth;
  int heightScaleFactor = sourceHeight / outHeight;

  int scaleFactor = rounding == SampleSizeRounding.MEMORY
      ? Math.max(widthScaleFactor, heightScaleFactor)
      : Math.min(widthScaleFactor, heightScaleFactor);

  int powerOfTwoSampleSize;
  // BitmapFactory does not support downsampling wbmp files on platforms <= M. See b/27305903.
  if (Build.VERSION.SDK_INT <= 23
      && NO_DOWNSAMPLE_PRE_N_MIME_TYPES.contains(options.outMimeType)) {
    powerOfTwoSampleSize = 1;
  } else {
    powerOfTwoSampleSize = Math.max(1, Integer.highestOneBit(scaleFactor));
    if (rounding == SampleSizeRounding.MEMORY
        && powerOfTwoSampleSize < (1.f / exactScaleFactor)) {
      powerOfTwoSampleSize = powerOfTwoSampleSize << 1;
    }
  }

  float adjustedScaleFactor = powerOfTwoSampleSize * exactScaleFactor;

  options.inSampleSize = powerOfTwoSampleSize;
  // Density scaling is only supported if inBitmap is null prior to KitKat. Avoid setting
  // densities here so we calculate the final Bitmap size correctly.
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    options.inTargetDensity = (int) (1000 * adjustedScaleFactor + 0.5f);
    options.inDensity = 1000;
  }
  if (isScaling(options)) {
    options.inScaled = true;
  } else {
    options.inDensity = options.inTargetDensity = 0;
  }

  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "Calculate scaling"
        + ", source: [" + sourceWidth + "x" + sourceHeight + "]"
        + ", target: [" + targetWidth + "x" + targetHeight + "]"
        + ", exact scale factor: " + exactScaleFactor
        + ", power of 2 sample size: " + powerOfTwoSampleSize
        + ", adjusted scale factor: " + adjustedScaleFactor
        + ", target density: " + options.inTargetDensity
        + ", density: " + options.inDensity);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:81,代码来源:Downsampler.java

示例14: decodeFromWrappedStreams

import android.util.Log; //导入方法依赖的package包/类
private Bitmap decodeFromWrappedStreams(InputStream is,
    BitmapFactory.Options options, DownsampleStrategy downsampleStrategy,
    DecodeFormat decodeFormat, int requestedWidth, int requestedHeight,
    boolean fixBitmapToRequestedDimensions, DecodeCallbacks callbacks) throws IOException {

  int[] sourceDimensions = getDimensions(is, options, callbacks);
  int sourceWidth = sourceDimensions[0];
  int sourceHeight = sourceDimensions[1];
  String sourceMimeType = options.outMimeType;

  int orientation = ImageHeaderParserUtils.getOrientation(parsers, is, byteArrayPool);
  int degreesToRotate = TransformationUtils.getExifOrientationDegrees(orientation);

  options.inPreferredConfig = getConfig(is, decodeFormat);
  if (options.inPreferredConfig != Bitmap.Config.ARGB_8888) {
    options.inDither = true;
  }

  int targetWidth = requestedWidth == Target.SIZE_ORIGINAL ? sourceWidth : requestedWidth;
  int targetHeight = requestedHeight == Target.SIZE_ORIGINAL ? sourceHeight : requestedHeight;

  calculateScaling(downsampleStrategy, degreesToRotate, sourceWidth, sourceHeight, targetWidth,
      targetHeight, options);

  boolean isKitKatOrGreater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
  // Prior to KitKat, the inBitmap size must exactly match the size of the bitmap we're decoding.
  if ((options.inSampleSize == 1 || isKitKatOrGreater)
      && shouldUsePool(is)) {
    int expectedWidth;
    int expectedHeight;
    if (fixBitmapToRequestedDimensions && isKitKatOrGreater) {
      expectedWidth = targetWidth;
      expectedHeight = targetHeight;
    } else {
      float densityMultiplier = isScaling(options)
          ? (float) options.inTargetDensity / options.inDensity : 1f;
      int sampleSize = options.inSampleSize;
      int downsampledWidth = (int) Math.ceil(sourceWidth / (float) sampleSize);
      int downsampledHeight = (int) Math.ceil(sourceHeight / (float) sampleSize);
      expectedWidth = Math.round(downsampledWidth * densityMultiplier);
      expectedHeight = Math.round(downsampledHeight * densityMultiplier);

      if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "Calculated target [" + expectedWidth + "x" + expectedHeight + "] for source"
            + " [" + sourceWidth + "x" + sourceHeight + "]"
            + ", sampleSize: " + sampleSize
            + ", targetDensity: " + options.inTargetDensity
            + ", density: " + options.inDensity
            + ", density multiplier: " + densityMultiplier);
      }
    }
    // If this isn't an image, or BitmapFactory was unable to parse the size, width and height
    // will be -1 here.
    if (expectedWidth > 0 && expectedHeight > 0) {
      setInBitmap(options, bitmapPool, expectedWidth, expectedHeight);
    }
  }
  Bitmap downsampled = decodeStream(is, options, callbacks);
  callbacks.onDecodeComplete(bitmapPool, downsampled);

  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    logDecode(sourceWidth, sourceHeight, sourceMimeType, options, downsampled,
        requestedWidth, requestedHeight);
  }

  Bitmap rotated = null;
  if (downsampled != null) {
    // If we scaled, the Bitmap density will be our inTargetDensity. Here we correct it back to
    // the expected density dpi.
    downsampled.setDensity(displayMetrics.densityDpi);

    rotated = TransformationUtils.rotateImageExif(bitmapPool, downsampled, orientation);
    if (!downsampled.equals(rotated)) {
      bitmapPool.put(downsampled);
    }
  }

  return rotated;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:80,代码来源:Downsampler.java

示例15: onServiceDisconnected

import android.util.Log; //导入方法依赖的package包/类
public void onServiceDisconnected(ComponentName componentName) {
    if (Log.isLoggable(NotificationManagerCompat.TAG, 3)) {
        Log.d(NotificationManagerCompat.TAG, "Disconnected from service " + componentName);
    }
    this.mHandler.obtainMessage(2, componentName).sendToTarget();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:NotificationManagerCompat.java


注:本文中的android.util.Log.isLoggable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。