@@ -0,0 +1,2127 @@
+package com.ae.apps.common.views;%0A%0Aimport android.content.Context;%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.util.AttributeSet;%0Aimport android.view.View;%0A%0A/**%0A * RecyclerView that supports an entry point to check if the data set is empty%0A * on its lifecycle%0A *%0A * %3Cpre%3E%0A * References%0A * http://stackoverflow.com/a/27801394/39540%0A * https://gist.github.com/adelnizamutdinov/31c8f054d1af4588dc5c%0A * %3C/pre%3E%0A */%0Apublic class EmptyRecyclerView extends RecyclerView %7B%0A%0A    private View emptyView;%0A%0A    final private AdapterDataObserver observer = new AdapterDataObserver() %7B%0A        @Override%0A        public void onChanged() %7B%0A            checkIfEmpty();%0A        %7D%0A%0A        @Override%0A        public void onItemRangeInserted(int positionStart, int itemCount) %7B%0A            checkIfEmpty();%0A        %7D%0A%0A        @Override%0A        public void onItemRangeRemoved(int positionStart, int itemCount) %7B%0A            checkIfEmpty();%0A        %7D%0A    %7D;%0A%0A    public EmptyRecyclerView(Context context) %7B%0A        super(context);%0A    %7D%0A%0A    public EmptyRecyclerView(Context context, AttributeSet attrs) %7B%0A        super(context, attrs);%0A    %7D%0A%0A    public EmptyRecyclerView(Context context, AttributeSet attrs,%0A                             int defStyle) %7B%0A        super(context, attrs, defStyle);%0A    %7D%0A%0A    void checkIfEmpty() %7B%0A        if (emptyView != null && getAdapter() != null) %7B%0A            final boolean emptyViewVisible =%0A                    getAdapter().getItemCount() == 0;%0A            emptyView.setVisibility(emptyViewVisible ? VISIBLE : GONE);%0A            setVisibility(emptyViewVisible ? GONE : VISIBLE);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void setAdapter(Adapter adapter) %7B%0A        final Adapter oldAdapter = getAdapter();%0A        if (oldAdapter != null) %7B%0A            oldAdapter.unregisterAdapterDataObserver(observer);%0A        %7D%0A        super.setAdapter(adapter);%0A        if (adapter != null) %7B%0A            adapter.registerAdapterDataObserver(observer);%0A        %7D%0A%0A        checkIfEmpty();%0A    %7D%0A%0A    public void setEmptyView(View emptyView) %7B%0A        this.emptyView = emptyView;%0A        checkIfEmpty();%0A    %7D%0A%7D

add EmptyRecyclerView