Skip to content

grofers/droid-dex

Repository files navigation

Maven Central Version GitHub Issues GitHub Stars GitHub License


Droid Dex

Introduction

Droid Dex helps you make smart, device-aware decisions like:

  • Delivering high-definition images and advanced animations only to capable devices
  • Optimize layouts for mid-tier phones to prevent lag and freezes
  • Skip heavy video playback on lower-end hardware to avoid crashes

It is a powerful tool that classifies and analyzes Android device performance across multiple parameters:

PARAMETER DESCRIPTION
Total RAM, Core Count, CPU Frequency
Heap Limit, Heap Remaining, Available RAM
Bandwidth Strength, Download Speed, Signal Strength
Available Storage
Percentage Remaining, If Phone is Charging or Not

into various levels: EXCELLENT, HIGH, AVERAGE, LOW

Droid Dex enhances your Android application's performance and elevates user experience by addressing key performance challenges such as Janky scrolling, Out of Memory (OOM) errors, High battery consumption, and Application Not Responding (ANR) instances.

More Info: https://lambda.blinkit.com/droid-dex-1f807901626f

Use Cases

  1. Battery-Aware API Polling: When background polling of an API is required, frequent requests can significantly drain the device's battery. Use the BATTERY performance level to dynamically adjust polling intervals:

    DroidDex.getPerformanceLevelLd(PerformanceClass.BATTERY).observe(this) {
       // Adjust the polling time interval
    }
  2. Adaptive Image Quality: When tailoring image quality based on device capabilities, both NETWORK and MEMORY conditions are important. Better image quality requires larger file sizes (impacting network) and generates heavier bitmaps (consuming memory). Optimize image quality delivery using weighted performance levels:

    DroidDex.getWeightedPerformanceLevelLd(PerformanceClass.NETWORK to 2F, PerformanceClass.MEMORY to 1F).observe(this) {
       // Implement image quality optimization
    }

Usage

Initialize the library in your Application class using the following code snippet:

DroidDex.init(this) // Parameter: Application Context
  1. To get performance level for single/multiple parameters:

    DroidDex.getPerformanceLevel(params)

    For observing the changes:

    DroidDex.getPerformanceLevelLd(params).observe(this) {
    }

    Replace params with a comma-separated list of Performance Class(es).

    Example:

    DroidDex.getPerformanceLevel(PerformanceClass.CPU, PerformanceClass.MEMORY)
  2. To get performance level for multiple parameters with unequal weights:

    DroidDex.getWeightedPerformanceLevel(params)

    For observing the changes:

    DroidDex.getWeightedPerformanceLevelLd(params).observe(this) {
    }

    Replace params with a comma-separated list of Performance Classes mapped to their Weights.

    Example:

    DroidDex.getWeightedPerformanceLevelLd(PerformanceClass.CPU to 2F, PerformanceClass.MEMORY to 1F).observe(this) {
    }

See Example Project for further usage

Setup

For versions 3.+

The latest release is available on Maven Central.

implementation("com.eternal.kits:droid-dex:<<latest_version>>")
For versions 2.x and before

Add this to your settings.gradle[.kts] file

dependencyResolutionManagement {
	repositories {
		maven {
			url = uri("https://maven.pkg.github.com/grofers/*")
			credentials {
				username = "Blinkit"
				password = GITHUB_PERSONAL_ACCESS_TOKEN
			}
		}
	}
}

And add this dependency to your project level build.gradle[.kts] file:

implementation("com.blinkit.kits:droid-dex:<<your_version>>")

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •