Example usage for android.net.http HttpResponseCache size

List of usage examples for android.net.http HttpResponseCache size

Introduction

In this page you can find the example usage for android.net.http HttpResponseCache size.

Prototype

public long size() 

Source Link

Document

Returns the number of bytes currently being used to store the values in this cache.

Usage

From source file:com.fastbootmobile.encore.app.OmniMusic.java

@Override
public void onCreate() {
    super.onCreate();

    // We need to filter here whether we're initializing the main app or an aux attached plugin
    String appName = Utils.getAppNameByPID(this, android.os.Process.myPid());
    final String process = appName.substring(appName.indexOf(':') + 1);

    Sentry.setCaptureListener(new Sentry.SentryEventCaptureListener() {
        @Override//w ww  . j  a v  a 2  s  .  c om
        public Sentry.SentryEventBuilder beforeCapture(Sentry.SentryEventBuilder sentryEventBuilder) {
            JSONObject tags = sentryEventBuilder.getTags();
            try {
                tags.put("OS", "Android " + Build.VERSION.RELEASE);
                tags.put("OSCodename", Build.VERSION.CODENAME);
                tags.put("Device", Build.DEVICE);
                tags.put("Model", Build.MODEL);
                tags.put("Manufacturer", Build.MANUFACTURER);
                tags.put("AppVersionCode", String.valueOf(BuildConfig.VERSION_CODE));
                tags.put("AppVersionName", BuildConfig.VERSION_NAME);
                tags.put("AppFlavor", BuildConfig.FLAVOR);
            } catch (JSONException e) {
                Log.e(TAG, "Failed to put a tag into Sentry", e);
            }

            sentryEventBuilder.addModule(process, BuildConfig.VERSION_NAME);
            return sentryEventBuilder;
        }
    });
    Sentry.init(this,
            "https://4dc1acbdb1cb423282e2a59f553e1153:9415087b9e1348c3ba4bed44be599f6a@sentry.fastboot.mobi/2");

    // Setup LeakCanary
    mRefWatcher = LeakCanary.install(this);

    if (PROCESS_APP.equals(process)) {
        // Setup the plugins system
        ProviderAggregator.getDefault().setContext(getApplicationContext());
        PluginsLookup.getDefault().initialize(getApplicationContext());

        /**
         * Note about the cache and EchoNest: The HTTP cache would sometimes cache request
         * we didn't want (such as status query for Taste Profile update). We're using
         * a hacked jEN library that doesn't cache these requests.
         */
        // Setup network cache
        try {
            final File httpCacheDir = new File(getCacheDir(), "http");
            final long httpCacheSize = 100 * 1024 * 1024; // 100 MiB
            final HttpResponseCache cache = HttpResponseCache.install(httpCacheDir, httpCacheSize);

            Log.i(TAG, "HTTP Cache size: " + cache.size() / 1024 / 1024 + "MB");
        } catch (IOException e) {
            Log.w(TAG, "HTTP response cache installation failed", e);
        }

        // Setup image cache
        ImageCache.getDefault().initialize(getApplicationContext());

        // Setup Automix system
        AutoMixManager.getDefault().initialize(getApplicationContext());

        // Setup custom fonts
        CalligraphyConfig.initDefault("fonts/Roboto-Regular.ttf", R.attr.fontPath);
    }
}