title: Proguard and RecyclerView item decoration
body: <p>I'm experiencing somewhat unexpected behavior with <code>ItemDecoration</code> for <code>RecyclerView</code> elements.</p>
  
  <p>On some phones (Samsung Android 5 devices), my ItemDecoration is not showing when proguard is applied with the build (minify true). Without proguard/minify it's working fine, you can see the ItemDecoration between the elements of the recycler. </p>
  
  <p>On most phones, the issue does not exist, you can see the item decoration with or without proguard applied.</p>
  
  <p>Not sure what happens there, but any input is appreciated.</p>
  
  <p>The item decorator code:</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.drawable.Drawable;
  import android.support.v4.content.ContextCompat;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.View;
  
  public class DividerItemDecoration extends RecyclerView.ItemDecoration {
      private Drawable mDivider;
  
      public DividerItemDecoration(Context context) {
          mDivider = ContextCompat.getDrawable(context, R.drawable.line_divider);
      }
  
      @Override
      public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
          int left = parent.getPaddingLeft();
          int right = parent.getWidth() - parent.getPaddingRight();
  
          int childCount = parent.getChildCount();
          for (int i = 0; i &lt; childCount; i++) {
              View child = parent.getChildAt(i);
              RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
  
              int top = child.getBottom() + params.bottomMargin;
              int bottom = top + mDivider.getIntrinsicHeight();
              int margin = 30;
              mDivider.setBounds(left + margin, top, right - margin, bottom);
              mDivider.draw(canvas);
          }
      }
  }
  </code></pre>
  
  <p>line_divider.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle"&gt;
      &lt;size
          android:width="1dp"
          android:height="1dp" /&gt;
      &lt;solid android:color="#ffc6c6c6" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>Proguard rules:</p>
  
  <pre><code>-keepclassmembers class fqcn.of.javascript.interface.for.webview {
     public *;
  }
  
  # support design library
  -dontwarn android.support.design.**
  -keep class android.support.design.** { *; }
  -keep interface android.support.design.** { *; }
  -keep public class android.support.design.R$* { *; }
  
  
  #retrofit
  -dontwarn retrofit.**
  -keep class retrofit.** { *; }
  -keep class com.myappspackage.catalog.** { *; }
  
  #OKHttp
  -dontwarn okio.**
  -keep class okio.** { *; }
  
  -dontwarn org.slf4j.**
  -keep class org.slf4j.** { *; }
  
  -keep class android.support.v7.** { *; }
  -keep interface android.support.v7.** { *; }
  
  -keepattributes Signature
  -keepattributes Exceptions
  
  #Google analytics
   -keep class com.google.android.gms.** { *; }
   -keep public class com.google.android.gms.**
   -dontwarn com.google.android.gms.**
  </code></pre>
  
  <p>Gradle build log:</p>
  
  <pre><code>Executing tasks: [clean, :app:generateReleaseSources]
  
  Configuration on demand is an incubating feature.
  :app:clean
  :app:preBuild UP-TO-DATE
  :app:preReleaseBuild UP-TO-DATE
  :app:checkReleaseManifest
  :app:preDebugBuild UP-TO-DATE
  :app:prepareComAndroidSupportAppcompatV72311Library
  :app:prepareComAndroidSupportCardviewV72311Library
  :app:prepareComAndroidSupportDesign2311Library
  :app:prepareComAndroidSupportRecyclerviewV72311Library
  :app:prepareComAndroidSupportSupportV42311Library
  :app:prepareComCrashlyticsSdkAndroidAnswers131Library
  :app:prepareComCrashlyticsSdkAndroidBeta113Library
  :app:prepareComCrashlyticsSdkAndroidCrashlytics251Library
  :app:prepareComCrashlyticsSdkAndroidCrashlyticsCore234Library
  :app:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library
  :app:prepareComGoogleAndroidGmsPlayServicesBase840Library
  :app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
  :app:prepareComGoogleAndroidGmsPlayServicesGcm840Library
  :app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library
  :app:prepareDeHdodenhofCircleimageview130Library
  :app:prepareIoFabricSdkAndroidFabric135Library
  :app:prepareReleaseDependencies
  :app:compileReleaseAidl
  :app:compileReleaseRenderscript
  :app:generateReleaseBuildConfig
  :app:generateReleaseAssets UP-TO-DATE
  :app:mergeReleaseAssets
  :app:processReleaseManifest
  :app:fabricGenerateResourcesRelease
  :app:generateReleaseResValues UP-TO-DATE
  :app:generateReleaseResources
  :app:mergeReleaseResources
  AAPT: /Users/aviran/Projects/app/src/main/res/drawable-xhdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
  AAPT: /Users/aviran/Projects/app/src/main/res/drawable-hdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
  AAPT: /Users/aviran/Projects/app/src/main/res/drawable-mdpi/ic_drawer.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
  :app:processReleaseResources
  :app:generateReleaseSources
  
  BUILD SUCCESSFUL
  
  Total time: 30.549 secs
  </code></pre>
  
  <hr>
  
  <p><strong>Super weird solution</strong></p>
  
  <p>Adding <code>Log.i(TAG, "decorating: " + i);</code> inside the <code>for</code> loop, actually makes it draw the lines for each item. Putting it outside the for loop does not work. Any idea what the heck is going on there?</p>