From d900e1d8cd67422407d638e7427fa57c17b31b63 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Thu, 5 Jul 2018 21:32:49 +0200 Subject: [PATCH] fix crash in TimelineFragment --- .../keylesspalace/tusky/fragment/TimelineFragment.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index e5c7a71a4..c09dc6c1f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -261,7 +261,7 @@ public class TimelineFragment extends SFragment implements } private void setupSwipeRefreshLayout() { - Context context = requireContext(); + Context context = swipeRefreshLayout.getContext(); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeResources(R.color.primary); swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context, @@ -269,7 +269,7 @@ public class TimelineFragment extends SFragment implements } private void setupRecyclerView() { - Context context = requireContext(); + Context context = recyclerView.getContext(); recyclerView.setHasFixedSize(true); layoutManager = new LinearLayoutManager(context); recyclerView.setLayoutManager(layoutManager); @@ -1049,8 +1049,9 @@ public class TimelineFragment extends SFragment implements @Override public void onInserted(int position, int count) { adapter.notifyItemRangeInserted(position, count); - if (position == 0) { - recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)); + Context context = getContext(); + if (position == 0 && context != null) { + recyclerView.scrollBy(0, Utils.dpToPx(context, -30)); } }