diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/ChatLinearLayoutManager.java b/app/src/main/java/com/nynja/mobile/communicator/utils/ChatLinearLayoutManager.java index f61f8f2d2e89bbb9d8f471b9c5a8f03de45f9a78..e596361efe81491f5e8729c8d130bfbe63f9ae89 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/ChatLinearLayoutManager.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/ChatLinearLayoutManager.java @@ -4,6 +4,7 @@ import android.content.Context; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.AttributeSet; +import timber.log.Timber; public class ChatLinearLayoutManager extends LinearLayoutManager { @@ -27,8 +28,14 @@ public class ChatLinearLayoutManager extends LinearLayoutManager { @Override public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { - super.onLayoutChildren(recycler, state); - if (mOnChatLinearLayoutListener != null) - mOnChatLinearLayoutListener.onLayoutChildren(recycler, state); + try { + super.onLayoutChildren(recycler, state); + } catch (IndexOutOfBoundsException e) { + Timber.tag("Error").e("IndexOutOfBoundsException in ChatLinearLayoutManager recycler"); + }finally { + if (mOnChatLinearLayoutListener != null) { + mOnChatLinearLayoutListener.onLayoutChildren(recycler, state); + } + } } }