From a239eec17ccde03690dadf3068984744e71039af Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 6 Sep 2021 23:09:37 +0800 Subject: Remove code related to NetworkState in PostRecyclerViewAdapter. --- .../adapters/PostRecyclerViewAdapter.java | 223 +++++++-------------- .../infinityforreddit/fragments/PostFragment.java | 33 --- 2 files changed, 71 insertions(+), 185 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 7f156a26..25125992 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -73,7 +73,6 @@ import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface; -import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SaveThing; import ml.docilealligator.infinityforreddit.VoteThing; @@ -111,8 +110,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override @@ -209,7 +206,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter= 0 && super.getItemCount() > position) { @@ -1755,34 +1731,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter mCallback.retryLoadingMore()); - retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme)); - retryButton.setTextColor(mButtonTextColor); - itemView.setOnClickListener(view -> retryButton.performClick()); - } - } - - class LoadingViewHolder extends RecyclerView.ViewHolder { - @BindView(R.id.progress_bar_item_footer_loading) - ProgressBar progressBar; - - LoadingViewHolder(@NonNull View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); - progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent)); - } - } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 48a39e41..57208029 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -216,7 +216,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { private boolean isLazyModePaused = false; private boolean hasPost = false; private boolean isShown = false; - private boolean isInitialRefreshingStarted = false; private boolean savePostFeedScrolledPosition; private boolean rememberMutingOptionInPostFeed; private Boolean masterMutingOption; @@ -1184,7 +1183,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mAdapter.addLoadStateListener(combinedLoadStates -> { LoadState refreshLoadState = combinedLoadStates.getRefresh(); - LoadState appendLoadState = combinedLoadStates.getAppend(); mSwipeRefreshLayout.setRefreshing(refreshLoadState instanceof LoadState.Loading); if (refreshLoadState instanceof LoadState.NotLoading) { @@ -1205,35 +1203,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mPostRecyclerView.setAdapter(mAdapter.withLoadStateFooter(new Paging3LoadingStateAdapter(mCustomThemeWrapper, R.string.load_more_posts_error, view -> mAdapter.retry()))); - - /*mPostViewModel.hasPost().observe(getViewLifecycleOwner(), hasPost -> { - this.hasPost = hasPost; - mSwipeRefreshLayout.setRefreshing(false); - if (hasPost) { - mFetchPostInfoLinearLayout.setVisibility(View.GONE); - } else { - if (isInLazyMode) { - stopLazyMode(); - } - - mFetchPostInfoLinearLayout.setOnClickListener(null); - showErrorView(R.string.no_posts); - } - }); - - mPostViewModel.getInitialLoadingState().observe(getViewLifecycleOwner(), networkState -> { - if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) { - mSwipeRefreshLayout.setRefreshing(false); - } else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) { - mSwipeRefreshLayout.setRefreshing(false); - mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh()); - showErrorView(R.string.load_posts_error); - } else { - mSwipeRefreshLayout.setRefreshing(true); - } - }); - - mPostViewModel.getPaginationNetworkState().observe(getViewLifecycleOwner(), networkState -> mAdapter.setNetworkState(networkState));*/ } public void changeSortType(SortType sortType) { @@ -1278,7 +1247,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mFetchPostInfoLinearLayout.setVisibility(View.GONE); mGlide.clear(mFetchPostInfoImageView); } - mAdapter.removeFooter(); hasPost = false; if (isInLazyMode) { stopLazyMode(); @@ -1356,7 +1324,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Override public void refresh() { - mAdapter.removeFooter(); mFetchPostInfoLinearLayout.setVisibility(View.GONE); hasPost = false; if (isInLazyMode) { -- cgit v1.2.3