mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Fix no post message not shown in PostFragment.
This commit is contained in:
parent
7f44b6a8de
commit
6aaef3820c
@ -1158,17 +1158,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter.addLoadStateListener(combinedLoadStates -> {
|
mAdapter.addLoadStateListener(combinedLoadStates -> {
|
||||||
LoadState refreshLoadState = combinedLoadStates.getRefresh();
|
LoadState refreshLoadState = combinedLoadStates.getRefresh();
|
||||||
|
LoadState appendLoadState = combinedLoadStates.getAppend();
|
||||||
|
|
||||||
mSwipeRefreshLayout.setRefreshing(refreshLoadState instanceof LoadState.Loading);
|
mSwipeRefreshLayout.setRefreshing(refreshLoadState instanceof LoadState.Loading);
|
||||||
if (refreshLoadState instanceof LoadState.NotLoading) {
|
if (refreshLoadState instanceof LoadState.NotLoading) {
|
||||||
if (refreshLoadState.getEndOfPaginationReached() && mAdapter.getItemCount() < 1) {
|
if (refreshLoadState.getEndOfPaginationReached() && mAdapter.getItemCount() < 1) {
|
||||||
hasPost = false;
|
noPostFound();
|
||||||
if (isInLazyMode) {
|
|
||||||
stopLazyMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
mFetchPostInfoLinearLayout.setOnClickListener(null);
|
|
||||||
showErrorView(R.string.no_posts);
|
|
||||||
} else {
|
} else {
|
||||||
hasPost = true;
|
hasPost = true;
|
||||||
}
|
}
|
||||||
@ -1176,6 +1171,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh());
|
mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh());
|
||||||
showErrorView(R.string.load_posts_error);
|
showErrorView(R.string.load_posts_error);
|
||||||
}
|
}
|
||||||
|
if (appendLoadState instanceof LoadState.NotLoading) {
|
||||||
|
if (appendLoadState.getEndOfPaginationReached() && mAdapter.getItemCount() < 1) {
|
||||||
|
noPostFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1183,6 +1183,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
view -> mAdapter.retry())));
|
view -> mAdapter.retry())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void noPostFound() {
|
||||||
|
hasPost = false;
|
||||||
|
if (isInLazyMode) {
|
||||||
|
stopLazyMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
mFetchPostInfoLinearLayout.setOnClickListener(null);
|
||||||
|
showErrorView(R.string.no_posts);
|
||||||
|
}
|
||||||
|
|
||||||
public void changeSortType(SortType sortType) {
|
public void changeSortType(SortType sortType) {
|
||||||
if (mPostViewModel != null) {
|
if (mPostViewModel != null) {
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
|
||||||
|
@ -117,7 +117,8 @@ public class ParsePost {
|
|||||||
|
|
||||||
public static String getLastItem(String response) {
|
public static String getLastItem(String response) {
|
||||||
try {
|
try {
|
||||||
return new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
|
JSONObject object = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
|
return object.isNull(JSONUtils.AFTER_KEY) ? null : object.getString(JSONUtils.AFTER_KEY);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
@ -190,7 +190,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
|
|||||||
int currentPostsSize = postLinkedHashSet.size();
|
int currentPostsSize = postLinkedHashSet.size();
|
||||||
postLinkedHashSet.addAll(newPosts);
|
postLinkedHashSet.addAll(newPosts);
|
||||||
if (currentPostsSize == postLinkedHashSet.size()) {
|
if (currentPostsSize == postLinkedHashSet.size()) {
|
||||||
return new LoadResult.Page<>(new ArrayList<>(), null, null);
|
return new LoadResult.Page<>(new ArrayList<>(), null, lastItem);
|
||||||
} else {
|
} else {
|
||||||
return new LoadResult.Page<>(new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()), null, lastItem);
|
return new LoadResult.Page<>(new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()), null, lastItem);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user