1
0
mirror of https://github.com/accelforce/Yuito synced 2024-12-24 23:01:41 +01:00

fix crash in TimelineFragment

This commit is contained in:
Conny Duck 2018-07-05 21:32:49 +02:00
parent 0c1893ff6e
commit d900e1d8cd

View File

@ -261,7 +261,7 @@ public class TimelineFragment extends SFragment implements
} }
private void setupSwipeRefreshLayout() { private void setupSwipeRefreshLayout() {
Context context = requireContext(); Context context = swipeRefreshLayout.getContext();
swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.setColorSchemeResources(R.color.primary); swipeRefreshLayout.setColorSchemeResources(R.color.primary);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context, swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context,
@ -269,7 +269,7 @@ public class TimelineFragment extends SFragment implements
} }
private void setupRecyclerView() { private void setupRecyclerView() {
Context context = requireContext(); Context context = recyclerView.getContext();
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(context); layoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
@ -1049,8 +1049,9 @@ public class TimelineFragment extends SFragment implements
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
adapter.notifyItemRangeInserted(position, count); adapter.notifyItemRangeInserted(position, count);
if (position == 0) { Context context = getContext();
recyclerView.scrollBy(0, Utils.dpToPx(requireContext(), -30)); if (position == 0 && context != null) {
recyclerView.scrollBy(0, Utils.dpToPx(context, -30));
} }
} }