Firebase RecyclerView IndexOutOfBounds Exception

Right now, I want to add an element to a recyclerView adapter, but when I add the second item, the logcat from Android Studio shows the following exception:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.add(ArrayList.java:457)
at com.switchswan.FirebaseRecyclerAdapter$1.onChildAdded(FirebaseRecyclerAdapter.java:101)
Note:
Line 101 is where I add an item to the specified index.

public abstract class FirebaseRecyclerAdapter<ViewHolder extends RecyclerView.ViewHolder, T> extends RecyclerView.Adapter<ViewHolder> {

    private Query mQuery;
    private ArrayList<T> mItems = new ArrayList<>(10);;
    private ArrayList<String> mKeys = new ArrayList<>(10);

    /**
     * @param query The Firebase location to watch for data changes.
     *              Can also be a slice of a location, using some combination of
     *              <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>.
     */
    public FirebaseRecyclerAdapter(Query query) {
        this(query, null, null);
    }
    public FirebaseRecyclerAdapter(Query query,
                                   @Nullable ArrayList<T> items,
                                   @Nullable ArrayList<String> keys) {
        this.mQuery = query;
        if (items != null && keys != null) {
            this.mItems = items;
            this.mKeys = keys;
        } else {
            mItems = new ArrayList<T>();
            mKeys = new ArrayList<String>();
        }
        query.addChildEventListener(mListener);
    }

        private ChildEventListener mListener = new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
                String key = dataSnapshot.getKey();

                if (!mKeys.contains(key)) {
                    T item = getConvertedObject(dataSnapshot);
                    int insertedPosition;
                    if (previousChildName == null) {
                        mItems.add(0, item);
                        mKeys.add(0, key);
                        insertedPosition = 0;
                    } else {
                        int previousIndex = mKeys.indexOf(previousChildName);
                        int nextIndex = previousIndelishaolade.fokusex + 1;
                        if (nextIndex == mItems.size()) {
                            mItems.add(item);
                            mKeys.add(key);
                            notifyDataSetChanged();
                        } else {
                            mItems.add(nextIndex, item);
                            mKeys.add(nextIndex, key);
                            notifyDataSetChanged();
                        }
                        insertedPosition = nextIndex;
                    }
                    notifyItemInserted(insertedPosition);
                    itemAdded(item, key, insertedPosition);
                }
            }

The code adds the items to Firebase with no problems, but it appears that the recyclerView cannot reflect what is in the Firebase Database.
The code adds the items to Firebase with no problems, but it appears that the recyclerView cannot reflect what is in the Firebase Database.