Example usage for android.os StatFs getBlockSize

List of usage examples for android.os StatFs getBlockSize

Introduction

In this page you can find the example usage for android.os StatFs getBlockSize.

Prototype

@Deprecated
public int getBlockSize() 

Source Link

Usage

From source file:gr.unfold.android.tsibato.images.ImageCache.java

@TargetApi(9)
public static long getUsableSpace(File path) {
    if (Utils.hasGingerbread()) {
        return path.getUsableSpace();
    }/* ww w  .jav a2 s. co  m*/
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.egoists.coco_nut.android.cache.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * /*from   www . ja  va 2s  . c  o m*/
 * @param path The path to check
 * @return The space available in bytes
 */
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public static long getUsableSpace(File path) {
    if (EtcUtils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.squareup.picasso3.Utils.java

static long calculateDiskCacheSize(File dir) {
    long size = MIN_DISK_CACHE_SIZE;

    try {/* w  w  w  .j  a  v a 2 s. c  o  m*/
        StatFs statFs = new StatFs(dir.getAbsolutePath());
        //noinspection deprecation
        long blockCount = SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockCount() : statFs.getBlockCountLong();
        //noinspection deprecation
        long blockSize = SDK_INT < JELLY_BEAN_MR2 ? (long) statFs.getBlockSize() : statFs.getBlockSizeLong();
        long available = blockCount * blockSize;
        // Target 2% of the total space.
        size = available / 50;
    } catch (IllegalArgumentException ignored) {
    }

    // Bound inside min/max size for disk cache.
    return Math.max(Math.min(size, MAX_DISK_CACHE_SIZE), MIN_DISK_CACHE_SIZE);
}

From source file:com.intuit.qboecoui.feeds.util.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/*  w w w.  j ava  2  s . co  m*/
 * @return The space available in bytes
 */
@TargetApi(VERSION_CODES.GINGERBREAD)
public static long getUsableSpace(File path) {
    if (ElvesUtil.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.android.volley.plus.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check//from ww  w .ja v a 2 s .  c om
 * @return The space available in bytes
 */
//    @TargetApi(9)
public static long getUsableSpace(File path) {
    if (OsVersionUtils.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.codingPower.framework.worker.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/*from  www  .  java  2 s  . c om*/
 * @return The space available in bytes
 */
public static long getUsableSpace(File path) {
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:com.airad.zhonghan.ui.components.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 * //w  ww.ja va 2s. c  o  m
 * @param path
 *            The path to check
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:net.iaf.framework.imgload.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check//from w w  w  .j a va2  s .  c om
 * @return The space available in bytes
 */
@TargetApi(9)
public static long getUsableSpace(File path) {
    if (SDKVersionUtil.hasGingerbread()) {
        return path.getUsableSpace();
    }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}

From source file:de.s2hmobile.bitmaps.ImageCache.java

@SuppressWarnings("deprecation")
private static int getUsableSpaceFroyo(final File path) {
    final StatFs stats = new StatFs(path.getPath());
    return stats.getBlockSize() * stats.getAvailableBlocks();
}

From source file:com.shine.hotels.util.ImageCache.java

/**
 * Check how much usable space is available at a given path.
 *
 * @param path The path to check/*w w  w . j  av a  2 s. c om*/
 * @return The space available in bytes
 */
//@TargetApi(9)
public static long getUsableSpace(File path) {
    //        if (UIUtils.hasGingerbread()) {
    //            return path.getUsableSpace();
    //        }
    final StatFs stats = new StatFs(path.getPath());
    return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
}