Skip to content

grofers/droid-dex

Repository files navigation

Droid Dex

Introduction

Droid Dex is a powerful tool crafted to enhance the performance of your Android applications, ultimately elevating the user experience. With a focus on addressing key performance issues, it is your solution for addressing prevalent challenges like Jerky(Janky) Scrolling, Out of Memory errors (OOMs), High Battery Consumption, and instances of Application Not Responding (ANR).

It classifies and lets you analyze Android Device Performance across various parameters like:

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

It is a compact library accompanied by extensive in-line documentation, providing users with the opportunity to delve into the code, comprehend each line thoroughly, and, ideally, contribute to its development.

Use Cases

  1. Consider a scenario where background polling of an API is necessary. In this context, the BATTERY level becomes a crucial factor, as frequent polling can significantly drain the device's battery. To address this concern, you can optimize the process using the following code snippet:

    DroidDex.getPerformanceLevelLd(PerformanceClass.BATTERY).observe(this) {
       // Adjust the polling time interval
    }
  2. Consider a scenario where you need to tailor the image quality for users based on their devices. In this context, the NETWORK condition plays a crucial role in decision-making, as achieving better image quality typically involves larger file sizes and increased data transfer. However, MEMORY is also a consideration, as higher-quality images generate heavier bitmaps, consuming more memory. To optimize this process, you can use the following code snippet:

    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 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 to their Weights.

    Example:

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

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 2

  •  
  •