Improve and avoid last empty when coming back
This commit is contained in:
parent
e93f194bb5
commit
230ed4b2ba
|
@ -15,9 +15,6 @@ package app.fedilab.android.ui.fragment.timeline;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.currentUserID;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -43,7 +40,6 @@ import app.fedilab.android.client.entities.app.StatusCache;
|
|||
import app.fedilab.android.client.entities.app.Timeline;
|
||||
import app.fedilab.android.databinding.FragmentPaginationBinding;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.MastodonHelper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.ui.drawer.ConversationAdapter;
|
||||
|
@ -70,6 +66,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
|
|||
flagLoading = false;
|
||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||
binding.getRoot().setBackgroundColor(ThemeHelper.getBackgroundColor(requireActivity()));
|
||||
isViewInitialized = false;
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
|
@ -86,9 +83,11 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (Timeline.TimeLineEnum.CONVERSATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 && !isViewInitialized) {
|
||||
if (!isViewInitialized) {
|
||||
isViewInitialized = true;
|
||||
initializeConversationCommonView(initialConversations);
|
||||
if (initialConversations != null) {
|
||||
initializeConversationCommonView(initialConversations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +220,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
|
|||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
isViewInitialized = Timeline.TimeLineEnum.CONVERSATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0;
|
||||
|
||||
int c1 = getResources().getColor(R.color.cyanea_accent_reference);
|
||||
binding.swipeContainer.setProgressBackgroundColorSchemeColor(getResources().getColor(R.color.cyanea_primary_reference));
|
||||
binding.swipeContainer.setColorSchemeColors(
|
||||
|
|
|
@ -14,9 +14,6 @@ package app.fedilab.android.ui.fragment.timeline;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static app.fedilab.android.BaseMainActivity.currentInstance;
|
||||
import static app.fedilab.android.BaseMainActivity.currentUserID;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -170,7 +167,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
|||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
flagLoading = false;
|
||||
isViewInitialized = Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0;
|
||||
isViewInitialized = false;
|
||||
binding = FragmentPaginationBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
if (getArguments() != null) {
|
||||
|
@ -323,9 +320,11 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (Timeline.TimeLineEnum.NOTIFICATION.getValue().compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0 && !isViewInitialized) {
|
||||
if (!isViewInitialized) {
|
||||
isViewInitialized = true;
|
||||
initializeNotificationView(initialNotifications);
|
||||
if (initialNotifications != null) {
|
||||
initializeNotificationView(initialNotifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,17 +164,17 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
private PinnedTimeline pinnedTimeline;
|
||||
private String ident;
|
||||
private String slug;
|
||||
private TimelinesVM.TimelineParams timelineParams;
|
||||
private boolean canBeFederated;
|
||||
private boolean rememberPosition;
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (slug != null && slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) != 0
|
||||
&& !isViewInitialized) {
|
||||
if (!isViewInitialized) {
|
||||
isViewInitialized = true;
|
||||
initializeStatusesCommonView(initialStatuses);
|
||||
if (initialStatuses != null) {
|
||||
initializeStatusesCommonView(initialStatuses);
|
||||
}
|
||||
}
|
||||
if (timelineStatuses != null && timelineStatuses.size() > 0) {
|
||||
route(DIRECTION.FETCH_NEW, true);
|
||||
|
@ -229,7 +229,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
timelinesVM = new ViewModelProvider(FragmentMastodonTimeline.this).get(viewModelKey, TimelinesVM.class);
|
||||
accountsVM = new ViewModelProvider(FragmentMastodonTimeline.this).get(viewModelKey, AccountsVM.class);
|
||||
initialStatuses = null;
|
||||
|
@ -244,22 +243,20 @@ 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
|
||||
if (!isViewInitialized) {
|
||||
if (slug != null) {
|
||||
isViewInitialized = slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
flagLoading = false;
|
||||
|
||||
router(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
timelineType = Timeline.TimeLineEnum.HOME;
|
||||
|
||||
canBeFederated = true;
|
||||
if (getArguments() != null) {
|
||||
timelineType = (Timeline.TimeLineEnum) getArguments().get(Helper.ARG_TIMELINE_TYPE);
|
||||
|
@ -592,14 +589,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
* @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) {
|
||||
if (direction == null && !isViewInitialized && slug != null) {
|
||||
isViewInitialized = slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0;
|
||||
}
|
||||
|
||||
if (binding == null || getActivity() == null || !isAdded()) {
|
||||
return;
|
||||
}
|
||||
//Initialize with default params
|
||||
timelineParams = new TimelinesVM.TimelineParams(timelineType, direction, ident);
|
||||
TimelinesVM.TimelineParams timelineParams = new TimelinesVM.TimelineParams(timelineType, direction, ident);
|
||||
timelineParams.limit = MastodonHelper.statusesPerCall(requireActivity());
|
||||
if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP || direction == DIRECTION.FETCH_NEW) {
|
||||
timelineParams.maxId = null;
|
||||
|
|
Loading…
Reference in New Issue