X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FMobileLedgerListFragment.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FMobileLedgerListFragment.java;h=94d54f16b41208063810ad5dbe3da8bc6c649b46;hp=b7cafca484a8cfb98271212ae01256046122e0f3;hb=b54a11eca1e4d0a03a3076047dc77f68666d4338;hpb=a024759d8803c0c8a0a801b0733144a7943a98c5 diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/MobileLedgerListFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/MobileLedgerListFragment.java index b7cafca4..94d54f16 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/MobileLedgerListFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/MobileLedgerListFragment.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Damyan Ivanov. + * Copyright © 2020 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -32,20 +32,24 @@ import net.ktnx.mobileledger.utils.DimensionUtils; public class MobileLedgerListFragment extends Fragment { public SwipeRefreshLayout swiper; public TransactionListAdapter modelAdapter; - protected MainActivity mActivity; protected RecyclerView root; + @NonNull + public MainActivity getMainActivity() { + return (MainActivity) requireActivity(); + } protected void themeChanged(Integer counter) { swiper.setColorSchemeColors(Colors.getSwipeCircleColors()); } public void onBackgroundTaskRunningChanged(Boolean isRunning) { - if (mActivity == null) + if (getActivity() == null) return; if (swiper == null) return; swiper.setRefreshing(isRunning); } protected void manageFabOnScroll() { - int triggerPixels = DimensionUtils.dp2px(mActivity, 30f); + final MainActivity mainActivity = getMainActivity(); + int triggerPixels = DimensionUtils.dp2px(mainActivity, 30f); root.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { private float upAnchor = -1; private float downAnchor = -1; @@ -62,14 +66,14 @@ public class MobileLedgerListFragment extends Fragment { // swipe down upAnchor = lastY; - mActivity.fabShouldShow(); + mainActivity.fabShouldShow(); } else { // swipe up downAnchor = lastY; if (currentY < upAnchor - triggerPixels) - mActivity.fabHide(); + mainActivity.fabHide(); } lastY = currentY;