Created
September 29, 2015 11:43
-
-
Save dpolishuk/debc7d056490eef231bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class AppModule { | |
private final Application application; | |
public AppModule(Application application) { | |
this.application = application; | |
} | |
@Provides public Application application() { | |
return application; | |
} | |
@Provides public AsyncBus asyncBus(Application app) { | |
MemoryInfo mi = new MemoryInfo(); | |
ActivityManager activityManager = (ActivityManager) app.getSystemService(ACTIVITY_SERVICE); | |
activityManager.getMemoryInfo(mi); | |
long availableMegs = mi.availMem / 1048576L; | |
long percentAvail = mi.availMem / mi.totalMem; | |
if (percentAvail > 70L) { | |
return new SuperPuperBus(); | |
} else { | |
return new SlowMemBus(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment