Profile media in a grid

pull/320/head
Thomas 2 years ago
parent e68db78dc4
commit 62b7fffce8

@ -49,6 +49,7 @@ public class FragmentMediaProfile extends Fragment {
private boolean flagLoading; private boolean flagLoading;
private List<Status> mediaStatuses; private List<Status> mediaStatuses;
private String max_id; private String max_id;
private ImageAdapter imageAdapter;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -77,6 +78,7 @@ public class FragmentMediaProfile extends Fragment {
* @param statuses {@link Statuses} * @param statuses {@link Statuses}
*/ */
private void initializeStatusesCommonView(final Statuses statuses) { private void initializeStatusesCommonView(final Statuses statuses) {
flagLoading = false; flagLoading = false;
if (binding == null || !isAdded() || getActivity() == null) { if (binding == null || !isAdded() || getActivity() == null) {
return; return;
@ -100,7 +102,7 @@ public class FragmentMediaProfile extends Fragment {
} }
} }
} }
ImageAdapter imageAdapter = new ImageAdapter(mediaStatuses); imageAdapter = new ImageAdapter(mediaStatuses);
flagLoading = statuses.pagination.max_id == null; flagLoading = statuses.pagination.max_id == null;
binding.recyclerView.setVisibility(View.VISIBLE); binding.recyclerView.setVisibility(View.VISIBLE);
@ -126,6 +128,7 @@ public class FragmentMediaProfile extends Fragment {
if (dy > 0) { if (dy > 0) {
int visibleItemCount = gvLayout.getChildCount(); int visibleItemCount = gvLayout.getChildCount();
int totalItemCount = gvLayout.getItemCount(); int totalItemCount = gvLayout.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount) { if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flagLoading) { if (!flagLoading) {
flagLoading = true; flagLoading = true;
@ -169,7 +172,9 @@ public class FragmentMediaProfile extends Fragment {
} }
} }
} }
int position = this.mediaStatuses.size();
this.mediaStatuses.addAll(mediaStatusesNew); this.mediaStatuses.addAll(mediaStatusesNew);
imageAdapter.notifyItemRangeChanged(position, mediaStatusesNew.size());
if (fetched_statuses.pagination.max_id == null) { if (fetched_statuses.pagination.max_id == null) {
flagLoading = true; flagLoading = true;
} else if (max_id == null || fetched_statuses.pagination.max_id.compareTo(max_id) < 0) { } else if (max_id == null || fetched_statuses.pagination.max_id.compareTo(max_id) < 0) {

Loading…
Cancel
Save