From f3a67c765033e582f3c89f2e3dc3241918714d6a Mon Sep 17 00:00:00 2001 From: Yunus Cagliyan Date: Sat, 4 May 2019 13:48:01 +0300 Subject: [PATCH] =?UTF-8?q?Swipe=20=C4=B0=C5=9Flemi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunuscagliyan/memorybook/adapter/NoteListAdapter.java | 7 ++++++- .../memorybook/adapter/NotesRecyclerView.java | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NoteListAdapter.java b/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NoteListAdapter.java index 1761b00..d75aaa9 100644 --- a/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NoteListAdapter.java +++ b/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NoteListAdapter.java @@ -65,7 +65,12 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int i) { @Override public int getItemCount() { - return mAllNotes.size()+1; + if(mAllNotes==null||mAllNotes.isEmpty()){ + return 0; + + }else { + return mAllNotes.size()+1; + } } @Override diff --git a/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NotesRecyclerView.java b/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NotesRecyclerView.java index a565122..6496b1a 100644 --- a/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NotesRecyclerView.java +++ b/app/src/main/java/com/yunuscagliyan/memorybook/adapter/NotesRecyclerView.java @@ -55,7 +55,7 @@ public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) { public void showOrHideView(){ if(getAdapter()!=null && !isEmptyVisible.isEmpty() &&!isEmptyInvisible.isEmpty()){ //no element state - if(getAdapter().getItemCount()==1){ + if(getAdapter().getItemCount()==0){ for(View view:isEmptyInvisible){ view.setVisibility(View.GONE); @@ -64,7 +64,7 @@ public void showOrHideView(){ view.setVisibility(View.VISIBLE); } setVisibility(View.GONE); - }else if (getAdapter().getItemCount()>1){ + }else { setVisibility(View.VISIBLE); for(View view:isEmptyInvisible){ view.setVisibility(View.VISIBLE);