Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +23 −16 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading @@ -168,9 +178,6 @@ public class TimelineHelper { } } } } } } return statuses; } Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +26 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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); } } /** Loading Loading @@ -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); Loading @@ -577,6 +601,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. flagLoading = true; binding.loadingNextElements.setVisibility(View.VISIBLE); router(DIRECTION.TOP); extraCalls = -1; } } } Loading app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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 Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +23 −16 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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(); Loading @@ -168,9 +178,6 @@ public class TimelineHelper { } } } } } } return statuses; } Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +26 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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); } } /** Loading Loading @@ -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); Loading @@ -577,6 +601,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. flagLoading = true; binding.loadingNextElements.setVisibility(View.VISIBLE); router(DIRECTION.TOP); extraCalls = -1; } } } Loading
app/src/main/java/app/fedilab/android/viewmodel/mastodon/NotificationsVM.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading
app/src/main/java/app/fedilab/android/viewmodel/mastodon/TimelinesVM.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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