title: Lags when RecyclerView scrolling
body: <p>I can not understand what is the reason the brakes when you scroll through my RecyclerView. Scrolling is called by <code>mRecyclerView.smoothScrollToPosition(position);</code>
  When you scroll through the list of twitches (rendering time frame> 16ms)</p>
  
  <p>AlphaAdapter.java</p>
  
  <pre><code>public class AlphaAdapter extends RecyclerView.Adapter&lt;AlphaAdapter.ViewHolder&gt; {
      private static final String TAG = "AlphaAdapter";
      private Context mContext;
      private List&lt;PrimaryWeapon&gt; mGunList;
      private boolean isAnimate;
  
      private final int VIEW_TYPE_NULL        = 0;
      private final int VIEW_TYPE_ITEM        = 1;
  
  
      public AlphaAdapter(Context mContext, List&lt;PrimaryWeapon&gt; mGunList) {
          this.mContext = mContext;
          this.mGunList = mGunList;
      }
  
      public AlphaAdapter(Context mContext, List&lt;PrimaryWeapon&gt; mGunList, boolean a) {
          this.mContext = mContext;
          this.mGunList = mGunList;
          this.isAnimate = a;
      }
  
      @Override
      public int getItemViewType(int position) {
          try {
              if (mGunList.get(position).getNameWeapon().equals(""))
                  return VIEW_TYPE_NULL;
              else return VIEW_TYPE_ITEM;
          } catch (Exception e) {
              e.printStackTrace();
              Log.e("AlphaAdapter", String.valueOf(position));
              return VIEW_TYPE_NULL;
          }
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = null;
          if (viewType == VIEW_TYPE_ITEM)
              view = LayoutInflater.from(mContext).inflate(R.layout.item_game, parent, false);
          else
              view = LayoutInflater.from(mContext).inflate(R.layout.item_null, parent, false);
          return new ViewHolder(view);
      }
  
      @Override
      public void onViewDetachedFromWindow(ViewHolder holder) {
          super.onViewDetachedFromWindow(holder);
          holder.itemView.clearAnimation();
      }
  
      @Override
      public boolean onFailedToRecycleView(ViewHolder holder) {
          return true;
      }
  
      @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
      @Override
      public void onBindViewHolder(final ViewHolder holder, int position) {
          try {
              long startTime = System.currentTimeMillis();
              if (!getWeapon(position).getNameWeapon().equals("")) {
                  if (isAnimate) {
                      if (mLastAnimPosition &lt; position) {
                          mLastAnimPosition = position;
                          Animation a = AnimationUtils.loadAnimation(mContext, R.anim.item_game_anim);
                          holder.itemView.startAnimation(a);
                          a.setAnimationListener(new Animation.AnimationListener() {
                              @Override
                              public void onAnimationStart(Animation animation) {
  
                              }
  
                              @Override
                              public void onAnimationEnd(Animation animation) {
                              }
  
                              @Override
                              public void onAnimationRepeat(Animation animation) {
  
                              }
                          });
                      }
                  }
  
                 Picasso.with(mContext)
                          .load("file:///android_asset/" + getWeapon(position).getImagePath())
                          .placeholder(R.drawable.loading)
                          .error(R.drawable.load_fail)
                          .into(holder.image);
                  holder.main.setText(getWeapon(position).getNameWeapon());
                  holder.desc.setText(getWeapon(position).getNameSkin());
  
              }
              Log.i(TAG, String.valueOf(System.currentTimeMillis() - startTime) + "ms onBind (" + String.valueOf(position) + ");");
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      private PrimaryWeapon getWeapon(int position) {
          return mGunList.get(position);
      }
  
      @Override
      public int getItemCount() {
          return mGunList.size();
      }
  
      class ViewHolder extends RecyclerView.ViewHolder {
  
          TextView main, desc;
          ImageView image;
  
          ViewHolder(View itemView) {
              super(itemView);
              main = (TextView) itemView.findViewById(R.id.item_textMain);
              desc = (TextView) itemView.findViewById(R.id.item_textDescription);
              image = (ImageView) itemView.findViewById(R.id.item_image);
          }
      }
  
  }
  </code></pre>
  
  <p>Layout element that participates in the adapter consists of LinearLayout, ImageView, 2 TextView.</p>
  
  <p>At first I thought that the problem in downloading images, try to load them into AsyncTask, upload bitmap through Picasso and without, but after all removed from their mark, and the list will still lag. </p>
  
  <p>To dump the RAM after the scroll is, it shows that there are 71 memory instances originally ViewHolder, after adding</p>
  
  <pre><code>@Override
      public boolean onFailedToRecycleView(ViewHolder holder) {
          return true;
      }
  </code></pre>
  
  <p>this value is reduced to 15-16, <a href="https://events.yandex.ru/lib/talks/3456/" rel="noreferrer">although the rate for RecyclerView - 5</a> copies, and it should override them, but does not create new ones when you scroll.
  <a href="https://i.stack.imgur.com/LIlmj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LIlmj.png" alt="Screenshot 1"></a></p>
  
  <p>item_null.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="74dp"
      android:layout_height="80dp"&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>item_game.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_gravity="center"
      android:padding="2dp"
      android:id="@+id/layout"
      android:layout_height="80dp"
      android:fitsSystemWindows="true"
      android:layout_width="74dp"&gt;
  
      &lt;ImageView
          android:id="@+id/item_image"
          android:layout_width="match_parent"
          android:layout_height="56dp"
          /&gt;
  
      &lt;TextView
          android:layout_gravity="top"
          android:layout_width="match_parent"
          android:singleLine="true"
          android:id="@+id/item_textMain"
          android:paddingLeft="4dp"
          android:paddingRight="4dp"
          android:paddingTop="1dp"
          android:gravity="left"
          android:textColor="#FFF"
          android:maxLines="1"
          android:textSize="8sp"
          android:layout_height="10dp" /&gt;
  
          &lt;TextView
              android:layout_gravity="bottom"
              android:layout_width="match_parent"
              android:id="@+id/item_textDescription"
              android:paddingLeft="4dp"
              android:paddingRight="4dp"
              android:gravity="left"
              android:textColor="#FFF"
              android:singleLine="true"
              android:maxLines="1"
              android:maxLength="40"
              android:textSize="6sp"
              android:layout_height="12dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>