Code Monkey home page Code Monkey logo

savestateobserver's Introduction

SaveStateObserver Build Status API

Android tool to output the contents sizes of saved state bundles in onSaveInstance state calls. This will allow you to analyze your bundles as you pass data to other classes to prevent them from growing to sizes that are not allowed by Android.

Usage

To use in debug builds only use:

debugImplementation 'com.pnuema.android:savestateobserver:2.13.0'

Once it has been included as a dependency it will listen for lifecycle state changes and output the following information without any code being inserted in your codebase.

Example Logcat:

   2022-07-06 08:59:54.618 27026-27026/com.pnuema.android.savestateobserver.app D/SaveStateObserver: ===== SaveStateObserver =====
MainActivity saved Bundle@142181721 which contained 8 elements for 304.73 KB
     String = 32 bytes
     Bundle@238359838 innerBundle contained 4 elements for 100.17 KB
         String = 40 bytes
         BigString = 100.02 KB
         Integer = 8 bytes
         Float = 8 bytes
     Bundle@205345279 android:viewHierarchyState contained 1 elements for 612 bytes
         android:views = 568 bytes
     Integer = 8 bytes
     Float = 8 bytes
     Bundle@257018828 androidx.lifecycle.BundlableSavedStateRegistry.key contained 4 elements for 203.19 KB
         Bundle@229907989 androidx:appcompat contained 0 elements for 4 bytes
         Bundle@1664298 android:support:lifecycle contained 0 elements for 4 bytes
         Bundle@2035483 android:support:activity-result contained 5 elements for 1.39 KB
             KEY_COMPONENT_ACTIVITY_RANDOM_OBJECT = 152 bytes
             KEY_COMPONENT_ACTIVITY_REGISTERED_KEYS = 752 bytes
             KEY_COMPONENT_ACTIVITY_REGISTERED_RCS = 56 bytes
             Bundle@230021304 KEY_COMPONENT_ACTIVITY_PENDING_RESULT contained 0 elements for 4 bytes
             KEY_COMPONENT_ACTIVITY_LAUNCHED_KEYS = 8 bytes
         Bundle@80053905 android:support:fragments contained 1 elements for 201.54 KB
             android:support:fragments = 201.47 KB
     android:lastAutofillId = 8 bytes
     android:fragments = 336 bytes

Notification

Consumers can register for detection events. Start by registering this on application start in debug only code to receive notifications and perform the action intended such as logging analytic events, or reporting a bug.

Example:

    uuid = OversizeBundleRegistrar.register { stringifyBundle ->
        // Action to perform when oversize bundle is detected
    }

Make sure to unregister when you no longer want to trigger the work to be done:

Example:

    OversizeBundleRegistrar.unregister(uuid)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.