X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2FMobileLedgerListFragment.java;h=da1ea1e642bb54c7e2a59cf8f6da0d6937372dca;hb=4f8b4f8bf16aaef182e1aac31a34f88a2adf5fa8;hp=13c4fe04bd1d61d41045f841831a35e6625c3c23;hpb=ef5ec74b5ccbc920e755aed94fa45948a2f9538b;p=mobile-ledger.git 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 13c4fe04..da1ea1e6 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 @@ -30,22 +30,26 @@ import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.DimensionUtils; public class MobileLedgerListFragment extends Fragment { - public SwipeRefreshLayout swiper; + public SwipeRefreshLayout refreshLayout; public TransactionListAdapter modelAdapter; - protected MainActivity mActivity; protected RecyclerView root; + @NonNull + public MainActivity getMainActivity() { + return (MainActivity) requireActivity(); + } protected void themeChanged(Integer counter) { - swiper.setColorSchemeColors(Colors.getColors()); + refreshLayout.setColorSchemeColors(Colors.getSwipeCircleColors()); } public void onBackgroundTaskRunningChanged(Boolean isRunning) { - if (mActivity == null) + if (getActivity() == null) return; - if (swiper == null) + if (refreshLayout == null) return; - swiper.setRefreshing(isRunning); + refreshLayout.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;