Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Love Your Developers Like Your Customers?

Ishan Khanna
February 02, 2018

How to Love Your Developers Like Your Customers?

In this talk I'll show how you can increase developer productivity of your Android Teams by adding simple debug features to your app, hacking Gradle and Android Studio to turn your Devs into Super Heroes who ship much better products faster than ever.

Everybody talks about Design, Architectures, Libraries, and whatnot, but, what we often forget is that most of the times quick wins for us as developers can be much more beneficial than tackling large refactors to use the latest technologies available so if we apply the 80-20 rule to our development workflow we can achieve so much more.
People with any level of android experience can see this talk.

Ishan Khanna

February 02, 2018
Tweet

More Decks by Ishan Khanna

Other Decks in Technology

Transcript

  1. HOW TO LOVE YOUR DEVELOPERS LIKE YOUR CUSTOMERS? Ishan Khanna

    Android @ Booking #droidkaigi @droidchef
  2. OUTLINE 1. INSPIRATION FOR THE TALK 2. DEBUG FEATURES 3.

    COMMON SCENARIOS 4. LEVERAGING THE POWER OF OPEN SOURCE 5. A COOL DEBUGGING TRICK #droidkaigi @droidchef
  3. public class NetworkThrottlingInterceptor implements Interceptor { private static final AtomicLong

    failRequestCount = new AtomicLong(Long.MAX_VALUE); private static boolean delayAllRequests = false; private static long minRequestDelay = 0; private static long maxRequestDelay = 0; private final Random random = new Random(4);
  4. public Response intercept(Chain chain) throws IOException { long delay =

    minRequestDelay; if( minRequestDelay != maxRequestDelay ) { delay = (long) ((random.nextDouble() * (maxRequestDelay - minRequestDelay)) + minRequestDelay); } long end = System.currentTimeMillis() + delay; long now = System.currentTimeMillis(); while( now < end ) { try { Thread.sleep( end - now); } catch (InterruptedException e) { // Nothing to do here, timing controlled by outer loop. } now = System.currentTimeMillis(); } return chain.proceed(chain.request()); }
  5. public static void delayAllRequests( long minRequestDelay, long maxRequestDelay ) {

    if( minRequestDelay == 0 && maxRequestDelay == 0 ) { delayAllRequests = false; } else { NetworkThrottlingInterceptor.minRequestDelay = minRequestDelay; NetworkThrottlingInterceptor.maxRequestDelay = maxRequestDelay; delayAllRequests = true; } }
  6. public OkHttpClient configure(@NonNull OkHttpClient client) { client = super.configure(client); return

    client.newBuilder() .addNetworkInterceptor(new NetworkThrottlingInterceptor()) .addInterceptor(new SomeOtherInterceptor()) .build(); }
  7. APPLYING APP WIDE CHANGES • USE A LIBRARY CALLED PROCESS

    PHEONIX • WRITTEN BY JAKE WHARTON • https://github.com/JakeWharton/ProcessPhoenix #droidkaigi @droidchef
  8. OR, IF YOU WANT TO LAUNCH WITH AN INTENT Intent

    nextIntent = //... ProcessPhoenix.triggerRebirth(context, nextIntent);
  9. TO CHECK IF YOUR APP IS IN PHEONIX PROCESS, TO

    SKIP INITIALIZATION IN onCreate if (ProcessPhoenix.isPhoenixProcess(this)) { return; }
  10. INSTALLS IN ONE LINE OF CODE public class MyApplication extends

    Application { public void onCreate() { super.onCreate(); Stetho.initializeWithDefaults(this); } }
  11. MAKING THE MOST OF ANDROID STUDIO DEBUGGER @Override public void

    onBindViewHolder(ViewHolder holder, final int position) { final String name = values.get(position); holder.txtHeader.setText(name); holder.txtFooter.setText("Footer: " + name); }
  12. @Override public void onBindViewHolder(ViewHolder holder, final int position) { final

    String name = values.get(position); holder.txtHeader.setText(name); if (position % 3 == 0) { holder.txtHeader.setTextColor(Color.GREEN); } holder.txtFooter.setText("Footer: " + name); }