Some fixes
This commit is contained in:
parent
30f21c035d
commit
0cbf0bfbd4
|
@ -761,6 +761,16 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
//Fetch some db values to initialize data
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (currentAccount == null) {
|
||||
if (currentToken == null || currentToken.trim().isEmpty()) {
|
||||
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
||||
}
|
||||
try {
|
||||
currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
MutedAccounts mutedAccounts = new MutedAccounts(BaseMainActivity.this).getMutedAccount(currentAccount);
|
||||
if (mutedAccounts != null && mutedAccounts.accounts != null) {
|
||||
filteredAccounts = mutedAccounts.accounts;
|
||||
|
|
|
@ -137,6 +137,8 @@ public class TimelineHelper {
|
|||
if (m.find()) {
|
||||
status.filteredByApp = filter;
|
||||
continue;
|
||||
} else {
|
||||
status.filteredByApp = null;
|
||||
}
|
||||
if (status.spoiler_text != null) {
|
||||
String spoilerText;
|
||||
|
@ -147,12 +149,20 @@ public class TimelineHelper {
|
|||
Matcher ms = p.matcher(spoilerText);
|
||||
if (ms.find()) {
|
||||
status.filteredByApp = filter;
|
||||
continue;
|
||||
} else {
|
||||
status.filteredByApp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filterTimeLineType == Timeline.TimeLineEnum.HOME) {
|
||||
if (filteredAccounts != null && filteredAccounts.size() > 0) {
|
||||
for (Status status : statuses) {
|
||||
if (status.filteredByApp != null) {
|
||||
continue;
|
||||
}
|
||||
for (Account account : filteredAccounts) {
|
||||
if (account.acct.equals(status.account.acct) || (status.reblog != null && account.acct.equals(status.reblog.account.acct))) {
|
||||
Filter filterCustom = new Filter();
|
||||
|
@ -168,9 +178,6 @@ public class TimelineHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
private String publicTrendsDomain;
|
||||
private int lockForResumeCall;
|
||||
private boolean isNotPinnedTimeline;
|
||||
|
||||
private int extraCalls;
|
||||
//Allow to recreate data when detaching/attaching fragment
|
||||
public void recreate() {
|
||||
initialStatuses = null;
|
||||
|
@ -290,6 +290,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
//Only fragment in main view pager should not have the view initialized
|
||||
//AND Only the first fragment will initialize its view
|
||||
flagLoading = false;
|
||||
extraCalls = -1;
|
||||
|
||||
}
|
||||
|
||||
|
@ -454,12 +455,34 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
min_id = fetched_statuses.pagination.min_id;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
flagLoading = true;
|
||||
}
|
||||
if (direction == DIRECTION.SCROLL_TOP) {
|
||||
binding.recyclerView.scrollToPosition(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -568,6 +591,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
flagLoading = true;
|
||||
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
||||
router(DIRECTION.BOTTOM);
|
||||
extraCalls = -1;
|
||||
}
|
||||
} else {
|
||||
binding.loadingNextElements.setVisibility(View.GONE);
|
||||
|
@ -577,6 +601,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
flagLoading = true;
|
||||
binding.loadingNextElements.setVisibility(View.VISIBLE);
|
||||
router(DIRECTION.TOP);
|
||||
extraCalls = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class NotificationsVM extends AndroidViewModel {
|
|||
sortDesc(notificationList);
|
||||
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
|
||||
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
|
||||
if (notificationList.get(notificationList.size() - 1).id.compareToIgnoreCase(timelineNotifications.get(0).id) > 0) {
|
||||
if (!timelineNotifications.contains(notificationList.get(notificationList.size() - 1))) {
|
||||
notificationList.get(notificationList.size() - 1).isFetchMore = true;
|
||||
notificationList.get(notificationList.size() - 1).positionFetchMore = Notification.PositionFetchMore.TOP;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
sortDesc(statusList);
|
||||
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
|
||||
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
|
||||
if (statusList.get(statusList.size() - 1).id.compareToIgnoreCase(timelineStatuses.get(0).id) > 0) {
|
||||
if (!timelineStatuses.contains(statusList.get(statusList.size() - 1))) {
|
||||
statusList.get(statusList.size() - 1).isFetchMore = true;
|
||||
statusList.get(statusList.size() - 1).positionFetchMore = Status.PositionFetchMore.TOP;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
sortDescConv(conversationList);
|
||||
if (timelineParams.direction == FragmentMastodonTimeline.DIRECTION.REFRESH || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || timelineParams.direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW) {
|
||||
//When refreshing/scrolling to TOP, if last statuses fetched has a greater id from newest in cache, there is potential hole
|
||||
if (conversationList.get(conversationList.size() - 1).id.compareToIgnoreCase(timelineConversations.get(0).id) > 0) {
|
||||
if (!timelineConversations.contains(conversationList.get(conversationList.size() - 1))) {
|
||||
conversationList.get(conversationList.size() - 1).isFetchMore = true;
|
||||
conversationList.get(conversationList.size() - 1).positionFetchMore = Conversation.PositionFetchMore.TOP;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue