Android Random Perfomance Tip: Replace Enums

Enums on Android might require more than twice the memory as compared to static constants.
Replace enums in your code with static constants. The Android support annotations provide some useful annotations to help you catch bugs and check that you’re using the expected values for your static constants just like enums would , without the overhead.
enums
[1] https://goo.gl/HPKBUw
[2] http://tools.android.com/tech-docs/support-annotations

Android Tint Drawables

Instead of adding multiple image assets that differ only in color to your androd project. Use only 1 asset and use TintDrawables to change the color.  e.g.:


public static void setImageColor(ImageView image,int color){
DrawableCompat.setTint(image.getDrawable(), color);
}

see the below gist for an example:
[1] https://gist.github.com/ckurtm/8e185ad9b4df9c0f98d1
[2] https://developer.android.com/reference/android/support/v4/graphics/drawable/DrawableCompat.html#setTint(android.graphics.drawable.Drawable, int)

Random Android Gradle Tip: App dependencies

If you need to see the dependency tree for your project you can run:
./gradlew :app:dependencies
and
./gradlew :app:androidDependencies
if you need to solve a conflict you could either exclude the conflicting module or use a resolution strategy to force a particular version of the library to be used .

 

Android TV Dialog

The leanback library for Android TV introduced the concept of guided step fragments. These have an intuitive way of presenting prompts to a user. I made a simple class that uses a GuidedStepFragment to create a simple yes/no dialog for TV. check out the git repo below

https://github.com/ckurtm/TvDialog

Native:

Native Dialog

TV dialog:

TV Dialog

I made the news!!… well my app did

Android Central wrote an article about my workout app,  365 Body Workout.

http://www.androidcentral.com/365-body-workout-brings-fitness-your-android-tv

You should try it out 🙂