Enhanced Implementation Layer of {@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder, int)}

@param holder   PeasyViewHolder
@param position position
511564
private void onBindViewHolder(Context context, PeasyViewHolder holder, int position) {
        if (holder == null) return;
        try {
            if (headerContent != null && holder.isHeaderView()) {
                headerContent.onBindViewHolder(context, holder.asIs(PeasyHeaderViewHolder.class), position, getItem(position));
            }
        } catch (Exception ignored) {
        }
        try {
            if (footerContent != null && holder.isFooterView()) {
                footerContent.onBindViewHolder(context, holder.asIs(PeasyFooterViewHolder.class), position, getItem(position));
            }
        } catch (Exception ignored) {
        }
        onBindViewHolder(context, holder, position, getItem(position));
    }
1228497
@Override
    public int getItemViewType(int position) {
        if (shouldInsertItemAtPosition(position)) {
            return getItem(position).getType();
        } else {
            return mAdapter.getItemViewType(position - itemInsertedBeforeCount(position));
        }
    }
88484
protected void onPreTransform(View view, float position) {
        final float width = view.getWidth();

        ViewHelper.setRotationX(view,0);
        ViewHelper.setRotationY(view,0);
        ViewHelper.setRotation(view,0);
        ViewHelper.setScaleX(view,1);
        ViewHelper.setScaleY(view,1);
        ViewHelper.setPivotX(view,0);
        ViewHelper.setPivotY(view,0);
        ViewHelper.setTranslationY(view,0);
        ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

        if (hideOffscreenPages()) {
            ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
        } else {
            ViewHelper.setAlpha(view,1f);
        }
        if(mCustomAnimationInterface != null){
            if(h.containsKey(view) == false || h.get(view).size() == 1){
                if(position > -1 && position < 1){
                    if(h.get(view) == null){
                        h.put(view,new ArrayList<Float>());
                    }
                    h.get(view).add(position);
                    if(h.get(view).size() == 2){
                        float zero = h.get(view).get(0);
                        float cha = h.get(view).get(1) - h.get(view).get(0);
                        if(zero > 0){
                            if(cha > -1 && cha < 0){
                                //in
                                mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                            }else{
                                //out
                                mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                            }
                        }else{
                            if(cha > -1 && cha < 0){
                                //out
                                mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                            }else{
                                //in
                                mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                            }
                        }
                    }
                }
            }
        }
    }
978321
@Override
    public VersionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.layout_change_item, parent, false);
        return new VersionViewHolder(view);
    }
1220453
public void setCurrentItem(int position) {
		if(mSelectedPosition != position){
			CheckedTextView tv = getTabView(mSelectedPosition);	
			if(tv != null)
				tv.setChecked(false);
		}
		
		mSelectedPosition = position;		
		CheckedTextView tv = getTabView(mSelectedPosition);				
		if(tv != null)
			tv.setChecked(true);	
		
		animateToTab(position);
	}
1025912
private void recycleViewHolders(boolean isRecycleAll) {

        if (mAdapter == null) {
            return;
        }

        final List<Integer> headerKeysToRemove = new ArrayList<>();

        // item view holders
        for (ViewHolder holder : mViewHolders.getAll()) {
            if (holder != null && !holder.isDragging()) {
                View view = holder.getItemView();
                // recycle view holder
                if (isRecycleAll
                        || (view.getRight() < 0
                        || view.getLeft() > mSettings.getLayoutWidth()
                        || view.getBottom() < 0
                        || view.getTop() > mSettings.getLayoutHeight())) {
                    // recycle view holder
                    mViewHolders.remove(holder.getRowIndex(), holder.getColumnIndex());
                    recycleViewHolder(holder);
                }
            }
        }
        if (!headerKeysToRemove.isEmpty()) {
            headerKeysToRemove.clear();
        }
        // column header view holders
        for (int count = mHeaderColumnViewHolders.size(), i = 0; i < count; i++) {
            int key = mHeaderColumnViewHolders.keyAt(i);
            // get the object by the key.
            ViewHolder holder = mHeaderColumnViewHolders.get(key);
            if (holder != null) {
                View view = holder.getItemView();
                // recycle view holder
                if (isRecycleAll
                        || view.getRight() < 0
                        || view.getLeft() > mSettings.getLayoutWidth()) {
                    headerKeysToRemove.add(key);
                    recycleViewHolder(holder);
                }
            }
        }

        removeKeys(headerKeysToRemove, mHeaderColumnViewHolders);

        if (!headerKeysToRemove.isEmpty()) {
            headerKeysToRemove.clear();
        }
        // row header view holders
        for (int count = mHeaderRowViewHolders.size(), i = 0; i < count; i++) {
            int key = mHeaderRowViewHolders.keyAt(i);
            // get the object by the key.
            ViewHolder holder = mHeaderRowViewHolders.get(key);
            if (holder != null && !holder.isDragging()) {
                View view = holder.getItemView();
                // recycle view holder
                if (isRecycleAll
                        || view.getBottom() < 0
                        || view.getTop() > mSettings.getLayoutHeight()) {
                    headerKeysToRemove.add(key);
                    recycleViewHolder(holder);
                }
            }
        }

        removeKeys(headerKeysToRemove, mHeaderRowViewHolders);
    }
334801
@Override
    public boolean onFailedToRecycleView(RecyclerView.ViewHolder holder) {
        if (mVerbose) Log.v(TAG, "onFailedToRecycleView: " + holder.getItemViewType());
        return mOnBindViewHolderListener.onFailedToRecycleView(holder, holder.getAdapterPosition()) || super.onFailedToRecycleView(holder);
    }
1347527
void pushRecycledView(@NonNull ViewHolder viewHolder) {
        Deque<ViewHolder> deque = mViewHolders.get(viewHolder.getItemType());
        if (deque == null) {
            deque = new ArrayDeque<>();
            mViewHolders.put(viewHolder.getItemType(), deque);
        }
        deque.push(viewHolder);
    }
1282945
@Deprecated
    public void replaceData(int position, @Nullable List<Card> data) {
        Preconditions.checkState(mGroupBasicAdapter != null, "Must call bindView() first");
        this.mGroupBasicAdapter.replaceGroup(position, data);
    }
179405
@SuppressWarnings("unchecked")
    public static <Item extends IItem> Item getHolderAdapterItemTag(@Nullable RecyclerView.ViewHolder holder) {
        if (holder != null) {
            Object item = holder.itemView.getTag(com.mikepenz.fastadapter.R.id.fastadapter_item);
            if (item instanceof IItem) {
                return (Item) item;
            }
        }
        return null;
    }
1181698
public void setCurrentTab(int position) {
        if(mSelectedPosition != position){
            View v = mLayoutManager.findViewByPosition(mSelectedPosition);
            if(v != null)
                ((Checkable)v).setChecked(false);
        }

        mSelectedPosition = position;
        View v = mLayoutManager.findViewByPosition(mSelectedPosition);
        if(v != null)
            ((Checkable)v).setChecked(true);

        animateToTab(position);
    }
319598
public Object getItemAtPosition(int position) {
        T adapter = getAdapter();
        return (adapter == null || position < 0) ? null : adapter.getItem(position);
    }
1319303
public static <Item extends IItem> void attachToView(final EventHook<Item> event, final RecyclerView.ViewHolder viewHolder, View view) {
        if (event instanceof ClickEventHook) {
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //get the adapter for this view
                    Object tagAdapter = viewHolder.itemView.getTag(R.id.fastadapter_item_adapter);
                    if (tagAdapter instanceof FastAdapter) {
                        FastAdapter<Item> adapter = (FastAdapter<Item>) tagAdapter;
                        //we get the adapterPosition from the viewHolder
                        int pos = adapter.getHolderAdapterPosition(viewHolder);
                        //make sure the click was done on a valid item
                        if (pos != RecyclerView.NO_POSITION) {
                            Item item = adapter.getItem(pos);
                            if (item != null) {
                                //we update our item with the changed property
                                ((ClickEventHook<Item>) event).onClick(v, pos, adapter, item);
                            }
                        }
                    }
                }
            });
        } else if (event instanceof LongClickEventHook) {
            view.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    //get the adapter for this view
                    Object tagAdapter = viewHolder.itemView.getTag(R.id.fastadapter_item_adapter);
                    if (tagAdapter instanceof FastAdapter) {
                        FastAdapter<Item> adapter = (FastAdapter<Item>) tagAdapter;
                        //we get the adapterPosition from the viewHolder
                        int pos = adapter.getHolderAdapterPosition(viewHolder);
                        //make sure the click was done on a valid item
                        if (pos != RecyclerView.NO_POSITION) {
                            Item item = adapter.getItem(pos);
                            if (item != null) {
                                //we update our item with the changed property
                                return ((LongClickEventHook<Item>) event).onLongClick(v, pos, adapter, item);
                            }
                        }
                    }
                    return false;
                }
            });
        } else if (event instanceof TouchEventHook) {
            view.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent e) {
                    //get the adapter for this view
                    Object tagAdapter = viewHolder.itemView.getTag(R.id.fastadapter_item_adapter);
                    if (tagAdapter instanceof FastAdapter) {
                        FastAdapter<Item> adapter = (FastAdapter<Item>) tagAdapter;
                        //we get the adapterPosition from the viewHolder
                        int pos = adapter.getHolderAdapterPosition(viewHolder);
                        //make sure the click was done on a valid item
                        if (pos != RecyclerView.NO_POSITION) {
                            Item item = adapter.getItem(pos);
                            if (item != null) {
                                //we update our item with the changed property
                                return ((TouchEventHook<Item>) event).onTouch(v, e, pos, adapter, item);
                            }
                        }
                    }
                    return false;
                }
            });
        } else if (event instanceof CustomEventHook) {
            //we trigger the event binding
            ((CustomEventHook<Item>) event).attachEvent(view, viewHolder);
        }
    }
1140049
@Override
	public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
		// Create a new view.
		View v = LayoutInflater.from(viewGroup.getContext())
				.inflate(R.layout.rv_card, viewGroup, false);
		ViewHolder viewHolder = new ViewHolder(v);

		v.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				int itemPosition = viewHolder.getAdapterPosition();

				RecyclerAdapter.this.getJarr();
				String id = jarr.get(itemPosition).asJsonObject().getString("id");
				Log.d(TAG, "Element " + itemPosition + " clicked. with id : " + id);
				MyJus.intructablesApi().info(id);
				Fragment prevFragment = ((MainActivity) v.getContext())
						.getSupportFragmentManager().findFragmentById(R.id.container);
				Fragment fragment = DetailFragment.newInstance();
				((MainActivity) v.getContext()).getSupportFragmentManager()
						.beginTransaction()
						.hide(prevFragment).add(R.id.container, fragment).addToBackStack(null)
						.commit();
			}
		});

		return viewHolder;
	}
323641
public void removeItemByPosition(int position) {
        if (mDrawerBuilder.checkDrawerItem(position, false)) {
            mDrawerBuilder.getItemAdapter().remove(position);
        }
    }
1253979
public static void bindDragHandle(final RecyclerView.ViewHolder holder, final IExtendedDraggable item) {
        // if necessary, init the drag handle, which will start the drag when touched
        if (item.getTouchHelper() != null && item.getDragView(holder) != null) {
            item.getDragView(holder).setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
                        if (item.isDraggable())
                            item.getTouchHelper().startDrag(holder);
                    }
                    return false;
                }
            });
        }
    }
536971
@Override
    public void bindView(ViewHolder viewHolder, List<Object> payloads) {
        super.bindView(viewHolder, payloads);

        viewHolder.radioButton.setChecked(isSelected());

        //set the text for the name
        StringHolder.applyTo(name, viewHolder.name);
        //set the text for the description or hide
        StringHolder.applyToOrHide(description, viewHolder.description);
    }