some fixes
This commit is contained in:
parent
827acad36d
commit
70a66ae4cd
|
@ -29,12 +29,12 @@ public class Conversation {
|
||||||
public List<Account> accounts;
|
public List<Account> accounts;
|
||||||
@SerializedName("last_status")
|
@SerializedName("last_status")
|
||||||
public Status last_status;
|
public Status last_status;
|
||||||
public transient boolean isFetchMore = false;
|
public boolean isFetchMore = false;
|
||||||
@SerializedName("cached")
|
@SerializedName("cached")
|
||||||
public boolean cached = false;
|
public boolean cached = false;
|
||||||
|
|
||||||
|
|
||||||
public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(@Nullable Object obj) {
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class Notification {
|
||||||
@SerializedName("cached")
|
@SerializedName("cached")
|
||||||
public boolean cached;
|
public boolean cached;
|
||||||
public Filter filteredByApp;
|
public Filter filteredByApp;
|
||||||
public transient PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
public PositionFetchMore positionFetchMore = PositionFetchMore.BOTTOM;
|
||||||
public transient List<Notification> relatedNotifications;
|
public List<Notification> relatedNotifications;
|
||||||
public transient boolean isFetchMore;
|
public transient boolean isFetchMore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2420,7 +2420,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = status.id;
|
fromId = status.id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMinId(fromId, status);
|
fetchMoreCallBack.onClickMinId(fromId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
drawerFetchMoreBinding.fetchMoreMax.setOnClickListener(v -> {
|
drawerFetchMoreBinding.fetchMoreMax.setOnClickListener(v -> {
|
||||||
|
@ -2432,7 +2432,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMaxId(fromId, status);
|
fetchMoreCallBack.onClickMaxId(fromId);
|
||||||
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
adapter.notifyItemChanged(holder.getBindingAdapterPosition());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -2968,7 +2968,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = status.id;
|
fromId = status.id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMinId(fromId, status);
|
fetchMoreCallBack.onClickMinId(fromId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
holder.bindingFilteredHide.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
||||||
|
@ -2981,7 +2981,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMaxId(fromId, status);
|
fetchMoreCallBack.onClickMaxId(fromId);
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -3025,7 +3025,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = status.id;
|
fromId = status.id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMinId(fromId, status);
|
fetchMoreCallBack.onClickMinId(fromId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.bindingFiltered.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
holder.bindingFiltered.layoutFetchMore.fetchMoreMax.setOnClickListener(v -> {
|
||||||
|
@ -3037,7 +3037,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
} else {
|
} else {
|
||||||
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
fromId = statusList.get(holder.getBindingAdapterPosition() - 1).id;
|
||||||
}
|
}
|
||||||
fetchMoreCallBack.onClickMaxId(fromId, status);
|
fetchMoreCallBack.onClickMaxId(fromId);
|
||||||
notifyItemChanged(holder.getBindingAdapterPosition());
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -3158,9 +3158,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
|
|
||||||
|
|
||||||
public interface FetchMoreCallBack {
|
public interface FetchMoreCallBack {
|
||||||
void onClickMinId(String min_id, Status statusToUpdate);
|
void onClickMinId(String min_id);
|
||||||
|
|
||||||
void onClickMaxId(String max_id, Status statusToUpdate);
|
void onClickMaxId(String max_id);
|
||||||
|
|
||||||
void autoFetch(String min_id, String max_id, Status status);
|
void autoFetch(String min_id, String max_id, Status status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ViewPreloadSizeProvider<Attachment> preloadSizeProvider;
|
|
||||||
private boolean checkRemotely;
|
private boolean checkRemotely;
|
||||||
private String accountIDInRemoteInstance;
|
private String accountIDInRemoteInstance;
|
||||||
private boolean isViewInitialized;
|
private boolean isViewInitialized;
|
||||||
|
@ -196,7 +195,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
private String publicTrendsDomain;
|
private String publicTrendsDomain;
|
||||||
private int lockForResumeCall;
|
private int lockForResumeCall;
|
||||||
private boolean isNotPinnedTimeline;
|
private boolean isNotPinnedTimeline;
|
||||||
private int extraCalls;
|
|
||||||
|
|
||||||
//Allow to recreate data when detaching/attaching fragment
|
//Allow to recreate data when detaching/attaching fragment
|
||||||
public void recreate() {
|
public void recreate() {
|
||||||
|
@ -342,7 +341,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
//Only fragment in main view pager should not have the view initialized
|
//Only fragment in main view pager should not have the view initialized
|
||||||
//AND Only the first fragment will initialize its view
|
//AND Only the first fragment will initialize its view
|
||||||
flagLoading = false;
|
flagLoading = false;
|
||||||
extraCalls = -1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,7 +484,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
} else if (update != null && insertedStatus == 0 && direction == DIRECTION.REFRESH) {
|
} else if (update != null && insertedStatus == 0 && direction == DIRECTION.REFRESH) {
|
||||||
update.onUpdate(0, timelineType, slug);
|
update.onUpdate(0, timelineType, slug);
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
|
||||||
if (direction == DIRECTION.TOP && fetchingMissing && canScroll) {
|
if (direction == DIRECTION.TOP && fetchingMissing && canScroll) {
|
||||||
int position = getAbsolutePosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1));
|
int position = getAbsolutePosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1));
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
|
@ -506,26 +503,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
if (search != null) {
|
if (search != null) {
|
||||||
offset += MastodonHelper.SEARCH_PER_CALL;
|
offset += MastodonHelper.SEARCH_PER_CALL;
|
||||||
}
|
}
|
||||||
int sizeBeforeFilter = 0;
|
|
||||||
int filteredMessage = 0;
|
|
||||||
int requestedMessages = MastodonHelper.statusesPerCall(requireActivity());
|
|
||||||
sizeBeforeFilter = fetched_statuses.statuses.size();
|
|
||||||
for (Status status : fetched_statuses.statuses) {
|
|
||||||
if (status.filteredByApp != null) {
|
|
||||||
filteredMessage++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//TODO: keep for an improvement in beta
|
|
||||||
/*
|
|
||||||
int displayedMessages = sizeBeforeFilter - filteredMessage;
|
|
||||||
if(displayedMessages < 5 && extraCalls < 8) {
|
|
||||||
router(direction);
|
|
||||||
if(extraCalls == -1) {
|
|
||||||
extraCalls = 1;
|
|
||||||
} else {
|
|
||||||
extraCalls++;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
} else if (direction == DIRECTION.BOTTOM) {
|
} else if (direction == DIRECTION.BOTTOM) {
|
||||||
flagLoading = true;
|
flagLoading = true;
|
||||||
}
|
}
|
||||||
|
@ -625,7 +602,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
binding.recyclerView.setAdapter(statusAdapter);
|
binding.recyclerView.setAdapter(statusAdapter);
|
||||||
|
|
||||||
preloadSizeProvider = new ViewPreloadSizeProvider<>();
|
ViewPreloadSizeProvider<Attachment> preloadSizeProvider = new ViewPreloadSizeProvider<>();
|
||||||
RecyclerViewPreloader<Attachment> preloader =
|
RecyclerViewPreloader<Attachment> preloader =
|
||||||
new RecyclerViewPreloader<>(
|
new RecyclerViewPreloader<>(
|
||||||
GlideApp.with(this), statusAdapter, preloadSizeProvider, PRELOAD_AHEAD_ITEMS);
|
GlideApp.with(this), statusAdapter, preloadSizeProvider, PRELOAD_AHEAD_ITEMS);
|
||||||
|
@ -652,7 +629,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
flagLoading = true;
|
flagLoading = true;
|
||||||
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
||||||
router(DIRECTION.BOTTOM);
|
router(DIRECTION.BOTTOM);
|
||||||
extraCalls = -1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.loadingNextElements.setVisibility(View.GONE);
|
binding.loadingNextElements.setVisibility(View.GONE);
|
||||||
|
@ -662,7 +638,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
flagLoading = true;
|
flagLoading = true;
|
||||||
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
||||||
router(DIRECTION.TOP);
|
router(DIRECTION.TOP);
|
||||||
extraCalls = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,7 +699,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
*
|
*
|
||||||
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
|
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
|
||||||
*/
|
*/
|
||||||
private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) {
|
private void routeCommon(DIRECTION direction, boolean fetchingMissing) {
|
||||||
if (binding == null || !isAdded() || getActivity() == null) {
|
if (binding == null || !isAdded() || getActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -881,9 +856,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
} else {
|
} else {
|
||||||
dealWithPagination(statusesCachedTop, DIRECTION.TOP, fetchingMissing, true);
|
dealWithPagination(statusesCachedTop, DIRECTION.TOP, fetchingMissing, true);
|
||||||
//Also check remotely to detect potential holes
|
//Also check remotely to detect potential holes
|
||||||
if (fetchingMissing) {
|
getLiveStatus(direction, true, timelineParams, false);
|
||||||
getLiveStatus(direction, true, timelineParams, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -929,34 +902,26 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Router for timelines
|
|
||||||
*
|
|
||||||
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
|
|
||||||
*/
|
|
||||||
private void route(DIRECTION direction, boolean fetchingMissing) {
|
|
||||||
route(direction, fetchingMissing, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Router for timelines
|
* Router for timelines
|
||||||
*
|
*
|
||||||
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
|
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
|
||||||
*/
|
*/
|
||||||
private void route(DIRECTION direction, boolean fetchingMissing, Status statusToUpdate) {
|
private void route(DIRECTION direction, boolean fetchingMissing) {
|
||||||
if (binding == null || !isAdded() || getActivity() == null) {
|
if (binding == null || !isAdded() || getActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// --- HOME TIMELINE ---
|
// --- HOME TIMELINE ---
|
||||||
if (timelineType == Timeline.TimeLineEnum.HOME) {
|
if (timelineType == Timeline.TimeLineEnum.HOME) {
|
||||||
//for more visibility it's done through loadHomeStrategy method
|
//for more visibility it's done through loadHomeStrategy method
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.LOCAL) { //LOCAL TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.LOCAL) { //LOCAL TIMELINE
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.PUBLIC) { //PUBLIC TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.PUBLIC) { //PUBLIC TIMELINE
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.BUBBLE) { //BUBBLE TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.BUBBLE) { //BUBBLE TIMELINE
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.REMOTE) { //REMOTE TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.REMOTE) { //REMOTE TIMELINE
|
||||||
//NITTER TIMELINES
|
//NITTER TIMELINES
|
||||||
if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) {
|
if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) {
|
||||||
|
@ -1025,12 +990,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else { //Other remote timelines
|
} else { //Other remote timelines
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
}
|
}
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.LIST) { //LIST TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.LIST) { //LIST TIMELINE
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.TAG || timelineType == Timeline.TimeLineEnum.ART) { //TAG TIMELINE
|
} else if (timelineType == Timeline.TimeLineEnum.TAG || timelineType == Timeline.TimeLineEnum.ART) { //TAG TIMELINE
|
||||||
routeCommon(direction, fetchingMissing, statusToUpdate);
|
routeCommon(direction, fetchingMissing);
|
||||||
} else if (timelineType == Timeline.TimeLineEnum.ACCOUNT_TIMELINE) { //PROFILE TIMELINES
|
} else if (timelineType == Timeline.TimeLineEnum.ACCOUNT_TIMELINE) { //PROFILE TIMELINES
|
||||||
String tempToken;
|
String tempToken;
|
||||||
String tempInstance;
|
String tempInstance;
|
||||||
|
@ -1198,26 +1163,26 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClickMinId(String min_id, Status statusToUpdate) {
|
public void onClickMinId(String min_id) {
|
||||||
//Fetch more has been pressed
|
//Fetch more has been pressed
|
||||||
min_id_fetch_more = min_id;
|
min_id_fetch_more = min_id;
|
||||||
route(DIRECTION.TOP, true, statusToUpdate);
|
route(DIRECTION.TOP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClickMaxId(String max_id, Status statusToUpdate) {
|
public void onClickMaxId(String max_id) {
|
||||||
max_id_fetch_more = max_id;
|
max_id_fetch_more = max_id;
|
||||||
route(DIRECTION.BOTTOM, true, statusToUpdate);
|
route(DIRECTION.BOTTOM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autoFetch(String min_id, String max_id, Status statusToUpdate) {
|
public void autoFetch(String min_id, String max_id, Status statusToUpdate) {
|
||||||
if (scrollingUp) {
|
if (scrollingUp) {
|
||||||
min_id_fetch_more = min_id;
|
min_id_fetch_more = min_id;
|
||||||
route(DIRECTION.TOP, true, statusToUpdate);
|
route(DIRECTION.TOP, true);
|
||||||
} else {
|
} else {
|
||||||
max_id_fetch_more = max_id;
|
max_id_fetch_more = max_id;
|
||||||
route(DIRECTION.BOTTOM, true, statusToUpdate);
|
route(DIRECTION.BOTTOM, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue