Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SponsoredDividerItemDecoration.java « recycler « widget « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84f5bdf31e43adb81a644738bdfc5a23a1c95c2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.mapswithme.maps.widget.recycler;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.*;
import android.view.View;

class SponsoredDividerItemDecoration extends DividerItemDecoration
{
  private int mDividerWidth;
  /**
   * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
   * {@link LinearLayoutManager}.
   *
   * @param context     Current context, it will be used to access resources.
   * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
   */
  SponsoredDividerItemDecoration(Context context, int orientation)
  {
    super(context, orientation);
  }

  @Override
  public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
  {
    super.getItemOffsets(outRect, view, parent, state);
    // First element.
    if (parent.getChildAdapterPosition(view) == 0)
      outRect.left = mDividerWidth;
  }

  @Override
  public void setDrawable(@NonNull Drawable drawable)
  {
    super.setDrawable(drawable);
    mDividerWidth = drawable.getIntrinsicWidth();
  }
}