Skip to content

Commit

Permalink
refactoring / remove duplicate variable
Browse files Browse the repository at this point in the history
Signed-off-by: David Luhmer <david-dev@live.de>
  • Loading branch information
David-Development committed Oct 16, 2024
1 parent 1c5de87 commit 73b9982
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.ArrayList;
import java.util.List;

import de.luhmer.owncloudnewsreader.LazyLoadingLinearLayoutManager;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.SettingsActivity;
import de.luhmer.owncloudnewsreader.LazyLoadingLinearLayoutManager;
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
import de.luhmer.owncloudnewsreader.database.model.RssItem;
import de.luhmer.owncloudnewsreader.databinding.ProgressbarItemBinding;
Expand Down Expand Up @@ -57,7 +57,6 @@ public class NewsListRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.V
private final PostDelayHandler pDelayHandler;
private final FragmentActivity activity;

private int totalItemCount = 0;
private int cachedPages = 1;

private final IPlayPausePodcastClicked playPausePodcastClicked;
Expand Down Expand Up @@ -94,13 +93,14 @@ public void onScrolled(@NonNull RecyclerView recyclerView,
int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);

int adapterTotalItemCount = layoutManager.getItemCount();
int adapterItemCount = layoutManager.getItemCount();
int adapterTotalItemCount = layoutManager.getTotalItemCount();
int lastVisibleItem = layoutManager
.findLastVisibleItemPosition();
if (!loading &&
adapterTotalItemCount <= (lastVisibleItem + visibleThreshold) &&
adapterTotalItemCount < totalItemCount &&
adapterTotalItemCount > 0) {
adapterItemCount <= (lastVisibleItem + visibleThreshold) &&
adapterItemCount < adapterTotalItemCount &&
adapterItemCount > 0) {
loading = true;

Log.v(TAG, "start load more task...");
Expand All @@ -125,16 +125,17 @@ public void onScrolled(@NonNull RecyclerView recyclerView,
}

public int getTotalItemCount() {
return totalItemCount;
if (this.layoutManager != null) {
return this.layoutManager.getTotalItemCount();
}
return 0;
}

public int getCachedPages() {
return cachedPages;
}

public void setTotalItemCount(int totalItemCount) {
this.totalItemCount = totalItemCount;

if (this.layoutManager != null) {
this.layoutManager.setTotalItemCount(totalItemCount);
}
Expand Down Expand Up @@ -355,7 +356,6 @@ public int getItemViewType(int position) {

@Override
public int getItemCount() {
//return totalItemCount;
return lazyList != null ? lazyList.size() : 0;
}

Expand Down

0 comments on commit 73b9982

Please sign in to comment.